Make FFTF newsletter opt-in

This commit is contained in:
Samuel Shifterovich 2017-07-10 22:25:05 +02:00
parent 71fdbd7dd8
commit d349873299

View File

@ -5,7 +5,7 @@ if(typeof theme=='object'){var keys=Object.keys(theme);var key;for(var i=0;i<key
return themeObj;}
function renderContent(theme){document.body.classList.add(theme.className);var fragment=document.createDocumentFragment();var img;for(var i=0;i<theme.logos.length;i++){img=document.createElement('img');img.setAttribute('src',theme.logos[i]);fragment.appendChild(img);}
document.getElementById('logos').appendChild(fragment);document.getElementById('headline').textContent=theme.headline;var bodyFragment=document.createDocumentFragment();bodyFragment.textContent=theme.body+' ';var learnMore=document.createElement('a');learnMore.setAttribute('href','https://www.battleforthenet.com/#widget-learn-more');learnMore.setAttribute('target','_blank');learnMore.textContent='Learn more.';bodyFragment.appendChild(learnMore);document.getElementById('content').appendChild(bodyFragment);}
function renderOrgRotation(org){var fragment=document.createDocumentFragment();var orgInput=document.createElement('input');orgInput.setAttribute('type','hidden');orgInput.setAttribute('name','org');orgInput.setAttribute('value',org.code);fragment.appendChild(orgInput);var checkbox=document.createElement('input');checkbox.setAttribute('type','checkbox');checkbox.setAttribute('name','opt_in');checkbox.setAttribute('checked','checked');fragment.appendChild(checkbox);var orgLink=document.createElement('a');orgLink.setAttribute('href',org.url);orgLink.setAttribute('target','_blank');orgLink.textContent=org.name;fragment.appendChild(orgLink);var disclaimer=document.createElement('span');disclaimer.textContent=' will contact you about future campaigns. FCC comments are public records.';fragment.appendChild(disclaimer);document.getElementById('rotation').appendChild(fragment);var donate=document.getElementById('donate');if(org.donate)donate.setAttribute('href',org.donate);}
function renderOrgRotation(org){var fragment=document.createDocumentFragment();var orgInput=document.createElement('input');orgInput.setAttribute('type','hidden');orgInput.setAttribute('name','org');orgInput.setAttribute('value',org.code);fragment.appendChild(orgInput);var checkbox=document.createElement('input');checkbox.setAttribute('type','checkbox');checkbox.setAttribute('name','opt_in');fragment.appendChild(checkbox);var orgLink=document.createElement('a');orgLink.setAttribute('href',org.url);orgLink.setAttribute('target','_blank');orgLink.textContent=org.name;fragment.appendChild(orgLink);var disclaimer=document.createElement('span');disclaimer.textContent=' will contact you about future campaigns. FCC comments are public records.';fragment.appendChild(disclaimer);document.getElementById('rotation').appendChild(fragment);var donate=document.getElementById('donate');if(org.donate)donate.setAttribute('href',org.donate);}
function addCloseListeners(){document.getElementById('close').addEventListener('mousedown',function(e){e.preventDefault();sendMessage('stop');});document.getElementById('background').addEventListener('mousedown',function(e){if(e.target==document.getElementById('background'))sendMessage('stop');});}
function sendMessage(requestType,data){data||(data={});data.requestType=requestType;data.BFTN_IFRAME_MSG=true;parent.postMessage(data,'*');}
var animations={main:{options:{debug:false,},init:function(options){for(var k in options)this.options[k]=options[k];renderContent(getTheme(this.options.theme));renderOrgRotation(getOrg(this.options.org));if(this.options.uncloseable){document.getElementById('close').classList.add('hidden');}else{addCloseListeners();}