MediaWiki:Common.js:修订间差异

此后如竟没有炬火,我便是唯一的光。
跳转到导航 跳转到搜索
无编辑摘要
无编辑摘要
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/*************多语言选择*************/

function cleartext(){
/*************多语言选择*************/
for(var i=0;i<t1.length;i++){
function cleartext() {
t1[i].style.display = 'none';
t2[i].style.display = 'none';
for (var i = 0; i < t1.length; i++) {
t3[i].style.display = 'none';
t1[i].style.display = 'none';
t4[i].style.display = 'none';
t2[i].style.display = 'none';
t5[i].style.display = 'none';
t3[i].style.display = 'none';
t6[i].style.display = 'none';
t4[i].style.display = 'none';
}
t5[i].style.display = 'none';
t6[i].style.display = 'none';
}
}
}


/*************编辑器注入*************/
/*************编辑器注入*************/
var xdi8Letters = [ //希顶字母表
var xdi8Letters = [ //希顶字母表
[
[
["!`", "b", "p", "m", "w", "j", "q", "x", "y", "n", "z", "D", "s", "r", "H", "N", "l", "d", "t", "g", "k", "h", "4", "5", "v", "F", "7", "B", "c", "f", "u", "a", "o", "e", "E", "A", "Y", "L", "6", "2", "T", "8", "3", "V", "1", "i"],
["!`", "b", "p", "m", "w", "j", "q", "x", "y", "n", "z", "D", "s", "r", "H", "N", "l", "d", "t", "g", "k", "h", "4", "5", "v", "F", "7", "B", "c", "f", "u", "a", "o", "e", "E", "A", "Y", "L", "6", "2", "T", "8", "3", "V", "1", "i"],
["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
],
],
[
[
["⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧"],
["⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧"],
["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
]
]
];
];
function translatePua(str) {//翻译作pua
function translatePua(str) {//翻译作pua
for (var i_ in xdi8Letters) {
for (var i_ in xdi8Letters) {
var i = xdi8Letters[i_];
var i = xdi8Letters[i_];
for (var j_ in i[0]) {
for (var j_ in i[0]) {
var j = i[j_];
var j = i[j_];
while (str != str.replace(j, i[1][i[0].indexOf(j)])) {
while (str != str.replace(j, i[1][i[0].indexOf(j)])) {
str = str.replace(j, i[1][i[0].indexOf(j)])
str = str.replace(j, i[1][i[0].indexOf(j)])
}
}
}
}
}
return str;
}
}
return str;
}


function injectBotton() {//注入希顶按钮
function injectBotton() {//注入希顶按钮
function findBotton() {
function findBotton() {
if (document.getElementsByTagName("div")) {
if (document.getElementsByTagName("div")) {
for (var childs_ in document.getElementsByTagName("div")) {
for (var childs_ in document.getElementsByTagName("div")) {
var childs = document.getElementsByTagName("div")[childs_];
var childs = document.getElementsByTagName("div")[childs_];
var attrs = childs.attributes;
var attrs = childs.attributes;
if (attrs && (attrs["rel"] && attrs["rel"].value == "latin") && (attrs["class"] && attrs["class"].value != "toolbar section section-main")) {
if (attrs && (attrs["rel"] && attrs["rel"].value == "latin") && (attrs["class"] && attrs["class"].value != "toolbar section section-main")) {
return childs;
return childs;
}
}
}
}
}
return null;
}
}
if (findBotton()) {
return null;
}
findBotton().setAttribute('class', '');
if (findBotton()) {
var xdi8Bottom = document.createElement('div');
xdi8Bottom.setAttribute('rel', 'xdi8');
findBotton().setAttribute('class', '');
xdi8Bottom.setAttribute('id', 'xdi8in');
var xdi8Bottom = document.createElement('div');
xdi8Bottom.onclick = function () { //取自mediawiki内部脚本
xdi8Bottom.setAttribute('rel', 'xdi8');
xdi8Bottom.setAttribute('id', 'xdi8in');
var section;
xdi8Bottom.onclick = function () { //取自mediawiki内部脚本
$(this).parent().parent().find('.page').hide();
var section;
$(this).parent().parent().find('.page-' + $(this).attr('rel')).show().trigger('loadPage');
$(this).siblings().removeClass('current');
$(this).parent().parent().find('.page').hide();
$(this).addClass('current');
$(this).parent().parent().find('.page-' + $(this).attr('rel')).show().trigger('loadPage');
section = $(this).parent().parent().attr('rel');
$(this).siblings().removeClass('current');
$(this).addClass('current');
$.cookie('wikiEditor-' + $(this).data('context').instance + '-booklet-' + section + '-page', $(this).attr('rel'), {
expires: 30,
section = $(this).parent().parent().attr('rel');
$.cookie('wikiEditor-' + $(this).data('context').instance + '-booklet-' + section + '-page', $(this).attr('rel'), {
path: '/'
});
expires: 30,
event.preventDefault();
path: '/'
}
});
xdi8Bottom.innerText = "希顶字母";
event.preventDefault();
findBotton().parentNode.insertBefore(xdi8Bottom, findBotton());
return true;
}
}
else { return false; }
xdi8Bottom.innerText = "希顶字母";
findBotton().parentNode.insertBefore(xdi8Bottom, findBotton());
return true;
}
}
else { return false; }
}


function insertText(obj, str) {//向texteara插入文本在当前光标处
function insertText(obj, str) {//向texteara插入文本在当前光标处
if (document.selection) {
if (document.selection) {
var sel = document.selection.createRange();
var sel = document.selection.createRange();
sel.text = str;
sel.text = str;
}
else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
var startPos = obj.selectionStart,
endPos = obj.selectionEnd,
cursorPos = startPos,
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
cursorPos += str.length;
obj.selectionStart = obj.selectionEnd = cursorPos;
}
else {
obj.value += str;
}
}
}
else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
function injectList() {//注入希顶输入列表
function findList() {
var startPos = obj.selectionStart,
endPos = obj.selectionEnd,
if (document.getElementsByTagName("div")) {
cursorPos = startPos,
for (var childs_ in document.getElementsByTagName("div")) {
var childs = document.getElementsByTagName("div")[childs_];
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
var attrs = childs.attributes;
cursorPos += str.length;
if (attrs && (attrs["rel"] && attrs["rel"].value == "latin") && (attrs["class"] && attrs["class"].value == "page page-latin page-characters")) {
obj.selectionStart = obj.selectionEnd = cursorPos;
return childs;
}
}
else {
obj.value += str;
}
}
function injectList() {//注入希顶输入列表
function findList() {
if (document.getElementsByTagName("div")) {
for (var childs_ in document.getElementsByTagName("div")) {
var childs = document.getElementsByTagName("div")[childs_];
var attrs = childs.attributes;
if (attrs && (attrs["rel"] && attrs["rel"].value == "latin") && (attrs["class"] && attrs["class"].value == "page page-latin page-characters")) {
return childs;
}
}
}
}
return null;
}
};
return null;
};
if (findList()) {
findList().style = "display: none";
if (findList()) {
findList().style = "display: none";
var xdi8List = document.createElement('div');
xdi8List.setAttribute('rel', 'xdi8');
var xdi8List = document.createElement('div');
xdi8List.setAttribute('class', 'page page-xdi8 page-characters');
xdi8List.setAttribute('rel', 'xdi8');
xdi8List.setAttribute('class', 'page page-xdi8 page-characters');


var divin = document.createElement('div');
var divin = document.createElement('div');
divin.setAttribute('dir', 'ltr');
divin.setAttribute('dir', 'ltr');


for (var letter_ in xdi8Letters[0][1].concat(xdi8Letters[1][1])) {//内含物字母列表
for (var letter_ in xdi8Letters[0][1].concat(xdi8Letters[1][1])) {//内含物字母列表
letter = xdi8Letters[0][1].concat(xdi8Letters[1][1])[letter_];
letter = xdi8Letters[0][1].concat(xdi8Letters[1][1])[letter_];
var spanin = document.createElement("span")
var spanin = document.createElement("span")
spanin.setAttribute('rel', letter);
spanin.setAttribute('rel', letter);
spanin.innerText = letter;
spanin.innerText = letter;
spanin.style.fontFamily = "'XEGOEPUAall',-apple-system,'Helvetica Neue','Segoe UI',Helvetica,'Nimbus Sans L',Arial,'Liberation Sans','PingFang SC','Hiragino Sans GB','Noto Sans CJK SC','Source Han Sans SC','Microsoft YaHei','Wenquanyi Micro Hei','WenQuanYi Zen Hei','ST Heiti',SimHei,'WenQuanYi Zen Hei Sharp',sans-serif";
spanin.style.fontFamily = "'XEGOEPUAall',-apple-system,'Helvetica Neue','Segoe UI',Helvetica,'Nimbus Sans L',Arial,'Liberation Sans','PingFang SC','Hiragino Sans GB','Noto Sans CJK SC','Source Han Sans SC','Microsoft YaHei','Wenquanyi Micro Hei','WenQuanYi Zen Hei','ST Heiti',SimHei,'WenQuanYi Zen Hei Sharp',sans-serif";
divin.appendChild(spanin);
divin.appendChild(spanin);
spanin.onclick = function () { insertText(wpTextbox1, $(this).attr('rel')); };
spanin.onclick = function () { insertText(wpTextbox1, $(this).attr('rel')); };
}
xdi8List.appendChild(divin);
findList().parentNode.insertBefore(xdi8List, findList());
return true;
}
}
else { return false; }
xdi8List.appendChild(divin);
findList().parentNode.insertBefore(xdi8List, findList());
return true;
}
}
else { return false; }
}


