「MediaWiki:Common.js」の版間の差分

提供: Yourpedia
移動: 案内検索
(テスト)
5行目: 5行目:
 
   document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>');
 
   document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>');
 
}
 
}
 +
 +
/* 計算スクリプト */
 +
var Keisans = document.getElementsByClassName('tashizan');
 +
 +
var Childs;
 +
var numA;
 +
var numB;
 +
var numC;
 +
 +
for(var i in Keisans){
 +
Childs = Keisans[i].childNodes;
 +
for(var i2 in Childs){
 +
if(Childs[i2].className == 'numA') numA = Childs[i2].innerText;
 +
if(Childs[i2].className == 'numB') numB = Childs[i2].innerText;
 +
if(Childs[i2].className == 'numC') numC = Childs[i2];
 +
 +
if(numA && numB && numC){
 +
numC.innerText = Number(numA) + Number(numB);
 +
break;
 +
}
 +
}
 +
}

2019年4月4日 (木) 05:07時点における版

/* Any JavaScript here will be loaded for all users on every page load. */

var isViewingMainPage = (/^メインページ(\/..)? - Yourpedia$/.test(document.title));
if (isViewingMainPage) {
  document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>');
}

/* 計算スクリプト */
	var Keisans = document.getElementsByClassName('tashizan');
	
	var Childs;
	var numA;
	var numB;
	var numC;
	
	for(var i in Keisans){
		Childs = Keisans[i].childNodes;
		for(var i2 in Childs){
			if(Childs[i2].className == 'numA') numA = Childs[i2].innerText;
			if(Childs[i2].className == 'numB') numB = Childs[i2].innerText;
			if(Childs[i2].className == 'numC') numC = Childs[i2];
			
			if(numA && numB && numC){
				numC.innerText = Number(numA) + Number(numB);
				break;
			}
		}
	}