跳转到内容

User:Isnow/CategoryPageForm.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
////////// Category Page form
function CategoryPageForm() {
  var contentDiv = document.getElementById("bodyContent");

  var myForm = document.createElement("form");
  var mySelect = document.createElement("select");
  var myInput = document.createElement("input");
  var myButton = document.createElement("input");

  myForm.method = "post";

  // [[Unicode字符列表]]
  var myOption = document.createElement("option");
  var myText = document.createTextNode("字符集");
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode("拉丁字符");
  myOption.value = "!";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode(wgUVS("希腊字母","希臘字母"));
  myOption.value = "ʹ";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode(wgUVS("西里尔字母","西里爾字母"));
  myOption.value = "Ѐ";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode("希伯来字母");
  myOption.value = "־";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode("阿拉伯字母");
  myOption.value = "؀";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode(wgUVS("日语假名","日語假名"));
  myOption.value = "ぁ";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode(wgUVS("朝鲜语谚文","朝鮮語諺文"));
  myOption.value = "ㄱ";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  myOption = document.createElement("option");
  myText = document.createTextNode(wgUVS("汉字","漢字"));
  myOption.value = "一";
  myOption.appendChild(myText);
  mySelect.appendChild(myOption);
  mySelect.onchange = function() {
    location.href = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + wgPageName + '&from=' + mySelect.options[mySelect.selectedIndex].value;
    }

  myInput.type = "text";
  myInput.onkeyup = function(e) {
  	if (e.keyCode == 13) { location.href = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + wgPageName + '&from=' + myInput.value; }
  	}
  
  myButton.type = "button";
  myButton.value = wgUVS("跳转","跳轉");
  myButton.onclick = function() {
    location.href = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + wgPageName + '&from=' + myInput.value;
    }

  myText = document.createTextNode(wgUVS("请选择","請選擇"));
  myForm.appendChild(myText);
  myForm.appendChild(mySelect);
  myText = document.createTextNode(wgUVS("或自定义索引字符","或自定義索引字符"));
  myForm.appendChild(myText);
  myForm.appendChild(myInput);
  myForm.appendChild(myButton);
  contentDiv.insertBefore(myForm, contentDiv.firstChild);
}

if (mw.config.get('wgCanonicalNamespace') == "Category" && mw.config.get('wgAction') == "view"){ //scripts specific to Category:XXX
  $(CategoryPageForm);
}