Skip to content

Commit 7cdc524

Browse files
committed
updated js for prepaids
1 parent 25aeec4 commit 7cdc524

File tree

3 files changed

+243
-4
lines changed

3 files changed

+243
-4
lines changed

app/assets/javascripts/application.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
//= require jquery
1414
//= require jquery_ujs
1515
//= require jquery-ui.min
16-
//= require_tree .
16+
//= require_tree .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

app/assets/javascripts/public.js

+239-3
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ $(document).ready(function()
223223
}
224224
);
225225

226+
$(document).ready(function()
227+
{
228+
$("#prepaidTable").tablesorter({
229+
sortList: [[sortcell,0]]
230+
});
231+
}
232+
);
226233
// ***************** sliders for secured card calculator ************//
227234

228235

@@ -252,7 +259,7 @@ $(document).ready(function () {
252259
// console.log('cashAPR is', cashAPR, 'and is of type ', typeof(cashAPR));
253260
// console.log('totalFee is', totalFee, 'and is of type ', typeof(totalFee));
254261
// console.log('totalInt is', totalInt, 'and is of type ', typeof(totalInt));
255-
$('#cardCost'+i+'').html("$" + (totalInt+totalFee).toFixed(0));
262+
$('#cardCost'+i+'').html("$" + (((totalInt+totalFee)/duration).toFixed(2)));
256263
};
257264
}
258265

