- 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
/*
campaign pages: single point of failure, low dev depencency
past dev dependencies: every flip compile + upload pages with RSI, upload images, upload crescendos, upload expiration date, when needed update templates
future dev dependencies: when needed update Templates + RSIs
future marketing dependencies: every flip upload images, upload crescendos, upload expiration date, update promo codes
test url: http://www.rosettastone.com/lp/sbsr/testing/?c=watermelon&r=aii
*/
// IF CAMPGAIN AND RSI URL PARAMS EXIST
if(parameterExists('c') && parameterExists('r')){
var campaign = getParameter('c');
var pricepoint = getParameter('r');
var rsiURL = "http://www.rosettastone.com/lp/globals/models/"+ campaign + pricepoint +".js";
$.ajax({
url: rsiURL,
})
// UPDATE RSI VIA SUCCESS
.done(function(res){
// UPDATE URL
history.replaceState({},"campaign title","/lp/sbsr/"+campaign+pricepoint);
// UPDATE MASTHEAD IMAGE
document.getElementById('masthead').style.backgroundImage = "url('http://www.rosettastone.com/lp/globals/img/mastheads/sbsr/"+ campaign +".jpg')";
// UPDATE EXPIRATION DATE
document.getElementById('expirationdate').innerHTML = RSI.expirationDate;
// UPDATE CRESCENDO
$.getJSON('../../globals/crescendos/' + RSI.crescendo, startCrescendo);
})
// KEEP SITEWIDE EXPERIENCE
.fail(function(err){
console.log('Error: ' + err.status);
});
}
function parameterExists(param){
var reg = new RegExp('[?&]'+param+'=','i');
return !!window.location.search.match(reg);
}
function getParameter(param){
var reg = new RegExp('[?&]'+param+'=([^&]+)','i');
return parameterExists(param) ? window.location.search.match(reg)[1] : '';
}