function insertTextBothSide(obj, str1, str2) {//向texteara插入文本在当前光标两侧
function insertTextBothSide(obj, str1, str2) {//向texteara插入文本在当前光标两侧
if (document.selection) {
if (document.selection) {
var sel = document.selection.createRange();
var sel = document.selection.createRange();
sel.text = str1 + sel.text + str2;
sel.text = str1 + sel.text + str2;
}
else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
var startPos = obj.selectionStart,
endPos = obj.selectionEnd,
cursorPos = startPos,
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + str1 + tmpStr.substring(startPos, endPos) + str2 + tmpStr.substring(endPos, tmpStr.length);
cursorPos += str1.length;
obj.selectionStart = obj.selectionEnd = cursorPos;
}
else {
obj.value = str1 + obj.value + str2;
}
}
}
else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
function insertTransPua(obj) {//向texteara文段翻译
var startPos = obj.selectionStart,
if (document.selection) {
var sel = document.selection.createRange();
endPos = obj.selectionEnd,
sel.text = translatePua(sel.text);
cursorPos = startPos,
}
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + str1 + tmpStr.substring(startPos, endPos) + str2 + tmpStr.substring(endPos, tmpStr.length);
else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
var startPos = obj.selectionStart,
cursorPos += str1.length;
endPos = obj.selectionEnd,
obj.selectionStart = obj.selectionEnd = cursorPos;
cursorPos = startPos,
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + translatePua(tmpStr.substring(startPos, endPos)) + tmpStr.substring(endPos, tmpStr.length);
cursorPos += translatePua(tmpStr.substring(startPos, endPos)).length - tmpStr.substring(startPos, endPos).length;
obj.selectionStart = obj.selectionEnd = cursorPos;
}
else {
obj.value = translatePua(obj.value);
}
}
}
else {
function findTransPua(obj) {//在texteara里寻找{{x}}翻译
obj.value = str1 + obj.value + str2;
function findX(str) {
}
for (var indx = str.indexOf("{{x|"); indx >= 0; indx = str.indexOf("{{x|")) {
}
var floor = 1;
function insertTransPua(obj) {//向texteara文段翻译
var nowin = indx;
while (floor > 0) {
if (document.selection) {
var floorb = str.indexOf("}}", nowin);
var sel = document.selection.createRange();
if (floorb >= 0) {
sel.text = translatePua(sel.text);
}
floor--;
else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
nowin = floorb;
}
var startPos = obj.selectionStart,
else {
endPos = obj.selectionEnd,
var floora = str.indexOf("{{", nowin);
cursorPos = startPos,
if (floora >= 0) {
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + translatePua(tmpStr.substring(startPos, endPos)) + tmpStr.substring(endPos, tmpStr.length);
floor++;
cursorPos += translatePua(tmpStr.substring(startPos, endPos)).length - tmpStr.substring(startPos, endPos).length;
nowin = floora;
obj.selectionStart = obj.selectionEnd = cursorPos;
}
}
else {
obj.value = translatePua(obj.value);
}
}
function findTransPua(obj) {//在texteara里寻找{{x}}翻译
function findX(str) {
for (var indx = str.indexOf("{{x|"); indx >= 0; indx = str.indexOf("{{x|")) {
var floor = 1;
var nowin = indx;
while (floor > 0) {
var floorb = str.indexOf("}}", nowin);
if (floorb >= 0) {
floor--;
nowin = floorb;
}
else {
var floora = str.indexOf("{{", nowin);
if (floora >= 0) {
floor++;
nowin = floora;
}
}
}
}
str = str.substring(0, indx) + translatePua(str.substring(indx + 4, nowin)) + str.substring(nowin + 2, str.length);
}
}
str = str.substring(0, indx) + translatePua(str.substring(indx + 4, nowin)) + str.substring(nowin + 2, str.length);
return str;
}
}
obj.value = findX(obj.value);
return str;
}
}
obj.value = findX(obj.value);
function injectBelow() {//注入下面的按钮
}
function findBelow() {//寻找位置
function injectBelow() {//注入下面的按钮
if (document.getElementsByTagName("div")) {
function findBelow() {//寻找位置
for (var childs_ in document.getElementsByTagName("div")) {
var childs = document.getElementsByTagName("div")[childs_];
if (document.getElementsByTagName("div")) {
var attrs = childs.attributes;
for (var childs_ in document.getElementsByTagName("div")) {
var childs = document.getElementsByTagName("div")[childs_];
if (attrs && attrs["class"] && attrs["class"].value == "editOptions") {
return childs;
var attrs = childs.attributes;
}
if (attrs && attrs["class"] && attrs["class"].value == "editOptions") {
return childs;
}
}
}
}
return null;
}
};
return null;
};
if (findBelow()) {
if (findBelow()) {
//希顶翻译块
//希顶翻译块
var belowBottom3 = document.createElement('a');
belowBottom3.onclick = function () { insertTransPua(wpTextbox1); };
var belowBottom3 = document.createElement('a');
belowBottom3.onclick = function () { insertTransPua(wpTextbox1); };
belowBottom3.innerText = "转换选中区域希顶为PUA";
belowBottom3.style.marginLeft = "1.4em";
belowBottom3.innerText = "转换选中区域希顶为PUA";
belowBottom3.style.marginLeft = "1.4em";
findBelow().insertBefore(belowBottom3, findBelow().childNodes[0]);
findBelow().insertBefore(belowBottom3, findBelow().childNodes[0]);
//希顶翻译全文
//希顶翻译全文
var belowBottom4 = document.createElement('a');
belowBottom4.onclick = function () { findTransPua(wpTextbox1); };
var belowBottom4 = document.createElement('a');
belowBottom4.onclick = function () { findTransPua(wpTextbox1); };
belowBottom4.innerText = "转换全文{{x|}}内希顶为PUA";
belowBottom4.style.marginLeft = "1.4em";
belowBottom4.innerText = "转换全文{{x|}}内希顶为PUA";
belowBottom4.style.marginLeft = "1.4em";
findBelow().insertBefore(belowBottom4, findBelow().childNodes[0]);
findBelow().insertBefore(belowBottom4, findBelow().childNodes[0]);
//插入功能表
var funcLists = [
//插入功能表
["[[", "]]"],
var funcLists = [
["{{拼|", "}}"],
["[[", "]]"],
["{{|", "}}"],
["{{|", "}}"],
["{{ruby|", "|}}"],
["{{|", "}}"],
["{{color|red|", "}}"],
["{{ruby|", "|}}"],
["{{国家声明}}", ""],
["{{color|red|", "}}"],
["{{人物声明}}", ""],
["{{国家声明}}", ""],
["{{Info|", "}}"],
["{{人物声明}}", ""],
["{{x|", "}}"]
["{{Info|", "}}"],
]
["{{x|", "}}"]
]
for (var funcList_ in funcLists) {
var funcList = funcLists[funcList_];
for (var funcList_ in funcLists) {
var belowBottom2 = document.createElement('a');
var funcList = funcLists[funcList_];
var belowBottom2 = document.createElement('a');
belowBottom2.setAttribute('onclick', "insertTextBothSide(wpTextbox1,'" + funcList[0] + "','" + funcList[1] + "');");//需要固定量
belowBottom2.innerText = funcList[0] + (funcList[1] != "" ? "..." : "") + funcList[1];
belowBottom2.setAttribute('onclick', "insertTextBothSide(wpTextbox1,'" + funcList[0] + "','" + funcList[1] + "');");//需要固定量
belowBottom2.innerText = funcList[0] + (funcList[1] != "" ? "..." : "") + funcList[1];
belowBottom2.style.marginLeft = "1.4em";
belowBottom2.style.marginLeft = "1.4em";
findBelow().insertBefore(belowBottom2, findBelow().childNodes[0]);
findBelow().insertBefore(belowBottom2, findBelow().childNodes[0]);
}
}


var belowBottom = document.createElement('a');
var belowBottom = document.createElement('a');
belowBottom.href = "#xdi8in";
belowBottom.href = "#xdi8in";
belowBottom.onclick = function () {
belowBottom.onclick = function () {
document.getElementById("wikiEditor-section-characters").setAttribute('class', 'booklet section section-characters section-visible');
document.getElementById("wikiEditor-section-characters").setAttribute('class', 'booklet section section-characters section-visible');
}
belowBottom.innerText = "输入希顶字母";
findBelow().insertBefore(belowBottom, findBelow().childNodes[0]);
return true;
}
}
else { return false; }
belowBottom.innerText = "输入希顶字母";
findBelow().insertBefore(belowBottom, findBelow().childNodes[0]);
return true;
}
}
else { return false; }
}


