Mon Oct 30 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
<script async defer>
function switchToMonthlyPricesDesktop($productsquare){
    function changePriceDisplay($bigpricesquare){
        var $bps = $bigpricesquare.find('.oct_2016_big_price_square');
        //debugger;
        var currentprice = parseInt($bps.text(), 10);
        var months = parseInt($bps.data('lvl'), 10);
        var monthlyprice = Math.round((currentprice / months) * 100);
        var dollars = ~~(monthlyprice / 100);
        var cents = monthlyprice - dollars * 100;
        //console.log('big price square: ', currentprice, ' months: ', months, ' monthlyprice: ', monthlyprice, ' dollars: ', dollars, 'cents: ', cents);

        $bps.text(dollars);
        //debugger;
        $bps.append('<div style="display: inline-block; font-size: 0.385em; vertical-align: top; text-align: left; margin-top: 0.3em"><p>.' + (cents + '00').substring(0,2) + '</p><p>/Month</p></div>');
        return currentprice;
    }
    function changeMSRPDisplay($msrpcontainer, originalprice){
        var nodes = Array.prototype.slice.call($msrpcontainer.get(0).childNodes);
        nodes[0] && nodes[0].nodeName.match(/text/gi) && nodes[0].remove();
        $msrpcontainer.append('<strong style="display: inline-block; margin: 0 .5em; font-family: GothamBold;">$' + originalprice + '</strong><span>due today</span>');
        //console.log('msrp square: ');
    }
    
    var $pricecontainer = $productsquare.find('.oct_2016_price_container_square');
    var $msrpcontainer = $productsquare.find('.oct_2016_msrp_square');
    var originalprice = $pricecontainer && changePriceDisplay($pricecontainer);
    $msrpcontainer && changeMSRPDisplay($msrpcontainer, originalprice);
}

function switchToMonthlyPricesMobileExpB($mobileproductlabel, i){
    //console.count();
    var $mpc = $mobileproductlabel.find('.mobile_prices_container');
    var $msrp = $mpc.find('.mobile_msrp').detach();
    var $mobileprice = $mpc.find('.mobile_price');
    var currentprice = parseInt($mobileprice.text(), 10);
    var months = parseInt($mobileprice.data('lvl'), 10);
    var monthlyprice = Math.round((currentprice / months) * 100);
    var dollars = ~~(monthlyprice / 100);
    var cents = monthlyprice - dollars * 100;

    //console.log(currentprice,'#',months,'#',monthlyprice,'#',dollars,'#',cents);
    $mobileprice.text(dollars).css('font-size','2.5em');
    $mpc.append('<div style="display: inline-block; font-size: 1em; vertical-align: top; text-align: left; margin-top: 0.3em"><p>.' + (cents + '00').substring(0,2) + '</p><p>/Month</p></div>');
    //debugger;
    $mobileproductlabel.find('.mobile_product_name_container').css('top','7px');
    $mobileproductlabel.css('border-radius','unset');
    
    var $bot = $('<div class="monthly_mobilebottom labelcontain"><strong style="font-family: GothamBold; display: inline-block; margin: 0 .1em;">$'+ currentprice +'</strong> due today</div>');
    $mobileproductlabel.after($bot);
    $bot.css({
       'font-size': '16px',
       'color': '#555',
       'background-color': '#e5e5e5',
       'padding': '.25em 0',
       'border-bottom-left-radius': '5px',
       'border-bottom-right-radius': '5px' 
    });
    //$bot.prepend($msrp);

    if(i < 3){
        var $top = $('<div class="labelcontain">Save ' + {'0':'61','1':'43','2':'26'}[i] + '%</div>');

        $top.css({
           'font-size': '16px',
           'color': '#333',
           'background-color': '#EFC344',
           'padding': '.25em 0',
           'border-top-left-radius': '5px',
           'border-top-right-radius': '5px',
           'text-transform': 'uppercase',
           'font-family': 'GothamBold',
           'margin-top': '10px' 
        });
        $mobileproductlabel.before($top);
        $mobileproductlabel.css('margin-top','0');

        if(!i){
            $top.append('<p style="font-family: GothamBook; font-size: 15px;">Best Value</p>')
        }
    }
    else {
        $mobileproductlabel.css({
           'border-top-left-radius': '5px',
           'border-top-right-radius': '5px'
        });
    }
}

