Opmerking: na het publiceren moet je misschien je browsercache legen om de veranderingen te zien.

  • Firefox / Safari: houd Shift ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5 of Ctrl-R (⌘-Shift-R op een Mac)
  • Google Chrome: druk op Ctrl-Shift-R (⌘-Shift-R op een Mac)
  • Edge: houd Ctrl ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5.
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 += '<div id="msb3"> (<span style="'+msb.patrol.linksStyle+'"><a href="#" onclick="msb.patrol.markeer(\''+url+'\'); return false;"> Markeer en ongedaan maken</a></span>)</div>';

                var ntitle2 = document.getElementById('mw-diff-ntitle2');
                var user = ntitle2.innerHTML.match(/ijdragen\/([^"]+)"/)[1];
                if (user.search(/\d+\.\d+\.\d+\.\d+/) >= 0) {
                        var s = '><small><a href="http://toolserver.org/~chm/whois.php?ip='+user+'" target="_blank">whois</a>, '
                        s = s + '<a href="http://www.infosniper.net/index.php?ip_address='+user+'" target="_blank">locatie</a>'
                        s = s + '</small> (<';
                        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 += '<div id="msb1"> [<span style="'+msb.patrol.linksStyle+'"><a href="#" onclick="msb.patrol.markeer(\''+prevlink+'\'); return false;"> ← Markeer en vorige</a></span>]</div>';
                        }
                }

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

                if (nextlink !== null) {

                        ntitle4.innerHTML = ntitle4.innerHTML.replace(/[Nn]ieuwere\sbewerking.*/, 'Volgende →</a>');
                        var s = '<div id="msb2"> [<span style="'+msb.patrol.linksStyle+'"><a href="#" onclick="msb.patrol.markeer(); return false;">Markeer</a></span>]';
                        s += ' [<span style="'+msb.patrol.linksStyle+'"><a href="#" onclick="msb.patrol.markeer(\''+nextlink+'\'); return false;"> Markeer en volgende →</a></span>]</div>';
                        ntitle4.innerHTML += s;

                } else {

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

                var html = '<small>Actie na markeren: ';
                html += '<span style="'+msb.patrol.linksStyle+'"><input type="radio" name="msbAction" value="1" onchange="msb.patrol.setCookie()" />Geen</span> ';
                html += '<span style="'+msb.patrol.linksStyle+'"><input type="radio" name="msbAction" value="2" onchange="msb.patrol.setCookie()" />Vorige pagina</span></small>';
                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 = mw.user.tokens.get('editToken'); 
                msb.patrol.rcid = url.match(/rcid=(\d+)/)[1];

        }
        
}


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

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