Tue Apr 24 2018
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
<script>
var exp = 2   // change this to 1 or 2



if (exp === 1)
{   

    var newdata = {
        "06": { dollar: '19', cents: '84', total: '119.94', currentpromo: 'parthenon_', newpromo: 'taxday' },
        "12": { dollar: '14', cents: '92', total: '179.04', currentpromo: 'parthenon_', newpromo: 'taxday' }
    }

     // LP Redirects
     var destination = {
        sitewide: 		'aprilshowers24M749',
        rmsitewide: 	'aprilshowers24M749',
        sale: 			'aprilshowers24M749',
        earthday749: 	'earthday24M749',
        earthday699:	'earthday24M699',
        taxday749: 		'taxday24M749',
        taxday699:		'taxday24M699',
        aprilshowers11: 'aprilshowers24M11',
        aprilshowers749:'aprilshowers24M749',
        aprilclose699:'aprilshowers24M699',
        earthday599:	'earthday24M599',
        taxday599:		'taxday24M599'   
    }
    
}
else
{
    var newdata = {
        "03": { dollar: '18', cents: '99', total: '56.97', currentpromo: 'parthenon', newpromo: 'mountfuji' },
        "06": { dollar: '16', cents: '99', total: '101.94', currentpromo: 'parthenon', newpromo: 'goldengate' },
        "12": { dollar: '12', cents: '99', total: '155.88', currentpromo: 'parthenon', newpromo: 'goldengate' },
        "24": { dollar: '8', cents: '49', total: '203.76', currentpromo: 'parthenon', newpromo: 'goldengate' }
    }

    // LP Redirects
    var destination = {
        sitewide: 		'aprilshowers3M27',
        rmsitewide: 	'aprilshowers3M1899',
        sale: 			'aprilshowers3M1899',
        earthday749: 	'earthday3M1899',
        earthday699:	'earthday3M1799',
        taxday749: 		'taxday3M1899',
        taxday699:		'taxday3m1799',
        aprilshowers11: 'aprilshowers3M27',
        aprilshowers749:'aprilshowers3M1899',
        aprilclose699:  'aprilshowers3M1799',
        earthday599:	'earthday3M1699',
        taxday599:		'taxday3M1699'   
    }

    // Update best offer
    var bv = $('.oct_2016_best_value').html('Introductory Offer').detach()
    $('a[data-lvl="03"]').parents('.oct_2016_product_square_content').prepend(bv)

    // mobile
    if ($('.mobile_products_container.js_oct_2016_product').is(':visible'))
    {
        var bvm = $('.labelcontain.topper').css({margin: '11px 0 -13px', padding: '.5em 0'}).html('Introductory Offer').detach()
        $('.mobile_msrp[data-lvl="03"]').parents('.monthly_mobilebottom.labelcontain').siblings('label.mobile_product_label').eq(3).before(bvm)
        try
        {
            $('.js_onemonth_toggle_3').before(bvm)
        }
        catch (e)   { }
        $('.mobile_product_label').eq(0).css({'border-top-left-radius' : '5px'})
        $('.mobile_product_label').eq(0).css({'border-top-right-radius' : '5px'})
    }
}



/************* CATALOG ****************/

if (!!window.location.href.match(/learn-/)) { 

} 

/***************** LP ****************/
else
{    
    // In Landing Pages, we redirect
    Object.keys(destination).forEach(function(e,i) {    
        if (e == RSI.rsi) {
            var re = new RegExp(e, "g");
            var dst = window.location.href.replace(re, destination[e]);	
            window.location.href = dst
        }
    })
}




// Loop through cart buttons on desktop
$.each($('a.oct_2016_addtocart_square.js_oct_2016_addtocart'), function(i, e) {        
    var lvl = $(e).attr('data-lvl')          
    update_cart_buttons(lvl, $(e))
    update_html(lvl)    
})


// Update egift add to cart when radio changes 
$('#giftinglevelselect').on('change', function(e) {
    update_cart_buttons(e.target.value, $('#giftingproduct_cartlink'))
    update_html(e.target.value)
})   

// Update mobile add-to-cart when radio changes
$('.mobile_radio').on('change', function(e) {
    var lvl = e.target.dataset.lvl
    update_cart_buttons(lvl, $('.js_addtocart_mobile'))
    update_html(lvl)
})




/****************************************
 Update Cart Buttons
*********************************************/
function update_cart_buttons (lvl, $cartbtn) 
{
    if ( !(lvl in newdata)) return   

    var href = $cartbtn.attr('href')
    var re = new RegExp(newdata[lvl].currentpromo, "g");
    var newhref = href.replace(re, newdata[lvl].newpromo);    
}



function update_html (lvl)
{   
    if ( !(lvl in newdata)) return

    // Desktop
    $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"] > div > p:first-of-type').html('.'+newdata[lvl].cents)
    var $cents = $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"] > div').detach()
    $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"]').text(newdata[lvl].dollar)
    $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"]').append($cents)

    $('a.oct_2016_addtocart_square.js_oct_2016_addtocart[data-lvl="'+lvl+'"')
        .siblings('.oct_2016_msrp_square').find('strong').html(newdata[lvl].total)


    // Mobile 
    $('.mobile_price.js_oct_2016_price.no_month[data-lvl="'+lvl+'"]').html(newdata[lvl].dollar)
    $('.mobile_price.js_oct_2016_price.no_month[data-lvl="'+lvl+'"] + .productcents > p:first-of-type').html('.'+newdata[lvl].cents)
    $('.mobile_msrp[data-lvl="'+lvl+'"] + strong').html('$' + newdata[lvl].total)

    // Egift
    $('p#giftingproduct_saleprice').html('$' + newdata[lvl].dollar)
    $('.giftingproduct_buysection > div > p:first-of-type').html('.' + newdata[lvl].cents)
}
</script>