Difference between revisions of "User:Svip/monobook.js"
Jump to navigation
Jump to search
m (BRAINS) |
m |
||
(4 intermediate revisions by the same user not shown) | |||
Line 50: | Line 50: | ||
} | } | ||
/ | //addOnloadHook(function() {if(wgPageName == 'Main_Page') importScript('User:Svip/brains.js')}); | ||
function | |||
Latest revision as of 19:05, 23 July 2009
var barWidth = 200; var topAmount = 500; var currentAmount = 0; function updateDonationNotice() { if(!document.getElementById("donation-progress-number")) return; getDonation(); } addOnloadHook(updateDonationNotice); function getDonation() { var url = "/api.php?action=query&meta=allmessages&ammessages=donation-amount&amlang=en&format=xml"; ajax(url, getDonationEnd, []); } function getDonationEnd(xml, data) { var doc = xml.documentElement; var currentAmount = parseInt(doc.getElementsByTagName("message")[0].firstChild.data); var nowWidth = (currentAmount/topAmount)*barWidth; var number = document.getElementById("donation-progress-number"); number.innerHTML = currentAmount; var progBar = document.getElementById("donation-progress-indicator"); progBar.setAttribute("style", "width: " + nowWidth + "px"); } function ajax(url, callbackFunction, data) { var request = new XMLHttpRequest(); request.open("GET", url, true); //request.setRequestHeader("Content-Type", // "application/x-www-form-urlencoded"); request.onreadystatechange = function() { var done = 4, ok = 200; if (request.readyState == done) { if (request.status == ok) { if (request.responseXML) { callbackFunction(request.responseXML, data); } } else { if (request.responseXML) { alert(request.responseXML); } else { //alert('Fejl: Serveren stak mig i ryggen og skred. ' + request.status) } } } }; request.send(null); } //addOnloadHook(function() {if(wgPageName == 'Main_Page') importScript('User:Svip/brains.js')});