Jump to content

User:Swedmann/Consermon.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Swedmann (talk | contribs) at 15:32, 9 March 2010 (Created page with 'addOnloadHook(function() { with http://consermon.appspot.com/: var element = function(enabled) { var id = 'pt-consermon'; var s = document.getEleme...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
addOnloadHook(function() {
    /* with http://consermon.appspot.com/ */
 
    var element = function(enabled) {
	var id = 'pt-consermon';
	var s = document.getElementById(id);
 
	if (!s) {
	    s = addPortletLink('p-personal', 'http://www.conservapedia.com',
                               'internal error', id, 'Go to Conservapedia');
	}
 
	if (enabled) {
	    s.firstChild.innerHTML = 'account creation enabled';
	    s.firstChild.style.color = '#00ff00';
	} else {
	    s.firstChild.innerHTML = 'account creation disabled';
	    s.firstChild.style.color = '#ff0000';
	}
    }
 
    consermonCallback = function(cur) {
	var enabled = 'CONSERMON_ACCOUNT_CREATION=true';
	var disabled = 'CONSERMON_ACCOUNT_CREATION=false';
	var prev = null;
 
	if (document.cookie.indexOf(enabled) != -1) {
	    prev = true;
	} else  if (document.cookie.indexOf(disabled) != -1) {
	    prev = false;
	}
 
	element(cur);
 
	if (cur != prev) {
	    if (cur) {
		alert('cp account creation enabled');
		document.cookie = enabled;
	    } else {
		alert('cp account creation disabled');
		document.cookie = disabled;
	    }
	}
    }
 
    var check = function() {
	var script = document.createElement('script');
	script.src = 'http://consermon.appspot.com/get';
	document.head.appendChild(script);
    }
 
    check();
    setInterval(check, 2 * 60 * 60 * 1000);
});