//函数执行块,dom加载完备时执行
//函数执行块,dom加载完备时执行
$(function () {
$(function () {
//多语言选择
//多语言选择
document.getElementById("b1").onclick = function() {
document.getElementById("b1").onclick = function () {
cleartext();
cleartext();
for(var i=0;i<t1.length;i++){
for (var i = 0; i < t1.length; i++) {
t1[i].style.display = 'block';
t1[i].style.display = 'block';
}
}
}
}
document.getElementById("b2").onclick = function() {
document.getElementById("b2").onclick = function () {
cleartext();
for(var i=0;i<t1.length;i++){
cleartext();
for (var i = 0; i < t1.length; i++) {
t2[i].style.display = 'block';
t2[i].style.display = 'block';
}
}
}
}
document.getElementById("b3").onclick = function() {
document.getElementById("b3").onclick = function () {
cleartext();
for(var i=0;i<t1.length;i++){
cleartext();
for (var i = 0; i < t1.length; i++) {
t3[i].style.display = 'block';
t3[i].style.display = 'block';
}
}
}
}
document.getElementById("b4").onclick = function() {
document.getElementById("b4").onclick = function () {
cleartext();
for(var i=0;i<t1.length;i++){
cleartext();
for (var i = 0; i < t1.length; i++) {
t4[i].style.display = 'block';
t4[i].style.display = 'block';
}
}
}
}
document.getElementById("b5").onclick = function() {
document.getElementById("b5").onclick = function () {
cleartext();
for(var i=0;i<t1.length;i++){
cleartext();
for (var i = 0; i < t1.length; i++) {
t5[i].style.display = 'block';
t5[i].style.display = 'block';
}
}
}
}
document.getElementById("b6").onclick = function() {
document.getElementById("b6").onclick = function () {
cleartext();
for(var i=0;i<t1.length;i++){
cleartext();
for (var i = 0; i < t1.length; i++) {
t6[i].style.display = 'block';
t6[i].style.display = 'block';
}
}
}
}
//编辑器注入
//编辑器注入
alert("你好,我是一个警告框!");



var isjectBotton=false;
var isjectBotton = false;
setInterval(function()
{
setInterval(function () {
isjectBotton=(!isjectBotton)?injectBotton():true;
isjectBotton = (!isjectBotton) ? injectBotton() : true;
}
}
,"5000");
, "5000");
var isjectList=false;
var isjectList = false;
setInterval(function()
setInterval(function () {
{
isjectList = (!isjectList) ? injectList() : true;
}
isjectList=(!isjectList)?injectList():true;
}
, "5000");
,"5000");
var isjectBelow = false;
setInterval(function () {
var isjectBelow=false;
isjectBelow = (!isjectBelow) ? injectBelow() : true;
setInterval(function()
{
}
, "5000");
isjectBelow=(!isjectBelow)?injectBelow():true;
});
}

,"5000");
(function (mw) { })(mediaWiki);
});

