Gebruiker:Orlando of Arrakon "Kharakovh"/javascript

// Script op basis van en:User:Enterprisey/watchlist-notice.js // Dit script geeft een melding op de plek van de volglijst-link van de laatst geüpdatete pagina uit de volglijst. een rood sterretje linkt naar de diff van die wijziging en geeft ook extra informatie als de muis erboven is. // Indien gewenst kan ook één pagina extra in de gaten gehouden worden (de string pageToWatch), met een opvallende melding op de plek van de SiteNotice als deze bovenaan de volglijst komt.

// Specifieke pagina om in de gaten te houden (moet wel op de volglijst staan): const pageToWatch = "Vervang deze tekst"; const meldingMinuten = 120 // minuten waarbinnen een edit moet zijn gedaan om nog een melding te geven.

// Volglijst update-notice tonen aan of uit? const volglijstNotice = true;

mw.loader.using("mediawiki.util", function () {

 var showNotice = function (bewerking) {
   // Stick a "Watchlist update!" notice after the notification count
   $("#pt-notifications-notice").after(

$("

  • ") .append( $("<a>") .text(bewerking.title + " geüpdatet") .css({ "background-color": "#3385ff", color: "white", "border-radius": "2px", padding: "0.25em 0.45em 0.2em", cursor: "pointer", "font-weight": "bold", transition: "background-color 0.5s", }) .attr("href", "/wiki/Special:Watchlist") .mouseover(updateNotice) ) .attr("id", "watchlist-update-notice") ); var commentString = bewerking.comment.replace("/* ", ""); var bewerkingArray = commentString.split (' */'); var tooltip = '➝ ' + bewerkingArray[0]; if (bewerkingArray[1]) { tooltip += ': ' + bewerkingArray[1]; } var kop = bewerkingArray[0]; if (kop.substr (0, 22) == 'Nieuw kopje aangemaakt') { kop = bewerkingArray[0].substr(24, bewerkingArray[0].length); } $("#pt-mytalk").before( $("
  • ") .append( $("<a>") .text("*") .css({ color: "#555555", "border-radius": "2px", padding: "0.25em 0.45em 0.2em", cursor: "pointer", "font-weight": "bold", transition: "background-color 0.5s", }) .attr( "href", "https://nl.wikipedia.org/w/index.php?title=" + encodeURI(bewerking.title.replace(/ /g,"_")) + "&curid=" + bewerking.pageid + "&diff=" + bewerking.revid + "&volglijstmelder=true" ) ) .attr("id", "watchlist-update-diff") .attr( "title", bewerking.type + " door " + bewerking.user + " (" + tooltip + ")") ); $("#pt-mytalk").before( $("
  • ") .append( $("<a>") .text("→") .css({ color: "#555555", "border-radius": "2px", padding: "0.25em 0.45em 0.2em", cursor: "pointer", "font-weight": "bold", transition: "background-color 0.5s", }) .attr( "href", "https://nl.wikipedia.org/w/index.php?title=" + encodeURI(bewerking.title.replace(/ /g,"_")) + "#" + kop.replace(/ /g,"_") ) ) .attr("id", "watchlist-update-link") .attr( "title", tooltip) ); }; var updateNotice = function () { // Lighten the background color so the user knows we're updating $("#watchlist-update-notice a").css("background-color", "#7bff7b"); // Update the notice var aantalEdits = 1; if (pageToWatch) { aantalEdits = 5; } $.getJSON(mw.util.wikiScript("api"), { format: "json", action: "query", list: "watchlist", wlprop: "comment|title|user|timestamp", wlshow: "unread", wllimit: aantalEdits, }).done(function (data) { if (!data.query) return; if (data.query.watchlist.length) { // There are new watchlist diffs to read, so show notice console.log ('comment string: "' + data.query.watchlist[0].comment + '"'); var minuten = Math.round((Date.now() - Date.parse(data.query.watchlist[0].timestamp)) / 60000); if ( data.query.watchlist[0].title == pageToWatch && data.query.watchlist[0].user !== "Nlwikibots" && minuten <= meldingMinuten ) { document.getElementById("siteNotice").innerHTML = '
    De pagina <a href="' +
               "https://nl.wikipedia.org/wiki/" +
               encodeURI(pageToWatch.replace(/ /g,"_")) +
               '">' +
               pageToWatch +
               '</a> is onlangs gewijzigd door <a href = "https://nl.wikipedia.org/wiki/Overleg_gebruiker:' +
               encodeURI(data.query.watchlist[0].user) +
               '">' +
               data.query.watchlist[0].user +
               '</a>. (<a href="https://nl.wikipedia.org/w/index.php?title=' +
               encodeURI(pageToWatch.replace(/ /g,"_")) +
               "&curid=" +
               data.query.watchlist[0].pageid +
               "&diff=" +
               data.query.watchlist[0].revid +
    
    '">diff</a>)
    ';
           }
           if (!$("#watchlist-update-notice").length) {
             // That is, if it isn't shown already
             if (volglijstNotice) {
               showNotice(data.query.watchlist[0]);
             }
           } else {
             // There's already a notice, so change background
             $("#watchlist-update-notice a").css("background-color", "#3385ff");
           }
         } else {
           // No new watchlist diffs to read, so hide notice, diff and link
           $("#watchlist-update-notice").remove();
           $("#watchlist-update-diff").remove();
           $("#watchlist-update-link").remove();
         }
       });
     };
    
     $(document).ready(function () {
       updateNotice();
       window.setInterval(updateNotice, 120000);
     });
    

    });