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:Beleg Tâl/Visibility. |
/***************************************************************
/ Annotation switching
/ complain to User:Inductiveload
/**************************************************************/
//Map of properties of the different categories of visibility switch
var classUIProperties = {'typographic-long-s': {
'category' : 'arch-typo',
'text1' : 's',
'text2' : 'ſ',
'text' : 'long s (ſ)',
'title' : 'long s (ſ)',
'buttonID' : 't-showhide-long-s'},
'extiw': {
'category' : 'links',
'text' : 'interwiki links',
'title' : 'links to external Wikimedia projects',
'buttonID' : 't-showhide-extiw'},
}
function checkForElementsOfClass(className)
{ //see if we have any elements of a certain class
return $('.'+className).length > 0 ;
}
// a function to allow custom
function setupVisibilityButton(className, checkForElements)
{ //don't give a button if we don't have the elements to govern
if (!checkForElements || checkForElementsOfClass(className)){
switch( classUIProperties[className]['category'])
{
case 'links':
var shownAlready = !($('#bodyContent .'+className+':first').hasClass('disabledlink') );
var linkTarget = 'javascript:enableDisableLinks("'+className+'",'+!shownAlready+')';
break;
case 'arch-typo':
var shownAlready = !($('.'+className+':first').text() == classUIProperties[className]['text1']);
var linkTarget = 'javascript:toggleTypoVisibility("'+className+'",'+!shownAlready+')';
break;
}
//the properties are independent of the category
var showHide = shownAlready ? 'Hide ' : 'Show ';
var linkText = showHide + classUIProperties[className]['text'];
var linkTitle = showHide + classUIProperties[className]['title'];
var buttonID = classUIProperties[className]['buttonID'];
//If we already have the button, update it
if($('#'+buttonID).length){
$('#'+buttonID+' a').attr({href:linkTarget, title:linkTitle});
$('#'+buttonID+' a').html(linkText)
}
else{ // Add the button to the sidebar
mw.util.addPortletLink('p-tb', linkTarget, linkText, buttonID, linkTitle, '', '#t-print');
}
}
else
{
//if (wgUserName == 'InductiveLoad') alert('No ' + className + ' elements found!')
}
}
/******************************************************************************
* typography switching
* ***************************************************************************/
function toggleTypoVisibility(className, show)
{ //toggle a class's visibility on or off according to "show"
if (checkForElementsOfClass(className)){
$("."+className).text(show ? classUIProperties[className]['text2'] : classUIProperties[className]['text1']);
setupVisibilityButton(className, false)
}
}
$( function() { setupVisibilityButton('typographic-long-s', true) } );
/******************************************************************************
* link disabling
* ***************************************************************************/
function enableDisableLinks(className, enabled){
$('.'+ className).toggleClass('disabledlink', !enabled)
setupVisibilityButton(className, false)
}
$( function() { setupVisibilityButton('extiw', true) } );