Wed Oct 04 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
(function fetchRemarketingRSI(){
	var dfd = $.Deferred();
	//TODO
	var t=[];

	console.log('Fteching Remarketing RSI');
	var ifr = document.createElement('iframe');
	ifr.src = '//www.rosettastone.com/lp/sbsr/rmsitewide/';
	ifr.style.visibility = 'hidden';
	ifr.style.position = 'absolute';
	ifr.setAttribute('tabindex','-1');
	ifr.setAttribute('aria-hidden',true);

	window.addEventListener('message', function RSIReadyListener(d){ if(d.data=='RSIReady'){
			console.log('RSI is Ready');

			window.removeEventListener('message', RSIReadyListener);

			window.addEventListener('message', function(d){
				console.log('RSI Received');
				//debugger;
				if(typeof d.data=='string' && d.data.match(/RSI:::::/)) {
					try {
						window.rmRSI = JSON.parse( JSON.parse( d.data.replace(/RSI:::::/,'') ) );
						t = window.rmRSI;
						function RSI(e){function n(e){if(typeof e!="object")return[];var n=[],r=t.slice(),i=[],s;for(var o in e)e.hasOwnProperty(o)&&i.push([o,e[o]]);var u;if(!i.length)return[];while(s=r.pop()){u=!0;for(var a=0,f=i.length;a<f;a++){var l=i[a][0],c=i[a][1];if(!s[l]||s[l]!==c)u=!1,a=f}u&&n.push(s)}return n}return e?n(e):t}RSI.promo="q2_199",RSI.phone="1-800-ROSETTA",RSI.expirationDate="9/14/2017 at 11:59PM EST",RSI.crescendo="fallpause.json",RSI.header={type:"invisible",fivePay:40,mastheadImage:"fallyellowaii.jpg",strikeThrough:[],tophtml:"",bottomhtml:""},RSI.percentoff=60,RSI.rsi="rmsitewide"
						dfd.resolve(RSI);
					}
					catch(e){
						console.log('Rejected: RSI not handled properly');
					} 

				} 
			})

			ifr.contentWindow.postMessage('RSIRequest', window.location.protocol + '//' + window.location.hostname);
		}
	});

	document.body.appendChild(ifr);

	return dfd;
})()