function switchToMonthlyPricesMobile($mobileproductlabel, i){
    //console.count();
    var $mpc = $mobileproductlabel.find('.mobile_prices_container');
    var $msrp = $mpc.find('.mobile_msrp').detach();
    var $mobileprice = $mpc.find('.mobile_price');
    var currentprice = parseInt($mobileprice.text(), 10);
    var months = parseInt($mobileprice.data('lvl'), 10);
    var monthlyprice = Math.round((currentprice / months) * 100);
    var dollars = ~~(monthlyprice / 100);
    var cents = monthlyprice - dollars * 100;

    //console.log(currentprice,'#',months,'#',monthlyprice,'#',dollars,'#',cents);
    $mobileprice.text(dollars).css('font-size','2.5em');
    $mpc.append('<div style="display: inline-block; font-size: 1em; vertical-align: top; text-align: left; margin-top: 0.3em"><p>.' + (cents + '00').substring(0,2) + '</p><p>/Month</p></div>');
    //debugger;
    $mobileproductlabel.find('.mobile_product_name_container').css('top','7px');
    $mobileproductlabel.css('border-radius','unset');
    
    var $bot = $('<div class="monthly_mobilebottom labelcontain"><strong style="font-family: GothamBold; display: inline-block; margin: 0 .1em;">$'+ currentprice +'</strong> due today</div>');
    $mobileproductlabel.after($bot);
    $bot.css({
       'font-size': '16px',
       'color': '#555',
       'background-color': '#e5e5e5',
       'padding': '.25em 0',
       'border-bottom-left-radius': '5px',
       'border-bottom-right-radius': '5px' 
    });
    $bot.prepend($msrp);

    if(!i){
        var $top = $('<div class="labelcontain">Best Value</div>');
        $top.css({
           'font-size': '16px',
           'color': '#333',
           'background-color': '#EFC344',
           'padding': '.25em 0',
           'border-top-left-radius': '5px',
           'border-top-right-radius': '5px',
           'text-transform': 'uppercase',
           'font-family': 'GothamBold' 
        });
        $mobileproductlabel.before($top);
        $mobileproductlabel.css('margin-top','0');
    }
    else {
        $mobileproductlabel.css({
           'border-top-left-radius': '5px',
           'border-top-right-radius': '5px'
        });
    }
}



function addRibbonsDesktop(){
    var $original = $('.oct_2016_best_value');
    

    var cla = $('.oct_2016_best_value').clone();
    cla.empty();
    var clb = $('.oct_2016_best_value').clone();
    clb.empty();

    $original.css({'font-family': 'GothamBook', 'font-size': '12px'});
    //debugger;
    var $twelve = $original.closest('.js_oct_2016_product').prev('.js_oct_2016_product');
    $twelve.prepend(cla);
    var $six = $twelve.prev('.js_oct_2016_product');
    $six.prepend(clb);

    $original.prepend('<strong style="font-family: GothamBold; display: block; text-transform: uppercase; font-size: 16px;">Save 61%</strong>');
    cla.prepend('<strong style="font-family: GothamBold; display: block; text-transform: uppercase; font-size: 16px;">Save 43%</strong>');
    clb.prepend('<strong style="font-family: GothamBold; display: block; text-transform: uppercase; font-size: 16px;">Save 26%</strong>');

}

function swapSquaresOrder(){
    var swapper = $('<div id="sqswap"></div>');
    var squares = $('.oct_2016_blue_bg .oct_2016_product_square').replaceWith(swapper);
    var tmp = [];
    squares.each(function(i,v){ tmp.unshift(v); });
    swapper.replaceWith($(tmp));
}


//EXPA::
/*$(function(){
    $('body').append('<style>@media (max-width: 560px){ .labelcontain{ max-width: 370px; margin: 0 auto; } }</style>');
	$('.oct_2016_blue_bg .oct_2016_product_square').map(function(i,el){ switchToMonthlyPricesDesktop($(el)); });
	$('.oct_2016_blue_bg .js_oct_2016_product .mobile_product_label').map(function(i,el){ switchToMonthlyPricesMobile($(el), i); });
});*/

//EXPB::
 $(function(){
 	$('.oct_2016_blue_bg .oct_2016_product_square').map(function(i,el){ switchToMonthlyPricesDesktop($(el)); });
 	$('.oct_2016_blue_bg .js_oct_2016_product .mobile_product_label').map(function(i,el){ switchToMonthlyPricesMobileExpB($(el), i); });
 	$('body').append('<style>@media (max-width: 560px){ .labelcontain{ max-width: 370px; margin: 0 auto; } }</style>');
 	addRibbonsDesktop();
 });

//EPXC::
// $(function(){
//     $('.oct_2016_blue_bg .oct_2016_product_square').map(function(i,el){ switchToMonthlyPricesDesktop($(el)); });
//     $('.oct_2016_blue_bg .js_oct_2016_product .mobile_product_label').map(function(i,el){ switchToMonthlyPricesMobile($(el), i); });
//     $('body').append('<style>@media (max-width: 560px){ .labelcontain{ max-width: 370px; margin: 0 auto; } }</style>');
//     swapSquaresOrder();
// });
</script>