How to use getIntFromInput method in wpt

Best JavaScript code snippet using wpt

hex.js

Source:hex.js Github

copy

Full Screen

...104*/105var hosted_inhouse_init = function() {106 //hosted_inhouse_moveCallout();107 //$('#callout').show();108 mailboxes = getIntFromInput(MAIL_ID);109 blackberry = getIntFromInput(BB_ID);110 //Get computer's year111 var year = new Date().getFullYear();112 $('#y1').text('In-house ' + year);113 $('#y2').text('In-house ' + (parseInt(year) + 1));114 $('#y3').text('In-house ' + (parseInt(year) + 2));115 //Make these rows clicked.116 updateUserSbs(true);117 updateHardwarePrimaryExchange(true);118 updateHardwareNetworkSecurity(true);119 updateLicensesWindows(false);120 updateLicensesExchange(false);121 updateLicensesSBS(true);122 updateUserRackspace(true);123 updateUserOutlook(true);124 $('#user_outlook_check').click(); // rather than set previous line to false, a click event triggers correct total calculations125 updateUserBlackberry(true);126 updateUserAntivirus(true);127 updateCostsHosting(true);128 updateCostsMicrosoft(true);129 updateCostsDeploy(true);130 updateCostsAdmin(true);131 $('#hardware_blackberry_check').attr('disabled', true);132 $('#licenses_sbs_check').attr('disabled', true);133 $('#licenses_blackberry_check').attr('disabled', true);134 $('#user_blackberry_check').attr('disabled', true);135}/*}}}*/136//var hosted_inhouse_moveCallout = function() {137// var position = $('#costs_totals_rax').position();138// $('#callout').css('left', position.left + 90);139// $('#callout').css('top', position.top + 6);140//}141/* {{{ updateCalculator142 Updates the values in the table related to the number of mailboxes and blackberry users.143*/144var updateCalculator = function() {145 mailboxes = getIntFromInput(MAIL_ID);146 blackberry = getIntFromInput(BB_ID);147 if ((mailboxes > 0) && (blackberry <= mailboxes)) {148 if (blackberry > 0) {149 if ($('#hardware_totals img').attr('src') == minus) {150 $('#hardware_blackberry').show();151 }152 if ($('#licenses_totals img').attr('src') == minus) {153 $('#licenses_blackberry').show();154 }155 if ($('#user_totals img').attr('src') == minus) {156 $('#user_blackberry').show();157 }158 updateHardwareBlackberry(true);159 updateLicensesBlackberry(true);160 updateUserBlackberry(true);161 } else {162 updateHardwareBlackberry(false);163 updateLicensesBlackberry(false);164 updateUserBlackberry(false);165 $('#hardware_blackberry').hide();166 $('#licenses_blackberry').hide();167 $('#user_blackberry').hide();168 }169 if (mailboxes <= 25) {170 if (mailboxes <= 5) {171 updateHardwareStorage(true);172 }173 updateUserSbs(true);174 } else {175 updateHardwareStorage(false);176 updateBackupServer(true);177 updateBackupStorage(true);178 updateBackupSoftware(true);179 }180 if (isSBS()) {181 updateLicensesSBS(true);182 updateLicensesWindows(false);183 updateLicensesExchange(false);184 $('#smallbiz').show();185 } else {186 updateLicensesSBS(false);187 updateUserWindows(true);188 updateUserExchange(true);189 $('#smallbiz').hide();190 }191 if (mailboxes >= 75) {192 $('#highavail').attr('checked', true);193 updateHardwareSecondaryExchange(true);194 $('form span.required').show();195 $('#user_sbs').hide();196 SBSshowing = false;197 } else {198 $('form span.required').hide();199 }200 updateWindowsLicenseCount();201 updateExchangeLicenseCount();202 updateUserTotalCount();203 updateUserRackspaceCount();204 updateUserWindowsCount();205 updateUserExchangeCount();206 updateUserOutlookCount();207 updateUserSbsCount();208 updateUserBlackberryCount();209 updateUserAntivirusCount();210 updateCostsHostingCount();211 updateCostsMicrosoft($('#costs_microsoft_check').attr('checked'));212 updateAvailability();213 } else {214 if (mailboxes <= 0 && mailboxes < blackberry) {215 alert('You must have a positive number of mailboxes and it must be greater than or equal to the number of BlackBerry users.');216 } else if (mailboxes <= 0) {217 alert('You must have a positive number of mailboxes.');218 } else {219 alert('The number of BlackBerry users must be less than or equal to the number of mailboxes.');220 }221 }222}/* }}} */223/*{{{ addFormEvents()224 Adds click events for items in the form.225*/226var addFormEvents = function() {227 $(MAIL_ID).keyup(function(e) {228 var mail_qty = getIntFromInput(MAIL_ID);229 var bb_qty = getIntFromInput(BB_ID);230 if ((mail_qty > 0) && (bb_qty <= mail_qty)) {231 $(CALC_ID).removeAttr('disabled');232 if (e.keyCode == 13) {233 $(CALC_ID).click();234 }235 } else {236 $(CALC_ID).attr('disabled', 'true');237 }238 });239 $(BB_ID).keyup(function(e) {240 var mail_qty = getIntFromInput(MAIL_ID);241 var bb_qty = getIntFromInput(BB_ID);242 if (bb_qty <= mail_qty) {243 $(CALC_ID).removeAttr('disabled');244 if (e.keyCode == 13) {245 $(CALC_ID).click();246 }247 }248 });249 $(CALC_ID).click(function() {250 updateCalculator();251 });252 $('#highavail').click(function() {253 updateCalculator();254 });255}/*}}}*/256/*{{{ Table Event Adders - these add the click events for items in the table.*/257/* {{{ addTableEvents() */258var addTableEvents = function() {259 addParentClickEvents();260 addHardwareEvents();261 addLicenseEvents();262 addBackupEvents();263 addUserEvents();264 addCostsEvents();265}/*}}}*/266/* {{{ addParentClickEvents() - add click events to parent rows */267var addParentClickEvents = function() {268 $.each(hierarchy, function(category, items) {269 var parentRowId = '#' + category + '_totals';270 $(parentRowId).click(function(){271 /* handle button switching */272 var button = parentRowId + ' td img';273 if ($(button).attr('src') == IMAGE_CDN + '/email-hosting/page/plus.png') {274 $(button).attr('src', IMAGE_CDN + '/email-hosting/page/minus.png');275 } else {276 $(button).attr('src', IMAGE_CDN + '/email-hosting/page/plus.png');277 }278 $.each(items, function(key, value) {279 //Handle sbs showing up. Otherwise just toggle the rows.280 if (category == 'user' && value == 'sbs') {281 //Only show if High Availability is checked and user items are displayed282 if (!$('#highavail').attr('checked') && mailboxes <= 25 && $('#user_totals img').attr('src') == minus) {283 $('#user_sbs').show();284 } else {285 $('#user_sbs').hide();286 }287 } else if (category == 'user' && (value == 'windows')) {288 if (($('#highavail').attr('checked') || mailboxes > 25) && $('#user_totals img').attr('src') == minus) {289 $('#user_' + value).show();290 } else {291 $('#user_' + value).hide();292 }293 } else if (category == 'hardware' && (value == 'blackberry')) {294 if (($('#hardware_totals img').attr('src') == minus) &&295 (blackberry > 0)) {296 $('#hardware_blackberry').show();297 } else {298 $('#hardware_blackberry').hide();299 }300 } else if (category == 'licenses') {301 if (value == 'windows') {302 if (isSectionOpen('licenses') && !isSBS()) {303 $('#licenses_windows').show();304 } else {305 $('#licenses_windows').hide();306 }307 } else if (value == 'exchange') {308 if (isSectionOpen('licenses') && !isSBS()) {309 $('#licenses_exchange').show();310 } else {311 $('#licenses_exchange').hide();312 }313 } else if (value == 'sbs') {314 if (isSectionOpen('licenses') && isSBS()) {315 $('#licenses_sbs').show();316 } else {317 $('#licenses_sbs').hide();318 }319 } else if (value == 'blackberry') {320 if (isSectionOpen('licenses') && (blackberry > 0)) {321 $('#licenses_blackberry').show();322 } else {323 $('#licenses_blackberry').hide();324 }325 }326 } else {327 $('#' + category + '_' + value).toggle();328 }329 });330 //hosted_inhouse_moveCallout();331 });332 });333}334/* }}}*/335/* {{{ Add Row Events - Handle events that occur in any table row. Most event handlers are going to call an updater */336/* {{{ addHardwareEvents() */337var addHardwareEvents = function() {338 $('#hardware_primaryExchange_check').click(function() {339 updateHardwarePrimaryExchange($('#hardware_primaryExchange_check').attr('checked'));340 });341 $('#hardware_secondaryExchange_check').click(function() {342 updateHardwareSecondaryExchange($('#hardware_secondaryExchange_check').attr('checked'));343 });344 $('#hardware_blackberry_check').click(function() {345 updateHardwareBlackberry($('#hardware_blackberry_check').attr('checked'));346 });347 $('#hardware_networkSecurity_check').click(function() {348 updateHardwareNetworkSecurity($('#hardware_networkSecurity_check').attr('checked'));349 });350 $('#hardware_storage_check').click(function() {351 updateHardwareStorage($('#hardware_storage_check').attr('checked'));352 });353}354/* }}} */355/* {{{ addLicenseEvents() */356var addLicenseEvents = function() {357 $('#licenses_windows_check').click(function() {358 updateLicensesWindows($('#licenses_windows_check').attr('checked'));359 });360 $('#licenses_exchange_check').click(function() {361 updateLicensesExchange($('#licenses_exchange_check').attr('checked'));362 });363}364/* }}} */365/* {{{ addBackupEvents() */366var addBackupEvents = function() {367 $('#backup_server_check').click(function() {368 updateBackupServer($('#backup_server_check').attr('checked'));369 });370 $('#backup_storage_check').click(function() {371 updateBackupStorage($('#backup_storage_check').attr('checked'));372 });373 $('#backup_software_check').click(function() {374 updateBackupSoftware($('#backup_software_check').attr('checked'));375 });376}377/* }}} */378/* {{{ addUserEvents() */379var addUserEvents = function() {380 $('#user_rackspace_check').click(function() {381 updateUserRackspace($('#user_rackspace_check').attr('checked'));382 });383 $('#user_windows_check').click(function() {384 updateUserWindows($('#user_windows_check').attr('checked'));385 });386 $('#user_exchange_check').click(function() {387 updateUserExchange($('#user_exchange_check').attr('checked'));388 });389 $('#user_outlook_check').click(function() {390 updateUserOutlook($('#user_outlook_check').attr('checked'));391 });392 $('#user_sbs_check').click(function() {393 updateUserSbs($('#user_sbs_check').attr('checked'));394 });395 $('#user_blackberry_check').click(function() {396 updateUserBlackberry($('#user_blackberry_check').attr('checked'));397 });398 $('#user_antivirus_check').click(function() {399 updateUserAntivirus($('#user_antivirus_check').attr('checked'));400 });401}402/* }}} */403/*{{{ addCostsEvents() */404var addCostsEvents = function() {405 $('#costs_hosting_check').click(function() {406 updateCostsHosting($('#costs_hosting_check').attr('checked'));407 });408 $('#costs_microsoft_check').click(function() {409 updateCostsMicrosoft($('#costs_microsoft_check').attr('checked'));410 });411 $('#costs_deploy_check').click(function() {412 updateCostsDeploy($('#costs_deploy_check').attr('checked'));413 });414 $('#deploy_costs').keyup(function() {415 updateCostsDeploy($('#costs_deploy_check').attr('checked'));416 });417 $('#costs_admin_check').click(function() {418 updateCostsAdmin($('#costs_admin_check').attr('checked'));419 });420 $('#fte').keyup(function() {421 updateCostsAdmin($('#costs_admin_check').attr('checked'));422 });423 $('#salary').keyup(function() {424 updateCostsAdmin($('#costs_admin_check').attr('checked'));425 });426}427/* }}} */428/*}}}*/429/*}}}*/430/* {{{ Updaters - these handle updating values when something has changed in the respective category ...431 When an updater is passed true for selected, it simulates the user clicking the row's checkbox (and vice versa).432 These handle most of the logic for pricing and related rows.433*/434/*{{{ Hardware Updaters */435/*{{{ updateHardwarePrimaryExchange()*/436var updateHardwarePrimaryExchange = function(selected) {437 $('#hardware_primaryExchange_check').attr('checked', selected);438 if(selected && mailboxes > 0) {439 windowsServerLicenses['primaryExchange'] = 1;440 exchangeServerLicenses['primaryExchange'] = 1;441 servers['primaryExchange'] = 1;442 hosted_inhouse_setValues('hardware', 'primaryExchange', COST_R720, 0, 0);443 //Enable secondary if primary is selected444 $('#hardware_secondaryExchange_check').attr('disabled', false);445 } else {446 windowsServerLicenses['primaryExchange'] = 0;447 exchangeServerLicenses['primaryExchange'] = 0;448 servers['primaryExchange'] = 0;449 hosted_inhouse_clear('hardware','primaryExchange');450 //Disable secondary if primary not selected451 if ($('#hardware_secondaryExchange_check').attr('checked')) {452 windowsServerLicenses['secondaryExchange'] = 0;453 exchangeServerLicenses['secondaryExchange'] = 0;454 servers['secondaryExchange'] = 0;455 }456 $('#hardware_secondaryExchange_check').attr('checked', false);457 $('#hardware_secondaryExchange_check').attr('disabled', true);458 hosted_inhouse_clear('hardware', 'secondaryExchange');459 }460 updateWindowsLicenseCount();461 updateExchangeLicenseCount();462 updateCostsHostingCount();463}/*}}}*/464/* {{{ updateHardwareSecondaryExchange() */465var updateHardwareSecondaryExchange = function(selected) {466 $('#hardware_secondaryExchange_check').attr('checked', selected);467 if(selected && mailboxes > 0) {468 windowsServerLicenses['secondaryExchange'] = 1;469 exchangeServerLicenses['secondaryExchange'] = 1;470 servers['secondaryExchange'] = 1;471 hosted_inhouse_setValues('hardware', 'secondaryExchange', COST_R720, 0, 0);472 } else {473 windowsServerLicenses['secondaryExchange'] = 0;474 exchangeServerLicenses['secondaryExchange'] = 0;475 servers['secondaryExchange'] = 0;476 hosted_inhouse_clear('hardware', 'secondaryExchange');477 }478 updateWindowsLicenseCount();479 updateExchangeLicenseCount();480 updateCostsHostingCount();481}/*}}}*/482/* {{{ updateHardwareBlackberry() */483var updateHardwareBlackberry = function(selected) {484 $('#hardware_blackberry_check').attr('checked', selected);485 if(selected && mailboxes > 0 && blackberry > 0) {486 hosted_inhouse_setValues('hardware', 'blackberry', COST_R320, 0, 0);487 } else {488 hosted_inhouse_clear('hardware', 'blackberry');489 }490 updateLicensesBlackberry(selected);491}/*}}}*/492/* {{{ updateHardwareNetworkSecurity() */493var updateHardwareNetworkSecurity = function(selected) {494 $('#hardware_networkSecurity_check').attr('checked', selected);495 if(selected && mailboxes > 0) {496 hosted_inhouse_setValues('hardware', 'networkSecurity', 1800, 0, 0);497 } else {498 hosted_inhouse_clear('hardware', 'networkSecurity');499 }500}/*}}}*/501/* {{{ updateHardwareStorage() */502var updateHardwareStorage = function(selected) {503 $('#hardware_storage_check').attr('checked', selected);504 if(selected && mailboxes > 0) {505 hosted_inhouse_setValues('hardware', 'storage', COST_MD1220, 0, 0);506 } else {507 hosted_inhouse_clear('hardware', 'storage');508 }509 updateWindowsLicenseCount();510}/*}}}*/511/*}}}*/512/* {{{ License Updaters */513/* {{{ updateLicensesWindows */514var updateLicensesWindows = function(selected) {515 var total = 0;516 $.each(windowsServerLicenses, function(item, value) {517 total += value;518 });519 $('#licenses_windows_check').attr('checked', selected);520 if (selected && mailboxes > 0 && total > 0) {521 if (isSectionOpen('licenses')) {522 $('#licenses_windows').show();523 }524 hosted_inhouse_setValues('licenses', 'windows', total * 999, 0, 0, 'Included');525 } else {526 hosted_inhouse_clear('licenses', 'windows');527 $('#licenses_windows').hide();528 }529}/*}}}*/530/* {{{ updateLicensesExchange() */531var updateLicensesExchange = function(selected) {532 var total = 0;533 $.each(exchangeServerLicenses, function(item, value) {534 total += value;535 });536 $('#licenses_exchange_check').attr('checked', selected);537 if (selected && mailboxes > 0 && total > 0) {538 if (isSectionOpen('licenses')) {539 $('#licenses_exchange').show();540 }541 hosted_inhouse_setValues('licenses', 'exchange', total * 699, 0, 0, 'Included');542 } else {543 hosted_inhouse_clear('licenses', 'exchange');544 $('#licenses_exchange').hide();545 }546}/*}}}*/547/* {{{ updateLicensesBlackberry() */548var updateLicensesBlackberry = function(selected) {549 $('#licenses_blackberry_check').attr('checked', selected);550 if(selected && mailboxes > 0 && blackberry > 0) {551 hosted_inhouse_setValues('licenses', 'blackberry', COST_BES, 0, 0);552 } else {553 hosted_inhouse_clear('licenses', 'blackberry');554 }555}/*}}}*/556/* {{{ updateLicensesSBS() */557var updateLicensesSBS = function(selected) {558 $('#licenses_sbs_check').attr('checked', selected);559 if (selected && (mailboxes > 0) && (mailboxes <= 25)) {560 if (isSectionOpen('licenses')) {561 $('#licenses_sbs').show();562 }563 hosted_inhouse_setValues('licenses', 'sbs', 1089, 0, 0);564 } else {565 hosted_inhouse_clear('licenses', 'sbs');566 $('#licenses_sbs').hide();567 }568}/*}}}*/569/*}}}*/570/* {{{ Backup Updaters */571/*{{{ updateBackupServer() */572var updateBackupServer = function(selected) {573 $('#backup_server_check').attr('checked', selected);574 if(selected && mailboxes > 0) {575 hosted_inhouse_setValues('backup', 'server', COST_LTO4, 0, 0);576 windowsServerLicenses['backupServer'] = 1;577 servers['backupServer'] = 1;578 } else {579 hosted_inhouse_clear('backup', 'server');580 windowsServerLicenses['backupServer'] = 0;581 servers['backupServer'] = 0;582 }583 updateWindowsLicenseCount();584 updateCostsHostingCount();585}/*}}}*/586/*{{{ updateBackupStorage() */587var updateBackupStorage = function(selected) {588 $('#backup_storage_check').attr('checked', selected);589 if(selected && mailboxes > 0) {590 hosted_inhouse_setValues('backup', 'storage', 10400, 0, 0);591 } else {592 hosted_inhouse_clear('backup', 'storage');593 }594}/*}}}*/595/*{{{ updateBackupSoftware() */596var updateBackupSoftware = function(selected) {597 $('#backup_software_check').attr('checked', selected);598 if(selected && mailboxes > 0) {599 hosted_inhouse_setValues('backup', 'software', COST_SYM_BACKUP_EXE, 0, 0);600 } else {601 hosted_inhouse_clear('backup', 'software');602 }603}604/*}}}*/605/*}}}*/606/* {{{ User Updaters */607/*{{{ updateUserRackspace() */608var updateUserRackspace = function(selected) {609 $('#user_rackspace_check').attr('checked', selected);610 if (selected) {611 hosted_inhouse_setValues('user', 'rackspace', 0, 0, 0, (mailboxes * 10 * 12));612 } else {613 hosted_inhouse_clear('user', 'rackspace');614 }615}/*}}}*/616/*{{{ updateUserWindows() */617var updateUserWindows = function(selected) {618 $('#user_windows_check').attr('checked', selected);619 if(selected && mailboxes > 5) {620 hosted_inhouse_setValues('user', 'windows', (mailboxes - 5) * 40, 0, 0);621 } else {622 hosted_inhouse_clear('user', 'windows');623 }624}/*}}}*/625/*{{{ updateUserExchange() */626var updateUserExchange = function(selected) {627 $('#user_exchange_check').attr('checked', selected);628 if(selected && mailboxes > 0) {629 hosted_inhouse_setValues('user', 'exchange', mailboxes * COST_EXCHANGE_CAL, 0, 0, 0);630 } else {631 hosted_inhouse_clear('user', 'exchange');632 }633}/*}}}*/634/*{{{ updateUserOutlook() */635var updateUserOutlook = function(selected) {636 $('#user_outlook_check').attr('checked', selected);637 if(selected && mailboxes > 0) {638 hosted_inhouse_setValues('user', 'outlook', mailboxes * COST_OUTLOOK, 0, 0, mailboxes * COST_HEX_OUTLOOK * 12);639 } else {640 hosted_inhouse_clear('user', 'outlook');641 }642}/*}}}*/643/*{{{ updateUserSbs() */644var updateUserSbs = function(selected) {645 $('#user_sbs_check').attr('checked', selected);646 if (selected && (mailboxes > 0)) {647 var total = (mailboxes - 5) * 77;648 total = (total < 0) ? 0 : total;649 if (total >= 0) {650 hosted_inhouse_setValues('user', 'sbs', total, 0, 0);651 } else {652 hosted_inhouse_setValues('user', 'sbs', 0, 0, 0);653 }654 } else {655 hosted_inhouse_clear('user', 'sbs');656 }657}/*}}}*/658/*{{{ updateUser`() */659var updateUserBlackberry = function(selected) {660 $('#user_blackberry_check').attr('checked', selected);661 if(selected && mailboxes > 0 && blackberry > 0) {662 hosted_inhouse_setValues('user', 'blackberry', (blackberry * COST_BLACKBERRY), 0, 0, blackberry * 120);663 } else {664 hosted_inhouse_clear('user', 'blackberry');665 }666}/*}}}*/667/*{{{ updateUserAntivirus() */668var updateUserAntivirus = function(selected) {669 $('#user_antivirus_check').attr('checked', selected);670 if(selected && mailboxes > 0) {671 hosted_inhouse_setValues('user', 'antivirus', (COST_AV_SETUP + Math.round(mailboxes * COST_AV_USER)), Math.round(mailboxes * COST_AV_USER), Math.round(mailboxes * COST_AV_USER));672 } else {673 hosted_inhouse_clear('user', 'antivirus');674 }675}/*}}}*/676/*}}}*/677/*{{{ Cost Updaters */678/*{{{ updateCostsHosting() */679var updateCostsHosting = function(selected) {680 var total = 0;681 $.each(servers, function(item, value) {682 total += value;683 });684 $('#costs_hosting_check').attr('checked', selected);685 if(selected && mailboxes > 0) {686 hosted_inhouse_setValues('costs', 'hosting', total * 1000, total * 1000, total * 1000);687 } else {688 hosted_inhouse_clear('costs', 'hosting');689 }690}/*}}}*/691/*{{{ updateCostsMicrosoft() */692var updateCostsMicrosoft = function(selected) {693 if( mailboxes > 0) {694 $('#costs_microsoft_check').attr('disabled', false);695 $('#costs_microsoft_check').attr('checked', selected);696 } else {697 $('#costs_microsoft_check').attr('checked', false);698 $('#costs_microsoft_check').attr('disabled', true);699 }700 //TODO Crazy math ... double check701 var serverCount = 0;702 // windows server703 if(blackberry > 0) {704 serverCount += 4 * 999;705 } else {706 serverCount += 3 * 999;707 }708 //exchange709 serverCount += 1398;710 //windows user cals711 if (mailboxes > 5) {712 serverCount += (mailboxes - 5) * 40;713 }714 //exchange715 serverCount += mailboxes * COST_EXCHANGE_CAL;716 //outlook717 serverCount += mailboxes * COST_OUTLOOK;718 if(selected && mailboxes > 0) {719 var price = Math.round(serverCount * .25);720 hosted_inhouse_setValues('costs', 'microsoft', price, price, price);721 } else {722 hosted_inhouse_clear('costs', 'microsoft');723 }724}/*}}}*/725/*{{{ updateCostsDeploy() */726var updateCostsDeploy = function(selected) {727 $('#costs_deploy_check').attr('checked', selected);728 if(selected && mailboxes > 0) {729 var cost = parseInt($('#deploy_costs').val());730 if (!isNaN(cost)) {731 hosted_inhouse_setValues('costs', 'deploy', 200 * cost, 0, 0);732 } else if ($('#deploy_costs').val() == '') {733 hosted_inhouse_setValues('costs', 'deploy', 0, 0, 0);734 }735 } else {736 hosted_inhouse_clear('costs', 'deploy');737 }738}/*}}}*/739/*{{{ updateCostsAdmin() */740var updateCostsAdmin = function(selected) {741 $('#costs_admin_check').attr('checked', selected);742 if(selected && mailboxes > 0) {743 var fte = parseInt($('#fte').val());744 var salary = parseInt($('#salary').val());745 if(!isNaN(fte) && !isNaN(salary)) {746 var price = parseInt(salary * (fte / 100));747 hosted_inhouse_setValues('costs', 'admin', price, price, price);748 } else if ($('#fte').val() == '' || $('#salary').val() == '') {749 hosted_inhouse_setValues('costs', 'admin', 0, 0, 0);750 }751 } else {752 hosted_inhouse_clear('costs', 'admin');753 }754}/*}}}*/755/*}}}*/756/* {{{ updateAvailability() - updates items when the High Availability button is checked */757var updateAvailability = function() {758 if (mailboxes >= 75) {759 $('#highavail').attr('checked', true);760 }761 if ($('#highavail').attr('checked')) {762 $('#smallbiz').hide();763 } else {764 if (mailboxes < 25) {765 $('#smallbiz').show();766 }767 }768 // If SBS, change text769 //if (mailboxes <= 25 && !($('#highavail').attr('checked'))) {770 // $('#hardware_primaryExchange td.left2 span').text('Small Business Server');771 //} else {772 // $('#hardware_primaryExchange td.left2 span').text('Primary Exchange Server');773 //}774 //Only want it to show sbs if High Availability not checked and others showing775 if (mailboxes <= 25 && !($('#highavail').attr('checked')) && isSectionOpen('user')) {776 $('#user_sbs').show();777 sbsEligible = true;778 } else {779 $('#user_sbs').hide();780 sbsEligible = false;781 }782 //if ($('#highavail').attr('checked') || mailboxes > 25) {783 if (isSectionOpen('user')) {784 $('#user_windows').show();785 $('#user_exchange').show();786 }787 updateUserWindows(true);788 updateUserExchange(true);789 //} else {790 // updateUserWindows(false);791 // $('#user_windows').hide();792 // updateUserExchange(false);793 // $('#user_exchange').hide();794 //}795 var checked = $('#highavail').attr('checked');796 updateHardwareSecondaryExchange(checked);797 if (mailboxes > 20) {798 updateHardwareStorage(false);799 } else {800 updateHardwareStorage(true);801 }802 updateUserSbs($('#user_sbs_check').attr('checked'));803}804/*}}}*/805/*}}}*/806/* {{{ setValues() - sets the values of the specified row ...807 If null or a non-numeric is passed for the rackspace column, it will set it to 'Included'.808 Also handles updating the totals after setting the values.809*/810var hosted_inhouse_setValues = function(category, name, val1, val2, val3, rax) {811 var row_id = '#' + category + '_' + name;812 $(row_id + ' td').removeClass('gray');813 $(row_id + '_y1').text('$' + addCommas(val1));814 $(row_id + '_y2').text('$' + addCommas(val2));815 $(row_id + '_y3').text('$' + addCommas(val3));816 if (isNaN(rax)) {817 $(row_id + '_rax').text('Included');818 } else {819 $(row_id + '_rax').text('$' + addCommas(rax));820 }821 updateTotals(category);822}/* }}} */823/* {{{ clear() - zeros out the row and grays it after it has been deselected. */824var hosted_inhouse_clear = function(category, name) {825 var row_id = '#' + category + '_' + name;826 $(row_id + ' td').addClass('gray');827 $(row_id + '_y1').text('$0');828 $(row_id + '_y2').text('$0');829 $(row_id + '_y3').text('$0');830 if($.trim($(row_id + '_rax').text()) != 'Included') {831 $(row_id + '_rax').text('$0');832 }833 updateTotals(category);834}/*}}}*/835/* {{{ updateTotals() - updates the values for the specified category total and the overall total */836var updateTotals = function(category) {837 updateInhouseTotals(category);838 updateRaxTotals(category);839 updateUserCosts();840}841var updateInhouseTotals = function(category) {842 var categoryTotal = {843 'y1': 0,844 'y2': 0,845 'y3': 0846 };847 var overallTotal = {848 'y1': 0,849 'y2': 0,850 'y3': 0851 };852 //Get Values853 $.each(hierarchy, function(parentRow, items) {854 $.each(items, function(key, item) {855 $.each(categoryTotal, function(year, value) {856 var cellValue = dollarToInt($('#' + parentRow + '_' + item + '_' + year).text());857 overallTotal[year] += cellValue;858 if (parentRow == category) {859 categoryTotal[year] += cellValue;860 }861 });862 });863 });864 //Display865 $.each(categoryTotal, function(year, value) {866 $('#' + category + '_totals_' + year).text('$' + addCommas(categoryTotal[year]));867 $('#total_' + year + '_top').text('$' + addCommas(overallTotal[year]));868 $('#total_' + year + '_bottom').text('$' + addCommas(overallTotal[year]));869 });870}871// This handles things on a more specific basis since Rax only has a few costs872var updateRaxTotals = function(category) {873 if (category == 'user') {874 var isSBS = false; //mailboxes <= 25 && !$('#highavail').attr('checked');875 var total = 0;876 total += dollarToInt($('#user_outlook_rax').text());877 total += dollarToInt($('#user_rackspace_rax').text());878 total += dollarToInt($('#user_blackberry_rax').text());879 $('#user_totals_rax').text('$' + addCommas(total));880 $('#total_rax_top').text('$' + addCommas(total));881 $('#total_rax_bottom').text('$' + addCommas(total));882 }883}884// Calculates the costs per user and displays it885var updateUserCosts = function() {886 var y1 = dollarToInt($('#total_y1_top').text());887 var y2 = dollarToInt($('#total_y2_top').text());888 var y3 = dollarToInt($('#total_y3_top').text());889 var rax = dollarToInt($('#total_rax_top').text());890 $('#in-house_price').text('$' + addCommas(Math.round((y1 + y2 + y3) / (mailboxes * 3))));891 $('#hosted_price').text('$' + addCommas(Math.round(rax / mailboxes)));892}893// }}}894/*{{{ Update Counts - these handle updating the counts for global values ...895 They also update the appropriate rows after modification.896*/897/*{{{ updateWindowsLicenseCount() */898var updateWindowsLicenseCount = function() {899 var total = 0;900 $.each(windowsServerLicenses, function(item, value) {901 total += value;902 });903 // If SBS, zero out Windows licenses904 if (isSBS()) {905 total = 0;906 }907 $('#licenses_windows span.count').text('(' + total + ') ');908 $('#licenses_windows_check').attr('checked', total != 0);909 $('#licenses_windows_check').attr('disabled', total == 0);910 updateLicensesWindows($('#licenses_windows_check').attr('checked'));911}/*}}}*/912/*{{{ updateExchangeLicenseCount() */913var updateExchangeLicenseCount = function() {914 var total = 0;915 $.each(exchangeServerLicenses, function(item, value) {916 total += value;917 });918 // If SBS, zero out Exchange licenses919 if (isSBS()) {920 total = 0;921 }922 $('#licenses_exchange span.count').text('(' + total + ') ');923 $('#licenses_exchange_check').attr('checked', total != 0);924 $('#licenses_exchange_check').attr('disabled', total == 0);925 updateLicensesExchange($('#licenses_exchange_check').attr('checked'));926}/*}}}*/927/* {{{ Update User Counts - these handle update the counts related to user licenses */928var updateUserTotalCount = function() {929 $('#num_users').text(mailboxes);930}931var updateUserRackspaceCount = function() {932 $('#userrackspace2 span').text('(' + mailboxes + ') ');933 updateUserRackspace($('#user_rackspace_check').attr('checked'));934}935var updateUserWindowsCount = function() {936 $('#userwindows2 span').text('(' + mailboxes + ') ');937 updateUserWindows($('#user_windows_check').attr('checked'));938}939var updateUserExchangeCount = function() {940 $('#userexchange2 span').text('(' + mailboxes + ') ');941 updateUserExchange($('#user_exchange_check').attr('checked'));942}943var updateUserOutlookCount = function() {944 $('#useroutlook2 span').text('(' + mailboxes + ') ');945 updateUserOutlook($('#user_outlook_check').attr('checked'));946}947var updateUserSbsCount = function() {948 $('#sbs_count').text('(' + mailboxes + ') ');949 updateUserSbs($('#user_sbs_check').attr('checked'));950}951var updateUserBlackberryCount = function() {952 if (blackberry <= 0) {953 $('#user_blackberry_check').attr('disabled', true);954 $('#user_blackberry_check').attr('checked', false);955 } else {956 $('#user_blackberry_check').attr('disabled', false);957 }958 $('#userblackberry2 span').text('(' + blackberry + ') ');959 updateUserBlackberry($('#user_blackberry_check').attr('checked'));960}961var updateUserAntivirusCount = function() {962 $('#userantivirus2 span.count').text('(' + mailboxes + ') ');963 updateUserAntivirus($('#user_antivirus_check').attr('checked'));964}965/*}}}*/966/* {{{ updateCostsHostingCount() - handles updating counts related to costs*/967var updateCostsHostingCount = function() {968 var total = 0;969 $.each(servers, function(item, value) {970 total += value;971 });972 $('#costshosting2').text(total);973 if (total == 1) {974 $('#costshostingServers').text('Server');975 } else {976 $('#costshostingServers').text('Servers');977 }978 updateCostsHosting($('#costs_hosting_check').attr('checked'));979}980/*}}}*/981/*}}}*/982/*{{{ addCommas() - adds commas to format a number like 100,000 */983function addCommas(nStr) {984 nStr += '';985 x = nStr.split('.');986 x1 = x[0];987 x2 = x.length > 1 ? '.' + x[1] : '';988 var rgx = /(\d+)(\d{3})/;989 while (rgx.test(x1)) {990 x1 = x1.replace(rgx, '$1' + ',' + '$2');991 }992 return x1 + x2;993}/*}}}*/994/*{{{ dollarToInt() - strips the string of dollar signs, commas, and periods */995var dollarToInt = function(dollar) {996 var newInt = parseInt(dollar.replace(/[^\d\.]/g, ''));997 if (isNaN(newInt)){998 newInt = 0;999 }1000 return newInt;1001};/*}}}*/1002// {{{ getIntFromInput()1003/**1004 * Gets an integer from an input field, or 0 if result is NaN.1005 *1006 * @param {String} selector jQuery selector string for input1007 */1008var getIntFromInput = function (selector) {1009 var parsed = parseInt($(selector).val());1010 var rv = 0;1011 if (!isNaN(parsed)) {1012 rv = parsed;1013 }1014 return rv;1015};1016// }}}...

Full Screen

Full Screen

thread.js

Source:thread.js Github

copy

Full Screen

1var _comments;2function submitComment() {3 const replayId = _replayId;4 const gameId = getIntFromInput("#gameId");5 const frameId = getIntFromInput("#frameId");6 const playerId = getIntFromInput("#playerId");7 const textArea = document.querySelector("#messageTextArea");8 const message = textArea.value;9 $.ajax({10 type: "POST",11 url: "/Thread/Comment",12 data: { replayId: replayId, gameId: gameId, frameId: frameId, playerId: playerId, message: message },13 success: function (data) {14 textArea.value = "";15 if (data.replayId === _replayId) {16 _comments = data.comments;17 updateComments();18 }19 }20 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('./wpt.js');2const a = wpt.getIntFromInput();3const b = wpt.getIntFromInput();4console.log(a + b);5module.exports = {6 getIntFromInput: function () {7 return parseInt(prompt('Enter an integer: '));8 }9};10Uncaught SyntaxError: Cannot use import statement outside a module

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2wpt.getIntFromInput("Enter an integer: ", function (err, val) {3 if (err) {4 console.log(err);5 } else {6 console.log("You entered: " + val);7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var int = wpt.getIntFromInput(5);3console.log(int);4module.exports = {5 getIntFromInput: function (input) {6 return parseInt(input);7 }8};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var i = wpt.getIntFromInput();3console.log("i: " + i);4exports.getIntFromInput = function() {5 var i = 0;6 var input = process.argv[2];7 if (input) {8 i = parseInt(input);9 }10 return i;11}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextinput = require('wptextinput');2console.log(wptextinput.getIntFromInput('Enter a number: '));3var prompt = require('prompt');4var wptextinput = {5 getIntFromInput: function(message) {6 var input = prompt(message);7 return parseInt(input);8 }9};10module.exports = wptextinput;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require("wptoolkit");2var result = wptoolkit.getIntFromInput("Enter a number: ");3console.log("You have entered " + result);4 var result = wptoolkit.getIntFromInput("Enter a number: ");5 console.log("You have entered " + result);6function getIntFromInput(message) {7 var result = 0;8 var isValid = false;9 while (!isValid) {10 result = prompt(message);11 if (result != null) {12 if (result.trim() != "") {13 if (isNaN(result)) {14 console.log("You have entered an invalid number. Please try again.");15 } else {16 result = parseInt(result);17 isValid = true;18 }19 } else {20 console.log("You have not entered anything. Please try again.");21 }22 } else {23 console.log("You have cancelled the operation.");24 isValid = true;25 }26 }27 return result;28}29function prompt(message) {30 var result = null;31 var input = document.createElement("input");

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2var wpt = new wpt();3wpt.getIntFromInput("Enter a number: ", function (number) {4 console.log("You entered: " + number);5});6module.exports = function () {7 this.getIntFromInput = function (prompt, callback) {8 var stdin = process.stdin, stdout = process.stdout;9 stdin.resume();10 stdout.write(prompt);11 stdin.once('data', function (data) {12 callback(parseInt(data.toString().trim(), 10));13 });14 };15};16exports.getIntFromInput = function (prompt, callback) {17 var stdin = process.stdin, stdout = process.stdout;18 stdin.resume();19 stdout.write(prompt);20 stdin.once('data', function (data) {21 callback(parseInt(data.toString().trim(), 10));22 });23};24module.exports = function () {25 this.getIntFromInput = function (prompt, callback) {26 var stdin = process.stdin, stdout = process.stdout;27 stdin.resume();28 stdout.write(prompt);29 stdin.once('data', function (data) {30 callback(parseInt(data.toString().trim(), 10));31 });32 };33};34exports.name = 'WPT';

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const wiki = new wptools();3let input = 123;4let output = wiki.getIntFromInput(input);5console.log("output = " + output);6const wptools = require('wptools');7const wiki = new wptools();8let input = 123.456;9let output = wiki.getFloatFromInput(input);10console.log("output = " + output);11const wptools = require('wptools');12const wiki = new wptools();13let input = true;14let output = wiki.getBoolFromInput(input);15console.log("output = " + output);16const wptools = require('wptools');17const wiki = new wptools();18let input = [1,2,3];19let output = wiki.getArrayFromInput(input);20console.log("output = " + output);21const wptools = require('wptools');22const wiki = new wptools();23let input = {a:1, b:2};24let output = wiki.getJSONFromInput(input);25console.log("output = " + output);26const wptools = require('wptools');27const wiki = new wptools();28let input = new Buffer("Hello World");29let output = wiki.getBufferFromInput(input);30console.log("output = " + output);31const wptools = require('wptools');32const wiki = new wptools();33let input = "Hello World";34let output = wiki.getBufferFromInput(input);35console.log("output = " + output);36const wptools = require('wptools');37const wiki = new wptools();38let input = new Buffer("Hello World");

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wptUtils = new wpt();3var input = '5';4var result = wptUtils.getIntFromInput(input);5console.log(result);6If you want to run the code on your local system, you need to install node.js and npm (node package manager) on your system. Then you can install the chai module using the command:

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful