Add net neutrality widget

This commit is contained in:
Samuel Shifterovich
2017-07-10 21:36:53 +02:00
parent 153967dfc4
commit 14c07c21b1
13 changed files with 453 additions and 0 deletions

View File

@ -59,6 +59,75 @@
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="privacytools.io" />
<!-- July 12 widget -->
<script type="text/javascript">
var _bftn_options = {
/*
* Choose from 'money', 'stop', and 'slow'. Omit this property to get the
* default theme.
*/
theme: 'stop', // @type {string}
/*
* Or, if you want your own custom theme, specify its properties here.
* Unspecified options will fall back to the default values.
*/
theme: {
className: 'stop', // @type {string} will be applied to iframe body tag
logos: ['images/stop.png'], // @type {Array} img src values
headline: 'This site has been blocked by your ISP.', // @type {string} modal headline text
body: 'Well, not yet. But without net neutrality, cable companies could censor websites, favoring their own business partners. We can stop them and keep the Internet open, fast, and awesome if we all contact Congress and the FCC, but we only have a few days left.' // @type {string} modal body text
},
/*
* Choose from 'fp' for Free Press, 'dp' for Demand Progress or
* 'fftf' for Fight for the Future. Omit this property to randomly split
* form submissions between all organizations in the Battle for the Net
* coalition.
*/
org: 'fftf', // @type {string}
/*
* Specify a delay (in milliseconds) before showing the widget. Defaults to one
* second.
*/
delay: 1000, // @type {number}
/*
* Specify a date on which to display the widget. Defaults to July 12th, 2017 if
* omitted. ISO-8601 dates are UTC time, three-argument dates (with a zero-based
* month) are local time.
*/
date: new Date(2017, 6, 12), // @type {Date}
/*
* If you show the modal on your homepage, you should let users close it to
* access your site. However, if you launch a new tab to open the modal, closing
* the modal just leaves the user staring at a blank page. Set this to true to
* prevent closing the modal - the user can close the tab to dismiss it. Defaults
* to false.
*/
uncloseable: false, // @type {Boolean}
/*
* Always show the widget. Useful for testing.
*/
always_show_widget: false // @type {Boolean}
};
</script>
<script>(function(){if(typeof _bftn_options=="undefined")_bftn_options={};if(typeof _bftn_options.iframe_base_path=="undefined")_bftn_options.iframe_base_path='net_neutrality_widget';if(typeof _bftn_options.animation=="undefined")_bftn_options.animation='main';if(typeof _bftn_options.delay=="undefined")_bftn_options.delay=1000;if(typeof _bftn_options.debug=="undefined")_bftn_options.debug=false;if(typeof _bftn_options.date=="undefined")_bftn_options.date=new Date(2017,6,12);if(typeof _bftn_options.always_show_widget=="undefined")_bftn_options.always_show_widget=false;var _bftn_animations={main:{options:{modalAnimation:'main'},init:function(options){for(var k in options)this.options[k]=options[k];return this;},start:function(){var iframe=_bftn_util.createIframe();_bftn_util.bindIframeCommunicator(document.getElementById('_bftn_iframe'),this);},stop:function(){_bftn_util.destroyIframe();}}}
var _bftn_util={injectCSS:function(id,css){var style=document.createElement('style');style.type='text/css';style.id=id;if(style.styleSheet)style.styleSheet.cssText=css;else style.appendChild(document.createTextNode(css));document.head.appendChild(style);},createIframe:function(){var wrapper=document.createElement('div');wrapper.id='_bftn_wrapper';var iframe=document.createElement('iframe');iframe.id='_bftn_iframe';iframe.src=_bftn_options.iframe_base_path+'/iframe.html';iframe.frameBorder=0;iframe.allowTransparency=true;iframe.style.display='none';wrapper.appendChild(iframe);document.body.appendChild(wrapper);return wrapper;},destroyIframe:function(){var iframe=document.getElementById('_bftn_wrapper');iframe.parentNode.removeChild(iframe);},bindIframeCommunicator:function(iframe,animation){function sendMessage(requestType,data){data||(data={});data.requestType=requestType;data.BFTN_WIDGET_MSG=true;iframe.contentWindow.postMessage(data,'*');}
var eventMethod=window.addEventListener?"addEventListener":"attachEvent";var eventer=window[eventMethod];var messageEvent=eventMethod=="attachEvent"?"onmessage":"message";eventer(messageEvent,function(e){if(!e.data||!e.data.BFTN_IFRAME_MSG)return;delete e.data.BFTN_IFRAME_MSG;switch(e.data.requestType){case'getAnimation':iframe.style.display='block';sendMessage('putAnimation',animation.options);break;case'stop':animation.stop();break;}},false);},setCookie:function(name,val,exdays){var d=new Date();d.setTime(d.getTime()+(exdays*24*60*60*1000));var expires="expires="+d.toGMTString();document.cookie=name+"="+ val+"; "+ expires;},getCookie:function(cname){var name=cname+"=";var ca=document.cookie.split(';');var c;for(var i=0;i<ca.length;i++){c=ca[i].trim();if(c.indexOf(name)==0){return c.substring(name.length,c.length);}}
return"";},log:function(){if(_bftn_options.debug)console.log.apply(console,arguments);}}
function onDomContentLoaded(){var images=new Array();var preloaded=0;function init(){setTimeout(function(){_bftn_animations[_bftn_options.animation].init(_bftn_options).start();},_bftn_options.delay);}
function preload(){for(i=0;i<preload.arguments.length;i++){images[i]=new Image()
images[i].src=_bftn_options.iframe_base_path+'/images/'+ preload.arguments[i]
images[i].onload=function(){preloaded++;_bftn_util.log('Preloaded '+ preloaded+' images.');if(preloaded==images.length){_bftn_util.log('DONE PRELOADING IMAGES. Starting animation in '+ _bftn_options.delay+' milliseconds.');init();}}}}
if(!_bftn_options.always_show_widget&&window.location.href.indexOf('ALWAYS_SHOW_BFTN_WIDGET')===-1){if(_bftn_util.getCookie('_BFTN_WIDGET_SHOWN'))return;var today=new Date();if(today.getFullYear()!==_bftn_options.date.getFullYear()||today.getMonth()!==_bftn_options.date.getMonth()||today.getDate()!==_bftn_options.date.getDate()){return;}}
_bftn_util.setCookie('_BFTN_WIDGET_SHOWN','true',365);_bftn_util.injectCSS('_bftn_iframe_css','#_bftn_wrapper { position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 20000; -webkit-overflow-scrolling: touch; overflow-y: scroll; } #_bftn_iframe { width: 100%; height: 100%; }');init();}
switch(document.readyState){case'complete':case'loaded':case'interactive':onDomContentLoaded();break;default:if(typeof document.addEventListener==='function'){document.addEventListener('DOMContentLoaded',onDomContentLoaded,false);}}})();</script>
</head>
<body>