MediaWiki:Common.js:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
| 第72行: | 第72行: | ||
//以下代码用于翻译北大陆文 | //以下代码用于翻译北大陆文 | ||
translate_to_NLLang = function(str) { | translate_to_NLLang = function(str) { | ||
console.log(str); | console.log(str); | ||
| 第102行: | 第101行: | ||
img.set("y", "У"); | img.set("y", "У"); | ||
img.set("z", "й"); | img.set("z", "й"); | ||
img.set("S", "д"); | img.set("S", "д"); | ||
img.set("T", "τ"); | img.set("T", "τ"); | ||
| 第108行: | 第106行: | ||
img.set("V", "v"); | img.set("V", "v"); | ||
img.set("W", "ш"); | img.set("W", "ш"); | ||
img.set("E", "ε"); | img.set("E", "ε"); | ||
img.set("F", "ѯ"); | img.set("F", "ѯ"); | ||
| 第116行: | 第113行: | ||
var ret = str; | var ret = str; | ||
for ( | for (x of img) { | ||
ret = ret.replace(new RegExp(x[0],"gm"), x[1]); | ret = ret.replace(new RegExp(x[0],"gm"), x[1]); | ||
} | } | ||
return ret; | return ret; | ||
} | } | ||
2018年4月18日 (三) 12:13的版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
var elist=document.getElementsByClassName("page-tags");
for(var i = 0; i < elist.length; i++) {
var str = elist[i].innerHTML;
str=str.replace("番外","<strong style=\"background-color:#92fda3;\">番外</strong>");
str=str.replace("长故事","<strong style=\"background-color:#ff8080;\">长故事</strong>");
str=str.replace("故事集","<strong style=\"background-color:#df6eef;\">故事集</strong>");
str=str.replace("故事","<strong style=\"background-color:#66b9f1;\">故事</strong>");
str=str.replace("设定","<strong style=\"background-color:#ffff7b;\">设定</strong>");
elist[i].innerHTML = str;
}
/* 以下代码用于模板折叠文字 -- Hineven */
random_string = function(str_length) {
var str = "",
arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
for (var i = 0; i < str_length; i++) {
pos = Math.round(Math.random()*(arr.length - 1));
str += arr[pos];
}
return str;
}
collapse_click = function(id) { // 大力爆改css
var ptitle = document.getElementById(id);
if(id.match("disp") == null) {
ptitle.attributes.getNamedItem("style").value = "display:none";
document.getElementById(id+"-disp").attributes.getNamedItem("style").value = "display:visible";
document.getElementById(id.replace("-title", "-content")).attributes.getNamedItem("style").value = "display:visible";
} else {
ptitle.attributes.getNamedItem("style").value = "display:none";
document.getElementById(id.replace("-disp", "").replace("-title", "-content")).attributes.getNamedItem("style").value = "display:none";
document.getElementById(id.replace("-disp", "")).attributes.getNamedItem("style").value = "display:visible";
}
}
collapse_preprocess = function() {
var col_arr = document.getElementsByClassName("collapse-box");
for(var i = 0; i<col_arr.length; i++) {
var hashcode = random_string(16);
// console.log(col_arr[i].childNodes);
for(var j = 0; j<col_arr[i].childNodes.length; j++) {
if(col_arr[i].childNodes[j].className == "collapse-box-title") {
var ap_id = document.createAttribute("id");
ap_id.value = "col-title-"+hashcode;
col_arr[i].childNodes[j].attributes.setNamedItem(ap_id);
ap_id = document.createAttribute("onclick");
ap_id.value = "collapse_click(this.id)";
col_arr[i].childNodes[j].attributes.setNamedItem(ap_id);
} else if(col_arr[i].childNodes[j].className == "collapse-display-title") {
var ap_id = document.createAttribute("id");
ap_id.value = "col-title-"+hashcode+"-disp";
col_arr[i].childNodes[j].attributes.setNamedItem(ap_id);
ap_id = document.createAttribute("onclick");
ap_id.value = "collapse_click(this.id)";
col_arr[i].childNodes[j].attributes.setNamedItem(ap_id);
} else if(col_arr[i].childNodes[j].className == "collapse-box-content") {
var ap_id = document.createAttribute("id");
ap_id.value = "col-content-"+hashcode;
col_arr[i].childNodes[j].attributes.setNamedItem(ap_id);
}
}
}
}
collapse_preprocess();
//以下代码用于翻译北大陆文
translate_to_NLLang = function(str) {
console.log(str);
var img = new Map();
img.set("a", "a");
img.set("b", "б");
img.set("c", "г");
img.set("d", "я");
img.set("e", "ε");
img.set("f", "ѯ");
img.set("g", "ѣ");
img.set("h", "ц");
img.set("i", "i");
img.set("j", "j");
img.set("k", "ѵ");
img.set("l", "I");
img.set("m", "м");
img.set("n", "п");
img.set("o", "ο");
img.set("p", "p");
img.set("q", "щ");
img.set("r", "ъ");
img.set("s", "д");
img.set("t", "τ");
img.set("u", "ы");
img.set("v", "v");
img.set("w", "ш");
img.set("x", "Х");
img.set("y", "У");
img.set("z", "й");
img.set("S", "д");
img.set("T", "τ");
img.set("U", "ы");
img.set("V", "v");
img.set("W", "ш");
img.set("E", "ε");
img.set("F", "ѯ");
img.set("G", "ѣ");
img.set("H", "ц");
img.set("I", "i");
var ret = str;
for (x of img) {
ret = ret.replace(new RegExp(x[0],"gm"), x[1]);
}
return ret;
}
var to_translate = document.getElementsByClassName("translate-to-nllang");
for(var i = 0; i<to_translate.length; i++) {
var s = to_translate[i].textContent;
to_translate[i].textContent = translate_to_NLLang(s);
}