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

提供: Yourpedia
移動: 案内検索
(こんどこそ)
 
(同じ利用者による、間の22版が非表示)
1行目: 1行目:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
  
/* 計算スクリプト */
+
/* #expr */
/* var Keisans = document.getElementsByClassName('tashizan');
+
var Expr = document.getElementsByClassName('expr');
+
for(var i = 0; i < Expr.length; i++){
var Childs;
+
var a = eval(Expr[i].innerText);
var numA;
+
Expr[i].innerText = a;
var numB;
+
Expr[i].className = "";
var numC;
+
i--;
+
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;
+
}
+
 
}
 
}
}*/
 
  
/* スタイルのバグ修正 */
+
/* #if */
if(location.host == 'ja.yourpedia.org'){
+
var Ifempty = document.getElementsByClassName('ifempty');
var link = document.getElementsByTagName('link');
+
for(var i = 0; i < Ifempty.length; i++){
for(var i in link){
+
var c = new Array();
if(link[i].rel == 'stylesheet' && link[i].href.indexOf('yourpedia.org/mediawiki/load.php') != -1){
+
var i3 = 0;
link[i].href = link[i].href.replace(/https:\/\/(.+).yourpedia.org\//, 'https://ja.yourpedia.org/');
+
for (var i2 in Ifempty[i].childNodes){
break;
+
if(Ifempty[i].childNodes[i2].tagName == "SPAN"){
 +
c[i3] = Ifempty[i].childNodes[i2].innerHTML;
 +
i3++;
 
}
 
}
 +
}
 +
if(c[0] == ""){
 +
if(c[2] == undefined){
 +
Ifempty[i].innerHTML = "";
 +
}else{
 +
Ifempty[i].innerHTML = c[2];
 +
Ifempty[i].className = "";
 +
i--;
 +
}
 +
}else{
 +
Ifempty[i].innerHTML = c[1];
 +
Ifempty[i].className = "";
 +
i--;
 
}
 
}
 
}
 
}
  
/* 実験 */
+
/* #if table用 */
var i = document.getElementsByClassName('gengo');
+
var Iftdempty = document.getElementsByClassName('iftdempty');
var i2;
+
for(var i = 0; i < Iftdempty.length; i++){
if(i[0] < 1989){
+
var str = "";
i2 = '昭和';
+
for (var i2 in Iftdempty[i].childNodes){
}else{
+
if(Iftdempty[i].childNodes[i2].tagName == "TD"){
i2 = '平成';
+
str = Iftdempty[i].childNodes[i2].innerHTML;
 +
break;
 +
}
 +
}
 +
str = str.replace(/^\s+|\s+$/g,'');
 +
if(str != ""){
 +
Iftdempty[i].className = "";
 +
i--;
 +
}
 
}
 
}
document.getElementsByClassName('gengo')[0].innerText = i2;
 
  
 
// END
 
// END

2020年4月13日 (月) 14:22時点における最新版

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

/* #expr */
	var Expr = document.getElementsByClassName('expr');
		for(var i = 0; i < Expr.length; i++){
			var a = eval(Expr[i].innerText);
			Expr[i].innerText = a;
			Expr[i].className = "";
			i--;
		}

/* #if */
	var Ifempty = document.getElementsByClassName('ifempty');
	for(var i = 0; i < Ifempty.length; i++){
		var c = new Array();
		var i3 = 0;
		for (var i2 in Ifempty[i].childNodes){
			if(Ifempty[i].childNodes[i2].tagName == "SPAN"){
				c[i3] = Ifempty[i].childNodes[i2].innerHTML;
				i3++;
			}
		}
		if(c[0] == ""){
			if(c[2] == undefined){
				Ifempty[i].innerHTML = "";
			}else{
				Ifempty[i].innerHTML = c[2];
				Ifempty[i].className = "";
				i--;
			}
		}else{
			Ifempty[i].innerHTML = c[1];
			Ifempty[i].className = "";
			i--;
		}
	}

/* #if table用 */
	var Iftdempty = document.getElementsByClassName('iftdempty');
	for(var i = 0; i < Iftdempty.length; i++){
		var str = "";
		for (var i2 in Iftdempty[i].childNodes){
			if(Iftdempty[i].childNodes[i2].tagName == "TD"){
				str = Iftdempty[i].childNodes[i2].innerHTML;
				break;
			}
		}
		str = str.replace(/^\s+|\s+$/g,'');
		if(str != ""){
			Iftdempty[i].className = "";
			i--;
		}
	}

// END