Gebruiker:Zanaq/browse.js
Uiterlijk
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.
/*
Browse through the articles alphabetically.
(c) Zanaq 2013, GPL
inspired by Trewal, http://nl.wikipedia.org/w/index.php?title=Wikipedia:De_kroeg&diff=36578376&oldid=36577552
*/
//<nowiki>
if (mw.config.get('wgNamespaceNumber') != -1)
{
if (typeof(browseShowRedirects) == "undefined") browseShowRedirects = true;
if (typeof(browseShowNavigationBelowTitle) == "undefined") browseShowNavigationBelowTitle = true;
if (typeof(browseNumberOfPagesToShowInNavigation) == "undefined") browseNumberOfPagesToShowInNavigation= 3;
browseNumberOfPagesToShowInNavigation = browseNumberOfPagesToShowInNavigation + 1;
if (browseNumberOfPagesToShowInNavigation < 2) browseNumberOfPagesToShowInNavigation = 2;
if (browseNumberOfPagesToShowInNavigation > 100) browseNumberOfPagesToShowInNavigation = 100;
var nextpage = null;
var nextpagedata = null;
var previouspage = null;
var nextredirect = false;
var previousredirect = false;
var navigation = '';
var encodedTitle = encodeURIComponent(mw.config.get('wgTitle'));
var thispagename = mw.config.get('wgPageName').replace(/_/g," ");
var redirectfilter = (browseShowRedirects) ? '' : '&gapfilterredir=nonredirects';
if (mw.user.options.values.skin == 'vector')
{
mw.util.addCSS('.browse-navigation-top {font-size:70%;}');
} else {
mw.util.addCSS('.browse-navigation-top {font-size:85%;}');
}
if (document.location.href.indexOf('//en.wikipedia.org/') != -1)
{
if (document.getElementById('coordinates') != null)
{
mw.util.addCSS('.browse-navigation-top {width:75%;}');
}
}
mw.util.addCSS('.browse-navigation-top {position:relative;top:-4px;padding-top:0;padding-bottom:0}');
mw.util.addCSS('#firstHeading {border-bottom:none}');
mw.util.addCSS('.browse-navigation-bottom {margin-top:.5em;}');
if (browseShowNavigationBelowTitle)
{
mw.util.addCSS('#siteSub {display:none;}');
navigationtop = '<div class="toc browse-navigation-top" id="browse-navigation-top"> <div>';
$(navigationtop).insertAfter('#firstHeading');
}
$('<span/>', {
id: 'linknextpage',
text: '>',
style:'margin-left:.25em;'
}).appendTo('#firstHeading');
dontredirect = (previousredirect == '') ? '?redirect=no' : '';
$('<span/>', {
id: 'linkpreviouspage',
text: '<',
style:'margin-right:.25em;'
}).prependTo('#firstHeading');
$.getJSON('/w/api.php?action=query&generator=allpages&format=json&gapfrom=' + encodedTitle + '&gapnamespace=' + mw.config.get('wgNamespaceNumber') + '&gaplimit=' + browseNumberOfPagesToShowInNavigation + '&gapdir=ascending&prop=info&indexpageids' + redirectfilter ,
function(data) {
nextpage = data.query.pages[data.query.pageids[0]].title;
nextpagedata = data;
nextredirect = data.query.pages[data.query.pageids[0]].redirect;
if (nextpage == thispagename)
{
nextpage = data.query.pages[data.query.pageids[1]].title;
nextredirect = data.query.pages[data.query.pageids[1]].redirect;
}
$.getJSON('/w/api.php?action=query&generator=allpages&format=json&gapfrom=' + encodedTitle + '&gapnamespace=' + mw.config.get('wgNamespaceNumber') + '&gaplimit=' + browseNumberOfPagesToShowInNavigation + '&gapdir=descending&prop=info&indexpageids' + redirectfilter,
function(data) {
previouspage = data.query.pages[data.query.pageids[0]].title;
previousredirect = data.query.pages[data.query.pageids[0]].redirect;
if (previouspage == thispagename)
{
var page = data.query.pages[data.query.pageids[1]];
previouspage = page && page.title;
previousredirect = page && page.redirect;
}
dontredirect = (nextredirect == '') ? '?redirect=no' : '';
$('#linknextpage').html($('<a/>', {
href: '/wiki/' + encodeURIComponent(nextpage) + dontredirect ,
title: nextpage,
text: '>',
}));
dontredirect = (previousredirect == '') ? '?redirect=no' : '';
$('#linkpreviouspage').html($('<a/>', {
href: '/wiki/' + encodeURIComponent(previouspage) + dontredirect,
title: previouspage,
text: '<',
}));
$(data.query.pageids).each(
function(id, pageid)
{
page = data.query.pages[pageid];
if (page.title != thispagename)
{
showntitle = (mw.config.get('wgNamespaceNumber') == 0) ? page.title : page.title.substr(page.title.indexOf(':') + 1);
classname = (typeof(page.redirect) != 'undefined') ? ' class="mw-redirect" ' : '';
href = '/wiki/' + encodeURIComponent(page.title);
redirectclassname = (typeof(page.redirect) != 'undefined') ? ' class="allpagesredirect browse-redirect" ' : '';
navigation = '<span ' + redirectclassname + '><a href="' + href + '"' + classname + ' >' + showntitle + '</a></span> · ' + navigation;
}
}
);
showntitle = (mw.config.get('wgNamespaceNumber') == 0) ? thispagename : thispagename.substr(thispagename.indexOf(':') + 1);
navigation += '<strong class="selflink">' + showntitle + '</strong class="selflink">'
$(nextpagedata.query.pageids).each(
function(id, pageid)
{
page = nextpagedata.query.pages[pageid];
if (page.title != thispagename)
{
showntitle = (mw.config.get('wgNamespaceNumber') == 0) ? page.title : page.title.substr(page.title.indexOf(':') + 1);
href = '/wiki/' + encodeURIComponent(page.title);
redirectclassname = (typeof(page.redirect) != 'undefined') ? ' class="allpagesredirect browse-redirect" ' : '';
classname = window.classname || '';
navigation = navigation + ' · <span ' + redirectclassname + '><a href="' + href + '"' + classname + '>' + showntitle + '</a></span>';
}
}
);
navigationbottom = '<div class="toc browse-navigation-bottom">' + navigation + '<div>';
$('#content').append(navigationbottom );
if (browseShowNavigationBelowTitle)
{
$('#browse-navigation-top').html(navigation);
}
});
});
}
//</nowiki>