wikiafrica:Monobook.js/henna.js

Da wikiafrica.
//
//**********************************************************************
// Mark multiple edits as patrolled
// Using fakeaction=markpatrolled
//
// Usage: http://nl.wikipedia.org/w/index.php?title=<pagename>&rcid=<rcid>&rcid=<rcid2>&rcid=<rcid3>&(...)&fakeaction=markpatrolled
// If the window should auto-close, add &closewindow
//
// (C)2006 by Merlijn 'valhallasw' van Deen
// 
// Licenced under the MIT license
//**********************************************************************
// Supported browsers:
// Opera, FireFox
//
// Developed on: Opera 9.02.8585 win32; FireFox {Gecko/20060909 Firefox/1.5.0.7}
//
// Known bugs:
// IE does not work; Konqueror gives red icons (Konq does not support overridemimetype and does not render the page structure so no header checking can be done)
//**********************************************************************

var closewindow = false;
var errors = false;

var rcids = []; //global!
var r = 0;
var title;
var xhrq = new XMLHttpRequest;

var waitimage = '<a href="/wiki/Afbeelding:Symbol_wait.svg" class="image" title=""><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Symbol_wait.svg/25px-Symbol_wait.svg.png" alt="" width="25" height="26" longdesc="/wiki/Afbeelding:Symbol_wait.svg" />';
var okimage = '<a href="/wiki/Afbeelding:Symbol_support_vote.svg" class="image" title=""><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/25px-Symbol_support_vote.svg.png" alt="" width="25" height="26" longdesc="/wiki/Afbeelding:Symbol_support_vote.svg" /></a>';
var badimage = '<a href="/wiki/Afbeelding:Symbol_oppose_vote.svg" class="image" title=""><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/25px-Symbol_oppose_vote.svg.png" alt="" width="25" height="26" longdesc="/wiki/Afbeelding:Symbol_oppose_vote.svg" /></a>';
var loadingimage = '<a href="/wiki/Afbeelding:Symbol_merge_vote.svg" class="image" title=""><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Symbol_merge_vote.svg/25px-Symbol_merge_vote.svg.png" alt="" width="25" height="26" longdesc="/wiki/Afbeelding:Symbol_merge_vote.svg" /></a>';

function runmarkpatrolled() {
  var i; //teller
  var element;
  if (document.location.href.indexOf("fakeaction=markpatrolled") > 0) {  //mark as patrolled!
    var ihtml = "<h3>Please wait while marking rcids...</h3> <br /><table class='prettytable' id='rcidtable'><tr><th></th><th>rcid</th><th>HTTP response</th><th>Header response</th></tr>";
    gml_url = location.pathname;
    l = location.search.substring(1).split('&');
    for (i = 0; i < l.length; i++) {
      var n = l[i].indexOf('=');
      var name = l[i].substring(0, n);
      if (name == 'rcid') {
        rcid = unescape(l[i].substring(n + 1));
        rcids.push(rcid);
        ihtml = ihtml + "<tr class='rcid' id='"+rcid+"'><td>"+waitimage+"</td><td>"+rcid+"</td><td></td><td></td></tr>";
      } else if (name == 'title') {
        title = unescape(l[i].substring(n + 1));
      } else if (name == 'closewindow') {
        closewindow = true;
      }
    }
    document.getElementById('bodyContent').innerHTML = ihtml + "</table>";
    //alert(rcids.length);
    dorunloop();
  }
}

addOnloadHook(runmarkpatrolled)

function dorunloop() {
  //alert("drl");
  if (r < rcids.length) {
    document.getElementById(rcids[r]).getElementsByTagName("td")[0].innerHTML = loadingimage;
    markpatrolled(rcids[r]);
  } else {
    if (!errors && closewindow) {
      window.setTimeout("window.close()",1000);
    }
  }
}

function rsc() {
 if (xhrq.readyState != 4)
    return;
  
  document.getElementById(rcids[r]).getElementsByTagName("td")[2].innerHTML = xhrq.status + "/" + xhrq.statusText;
  
  try {
    if (xhrq.status == 200 && xhrq.responseXML.getElementById("content").getElementsByTagName("h1")[0].innerHTML == "Gemarkeerd als gecontroleerd") {
      document.getElementById(rcids[r]).getElementsByTagName("td")[0].innerHTML = okimage;
      document.getElementById(rcids[r]).getElementsByTagName("td")[3].innerHTML = xhrq.responseXML.getElementById("content").getElementsByTagName("h1")[0].innerHTML;
    }
    else {
      errors = true;
      document.getElementById(rcids[r]).getElementsByTagName("td")[0].innerHTML = badimage;
      document.getElementById(rcids[r]).getElementsByTagName("td")[3].innerHTML = "<b>" + xhrq.responseXML.getElementById("content").getElementsByTagName("h1")[0].innerHTML + "</b>";
    }
  } catch (e) {
    document.getElementById(rcids[r]).getElementsByTagName("td")[0].innerHTML = badimage;
    errors = true;
  }
  
  r++;
  dorunloop()
}
  

function markpatrolled(rcid) {
  //alert("mp");
  xhrq = new XMLHttpRequest; //reset xhrq
  xhrq.open("GET", "http://www.wikiafrica.org/w/index.php?title="+title+"&rcid="+rcid+"&action=markpatrolled", true);
try {
  xhrq.overrideMimeType('text/xml');
} catch (e) {
  //xhrq.overridemimetype niet ondersteund
}
  xhrq.onreadystatechange = rsc;
  xhrq.send(null)
  //return [xhrq.status, xhrq.statusText, xhrq.responseXML.getElementById("content").getElementsByTagName("h1")[0].innerHTML] ;
}

//