User:Smile4ever/mark.js

if (!window.msb) { window.msb = {}; }

msb.patrol = { linksStyle: 'background-color: #dcdcdc;', rcid: null, token: null,

patrolIndex: function (fun) {

var index = window.mw.config.get('wgScriptPath') + '/index.php';

jQuery.get(index,                       {                                action:      'markpatrolled',                                rcid:        msb.patrol.rcid,                                token:       msb.patrol.token                        },                        fun                ); },

linksOnDiff: function {

var nextlink = null; var prevlink = null;

if ( mw.util.getParamValue('diff') == null) return;

var ntitle4 = document.getElementById('mw-diff-ntitle4');

if (ntitle4 == null) return; if (ntitle4.getElementsByTagName('span').length==0) return;

msb.patrol.getToken;

var ntitle1 = document.getElementById('mw-diff-ntitle1'); ntitle1.innerHTML = ntitle1.innerHTML.replace(/\([^)]+\)/, );               var url = ntitle1.innerHTML.match(/['"]([^"']+undoafter[^'"]+)['"]/)[1];                ntitle1.innerHTML += ' ( Markeer en ongedaan maken ) ';

var ntitle2 = document.getElementById('mw-diff-ntitle2'); var user = ntitle2.innerHTML.match(/ijdragen\/([^"]+)"/)[1]; if (user.search(/\d+\.\d+\.\d+\.\d+/) >= 0) { var s = '> whois, ' s = s + 'locatie' s = s + ' (<';                       ntitle2.innerHTML = ntitle2.innerHTML.replace(/>\(</,s); }

if (document.getElementById('differences-nextlink')) { nextlink = document.getElementById('differences-nextlink').href; }               if (document.getElementById('differences-prevlink')) { prevlink = document.getElementById('differences-prevlink').href; }

if (prevlink !== null) { var otitle4 = document.getElementById('mw-diff-otitle4'); if (otitle4) { otitle4.innerHTML = otitle4.innerHTML.replace(/[Oo]udere\sbewerking/, 'Vorige'); otitle4.innerHTML += ' [ ← Markeer en vorige ] '; }               }

var ntitle4 = document.getElementById('mw-diff-ntitle4');

if (nextlink !== null) {

ntitle4.innerHTML = ntitle4.innerHTML.replace(/[Nn]ieuwere\sbewerking.*/, 'Volgende →'); var s = ' [Markeer ]'; s += ' [ Markeer en volgende →</a> ] '; ntitle4.innerHTML += s;

} else {

ntitle4.innerHTML = ' [<span style="'+msb.patrol.linksStyle+'"><a href="#" onclick="msb.patrol.markeer; return false;">Markeer</a> ] '; }

var html = ' Actie na markeren: '; html += '<span style="'+msb.patrol.linksStyle+'"><input type="radio" name="msbAction" value="1" onchange="msb.patrol.setCookie" />Geen '; html += '<span style="'+msb.patrol.linksStyle+'"><input type="radio" name="msbAction" value="2" onchange="msb.patrol.setCookie" />Vorige pagina '; mw.util.$content.prepend(html);

var cookie = jQuery.cookie('msbAction'); if (cookie != 2) cookie=1; document.getElementsByName('msbAction')[cookie-1].checked = true;

},

setCookie: function {

var cookie = 1; if (document.getElementsByName('msbAction')[1].checked) cookie=2; jQuery.cookie( 'msbAction', cookie, { expires: 999});

},

markeer: function (target) { msb.patrol.patrolIndex(                       function(data) {                                if (target !== undefined) {                                        window.location = target;                                } else {                                        var n = document.getElementById("msb1");                                        if (n) n.style.visibility = "hidden";                                        n = document.getElementById("msb2");                                        if (n) {                                                var cookie = jQuery.cookie('msbAction');                                                if (cookie==2) {                                                        history.back;                                                } else {                                                        n.innerHTML = " [Gemarkeerd]";                                                } }                                       var n = document.getElementById("msb3"); if (n) n.style.visibility = "hidden"; }                       }                );                return false;        },

getToken: function {

var node = document.getElementById('mw-diff-ntitle4'); var url = node.innerHTML.match(/"([^"]+markpatrolled[^"]+)"/)[1]; msb.patrol.token = decodeURIComponent(url.match(/token=([^"&]+)/)[1]);               msb.patrol.rcid = url.match(/rcid=(\d+)/)[1];

} }

if ( mw.util.getParamValue('diff') !== null) {

jQuery(document).ready(msb.patrol.linksOnDiff); }