2022年4月10日 (日) 17:02的版本

/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */

/*************多语言选择*************/
function cleartext() {
    for (var i = 0; i < t1.length; i++) {
        t1[i].style.display = 'none';
        t2[i].style.display = 'none';
        t3[i].style.display = 'none';
        t4[i].style.display = 'none';
        t5[i].style.display = 'none';
        t6[i].style.display = 'none';
    }
}

/*************编辑器注入*************/
var xdi8Letters = [  //希顶字母表
    [
        ["!`", "b", "p", "m", "w", "j", "q", "x", "y", "n", "z", "D", "s", "r", "H", "N", "l", "d", "t", "g", "k", "h", "4", "5", "v", "F", "7", "B", "c", "f", "u", "a", "o", "e", "E", "A", "Y", "L", "6", "2", "T", "8", "3", "V", "1", "i"],
        ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
    ],
    [
        ["⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧", "⇧"],
        ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
    ]
];
function translatePua(str) {//翻译作pua
    for (var i_ in xdi8Letters) {
        var i = xdi8Letters[i_];
        for (var j_ in i[0]) {
            var j = i[j_];
            while (str != str.replace(j, i[1][i[0].indexOf(j)])) {
                str = str.replace(j, i[1][i[0].indexOf(j)])
            }
        }
    }
    return str;
}

