MediaWiki:ScrollingList.js

/* ======== Scrolling list ================================ author:    User:Slepi date:      06/2011 desc.:     This script's function is to display list of wanted articles and scroll it              on the page (element id "wanted-articles"). ======================================================== */

// FUNCTION THAT SCROLLS LIST OF WANTED ARTICLES // in element with id="wanted-articles" function wantedArticles(number) {

// for list of articles the offset must be increased number += 1; number += '';

// older browsers if (!window.XMLHttpRequest) { if (document.getElementById("wanted-pages-mp-box")) { // hide element document.getElementById("wanted-pages-mp-box").style.display = "none"; }   return false; }

// wait until data available if (xmlWanted.readyState != 4 || xmlWanted.status != 200) return;

// processing the server response var beginParse = ""; var endParse = ""; var htmlRes = xmlWanted.responseText; var start = htmlRes.indexOf(beginParse); var end = htmlRes.indexOf(endParse);

// processing the output from the list var output = htmlRes.substring(start+29+number.length, end-6); output = output.replace(/<\/li>\n/g, " • "); output = output.replace(//g, ""); output = output.replace(/<\/li>/g, ""); output = output.replace(/\(\)/g, ""); if (navigator.appName == "Opera") output = output.replace(/\/a>\)/g, ""); // Opera fix

// put the output into the element with id="wanted-articles" output = '' + output + ' '; document.getElementById("wanted-articles").innerHTML = output;

// delete variables delete output; delete htmlRes; delete xmlWanted; }

function wantedArticlesAdj { wantedArticles(wantedOffsetNumber); }

// START var wantedOffsetNumber;

addOnloadHook(function { if (document.getElementById("wanted-articles") != undefined) {    var xmlWanted;    wantedOffsetNumber = Math.round(Math.random*500);    getXMLHttpRequest("xmlWanted", wgServer + wgScript + "/Special:Wantedpages?limit=20&offset=" + wantedOffsetNumber, "wantedArticlesAdj");  } });

/* */