-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwidget.min.js
1 lines (1 loc) · 4.63 KB
/
widget.min.js
1
var _tfrce_config=typeof tfrce_config!=="undefined"?tfrce_config:{};(function(e,t){function s(e,t,n){var r=new Date((new Date).getTime()+n*1e3);var i=escape(t)+(n==null?"":"; expires="+r.toUTCString());document.cookie=e+"="+i}function o(e){var t=document.cookie;var n=t.indexOf(" "+e+"=");if(n==-1){n=t.indexOf(e+"=")}if(n==-1){t=null}else{n=t.indexOf("=",n)+1;var r=t.indexOf(";",n);if(r==-1){r=t.length}t=unescape(t.substring(n,r))}return t}t.show_style=t.show_style||"default";t.disableGeo=t.disableGeo||false;t.debug=t.debug||false;t.disableDate=t.disableDate||false;t.campaign=t.campaign||"stopwatchingus";t.cookieTimeout=t.cookieTimeout||172800;var n;var r,i;if(t.debug){r="../stopwatchingus/";i=20}else{r="//d1ux67szpr7bp0.cloudfront.net/project-megaphone/stopwatchingus/";i=t.cookieTimeout}var u={betweenDate:function(e,t){var n=e.getTime();var r=t.getTime();var i=(new Date).getTime();if(i>n&&i<r){return true}else{return false}},isMobile:function(){var e=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);return e?false:true},hasSeenCampaign:function(e){var t=o(e);if(t===null){return false}else{return true}},nearDC:function(t){e.nearDC=t;var n=document.createElement("script");n.src="//geoip.taskforce.is/?callback=nearDC";document.getElementsByTagName("head")[0].appendChild(n)}};var a={stopwatchingus:{cookieName:"stopwatchingus_hasseen6",startDate:new Date(2013,9,15,0),endDate:new Date(2013,9,26,12),hide:function(e,t){document.body.removeChild(e);s(n.cookieName,"true",i);if(t){t()}},styles:{"default":{campaign_container:"position:fixed;width:100%;bottom:0;left:0;z-index:100000; padding: 0 20px;-webkit-box-sizing: border-box; -moz-box-sizing: border-box;",iframe_container:"position: relative; height: 100px; max-width:1201px; margin: 0px auto 8px auto; background: #444;border-radius: 10px;",iframe:"width: 100%;height: 100%;border: 0;margin:0;padding:0;border-radius: 10px;",closeButton:'border: 0;height: 28px;width: 28px;cursor: pointer;position: absolute;top:33px;right:20px;background: url("'+r+'images/close-button.png");'},dev:{campaign_container:"position:fixed;width:100%;bottom:0;left:0;z-index:100000; padding: 0 20px;-webkit-box-sizing: border-box; -moz-box-sizing: border-box;",iframe_container:"position: relative; height: 100px; max-width:1201px; margin: 0px auto 8px auto; background: #444;border-radius: 10px;",iframe:"width: 100%;height: 100%;border: 0;margin:0;padding:0;border-radius: 10px;",closeButton:'border: 0;height: 28px;width: 28px;cursor: pointer;position: absolute;top:33px;right:20px;background: url("'+r+'images/close-button.png");'},strip:{campaign_container:"position:fixed;width:100%;left:0;bottom:0;opacity:1;z-index:100000;-webkit-box-sizing: border-box; -moz-box-sizing: border-box;",iframe_container:"position:relative;height:50px;margin:0 20px 0px 20px;background:#444;border-radius:10px 10px 0 0;",iframe:"width:100%;height:100%;border:0;margin:0;padding:0;border-radius:10px;",closeButton:'border:0;height:28px;width:28px;cursor:pointer;position:absolute;top:11px;right:10px;background:url("'+r+'images/close-button.png");'},modal:{overlay:"position:fixed; background:#000; width:100%; height:100%;z-index:100000;top:0; left:0; opacity:0.5;-moz-opacity: 0.50;filter: alpha(opacity=50);",campaign_container:"position:fixed;left:50%;margin-left:-250px;margin-top:40px;width:500px;top:0;opacity:1;z-index:100010;",iframe_container:"position:relative;height:365px; width:500px;background:#444;border-radius:10px;",iframe:"width:100%;height:100%;border:0;margin:0;padding:0;border-radius:10px;",closeButton:'border:0;height:28px;width:28px;cursor:pointer;position:absolute;top:15px;right:15px;background:url("'+r+'images/close-button.png");'}},show:function(){var e=n.styles[n.config.show_style];if(e.overlay){var t=document.createElement("div");t.style.cssText=e.overlay;document.body.appendChild(t)}var i=document.createElement("div");i.style.cssText=e.campaign_container;var s=document.createElement("div");s.style.cssText=e.iframe_container;i.appendChild(s);document.body.appendChild(i);var o=document.createElement("iframe");o.style.cssText=e.iframe;o.src=r+n.config.show_style+".html";s.appendChild(o);var u=document.createElement("button");u.style.cssText=e.closeButton;s.appendChild(u);u.onclick=function(){n.hide(i);if(e.overlay){document.body.removeChild(t)}}},init:function(e){n.config=e;if(u.hasSeenCampaign(n.cookieName)){return false}if(!u.betweenDate(n.startDate,n.endDate)&&!n.config.disableDate){return false}if(!u.isMobile()){return false}if(n.config.disableGeo){n.show()}else{u.nearDC(function(e){if(e.kilometersFromDC<=700){n.show()}})}}}};if(typeof a[t.campaign]!=="undefined"){n=a[t.campaign];n.init(t)}else{return false}})(window,_tfrce_config)