function injectBotton() {//注入希顶按钮
    function findBotton() {
        if (document.getElementsByTagName("div")) {
            for (var childs_ in document.getElementsByTagName("div")) {
                var childs = document.getElementsByTagName("div")[childs_];
                var attrs = childs.attributes;
                if (attrs && (attrs["rel"] && attrs["rel"].value == "latin") && (attrs["class"] && attrs["class"].value != "toolbar section section-main")) {
                    return childs;
                }
            }
        }
        return null;
    }
    if (findBotton()) {
        findBotton().setAttribute('class', '');
        var xdi8Bottom = document.createElement('div');
        xdi8Bottom.setAttribute('rel', 'xdi8');
        xdi8Bottom.setAttribute('id', 'xdi8in');
        xdi8Bottom.onclick = function () {  //取自mediawiki内部脚本
            var section;
            $(this).parent().parent().find('.page').hide();
            $(this).parent().parent().find('.page-' + $(this).attr('rel')).show().trigger('loadPage');
            $(this).siblings().removeClass('current');
            $(this).addClass('current');
            section = $(this).parent().parent().attr('rel');
            $.cookie('wikiEditor-' + $(this).data('context').instance + '-booklet-' + section + '-page', $(this).attr('rel'), {
                expires: 30,
                path: '/'
            });
            event.preventDefault();
        }
        xdi8Bottom.innerText = "希顶字母";
        findBotton().parentNode.insertBefore(xdi8Bottom, findBotton());
        return true;
    }
    else { return false; }
}

