Jump to content

User:The Obento Musubi/icons.js

From Simple English Wikipedia, the free encyclopedia

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
 * getElementsByClass : searches the elements of the page by "class" parameter
 */
function getElementsByClass(searchClass, node, tag) {
  if (node == null) node = document;
  if (tag == null) tag = '*';
  return getElementsByClassName(node, tag, searchClass);
}
 
/**
 * Title icons
 * 
 * Looks for title icons (class="icon") and
 * Shifts them to the right of the title on the page.
 */

function titleicons() {
  var h1 = document.getElementsByTagName("h1")[0];
  var icons = getElementsByClass( "icon", document, "div" );
  for( var j = icons.length; j > 0; --j ){
    icons[j-1].style.display = "block"; /* cancels "display: none" by default */
    icons[j-1].style.marginLeft = "0.35em";
    if( skin == "modern" ){
      icons[j-1].style.marginTop = "0.2em";
    }
    h1.parentNode.insertBefore(icons[j-1], h1); /* shift of the element */
  }
}
$(titleicons);