- 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
function update_prices(selector){
window.location.search.match(/showfull=/) && (window.__showFullPrices = 1);
var prices = document.querySelectorAll(selector);
var rsidata, lvl, media, isMsrp, multipay_divisor, msrp, price, isMobile;
for(var i=0; i<prices.length; i++){
lvl = prices[i].getAttribute('data-lvl');
media = prices[i].getAttribute('data-media');
isMsrp = prices[i].getAttribute('data-is-msrp');
isMobile = /mobile_/.test(prices[i].className);
multipay_divisor = prices[i].getAttribute('data-multipay-divisor');
rsidata = RSI({'lvl':lvl, 'media':media})[0];
// check if rsidata exists (to avoid errors such as looking for S5 data in an S3 product)
if(rsidata){
msrp = multipay_divisor ? Math.ceil(rsidata.msrp/multipay_divisor) : rsidata.msrp;
price = multipay_divisor ? Math.ceil(rsidata.price/multipay_divisor) : rsidata.price;
if(isMsrp){
//Reset MSRPs:
if(!window.__showFullPrices && rsidata.lvl in {'24':1,'12':1,'06':1,'03':1,'01':1}){
//Monthly
if(prices[i].getAttribute('class').match(/mobile_msrp/gi)){
//Mobile MSRP & Label Adjust
var mpc = prices[i].parentNode;
mpc.removeChild(prices[i]);
var mobileproductlabel = mpc.parentNode;
mobileproductlabel.style.top = '7px';
mobileproductlabel.style['border-radius'] ='unset';
if(rsidata.lvl == '24'){
!mobileproductlabel.querySelector('.labelcontain.topper') && mobileproductlabel.insertAdjacentHTML('beforebegin','<div class="labelcontain topper">Best Value</div>');
mobileproductlabel.style['margin-top'] = '0';
}
else {
mobileproductlabel.style['border-top-left-radius'] = '5px';
mobileproductlabel.style['border-top-right-radius'] = '5px';
}
!mobileproductlabel.querySelector('.monthly_mobilebottom') && mobileproductlabel.insertAdjacentHTML('afterend', '<div class="monthly_mobilebottom labelcontain">'+ prices[i].outerHTML +'<strong style="font-family: GothamBold; display: inline-block; margin: 0 .1em;">$'+ rsidata.price +'</strong> due today</div>');
}
else {
//Desktop
prices[i].innerHTML = msrp;
var msrpcontainer = prices[i].parentNode.parentNode;
var nodes = Array.prototype.slice.call(msrpcontainer.childNodes);
nodes[0] && nodes[0].nodeName.match(/text/gi) && nodes[0].parentNode.removeChild(nodes[0]);
if(!msrpcontainer.querySelector('.msrpstrong')){
msrpcontainer.insertAdjacentHTML('beforeend','<strong class="msrpstrong" style="display: inline-block; margin: 0 .5em; font-family: GothamBold;">$' + rsidata.price + '</strong><span>due today</span>');
}
}
}
else {
//Full
prices[i].innerHTML = msrp;
if(msrp===price){
if(isMobile){
prices[i].style.visibility = 'hidden';
}
else{
prices[i].parentElement.parentElement.style.visibility = 'hidden';
}
}
}
}
else{
//Reset prices:
if(!window.__showFullPrices && rsidata.lvl in {'24':1,'12':1,'06':1,'03':1,'01':1}){
var monthlyprice = (Math.ceil((parseInt(rsidata.price, 10)/parseInt(rsidata.lvl, 10))*100)/100).toFixed(2);
//Monthly
if(prices[i].getAttribute('class').match(/mobile_price/gi)){
//Mobile
var mpc = prices[i].parentNode;
prices[i].textContent = monthlyprice.split('.')[0];
prices[i].style['font-size'] ='2.5em';
!mpc.querySelector('.productcents') && mpc.insertAdjacentHTML('beforeend','<div class="productcents" style="display: inline-block; font-size: 1em; vertical-align: top; text-align: left; margin-top: 0.3em"><p>.' + monthlyprice.split('.')[1] + '</p><p>/Month</p></div>');
}
else {
//Desktop
prices[i].innerHTML = monthlyprice.split('.')[0];
prices[i].insertAdjacentHTML('beforeend', '<div style="display: inline-block; font-size: 0.385em; vertical-align: top; text-align: left; margin-top: 0.3em; vertical-align: baseline; line-height: 1.2;"><p>.' + monthlyprice.split('.')[1] + '</p><p>/Month</p></div>');
}
}
else {
//Full
prices[i].innerHTML = price;
}
}
}
}
}