function insertText(obj, str) {//向texteara插入文本在当前光标处
    if (document.selection) {
        var sel = document.selection.createRange();
        sel.text = str;
    }
    else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
        var startPos = obj.selectionStart,
            endPos = obj.selectionEnd,
            cursorPos = startPos,
            tmpStr = obj.value;
        obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
        cursorPos += str.length;
        obj.selectionStart = obj.selectionEnd = cursorPos;
    }
    else {
        obj.value += str;
    }
}
function injectList() {//注入希顶输入列表
    function findList() {
        if (document.getElementsByTagName("div")) {
            for (var childs_ in document.getElementsByTagName("div")) {
                var childs = document.getElementsByTagName("div")[childs_];
                var attrs = childs.attributes;
                if (attrs && (attrs["rel"] && attrs["rel"].value == "latin") && (attrs["class"] && attrs["class"].value == "page page-latin page-characters")) {
                    return childs;
                }
            }
        }
        return null;
    };
    if (findList()) {
        findList().style = "display: none";
        var xdi8List = document.createElement('div');
        xdi8List.setAttribute('rel', 'xdi8');
        xdi8List.setAttribute('class', 'page page-xdi8 page-characters');

        var divin = document.createElement('div');
        divin.setAttribute('dir', 'ltr');

        for (var letter_ in xdi8Letters[0][1].concat(xdi8Letters[1][1])) {//内含物字母列表
            letter = xdi8Letters[0][1].concat(xdi8Letters[1][1])[letter_];
            var spanin = document.createElement("span")
            spanin.setAttribute('rel', letter);
            spanin.innerText = letter;
            spanin.style.fontFamily = "'XEGOEPUAall',-apple-system,'Helvetica Neue','Segoe UI',Helvetica,'Nimbus Sans L',Arial,'Liberation Sans','PingFang SC','Hiragino Sans GB','Noto Sans CJK SC','Source Han Sans SC','Microsoft YaHei','Wenquanyi Micro Hei','WenQuanYi Zen Hei','ST Heiti',SimHei,'WenQuanYi Zen Hei Sharp',sans-serif";
            divin.appendChild(spanin);
            spanin.onclick = function () { insertText(wpTextbox1, $(this).attr('rel')); };
        }
        xdi8List.appendChild(divin);
        findList().parentNode.insertBefore(xdi8List, findList());
        return true;
    }
    else { return false; }
}

