Naar inhoud springen

Gebruiker:Zanaq/stalk.js

Uit Wikipedia, de vrije encyclopedie

Opmerking: na het publiceren is het wellicht nodig uw browsercache te 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.
/*
Open diffs live from the user contribution list
(c) 2013 Zanaq, GPL
*/

if (mw.config.get('wgCanonicalNamespace') == "Special" && mw.config.get('wgCanonicalSpecialPageName') == "Contributions")
{
    txtShowLiveDiff = '[toon]';
    txtHideLiveDiff = '[verberg]';
    
    var openeddiffcounter = 0;
    
    $('#mw-content-text li').append(' <a onclick=showlivediv(this) onmouseover=loadlivediff(this)>' + txtShowLiveDiff + '</a>');
    
    function loadlivediff(a)
    {
        diff = $(a).parent();
        if (typeof(diff.find('div').html()) != 'undefined') return;
    
        q = $('<div/>', {html: 'Ladende...'}).hide();
        diff.append(q);
    
        h = diff.find('a:nth-child(2)').attr('href');
        $.ajax({url: h, success: function(xml) { insertlivediv(xml, diff, q); }});
    }
    
    function insertlivediv(h, diff, q)
    {
        t = $(h).find('#mw-content-text > table.diff');
        q.html(t);
    }
    
    function showlivediv(a)
    {
    
        diff = $(a).parent();
        d = diff.find('div');
    
        if (d.is(":visible")) {
           d.hide();
           $(a).html(txtShowLiveDiff);
        } else {
           d.show();
           $(a).html(txtHideLiveDiff);
        }
    }
}