MediaWiki:Disclaimer.js

/* */

/* ============== DISCLAIMER ================================= author:        Petr Kajzar User:Slepi date:          04/2011 documentation: MediaWiki:Disclaimer.js/documentation description:   disclaimer in WL   ==========================================================

var disclaimerCreator = {

xmlhttpDiscText : "", urlText : wgServer + wgScript + "/MediaWiki:Disclaimer-text?action=raw", discText : "", agreeText : "I accept", disagreeText : "Back", urlLogin : "http://www.wikilectures.eu/index.php/Special:UserLogin", urlPrefs : "http://www.wikilectures.eu/index.php/Special:Preferences", disclaimerGadget : "Do not display the disclaimer",

install : function { // test cookies var cookiePos = document.cookie.indexOf("wl_disc=1"); if (cookiePos > -1) return false;

// add CSS style importStylesheet("MediaWiki:Disclaimer.css");

// create div for overlay overlayDiv = document.createElement("div"); overlayDiv.className = "overlay_div"; overlayDiv.id = "overlay_div";

// add div to the page document.body.appendChild(overlayDiv);

// block with text contentDiv = document.createElement("div"); contentDiv.className = "content_div"; contentDiv.id = "content_div";

// add block to the page document.body.appendChild(contentDiv);

// text of the disclaimer getXMLHttpRequest("disclaimerCreator.xmlhttpDiscText", disclaimerCreator.urlText, "disclaimerCreator.getText"); },

getText : function { if (disclaimerCreator.xmlhttpDiscText.readyState==4) {// 4 = "loaded" if (disclaimerCreator.xmlhttpDiscText.status==200) {// 200 = OK        disclaimerCreator.discText = disclaimerCreator.xmlhttpDiscText.responseText; // server response disclaimerCreator.showText; }   }  },

showText : function {

// add text contentDiv.innerHTML = " Notice " + " "     + disclaimerCreator.discText + " ";

// add buttons contentDiv.innerHTML += ' ' + '' + disclaimerCreator.agreeText + ' '     + '' + disclaimerCreator.disagreeText + ' ';

// info about switching off he disclaimer contentDiv.innerHTML += '

'     + 'Logged in users ' + 'can permanently switch off this notice in their ' + 'preferences: tab Gadgets, tool ' + '' + disclaimerCreator.disclaimerGadget + '. ';

// show disclaimer overlayDiv.style.display = "block"; contentDiv.style.display = "block"; },

writeCookies : function { document.cookie = "wl_disc=1"; },

closeDisclaimer : function(a) { if (a==1) { document.getElementById('overlay_div').style.display = 'none'; document.getElementById('content_div').style.display = 'none'; disclaimerCreator.writeCookies; return false; } else if (a==0) { history.back; return false; } }

}

if (wgAction == "view" && wgPageName != "Main_Page" && wgNamespaceNumber == 0) { if (wgUserName== null) { addOnloadHook(disclaimerCreator.install); // anonymous users: immediately } else { setTimeout("disclaimerCreator.install", 1000); // wait for cookie } }