function insertTextBothSide(obj, str1, str2) {//向texteara插入文本在当前光标两侧
    if (document.selection) {
        var sel = document.selection.createRange();
        sel.text = str1 + sel.text + str2;
    }
    else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
        var startPos = obj.selectionStart,
            endPos = obj.selectionEnd,
            cursorPos = startPos,
            tmpStr = obj.value;
        obj.value = tmpStr.substring(0, startPos) + str1 + tmpStr.substring(startPos, endPos) + str2 + tmpStr.substring(endPos, tmpStr.length);
        cursorPos += str1.length;
        obj.selectionStart = obj.selectionEnd = cursorPos;
    }
    else {
        obj.value = str1 + obj.value + str2;
    }
}
function insertTransPua(obj) {//向texteara文段翻译
    if (document.selection) {
        var sel = document.selection.createRange();
        sel.text = translatePua(sel.text);
    }
    else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
        var startPos = obj.selectionStart,
            endPos = obj.selectionEnd,
            cursorPos = startPos,
            tmpStr = obj.value;
        obj.value = tmpStr.substring(0, startPos) + translatePua(tmpStr.substring(startPos, endPos)) + tmpStr.substring(endPos, tmpStr.length);
        cursorPos += translatePua(tmpStr.substring(startPos, endPos)).length - tmpStr.substring(startPos, endPos).length;
        obj.selectionStart = obj.selectionEnd = cursorPos;
    }
    else {
        obj.value = translatePua(obj.value);
    }
}
function findTransPua(obj) {//在texteara里寻找{{x}}翻译
    function findX(str) {
        for (var indx = str.indexOf("{{x|"); indx >= 0; indx = str.indexOf("{{x|")) {
            var floor = 1;
            var nowin = indx;
            while (floor > 0) {
                var floorb = str.indexOf("}}", nowin);
                if (floorb >= 0) {
                    floor--;
                    nowin = floorb;
                }
                else {
                    var floora = str.indexOf("{{", nowin);
                    if (floora >= 0) {
                        floor++;
                        nowin = floora;
                    }
                }
            }
            str = str.substring(0, indx) + translatePua(str.substring(indx + 4, nowin)) + str.substring(nowin + 2, str.length);
        }
        return str;
    }
    obj.value = findX(obj.value);
}
function injectBelow() {//注入下面的按钮
    function findBelow() {//寻找位置
        if (document.getElementsByTagName("div")) {
            for (var childs_ in document.getElementsByTagName("div")) {
                var childs = document.getElementsByTagName("div")[childs_];
                var attrs = childs.attributes;
                if (attrs && attrs["class"] && attrs["class"].value == "editOptions") {
                    return childs;
                }
            }
        }
        return null;
    };
    if (findBelow()) {
        //希顶翻译块
        var belowBottom3 = document.createElement('a');
        belowBottom3.onclick = function () { insertTransPua(wpTextbox1); };
        belowBottom3.innerText = "转换选中区域希顶为PUA";
        belowBottom3.style.marginLeft = "1.4em";
        findBelow().insertBefore(belowBottom3, findBelow().childNodes[0]);
        //希顶翻译全文
        var belowBottom4 = document.createElement('a');
        belowBottom4.onclick = function () { findTransPua(wpTextbox1); };
        belowBottom4.innerText = "转换全文{{x|}}内希顶为PUA";
        belowBottom4.style.marginLeft = "1.4em";
        findBelow().insertBefore(belowBottom4, findBelow().childNodes[0]);
        //插入功能表
        var funcLists = [
            ["[[", "]]"],
            ["{{拼|", "}}"],
            ["{{|", "}}"],
            ["{{ruby|", "|}}"],
            ["{{color|red|", "}}"],
            ["{{国家声明}}", ""],
            ["{{人物声明}}", ""],
            ["{{Info|", "}}"],
            ["{{x|", "}}"]
        ]
        for (var funcList_ in funcLists) {
            var funcList = funcLists[funcList_];
            var belowBottom2 = document.createElement('a');
            belowBottom2.setAttribute('onclick', "insertTextBothSide(wpTextbox1,'" + funcList[0] + "','" + funcList[1] + "');");//需要固定量
            belowBottom2.innerText = funcList[0] + (funcList[1] != "" ? "..." : "") + funcList[1];
            belowBottom2.style.marginLeft = "1.4em";
            findBelow().insertBefore(belowBottom2, findBelow().childNodes[0]);
        }

        var belowBottom = document.createElement('a');
        belowBottom.href = "#xdi8in";
        belowBottom.onclick = function () {
            document.getElementById("wikiEditor-section-characters").setAttribute('class', 'booklet section section-characters section-visible');
        }
        belowBottom.innerText = "输入希顶字母";
        findBelow().insertBefore(belowBottom, findBelow().childNodes[0]);
        return true;
    }
    else { return false; }
}

