Skip to content

Instantly share code, notes, and snippets.

@nfreear
Created January 19, 2012 10:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfreear/1639314 to your computer and use it in GitHub Desktop.
Save nfreear/1639314 to your computer and use it in GitHub Desktop.
Adding SOPA blackout to a Drupal Gardens - Javascript + Iframe - by Jacob Singh.name, Zachstronaut.
<script>
/*!
* Javascript-iframe (Drupal) SOPA-blackout solution.
*
* authors: Jacob Singh, Zachstronaut, Nick Freear, 2012-01-17.
* help: http://jacobsingh.name/content/adding-sopa-blackout-drupal-gardens
* via: http://drupal.org/planet
*/
(function blackout(){
var a = new Date,
da = 19, //18,
hpx = 600, //window.innerHeight,
url = 'http://www.zachstronaut.com/lab/text-shadow-box/stop-sopa.html',
//url = 'http://wikimediafoundation.org/wiki/SOPA/Blackoutpage',
utm = false;
if (da == a.getDate() && 0 == a.getMonth() && 2012 == a.getFullYear()) {
window.onload = function () {
var cover = document.createElement('div');
cover.id = 'blackout';
cover.style.position = 'absolute'; //MSIE 8 fix. Not 'fixed';
cover.style.zIndex = 9999999;
cover.style.width = '100%'; //MSIE 8 fix. Not window.innerWidth + 'px';
cover.style.height = hpx + 'px';
cover.style.top = 0;
cover.style.left = 0;
cover.style.backgroundColor = '#000';
cover.innerHTML = '<iframe src="'+ url
+(utm ? '?utm_source='+ encodeURIComponent(document.location) +'&amp;utm_campaign=SOPA&amp;utm_medium=banner' : '')
+'" width="100%" height="100%" frameborder="0"></iframe>';
document.body.appendChild(cover);
/*window.onresize = function () {
cover.style.width = '100%';
cover.style.height = hpx + 'px';
}*/
document.body.className +=' js-blackout';
document.body.style.marginTop = (hpx + 10) + 'px';
document.body.style.backgroundColor = '#eee';
}
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment