Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for Visviva on every page load, when User:Visviva is using the Monobook skin.


/*</pre>
==Show/Hide citations button==
<pre>*/
function addCitesButton() {
   var hideButton = document.getElementById('cites-button');
   if ( hideButton === null ) return; 
   var Button     = document.createElement( 'span' );
   var ButtonLink = document.createElement( 'a' );
   var ButtonText = document.createTextNode( 'hide citations' );

   ButtonLink.setAttribute( 'id', 'hideButton' );
   ButtonLink.setAttribute( 'href', 'javascript:hideCitations();' );
   ButtonLink.setAttribute( 'title', 'hide citations' );
   ButtonLink.appendChild( ButtonText );

   Button.appendChild( document.createTextNode( '[' ) );
   Button.appendChild( ButtonLink );
   Button.appendChild( document.createTextNode( ']' ) );

   hideButton.appendChild( Button );
}

function hideCitations() {
// function addCSSRule(selector,cssText) is in [[MediaWiki:Common.js#CSS]]
 mw.util.addCSS('ol ul{list-style:none; display:none;}');
 var hideButtonLink = document.getElementById('hideButton');
 hideButtonLink.innerHTML = 'show citations';
 hideButtonLink.title='show citations';
 hideButtonLink.href='javascript:showCitations();';

}

function showCitations() {
 mw.util.addCSS('ol ul{list-style:square; display:inline;}');
 var hideButtonLink = document.getElementById('hideButton');
 hideButtonLink.innerHTML = 'hide citations';
 hideButtonLink.title='hide citations';
 hideButtonLink.href='javascript:hideCitations();';

}

/*</pre>
==Jump functionality (experimental)==
<pre>*/

//Associates jump span id with parent line
//Allows whole line to be highlighted, prevents cutoff at top of screen.

function moveJump() {
 var allLines = document.getElementsByTagName("li");
 for (var i = 0; i < allLines.length; i++) {
    var currentLine=allLines[i];
    var allNotes = allLines[i].getElementsByTagName("span");
    var allDeflists = allLines[i].getElementsByTagName("dl");
    for (var j=0; j < allNotes.length; j++) {
       if (allNotes[j].className == "jump-target" || allNotes[j].className == "jump-target-section") {
           var noteInLine = allNotes[j];
           currentLine.id = noteInLine.id;
           noteInLine.id="";
       } 
    }
 }
}

//Opens target translation table
//Called by onclick handler in superscript "transl." link
//Needs to be rewritten to always open (not just toggle) target bar.

function toggleNavigationBarRemote() {
    var counter=this.className*1;
    toggleNavigationBar(counter);
}

//Sets up onclick functionality for links to translation tables.

function openBoxes() {
  var allSups = document.getElementsByTagName("sup");
  var y = allSups.length;
  var z = 0;
  allTrans = new Array();
  for (var x=y-1; x > 0; x--) {
      if (allSups[x].title && allSups[x].title == "translations") {
          z++;
          allTrans.length=z;
          allTrans[z-1]=allSups[x];
          allTrans[z-1].title=x;
      } 
  }
  var allDivs = document.getElementsByTagName("div");
  var indexNav=0;
  for (var j=0; j < allDivs.length; j++) {
       if (allDivs[j].className == "NavHead") {
           indexNav++; 
           var spansInNav=allDivs[j].getElementsByTagName("span");
           var currentNavGloss='';
           for (var q=0; q < spansInNav.length; q++) {
               if ( spansInNav[q].className == 'jump-target-section' ) {
                   currentNavGloss = spansInNav[q].id.substr(13);
                   break;
               }
           }
           for (var p=0; p < allTrans.length; p++) {
               var r=1*allTrans[p].title;
               if (isNaN(r)) {
                   continue;
               }
               var currentLink=allSups[r].getElementsByTagName("a")[0];
               var currentLinkGloss=currentLink.href.substr(document.URL.length+14);
               if ( currentLinkGloss == currentNavGloss) {
                   allSups[r].addEventListener("click", toggleNavigationBarRemote, false);
                   allSups[r].className=indexNav;
               }
           }
        }
    }
}

/*</pre>
==Preload text==
<pre>*/

importScript('MediaWiki:Edit.js');

/*</pre>

==Hooks==

<pre>*/

$( addCitesButton );
$( moveJump );
$( openBoxes );