Gebruiker:Erik Baas/monobook.js

Uit Wikipedia, de vrije encyclopedie

Opmerking: nadat u de wijzigingen hebt gepubliceerd is het wellicht nodig uw browsercache te legen.

  • Firefox / Safari: houd Shift ingedrukt terwijl u 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)
  • Internet Explorer / Edge: houd Ctrl ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5
  • Opera: druk op Ctrl-F5.
importScript('Gebruiker:Erik Baas/rm-images.js');
importScript('Gebruiker:MrBlueSky/markeer.js');

/* Focus op zoekveld hoofdpagina */
/*
if (wgPageName == "Hoofdpagina") {
 hookEvent("load", function() {document.getElementById('searchInput').focus();});
}
*/

// Verwendung von OpenStreetMap in Wikipedia.
// (c) 2008 by Magnus Manske
// Released under GPL
// bron: http://de.wikipedia.org/w/index.php?title=Benutzer:Magnus_Manske/osm.js&oldid=57999905

function openStreetMapInit () {
  c = document.getElementById ( 'Coordinaten' ) ; // N.B.: "Coordinaten" ipv. "coordinates" !
  if ( !c ) return ;

  a = c.getElementsByTagName ( 'a' ) ;
  geohack = 0 ;
  for ( i = 0 ; i < a.length ; i++ ) {
    h = a[i].href ;
    if ( !h.match(/maps/) ) continue ;
    geohack = 1 ;
    break ;
  }
  if ( geohack == 0 ) return ;
  na = document.createElement ( 'a' ) ;
  with (na) {
   href = '#' ;
   onclick = openStreetMapToggle ;
   title="Toggle map (OpenStreetmap)";
   style.backgroundColor = "#00A000";
   marginLeft = "2px";
   appendChild ( document.createTextNode ( ' *' ) ) ;
  }
//  c.appendChild ( document.createElement ( 'br' ) )
//  c.appendChild ( document.createTextNode ( ' (' ) ) ;
  c.appendChild ( na ) ;
//  c.appendChild ( document.createTextNode ( ')   ' ) ) ;
}

function openStreetMapToggle () {
  c = document.getElementById ( 'Coordinaten' ) ;
  if ( !c ) return ;

  cs = document.getElementById ( 'contentSub' ) ;
  osm = document.getElementById ( 'openstreetmap' ) ;

  if ( cs && osm ) {
    cs.removeChild ( osm ) ;
    return ;
  }

  var found_link = 0 ;
  a = c.getElementsByTagName ( 'a' ) ;
  for ( i = 0 ; i < a.length ; i++ ) {
    h = a[i].href ;
    if ( !h.match(/maps/) ) continue ;
    found_link = 1 ;
    break ;
  }
  if ( found_link == 0 ) return ; // No geohack link found

  h = h.split('params=')[1] ; 
  i = document.createElement ( 'iframe' ) ;
  url = 'http://tools.wikimedia.de/~magnus/ol/wp_poi.php?title=' + wgTitle ;
  url += '&language=' + wgUserLanguage ;
  url += '&params=' + h ;
  i.id = 'openstreetmap' ;
  i.style.position = "absolute" ;
  // i.style.clear = 'both' ;
  i.style.zIndex = "9999" ;
  i.style.width = '400px' ;
  i.style.height = '400px' ;
  i.style.top = "50px" ;
  i.style.right = "50px" ;
  i.style.backgroundColor = '#f0f0f0';
  i.style.border = "1px solid silver" ;
  i.src = url ;
  cs.appendChild ( i ) ;
}
$(openStreetMapInit);


// === Unwatchlink per item op volglijst ===
// Geeft op de volglijst een link "niet volgen" bij elk artikel
// Nieuwe versie d.d. 20070926

$(function () {

    // Alleen voor "Volglijst":
    if (window.location.href.indexOf("Speciaal:Volglijst") == -1) return; 

    // Niet voor "Volglijst bekijken en bewerken":
    if (window.location.href.indexOf("Speciaal:Volglijst/edit") > 0) return;

    // Idem, via link op "Ruwe volglijst bewerken":
    if (window.location.href.indexOf("Special:Watchlist/raw") > 0) return; 

    var query_prefix = "&action=unwatch";
    var count = 0;
    var links = document.getElementById('content').getElementsByTagName('a');
    for (var i = 0; i < links.length; i++) {
        if (links[i].href.substring(links[i].href.length-15) != '&action=history')
            continue;
        count++;
        if (count>35) {
         break;
        }
        var unwatch = document.createElement('a');
        unwatch.href = "/w/index.php?title=" + encodeURIComponent(links[i].title) + query_prefix;
        unwatch.title = "Verwijder "+links[i].title+" van je volglijst";
        unwatch.appendChild(document.createTextNode("unwatch"));
        links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);
        // kluge to handle case where "diff" is unlinked:
        var delim = links[i].previousSibling;
        delim = (delim.nodeType == 3 ? delim.nodeValue : "");
        links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch);
    }

});


/* Extra tab: edit section 0 */
$(function () {
    var x;
    if (!(x = document.getElementById('ca-edit') )) return;
    var url;
    if (!(url = x.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    var y = mw.util.addPortletLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
                           'Bewerk de eerste sectie van deze pagina', '0', x.nextSibling);
 
    y.className = x.className;  // steal classes from the the edit tab...
    x.className = 'istalk';     // ...and make the edit tab have no right margin
 
    // exception: don't steal the "selected" class unless actually editing section 0:
    if (/(^| )selected( |$)/.test(y.className)) {
        if (!document.editform || !document.editform.wpSection
            || document.editform.wpSection.value != "0") {
            y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
            x.className += ' selected';
        }
    }
});