User:Eirikr/common.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • 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 Eirikr on every page load.


/*</pre>
==Orange links for missing langs==
<pre>*/

// ⇒ Commented out since it seems to play funny with the per-browser prefs.
// ⇒ 2013-01-29: Uncommenting since I'm not using per-browser prefs.
//importScript('User:Yair rand/orangelinks2.js');
mw.loader.load('/w/index.php?title=User:Yair rand/orangelinks2.js&action=raw&ctype=text/javascript');

/*</pre>
==Make <s> and <strike> and redlinks in headers apparent in TOC==
<pre>*/

//addOnloadHook
jQuery( document ).ready( 

   function ()
   {
     if(! document.getElementById)
       return;
     var toc = document.getElementById('toc');
     if(! toc)
       return;
     if(! toc.getElementsByTagName)
       return;
     toc = toc.getElementsByTagName('a');
     for(var i = 0; i < toc.length; ++i)
     {
       var link = toc[i];
       var target = link.hash.substr(1);
       if(! target || ! target.length)
         continue;
       target = document.getElementById(target);
       if(! target)
         continue;
       if(target.getElementsByTagName('a').length > 0)
         if(target.getElementsByTagName('a')[0].className == 'new')
           link.className = 'new';
       var firstChild = target.childNodes[0];
       if(firstChild.nodeType != Node.ELEMENT_NODE)
         continue;
       if(firstChild.tagName == 'S' || firstChild.tagName == 'STRIKE')
       {
         var s = document.createElement('s');
         while(link.childNodes.length > 0)
           s.appendChild(link.childNodes[0]);
         link.appendChild(s);
       }
     }
   }

);

/*</pre>
==Edittools==
<pre>*/

// mw.loader.load("http://en.wiktionary.org/w/index.php?title=User:Eirikr/edittools.js&action=raw&ctype=text/javascript");
// mw.loader.load('http://en.wiktionary.org/w/index.php?title=User:Eirikr/edittools.js&action=raw&ctype=text/javascript');
//importScript('User:Eirikr/edittools.js');

// This fails to run properly in certain cases due to a race condition -- we wrap this here to ensure the page has loaded first, *then* we run this.
jQuery( document ).ready( 
    function() 
        { 
            mw.loader.load('/w/index.php?title=User:Eirikr/edittools.js&action=raw&ctype=text/javascript'); 
        } 
    );

/* </pre>
==Disabling unwanted MediaWiki-specific keyboard shortcuts==
<pre>*/
$( function () {$( "[accesskey]" ).removeAttr( "accesskey" );});