User:Swedmann/Consermon.js

/* with http://consermon.appspot.com/ */

(function {   function withjQuery(cb) {	if (window.jQuery) {	    cb(jQuery);	    return;	}

var script = document.createElement('script'); script.onload = function { jQuery.noConflict; cb(jQuery); }; script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'; document.head.appendChild(script); }

withjQuery(function($) {	var portlet = null;	var status = undefined;

function makePortlet { var id = 'pt-consermon';

portlet = addPortletLink('p-personal',				    'http://www.conservapedia.com',				     'consermon loading',				     id,				     'Go to Conservapedia'); display; }

function display { if (status == undefined) { return; }

var link = $(portlet).find(':first');

if (status) { link.html('account creation enabled'); link.css('color', 'green'); } else { link.html('account creation disabled'); link.css('color', 'red'); }	}

consermonCallback = function(cur) { status = cur; display; }

function check { $.getScript('http://consermon.appspot.com/get'); }

check; setInterval(check, 2 * 60 * 1000);

$(makePortlet); }); });