@@ -284,7 +291,6 @@ $(document).ready(function () {
284291
update();
285292
},
286293
stop: function (event, ui) {
287-
console.log('this thing stopped');
288294
$("#securedCardTable").tablesorter({
289295
sortList: [[sortcell,0]]
290296
});
@@ -349,4 +355,234 @@ $(document).ready(function () {
349355
});
350356

351357
});
352-
// ************** end slider for secured card blog site **********//
358+
// ************** end slider for secured card blog site **********//
359+
360+
361+
// ***************** sliders for prepaid card calculator ************//
362+
363+
$(document).ready(function () {
364+
var prepaidDuration = parseFloat($("#prepaidDuration").html());
365+
var wklyLoad = parseFloat($("#wklyLoad").html());
366+
var directDep = ($("#directDep").html())=="true";
367+
var wklyTrans = parseFloat($("#wklyTrans").html());
368+
var wklyATMBalChk = parseFloat($("#wklyATMBalChk").html());
369+
var wklyATMCash = parseFloat($("#wklyATMCash").html());
370+
var cards = parseFloat($("#prepaidCards").html());
371+
372+
373+
// console.log('purBal is', purBal, 'and is of type ', typeof(purBal));
374+
// console.log('cashBal is', cashBal, 'and is of type ', typeof(cashBal));
375+
// console.log('duration is', duration, 'and is of type ', typeof(duration));
376+
// console.log('cards is', cards, 'and is of type ', typeof(cards));
377+
378+
function update (){
379+
for ( var i = 0 ; i<cards ; i++){
380+
var activationFee = parseFloat($('#activationFee'+i+'').html());
381+
var mthFeeDirectDep = parseFloat($('#mthFeeDirectDep'+i+'').html());
382+
var mthFeeNoDirectDep = parseFloat($('#mthFeeNoDirectDep'+i+'').html());
383+
var transFeeSig = parseFloat($('#transFeeSig'+i+'').html());
384+
var atmBalInq = parseFloat($('#atmBalInq'+i+'').html());
385+
var atmWithdraw = parseFloat($('#atmWithdraw'+i+'').html());
386+
var reduceMthFeeLevel = parseFloat($('#reduceMthFeeLevel'+i+'').html());
387+
var reduceMthFee = parseFloat($('#reduceMthFee'+i+'').html());
388+
var mthFeeDirectDep = parseFloat($('#mthFeeDirectDep'+i+'').html());
389+
390+
391+
var transFees = (wklyTrans*transFeeSig+wklyATMBalChk*atmBalInq+wklyATMCash*atmWithdraw)
392+
393+
394+
// calculates monthly fee based on minimums and direct deposit
395+
if (!isNaN(reduceMthFeeLevel) && wklyLoad/7*30.5>=reduceMthFeeLevel) {prepaidMonthlyFee = reduceMthFee}
396+
else if (directDep) {prepaidMonthlyFee=mthFeeDirectDep}
397+
else {prepaidMonthlyFee=mthFeeNoDirectDep}
398+
399+
// console.log('directDep is', directDep, 'and is of type ', typeof(directDep));
400+
// console.log('transFeeSig is', transFeeSig, 'and is of type ', typeof(transFeeSig));
401+
// console.log('wklyATMBalChk is', wklyATMBalChk, 'and is of type ', typeof(wklyATMBalChk));
402+
// console.log('atmBalInq is', atmBalInq, 'and is of type ', typeof(atmBalInq));
403+
// console.log('wklyATMBalChk is', wklyATMBalChk, 'and is of type ', typeof(wklyATMBalChk));
404+
// console.log('atmWithdraw is', atmWithdraw, 'and is of type ', typeof(atmWithdraw));
405+
// $('#prepaidCost'+i+'').html("$" + (activationFee/prepaidDuration+transFees).toFixed(2));
406+
$('#prepaidCost'+i+'').html("$" + ((activationFee/prepaidDuration + prepaidMonthlyFee)/30.5*7 + transFees).toFixed(2));
407+
408+
};
409+
}
410+
$("#sliderWklyTrans").slider({
411+
value: wklyTrans,
412+
min: 0,
413+
max: 40,
414+
step: 1,
415+
slide: function (event, ui){
416+
$("#calcWklyTrans").html(ui.value);
417+
wklyTrans = ui.value;
418+
update();
419+
},
420+
stop: function (event, ui) {$("#prepaidTable").tablesorter({
421+
sortList: [[sortcell,0]]
422+
});
423+
}
424+
});
425+
426+
$("#sliderATMInq").slider({
427+
value: wklyATMBalChk,
428+
min: 0,
429+
max: 7,
430+
step: 1,
431+
slide: function (event, ui){
432+
$("#calcATMInq").html(ui.value);
433+
wklyATMBalChk= ui.value;
434+
update();
435+
},
436+
stop: function (event, ui) {$("#prepaidTable").tablesorter({
437+
sortList: [[sortcell,0]]
438+
});
439+
}
440+
});
441+
442+
$("#sliderATMCash").slider({
443+
value: wklyATMCash,
444+
min: 0,
445+
max: 7,
446+
step: 1,
447+
slide: function (event, ui){
448+
$("#calcATMCash").html(ui.value);
449+
wklyATMCash = ui.value;
450+
update();
451+
},
452+
stop: function (event, ui) {$("#prepaidTable").tablesorter({
453+
sortList: [[sortcell,0]]
454+
});
455+
}
456+
});
457+
458+
$("input[name='radioDirectDep']").change(function(){
459+
directDep = ($('input[name=radioDirectDep]:checked').val())=="true";
460+
if (directDep){$("#calcDirectDep").html("Yes")}
461+
else {$("#calcDirectDep").html("No")} ;
462+
update();
463+
$("#prepaidTable").tablesorter({
464+
sortList: [[sortcell,0]]
465+
});
466+
});
467+
468+
$("#sliderWklyLoad").slider({
469+
value: wklyLoad,
470+
min: 20,
471+
max: 1000,
472+
step: 50,
473+
slide: function (event, ui){
474+
$("#calcWklyLoad").html(ui.value).currency({decimals:0});
475+
wklyLoad = ui.value;
476+
update();
477+
},
478+
stop: function (event, ui) {$("#prepaidTable").tablesorter({
479+
sortList: [[sortcell,0]]
480+
});
481+
}
482+
});
483+
484+
$("#sliderPrepaidDuration").slider({
485+
value: prepaidDuration,
486+
min: 1,
487+
max: 36,
488+
step: 1,
489+
slide: function (event, ui){
490+
$("#calcPrepaidDur").html(ui.value);
491+
prepaidDuration = ui.value;
492+
update();
493+
},
494+
stop: function (event, ui) {$("#prepaidTable").tablesorter({
495+
sortList: [[sortcell,0]]
496+
});
497+
}
498+
});
499+
500+
501+
});
502+
// ***************** end sliders for prepaid card calculator************//
503+
504+
505+
// ***************** sliders for prepaid card calculator blog version ************//
506+
507+
$(document).ready(function () {
508+
509+
var prepaidDuration = parseFloat($("#prepaidDuration").html());
510+
var wklyLoad = parseFloat($("#wklyLoad").html());
511+
var directDep = ($("#directDep").html())=="true";
512+
var wklyTrans = parseFloat($("#wklyTrans").html());
513+
var wklyATMBalChk = parseFloat($("#wklyATMBalChk").html());
514+
var wklyATMCash = parseFloat($("#wklyATMCash").html());
515+
var cards = parseFloat($("#prepaidCards").html());
516+
517+
$("#blogSliderWklyTrans").slider({
518+
value: wklyTrans,
519+
min: 0,
520+
max: 40,
521+
step: 1,
522+
slide: function (event, ui){
523+
$("#blogCalcWklyTrans").html(ui.value);
524+
$("#criteria_CalcWklyTrans").val(ui.value);
525+
},
526+
});
527+
528+
$("#blogSliderATMInq").slider({
529+
value: wklyATMBalChk,
530+
min: 0,
531+
max: 7,
532+
step: 1,
533+
slide: function (event, ui){
534+
$("#blogCalcATMInq").html(ui.value);
535+
$("#criteria_CalcATMInq").val(ui.value);
536+
},
537+
});
538+
539+
$("#blogSliderATMCash").slider({
540+
value: wklyATMCash,
541+
min: 0,
542+
max: 7,
543+
step: 1,
544+
slide: function (event, ui){
545+
$("#blogCalcATMCash").html(ui.value);
546+
$("#criteria_CalcATMCash").val(ui.value);
547+
},
548+
});
549+
550+
$("input[name='blogRadioDirectDep']").change(function(){
551+
directDep = ($('input[name=blogRadioDirectDep]:checked').val())=="true";
552+
if (directDep){
553+
$("#blogCalcDirectDep").html("Yes");
554+
$("#criteria_CalcDirectDep").val("true");
555+
}
556+
else {
557+
$("#blogCalcDirectDep").html("No");
558+
$("#criteria_CalcDirectDep").val("false");
559+
};
560+
});
561+
562+
$("#blogSliderWklyLoad").slider({
563+
value: wklyLoad,
564+
min: 20,
565+
max: 1000,
566+
step: 50,
567+
slide: function (event, ui){
568+
$("#blogCalcWklyLoad").html(ui.value).currency({decimals:0});
569+
$("#criteria_CalcWklyLoad").val(ui.value);
570+
},
571+
});
572+
573+
$("#blogSliderPrepaidDuration").slider({
574+
value: prepaidDuration,
575+
min: 1,
576+
max: 36,
577+
step: 1,
578+
slide: function (event, ui){
579+
$("#blogCalcPrepaidDur").html(ui.value);
580+
$("#criteria_CalcPrepaidDur").val(ui.value);
581+
},
582+
});
583+
584+
585+
});
586+
// ***************** end sliders for prepaid card calculator blog version ************//
587+
588+

0 commit comments

Comments
 (0)