Advertisement
Guest User

preview of timed sopablackout.org script

a guest
Jan 17th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // Preview the timed sopablackout.org script
  2.     var today = new Date();
  3.     if(true || (today.getDate() == 18) && (today.getMonth() == 0) && (today.getFullYear() == 2012)) {
  4.     (function (){
  5.         var root = this;
  6.  
  7.         var SopaBlackout = function(){};
  8.         var addEvent = function(obj, type, fn, ref_obj){
  9.             if (obj.addEventListener){
  10.                 obj.addEventListener(type, fn, false);
  11.             }else if (obj.attachEvent){
  12.                 obj["e"+type+fn] = fn;
  13.                 obj[type+fn] = function(){
  14.                     obj["e"+type+fn](window.event,ref_obj);
  15.                 };
  16.                 obj.attachEvent("on"+type, obj[type+fn]);
  17.             }
  18.         };
  19.         var onDomReady = function(fn){
  20.             if (document.addEventListener){
  21.                 document.addEventListener('DOMContentLoaded', fn, false);
  22.             }else{
  23.                 if (!document.uniqueID && document.expando){return;};
  24.                 var tempNode = document.createElement('document:ready');
  25.                 try{
  26.                     tempNode.doScroll('left');
  27.                     fn();
  28.                 }catch (err){
  29.                     setTimeout(arguments.callee, 0);
  30.                 }
  31.             }
  32.         };
  33.         var getStyle = function(e, prop){
  34.             if (e.currentStyle){
  35.                 return e.currentStyle[prop];
  36.             }else if (document.defaultView && document.defaultView.getComputedStyle){
  37.                 return document.defaultView.getComputedStyle(e, "")[prop];
  38.             }else{
  39.                 return e.style[prop];
  40.             }
  41.         };
  42.         var findPos = function(obj){
  43.             var curleft = 0;
  44.             var curtop = 0;
  45.             if (obj.offsetParent){
  46.                 do{
  47.                     curleft += obj.offsetLeft;
  48.                     curtop += obj.offsetTop;
  49.                 }while(obj = obj.offsetParent);
  50.             }
  51.             return [curleft, curtop];
  52.         };
  53.         var txt = function(s){
  54.             return document.createTextNode(s);
  55.         };
  56.         var create = function(e, props){
  57.             var elem = document.createElement(e);
  58.             var props = props !== null ? props : {};
  59.             for (var key in props){
  60.                 if (key == 'href'){
  61.                     elem.href = props[key];
  62.                 }else{
  63.                     elem.style[key] = props[key];
  64.                 }
  65.             }
  66.             l = arguments.length;
  67.             for (var i=2; i<l; i++){
  68.                 elem.appendChild(arguments[i]);
  69.             }
  70.             return elem;
  71.         };
  72.  
  73.         SopaBlackout.VERSION = '0.1.0';
  74.         SopaBlackout.MIN_HEIGHT = 100;
  75.         SopaBlackout.HEADER_TEXT = "This is what the web could look like under the Stop Online Piracy Act.";
  76.         SopaBlackout.CONTINUE_TEXT = "(click anywhere to continue)";
  77.         SopaBlackout.blackout = function(obj_id, srsbzns){
  78.             var obj;
  79.             var body = document.body;
  80.             if (obj_id === false){
  81.                 obj = body;
  82.                 height = "100%";
  83.             }else{
  84.                 obj = document.getElementById(obj_id);
  85.                 var height = parseInt(getStyle(obj, 'height'), 10);
  86.                 height = height > SopaBlackout.MIN_HEIGHT ? height : SopaBlackout.MIN_HEIGHT;
  87.             }
  88.             var offsets = findPos(obj);
  89.  
  90.             var blackout = create('div', {
  91.                     position: 'absolute',
  92.                     top: offsets[1],
  93.                     width: '100%',
  94.                     backgroundColor: 'black',
  95.                     textAlign: 'center',
  96.                     paddingTop: '10px',
  97.                     zIndex: 2147483646,
  98.                     height: height,
  99.                     color: '#999'},
  100.                 create('h1', {color: '#999'}, txt(SopaBlackout.HEADER_TEXT)),
  101.                 create('p', null,
  102.                     txt("Keep the web open. "),
  103.                 create('a', {href: "https://wfc2.wiredforchange.com/o/9042/p/dia/action/public/?action_KEY=8173"}, txt("Contact your representatives")),
  104.                     txt(" or "),
  105.                     create('a', {href: "http://sopablackout.org/learnmore"}, txt("find out more")))
  106.             );
  107.             if (srsbzns !== true){
  108.                 blackout.appendChild(create('p', {paddingTop: '250px', color: '#333'}, txt(SopaBlackout.CONTINUE_TEXT)));
  109.                 addEvent(blackout, 'click', function(e){
  110.                     body.removeChild(blackout);
  111.                 });
  112.             }
  113.             body.appendChild(blackout);
  114.         };
  115.         SopaBlackout.go = function(){
  116.             var obj_id = (typeof sopablackout_id === 'undefined') ? false : sopablackout_id;
  117.             var srsbzns = (typeof sopablackout_srsbzns === 'undefined') ? false : sopablackout_srsbzns;
  118.             SopaBlackout.blackout(obj_id, srsbzns);
  119.         };
  120.  
  121.         onDomReady(SopaBlackout.go);
  122.     }).call(this);
  123.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement