For faster navigation, this Iframe is preloading the Wikiwand page for Gebruiker:Silver Spoon/dpzoeker.js.

Gebruiker:Silver Spoon/dpzoeker.js

/* Doorverwijspagina lookup-script
http://nl.wikipedia.org/wiki/Gebruiker:Silver Spoon/dpzoeker.js
Dit script is een vertaling naar het Nederlands van het "Disambiguation lookup script, version [0.2.8]"-script
van User:Splarka dat op de Engelstalige Wikipedia gebruikt wordt. Zie: http://en.wikipedia.org/wiki/User:Splarka/dabfinder.js

In deze Nederlandse versie van het script is het highlighten van redirects verwijderd aangezien een ieder dit simpel aan zijn
eigen css instellingen kan toevoegen.

Hieronder staan de oorspronkelijke Engelstalige-gegevens van het script:
 
Notes:
* Uses the API using head/appendchild(script) and callback to avoid ajax.
* Alt command finds and hilights redirects with simple CSS append (class="mw-redirect").
* Per http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=37270 we are limited to 500 subtemplates
** The query-continue seems to work fine even as a generator. Built a re-query system to do this automatically.
 
Operation:
* Adds portlet button (or works with URI parameter &finddab=true)
** Makes call to MediaWiki:Disambiguationspage links, generates array of these.
*** Makes call to generator=links / prop=templates on page title.
**** Builds array of registered links that link to disambiguation pages (that contain a disambiguation template).
***** Iterates over all <a> link objects on page, matching any that link to disambiguation, and applies green border.
***** .dablink descendant links are given a dashed border, all other found links are given a solid border.
*** Repeats call with tlcontinue if more than 500 templates have been returned in previous query.
 
This is a bit messy but at the time was the easiest and most thorough way to do it I could think of.
Of course, a bot might be much more efficient, but this is handy for quick on-the-fly live checking.
 
To do:
* test it
* centralized link list in contentSub?
* test unicode support
*/

var dabnames = new Array();
var dabfound = 0;
if(mw.config.get('wgNamespaceNumber') != -1) $(findDABsButton)
function findDABsButton() {
  if(!queryString('oldid') && !queryString('diff') && (mw.config.get('wgAction') == 'view' || mw.config.get('wgAction') == 'purge')) {
    mw.util.addPortletLink('p-tb','javascript:findDABs()','Vind doorverwijspagina\'s','t-dab');
    if(queryString('finddab')=='true') findDABs();
  }
}
 
function findDABs() {
  var dab = document.getElementById('t-dab');
  if(dab) injectSpinner(dab,'dab');
  var url = wgScriptPath + '/api.php?maxage=86400&smaxage=86400&action=query&rawcontinue=1&prop=links&pllimit=500&tlnamespace=10&indexpageids&format=json&callback=findDABsCB&titles=MediaWiki:Disambiguationspage';
  mw.loader.load(url);
}
 
function findDABsCB(obj) {
  if(!obj['query'] || !obj['query']['pages'] || !obj['query']['pageids']) return
  var links = obj['query']['pages'][obj['query']['pageids'][0]]['links']
  if(!links) return
  for(var i=0;i<links.length;i++) {
    dabnames.push(links[i]['title']);
  }
  findDABsQuery();
}
 
function findDABsQuery(qcont) {
  var url = mw.config.get('wgScriptPath') + '/api.php?maxage=300&smaxage=300&action=query&rawcontinue=1&redirects&generator=links&gpllimit=500&prop=templates&tllimit=500&indexpageids&format=json&callback=findDABlinksCB&titles=' + encodeURIComponent(mw.config.get('wgPageName'));
  if(qcont) url += '&tlcontinue=' + encodeURIComponent(qcont)
  mw.loader.load(url);
}

function findDABlinksCB(obj) {
  var dablinks = new Array();
  if(!obj['query'] || !obj['query']['pages'] || !obj['query']['pageids']) return
  mw.util.addCSS('.dablink-found {background-color: #E6E6FA; border: 2px solid #6A5ACD}\n .dablink .dablink-found {background-color:#E6E6FA; border: 2px solid #6A5ACD}');
 
  var ids = obj['query']['pageids'];
  var links = new Array()
  for(var i=0;i<ids.length;i++) {
    var templates = obj['query']['pages'][ids[i]]['templates'];
    if(!templates) continue
    for(var j=0;j<templates.length;j++) {
      var tpl = templates[j]['title'];
      for(var k=0;k<dabnames.length;k++) {
        if(tpl == dabnames[k]) {
          dablinks.push(obj['query']['pages'][ids[i]]['title']);
          continue;
        }
      }
    }
  }
  if(obj['query']['redirects']) {
    var dablen = dablinks.length;
    var redirects = obj['query']['redirects'];
    if(redirects) {
      for(var i=0;i<redirects.length;i++) {
        for(var j=0;j<dablen;j++) {
          if(obj['query']['redirects'][i]['to'] == dablinks[j]) {
            dablinks.push(obj['query']['redirects'][i]['from']);
            continue;
          }
        }
      }
    }
  }
  var docobj = document.getElementById('bodyContent') || document.getElementById('content') || document.body;
  var links = docobj.getElementsByTagName('a')
  for(var i=0;i<links.length;i++) {
    for(var j=0;j<dablinks.length;j++) {
      var dablink = dablinks[j].replace(/ /g,'_');
      var chklink = (links[i].hasAttribute('href')) ? links[i].getAttribute('href', 2).replace(/\#.*/,'') : ''
      chklink = chklink.replace(mw.config.get('wgArticlePath').replace(/\$1/,''),'');
      chklink = decodeURIComponent(chklink);
      if(chklink == dablink && links[i].className.indexOf('dablink-found') == -1) {
        links[i].className += ' dablink-found';
        dabfound++;
      }
    }
  }
 
  var dab = document.getElementById('t-dab');
  if(obj['query-continue'] && obj['query-continue']['templates']) {
    if(dab) {
      dab.appendChild(document.createElement('br'));
      dab.appendChild(document.createTextNode('zoeken...'));
    }
    findDABsQuery(obj['query-continue']['templates']['tlcontinue']);
  } else {
    if(dab) {
      removeSpinner('dab');
      dab.appendChild(document.createElement('br'));
      if(dabfound > 0) {
        var span = document.createElement('span');
        span.appendChild(document.createTextNode(dabfound + ' links naar DPs gevonden.'));
        span.className = 'dablink-found';
        dab.appendChild(span);
      } else {
        dab.appendChild(document.createTextNode('Geen DP-links gevonden.'));
      }
    } else {
      alert(dabfound + ' links naar DPs gevonden.');
    }
  }
}
 
function queryString(p) {
  var re = RegExp('[&?]' + p + '=([^&]*)');
  var matches;
  if (matches = re.exec(document.location)) {
    try { 
      return decodeURI(matches[1]);
    } catch (e) {
    }
  }
  return null;
}
{{bottomLinkPreText}} {{bottomLinkText}}
Gebruiker:Silver Spoon/dpzoeker.js
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 ๐ŸŽ‰! the new version arrives on September 1st! Don't want to wait?