MediaWiki:Common.js

From open-support.info

Revision as of 08:30, 19 April 2011 by Dick6809 (Talk | contribs)
Jump to: navigation, search

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: click Reload or press F5; Opera: clear the cache in Tools → Preferences; Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
function getElementsByClass(searchClass) {
  if (document.getElementsByClassName) {
    return document.getElementsByClassName(searchClass);
  } else if (document.all) {
    var classElements = new Array();
    var allElements = document.all;
    for (i = 0, j = 0; i < allElements.length; i++) {
      if (allElements[i].className == searchClass) {
        classElements[j] = allElements[i];
        j++;
      }
    }    
  } else if (document.getElementsByTagName) {
    var classElements = new Array();
    var allElements = document.getElementsByTagName("*");
    for (i = 0, j = 0; i < allElements.length; i++) {
      if (allElements[i].className == searchClass) {
         classElements[j] = allElements[i];
         j++;
      }
    }        
  } else {
    return;
  }
  return classElements;
}

function resizeWidthMax() {
  var elements = getElementsByClass("resizeWidthMax");
  for (var i=0; i<elements.length; i++) {
    alert (elements[i].clientWidth);
  }
}
addOnloadHook( resizeWidthMax );

function createBookNavLink() {
	if (
		document.getElementById &&
		document.getElementById('bodyContent') &&
		document.getElementById('bookFooterMargin')
	) {
		var bct = document.getElementById('bodyContent');
		var bfm = document.getElementById('bookFooterMargin');
		if ( bct.clientHeight < 350 ) {
			bfm.style.height = ( 350 + bfm.clientHeight - bct.clientHeight ) + "px";
		}
 	}
	if (
		document.getElementById &&
		document.getElementById('bookHeaderNavSrc') &&
		document.getElementById('bookHeaderNavSrc').innerHTML &&
		document.getElementById('contentSub') &&
		document.getElementById('contentSub').innerHTML
	) {

		var curNode = document.getElementById('contentSub');
		var newNode = document.getElementById('bookHeaderNavSrc');
		if( ! curNode.innerHTML ) {
			curNode.innerHTML = '&nbsp;';
		}
		curNode.innerHTML = newNode.innerHTML + curNode.innerHTML;

	}
	if (
		document.getElementById &&
		document.getElementById('bookFooterNavSrc') &&
		document.getElementById('bookFooterNavSrc').innerHTML &&
		document.getElementById('catlinks') &&
		document.getElementById('catlinks').innerHTML &&
		document.createElement &&
		document.insertBefore
	) {
		var curNode = document.getElementById('catlinks');
		var newNode = document.createElement('div');
		newNode.id = 'bookFooter';
		newNode.innerHTML = document.getElementById('bookFooterNavSrc').innerHTML;
		newNode.style.margin        = '0px';
		newNode.style.padding       = '0px';
		newNode.style.verticalAlign = 'bottom';
		curNode.parentNode.insertBefore(newNode,curNode);
	}
}
addOnloadHook( createBookNavLink );
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox