「MediaWiki:Common.js/ParserFunctions.js」の版間の差分
提供: Yourpedia
(仮作成) |
細 |
||
(同じ利用者による、間の27版が非表示) | |||
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 | + | 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 = ""; | |
− | var | + | i--; |
− | + | } | |
− | for(var i | + | |
− | + | /* #if */ | |
− | for(var i2 in | + | var Ifempty = document.getElementsByClassName('ifempty'); |
− | if( | + | for(var i = 0; i < Ifempty.length; i++){ |
− | if( | + | var c = new Array(); |
− | + | var i3 = 0; | |
− | + | for (var i2 in Ifempty[i].childNodes){ | |
− | if( | + | 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; | break; | ||
} | } | ||
+ | } | ||
+ | str = str.replace(/^\s+|\s+$/g,''); | ||
+ | if(str != ""){ | ||
+ | Iftdempty[i].className = ""; | ||
+ | i--; | ||
} | } | ||
} | } | ||
// 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