User:Inductiveload/InlinePagenums.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
Documentation for this script can be added at User:Inductiveload/InlinePagenums. |
/* Javascript to show page numbers of transcluded text in the text
* itself. This is common in come legal works
*/
function setInlinePagenumsButton() {
if(mw.config.get('wgNamespaceNumber') !== 0 && mw.config.get('wgNamespaceNumber') != 2 )
return;
if (!$('#optlist').length || !$('.pagenum').length )
return; //we don't have any layout menu or we don't have pages
enabledNow = $.cookie("showInlinePagenums") === '1';
text = enabledNow ? 'Hide inline page numbers' : 'Show inline page numbers' ;
link = 'javascript:showInlinePagenums('+!enabledNow+');';
if (!$('#option-inlinePagenums').length )
$('#optlist').append( '<li id="option-inlinePagenums"><a href="'+link+'">'+text+'</a></li>');
else
$('#option-inlinePagenums>a').text(text).attr('href', link);
}
function showInlinePagenums(show) {
if (show === undefined)
show = $.cookie("showInlinePagenums") === '1';
$.cookie("showInlinePagenums", show ? '1' : 0);
$.each($('.pagenum'), function(index, num) {
$(num).text(show ? ' ['+$(num).attr('id')+'] ' : '');
});
setInlinePagenumsButton();
}
$(function() { setTimeout(showInlinePagenums, 100) }); //hacky hacky