//函数执行块,dom加载完备时执行
$(function () {
    //多语言选择
    document.getElementById("b1").onclick = function () {
        cleartext();
        for (var i = 0; i < t1.length; i++) {
            t1[i].style.display = 'block';
        }
    }
    document.getElementById("b2").onclick = function () {
        cleartext();
        for (var i = 0; i < t1.length; i++) {
            t2[i].style.display = 'block';
        }
    }
    document.getElementById("b3").onclick = function () {
        cleartext();
        for (var i = 0; i < t1.length; i++) {
            t3[i].style.display = 'block';
        }
    }
    document.getElementById("b4").onclick = function () {
        cleartext();
        for (var i = 0; i < t1.length; i++) {
            t4[i].style.display = 'block';
        }
    }
    document.getElementById("b5").onclick = function () {
        cleartext();
        for (var i = 0; i < t1.length; i++) {
            t5[i].style.display = 'block';
        }
    }
    document.getElementById("b6").onclick = function () {
        cleartext();
        for (var i = 0; i < t1.length; i++) {
            t6[i].style.display = 'block';
        }
    }
    //编辑器注入
    alert("你好,我是一个警告框!");


    var isjectBotton = false;
    setInterval(function () {
        isjectBotton = (!isjectBotton) ? injectBotton() : true;
    }
        , "5000");
    var isjectList = false;
    setInterval(function () {
        isjectList = (!isjectList) ? injectList() : true;
    }
        , "5000");
    var isjectBelow = false;
    setInterval(function () {
        isjectBelow = (!isjectBelow) ? injectBelow() : true;
    }
        , "5000");
});

(function (mw) { })(mediaWiki);