MediaWiki:Monobook.js
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer / Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
- 此腳本缺少說明文檔。請協助創建。
- 相關-{zh-hans:链接; zh-hant:連接}-:子頁面列表 • -{zh-hans:链入; zh-hant:連入}- • -{zh-hans:重定向; zh-hant:重新導向}-
// 移动元素
function elementMoveto(node, refNode, pos){//默认位置为refNode前
if(node && refNode){
var parent=refNode.parentNode;
if (pos && pos=='after') refNode=refNode.nextSibling;
try {
parent.insertBefore(node, refNode);
} catch (DOMException) {};
}
}
// 优秀词条链接显示
function LinkFA()
{
for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
if(a.className == "ICQ") {
a.style.padding = "0 0 0 20px";
a.style.backgroundImage = "url('http://status.icq.com/online.gif?icq="+a.id+"&img=5')";
a.style.backgroundRepeat = "no-repeat";
}
if(a.className == "FA") {
for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
if(b.className == "interwiki-" + a.id) {
b.style.padding = "0 0 0 16px";
b.style.backgroundImage = "url('//upload.wikimedia.org/wikipedia/ru/3/33/Small_skew_star.gif')";
b.style.backgroundRepeat = "no-repeat";
b.title = "此词条被评为优秀词条";
}
}
}
}
}
$(LinkFA);
// 增加特殊符号的下拉选单 (须与[[MediaWiki:Edittools]]的内容一致)
/* add menu for selecting subsets of secial characters */
/***** must match MediaWiki:Edittools *****/
function addCharSubsetMenu() {
var edittools = document.getElementById('editpage-specialchars');
if (edittools) {
var name;
var menu=document.createElement("select");
menu.style.display="inline";
var line = edittools.getElementsByTagName('p');
for (var i = 0; i < line.length ; i++) {
if(line[i].title)name=line[i].title;
else name = line[i].id;
menu.options[menu.options.length]=new Option(name);
}
menu.onchange=function(){chooseCharSubset(this.selectedIndex);};
edittools.insertBefore(menu,edittools.firstChild);
chooseCharSubset(0);
}
}
/* select subsection of special characters */
function chooseCharSubset(s) {
var l = document.getElementById('editpage-specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
l[i].style.display = i == s ? 'inline' : 'none';
l[i].style.visibility = i == s ? 'visible' : 'hidden';
}
}
$(addCharSubsetMenu);
// 把工具栏置于顶部
function fixToolbar(){
var wpEditToolbar=document.getElementById("toolbar");
//移動下拉選單
var dropdownListEditTools=document.getElementById("dropdownListEditTools");
elementMoveto(dropdownListEditTools , wpEditToolbar , 'after' );
if(dropdownListEditTools)dropdownListEditTools.style.display="block";
//移動符號表
var editspecialchars=document.getElementById("editpage-specialchars");
elementMoveto(editspecialchars , wpEditToolbar , 'after' );
}
$(fixToolbar);
// 啤酒馆与茶室发起新讨论标签
function addJiahao() {
// 取得页名
var pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue;
// 确定是啤酒馆或茶室
if ((pagetitle.search(/^Wiktionary:啤酒馆$/) != -1) || (pagetitle.search(/^Wiktionary:茶室$/) != -1)) {
// 位置选择
var edittabli = document.getElementById('ca-edit');
// 创建
var plustabli = document.createElement('li');
plustabli.id = 'ca-addsection';
var plustablink = document.createElement('a');
plustablink.href = '/w/index.php?title=' + pagetitle + '&action=edit§ion=new';
plustablink.appendChild(document.createTextNode('+'));
plustabli.appendChild(plustablink);
// + 符号加入顶部
edittabli.className = 'istalk';
edittabli.parentNode.insertBefore(plustabli, edittabli.nextSibling);
}
}
// 啤酒馆/茶室/沙盒标签显示
function addBiaoqian() {
// 取得页名
var pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue;
// 确定是啤酒馆
if (pagetitle.search(/^Wiktionary:啤酒馆$/) != -1) {
if(document.getElementById('ca-nstab-wp'))
{
document.getElementById('ca-nstab-wp').firstChild.innerHTML = '啤酒馆';
}
else if(document.title.indexOf("Wiktionary:啤酒馆") != 3)
{
if(document.getElementById('ca-nstab-wp'))
{
document.getElementById('ca-nstab-wp').firstChild.innerHTML = '啤酒馆';
}
}
}
// 确定是茶室
if (pagetitle.search(/^Wiktionary:茶室$/) != -1) {
if(document.getElementById('ca-nstab-wp'))
{
document.getElementById('ca-nstab-wp').firstChild.innerHTML = '茶室';
}
else if(document.title.indexOf("Wiktionary:茶室") != 3)
{
if(document.getElementById('ca-nstab-wp'))
{
document.getElementById('ca-nstab-wp').firstChild.innerHTML = '茶室';
}
}
}
// 确定是沙盒
if (pagetitle.search(/^Wiktionary:沙盒$/) != -1) {
if(document.getElementById('ca-nstab-wp'))
{
document.getElementById('ca-nstab-wp').firstChild.innerHTML = '沙盒';
}
else if(document.title.indexOf("Wiktionary:沙盒") != 3)
{
if(document.getElementById('ca-nstab-wp'))
{
document.getElementById('ca-nstab-wp').firstChild.innerHTML = '沙盒';
}
}
}
}
// 维基词典特有的设置
function customizeWiktionary() {
addJiahao();
addBiaoqian();
}
$(customizeWiktionary);
// 记住在[[MediaWiki:Common.js]]上要做同样的更改使得“怀旧皮肤”显示一致