MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 198: Line 198:
/* For Favicon  */
/* For Favicon  */
<!-- document.write("<link rel='shortcut icon' href='http://conlang.wikkii.com/w/images/conlang/uploads/2/26/Favicon.png' type='image/x-icon'>"); -->
<!-- document.write("<link rel='shortcut icon' href='http://conlang.wikkii.com/w/images/conlang/uploads/2/26/Favicon.png' type='image/x-icon'>"); -->
===Hidden Quotes===
<pre>*/
function setupHiddenQuotes(li)
{
  var HQToggle, liComp;
  var HQShow = 'quotations ▼';
  var HQHide = 'quotations ▲';
  for (var k = 0; k < li.childNodes.length; k++) {
      // Look at each component of the definition.
      liComp = li.childNodes[k];
      // If we find a ul or dl, we have quotes or example sentences, and thus need a button.
      if (/^(ul|UL)$/.test(liComp.nodeName)) {
        HQToggle = newNode('a', {href: 'javascript:(function(){})()'}, '');
        li.insertBefore(newNode('span', {'class': 'HQToggle'}, ' [', HQToggle, ']'), liComp);
        HQToggle.onclick = VisibilityToggles.register('quotations',         
            function show() {
              HQToggle.innerHTML = HQHide;
              for (var child = li.firstChild; child != null; child = child.nextSibling) {
                  if (/^(ul|UL)$/.test(child.nodeName)) {
                    child.style.display = 'block';
                    }
                  }
              },
            function hide() {
              HQToggle.innerHTML = HQShow;
              for (var child = li.firstChild; child != null; child = child.nextSibling) {
                  if (/^(ul|UL)$/.test(child.nodeName)) {
                    child.style.display = 'none';
                    }
                  }
              });
        break;
        }
      }
  }           
             
addOnloadHook( function ()
{
  if (wgNamespaceNumber == 0) {
      var ols, lis, li;
      // First, find all the ordered lists, i.e. all the series of definitions.
      var ols = document.getElementsByTagName('ol');
      for(var i = 0; i < ols.length; i++) {
        // Then, for every set, find all the individual definitions.
        for (var j = 0; j < ols[i].childNodes.length; j++) {
            li = ols[i].childNodes[j];
            if (li.nodeName.toUpperCase() == 'LI') {
              setupHiddenQuotes(li);
              }
            }
        }
      }
  });
/*</pre>

Navigation menu