MediaWiki:Common.js

From open-support.info

(Difference between revisions)
Jump to: navigation, search
m
m
Line 1: Line 1:
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
-
if (!document.getElementsByClassName) {
+
function getElementsByClassName(searchClass) {
-
  function getElementsByClassName(searchClass) {
+
  if (document.all) {
-
    if (document.all) {
+
    var classElements = new Array();
-
      var classElements = new Array();
+
    var allElements = document.all;
-
      var allElements = document.all;
+
    for (i = 0, j = 0; i < allElements.length; i++) {
-
      for (i = 0, j = 0; i < allElements.length; i++) {
+
      if (allElements[i].className == searchClass) {
-
        if (allElements[i].className == searchClass) {
+
        classElements[j] = allElements[i];
-
          classElements[j] = allElements[i];
+
        j++;
-
          j++;
+
      }
-
        }
+
    }     
-
      }     
+
  } else if (document.getElementsByTagName) {
-
    } else if (document.getElementsByTagName) {
+
    var classElements = new Array();
-
      var classElements = new Array();
+
    var allElements = document.getElementsByTagName("*");
-
      var allElements = document.getElementsByTagName("*");
+
    for (i = 0, j = 0; i < allElements.length; i++) {
-
      for (i = 0, j = 0; i < allElements.length; i++) {
+
      if (allElements[i].className == searchClass) {
-
        if (allElements[i].className == searchClass) {
+
        classElements[j] = allElements[i];
-
          classElements[j] = allElements[i];
+
        j++;
-
          j++;
+
      }
-
        }
+
    }         
-
      }         
+
  } else {
-
    } else {
+
     return;
-
      return;
+
-
    }
+
-
     return classElements;
+
   }
   }
 +
  return classElements;
}
}
function resizeWidthMax() {
function resizeWidthMax() {
-
   alert (document.getElementsByClassName);
+
   var elements = getElementsByClass('resizeWidthMax');
-
   if(
+
   alert (elements.length);
-
      document.getElementsByClassName &&
+
/*  if elements.length > 0
-
      document.getElementsByClassName('resizeWidthMax') &&
+
-
      document.getElementsByClassName('resizeWidthMax').length > 0
+
   ) {
   ) {
     var elements = document.getElementsByClassName('resizeWidthMax');
     var elements = document.getElementsByClassName('resizeWidthMax');
     alert(elements.length);
     alert(elements.length);
-
   }
+
   } */
}
}
addOnloadHook( resizeWidthMax );
addOnloadHook( resizeWidthMax );

Revision as of 07:51, 19 April 2011

/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
function getElementsByClassName(searchClass) {
  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');
  alert (elements.length);
/*  if elements.length > 0
  ) {
    var elements = document.getElementsByClassName('resizeWidthMax');
    alert(elements.length);
  } */
}
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