MediaWiki:Common.js

出自伪基百科
跳至導覽 跳至搜尋

注意:在您儲存之後您必須清除瀏覽器快取才可看到最新的變更。

  • Firefox / Safari:按住 Shift 時點選 重新整理,或按 Ctrl-F5Ctrl-R (Mac 則為 ⌘-R)
  • Google Chrome:Ctrl-Shift-R (Mac 則為 ⌘-Shift-R)
  • Internet Explorer:按住 Ctrl 時點選 重新整理,或按 Ctrl-F5
  • Opera:前往 選單 → 設定 (在 Mac 為 Opera → 偏好設定) 然後再到 隱私 & 安全性 → 清除瀏覽資料 → 已快取的圖片與檔案
/*
=== 工具提示与快捷键 ===
<pre>*/
ta = {};
ta['pt-userpage'] = ['.','我的用户页'];
ta['pt-anonuserpage'] = ['.','您编辑本站所用IP的对应用户页'];
ta['pt-mytalk'] = ['n','我的对话页'];
ta['pt-anontalk'] = ['n','对于来自此IP地址编辑的讨论'];
ta['pt-preferences'] = ['','我的参数设置'];
ta['pt-watchlist'] = ['l','监视列表'];
ta['pt-mycontris'] = ['y','我的贡献列表'];
ta['pt-login'] = ['o','建议你登录,尽管并非必须。'];
ta['pt-anonlogin'] = ['o','建议你登录,尽管并非必须。'];
ta['pt-logout'] = ['o','退出'];
ta['ca-article'] = ['a','浏览条目正文'];
ta['ca-talk'] = ['t','关于条目正文的讨论'];
ta['ca-edit'] = ['e','你可编辑此页。请在保存前先预览一下。'];
ta['ca-addsection'] = ['+','在该讨论页增加新的评论主题。'];
ta['ca-viewsource'] = ['e','该页面已被保护。你可以查看该页源码。'];
ta['ca-history'] = ['h','本页面的早前版本。'];
ta['ca-protect'] = ['=','保护本页'];
ta['ca-unprotect'] = ['=','重新设定本页的保护权限'];
ta['ca-delete'] = ['d','删除本页'];
ta['ca-undelete'] = ['d','将这个页面恢复到被删除以前的状态'];
ta['ca-move'] = ['m','移动本页'];
ta['ca-nomove'] = ['','你不能移动这个页面'];
ta['ca-watch'] = ['w','将此页面加入监视列表'];
ta['ca-unwatch'] = ['w','将次页面从监视列表中移去'];
ta['search'] = ['f','搜索伪基百科'];
ta['p-logo'] = ['','首页'];
ta['n-mainpage'] = ['z','访问首页'];
ta['n-portal'] = ['','关于本计划、你可以做什么、应该如何做'];
ta['n-Featured_articles']=['','查看中文伪基百科的特色条目'];
ta['n-currentevents'] = ['','提供当前新闻事件的背景资料'];
ta['n-recentchanges'] = ['r','列出伪基百科中的最近修改'];
ta['n-randompage'] = ['x','随机载入一个页面'];
ta['n-help'] = ['','寻求帮助'];
ta['n-contact'] = ['','如何联络伪基百科'];
ta['n-villagepump'] = ['','参与伪基百科社群的讨论'];
ta['n-conversion'] = ['','提出繁简体转换请求'];
ta['n-allpages'] = ['','浏览所有页面的清单'];
ta['n-sitesupport'] = ['','资助我们'];
ta['t-whatlinkshere'] = ['j','列出所有与本页相链的页面'];
ta['t-recentchangeslinked'] = ['k','页面链出所有页面的更改'];
ta['feed-rss'] = ['','本页的RSS聚合'];
ta['feed-atom'] = ['','本页的Atom聚合'];
ta['t-contributions'] = ['','查看该用户的贡献列表'];
ta['t-emailuser'] = ['','给该用户发送电子邮件'];
ta['t-upload'] = ['u','上传图像或多媒体文件'];
ta['t-specialpages'] = ['q','全部特殊页面的列表'];
ta['ca-nstab-main'] = ['c','查看页面内容'];
ta['ca-nstab-user'] = ['c','查看用户页'];
ta['ca-nstab-media'] = ['c','查看媒体页'];
ta['ca-nstab-special'] = ['','这是一个特殊页面,你不能对其进行编辑。'];
ta['ca-nstab-wp'] = ['a','查看本站计划页面'];
ta['ca-nstab-image'] = ['c','查看图像页'];
ta['ca-nstab-mediawiki'] = ['c','查看系统信息'];
ta['ca-nstab-template'] = ['c','查看模板'];
ta['ca-nstab-help'] = ['c','查看帮助页面'];
ta['ca-nstab-category'] = ['c','查看分类页面'];
ta['ca-nstab-project'] = ['a','查看项目页面'];
// 兼容性修正
if (window.showModalDialog && document.compatMode && document.compatMode == "CSS1Compat")
{
  var oldWidth;
  var docEl = document.documentElement;

  function fixIEScroll()
  {
    if (!oldWidth || docEl.clientWidth > oldWidth)
      doFixIEScroll();
    else
      setTimeout(doFixIEScroll, 1);

    oldWidth = docEl.clientWidth;
  }

  function doFixIEScroll() {
    docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
  }

try{
  document.attachEvent("onreadystatechange", fixIEScroll);
  attachEvent("onresize", fixIEScroll);
} catch(e1){
}

}

// onload事件处理添加器
function addLoadEvent(func)
{
  if (window.addEventListener)
    window.addEventListener("load", func, false);
  else if (window.attachEvent)
    window.attachEvent("onload", func);
}

// 移动元素
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) {};
	}
}

/*</pre>

=== 特色条目链接显示===
<pre>*/ 
function LinkFA()
{
   // iterate over all <span>-elements
   for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
      // if found a FA span
      if(a.className == "FA") {
         // iterate over all <li>-elements
         for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
            // if found a FA link
            if(b.className == "interwiki-" + a.id) {
               b.style.padding = "0 0 0 16px";
               b.style.backgroundImage = "url('http://images2.wikia.nocookie.net/zh.uncyclopedia/images/6/60/LinkFA-star.png')";
               b.style.backgroundRepeat = "no-repeat";
               b.title = "此条目为特色条目";
            }
         }
      }
   }
}

addLoadEvent(LinkFA);


/*</pre>
=== 表格生成器===
<pre>*/ 
/**
 *
 * English: Generate an  a r r a y  using Mediawiki syntax
 *
 * @author: fr:user:dake
 * @version: 0.1
 */
 
function generateTableau(nbCol, nbRow, border, styleHeader, styleLine)
{
        var code = "\n";
        if (styleHeader==1) {
                code += '{\{entête tableau charte}\}\n';
        } else {
                code += '{| border="' + border + '"\n';
                code += '|+ 表格标题\n';
        }
        
        for (var i=0;i<nbCol;i++) code += '! 表头 ' + i + '\n'
        
        for (var j=0;j<nbRow;j++) {
                if ((j+1)%2==0 && styleLine==1) {
                        code += '|-{'+'{grey row}'+'}\n'
                } else {                
                        code += '|-----\n'
                }
                
                for (var i=0;i<nbCol;i++) code += '| 内容\n';
        }
        
        code += '|}';
        insertTags('','', code); 
}

/**
 *
 * English: Open a popup with parameters to generate an  a r r a y. 
 * The number of rows/columns can be modified. Some additional
 * parameters are related to templates available on :fr
 *
 * @author: fr:user:dake
 * @version: 0.1
 */
 
function popupTableau()
{
  var popup = window.open('','name','height=400,width=500');
  
  javaCode =  '<script type="text\/javascript">function insertCode(){';
  javaCode += 'var row = parseInt(document.paramForm.inputRow.value); '
  javaCode += 'var col = parseInt(document.paramForm.inputCol.value); '
  javaCode += 'var bord = parseInt(document.paramForm.inputBorder.value); '
  javaCode += 'var styleHeader = document.paramForm.inputHeader.checked; '
  javaCode += 'var styleLine = document.paramForm.inputLine.checked; '
  javaCode += 'window.opener.generateTableau(col,row,bord,styleHeader,styleLine); '
  javaCode += '}<\/script>';
  
  popup.document.write('<html><head><title>表格参数</title>');
  popup.document.write('<script type="text\/javascript" src="\/skins-1.5\/common\/wikibits.js"><!-- wikibits js --><\/script>');
  popup.document.write('<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>');
  popup.document.write(javaCode); 
  popup.document.write('</head><body>');
  popup.document.write('<p>请输入想要生成表格的参数:</p>');
  popup.document.write('<form name="paramForm">');
  popup.document.write('行数:<input type="text" name="inputRow" value="3" ><p>');
  popup.document.write('列数:<input type="text" name="inputCol" value="3" ><p>');
  popup.document.write('边框宽度:<input type="text" name="inputBorder" value="1" ><p>');
  popup.document.write('灰色表头:<input type="checkbox" name="inputHeader" checked="1" ><p>');
  popup.document.write('灰色斑马表:<input type="checkbox" name="inputLine" checked="1" ><p>');
  popup.document.write('</form">');
  popup.document.write('<p><a href="javascript:insertCode()"> 将代码插入到编辑窗口中</a></p>');
  popup.document.write('<p><a href="javascript:self.close()"> 关闭</a></p>');
  popup.document.write('</body></html>');
  popup.document.close();
}

//增加弹出表格按钮
function marque_tab()
{
    var toolbar = document.getElementById('toolbar');
    if (!toolbar) return false;

    var textbox = document.getElementById('wpTextbox1');
    if (!textbox) return false;

    if (!document.selection && textbox.selectionStart == null)
    return false;

    var CustomTableButt = document.createElement("img");
    CustomTableButt.width = 23;
    CustomTableButt.height = 22;
    CustomTableButt.src = 'http://images3.wikia.nocookie.net/central/images/4/4a/Button_ta' + 'ble.png';
    CustomTableButt.border = 0;
    CustomTableButt.style.cursor = "pointer";
    CustomTableButt.alt = '自定义表格';
    CustomTableButt.onclick = function() {popupTableau(); return false;}
    toolbar.appendChild(CustomTableButt);
}

addLoadEvent(marque_tab);


/*</pre>

=== 编辑工具按钮===
<pre>*/ 

if (typeof mwCustomEditButtons!="undefined"&&mwCustomEditButtons)
{
    function addEditButton(imageFile, tagOpen, sampleText, tagClose, speedTip)
    {
        mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://upload.wikimedia.org/wikipedia/" + imageFile,
        "tagOpen": tagOpen,
        "sampleText": sampleText,
        "tagClose": tagClose,
        "speedTip": speedTip
        };
    }

    addEditButton("he/e/e9/Button_headline2.png", "=== ", "标题文本", " ===", "三级子标题");
    addEditButton("he/e/e9/Button_headline3.png", "==== ", "标题文本", " ====", "四级子标题");
    addEditButton("commons/9/97/Template_button.png", "{{", "模板名", "}}", "应用模板");
    addEditButton("meta/c/c9/Button_strike.png", "<del>", "删除线", "</del>", "删除线");
    addEditButton("he/e/ea/Button_align_left.png", '<div style="direction: ltr;">\n', "左对齐", "\n</div>", "左对齐");
    addEditButton("he/5/5f/Button_center.png", '<div style="text-align: center;">\n', "居中", "\n</div>", "居中");
    addEditButton("he/6/60/Button_insert_table.png", '\n{| border="1" \n|- \n| 第一部分 || 第二部分 \n|- \n| 第三部分 || 第四部分',"","\n|}\n", "插入表格");
    addEditButton("he/1/13/Button_enter.png", "<br />", "", "", "换行");
    addEditButton("he/8/80/Button_upper_letter.png", "<sup>", "上标", "</sup>", "上标");
    addEditButton("he/7/70/Button_lower_letter.png", "<sub>", "下标", "</sub>", "下标");
    addEditButton("commons/5/56/Button_big.png", '<span style="font-size:larger;">', "放大", "</span>", "放大");
    addEditButton("commons/5/58/Button_small.png", '<span style="font-size:smaller;">', "缩小", "</span>", "缩小");
    addEditButton("commons/9/9e/Btn_toolbar_gallery.png", "<gallery>\n", "Image:PictureFileName.jpg|图片题注\nImage:PictureFileName.jpg|图片题注", "\n</gallery>", "画廊");
    addEditButton("en/c/c8/Button_redirect.png", "#REDIRECT [[", "目标条目名", "]]", "复位向");
    addEditButton("he/8/8e/Button_shifting.png", ":", "", "", "缩进");
    addEditButton("he/f/fd/Button_blockquote.png", '<blockquote style="border: 1px solid blue; padding: 0.5em 0.8em;">\n', "引文", "\n</blockquote>", "块引用");
    addEditButton("he/2/23/Button_code.png", "<code>", "代码", "</code>", "代码文本");
    addEditButton("he/9/93/Button_sub_link.png", "[[条目#", "章节|文本", "]]", "内部段落链接");
    addEditButton("he/d/d3/Button_definition_list.png", "\n; ", "释义", " : ", "定义文本");
    addEditButton("he/1/1e/Button_font_color.png", '<span style="color: ColorName;">', "颜色文本", "</span>", "彩色文本");
    addEditButton("he/3/34/Button_hide_comment.png", "<!-- ", "隐藏文字", " -->", "注释或隐藏文字");
}

/*</pre>

=== 增加特殊符号的下拉选单 ===
<pre>*/ 
/* 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';
	}
}

addLoadEvent(addCharSubsetMenu);

/*</pre>

=== 调整工具位置 ===
<pre>*/ 
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' ); 	 
}

addLoadEvent(fixToolbar);

/*</pre>

=== 增加折迭功能 ===
<pre>*/ 
/*var NavigationBarHide = '隐藏 ▲';
var NavigationBarShow = '显示 ▼';
// NavigationBarShowDefault 设置最少不折迭的个数
// 当折迭栏个数多于NavigationBarShowDefault时,页面载入后隐藏所有折迭栏。
// 当折迭栏个数不多于NavigationBarShowDefault时,页面载入后展开所有折迭栏。
var NavigationBarShowDefault = 0;

function toggleNavigationBar(indexNavigationBar)
{
   var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
   var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);

   if (!NavFrame || !NavToggle) {
       return false;
   }

   if (NavToggle.firstChild.data == NavigationBarHide) {
       for (
               var NavChild = NavFrame.firstChild;
               NavChild != null;
               NavChild = NavChild.nextSibling
           ) {
           if (NavChild.className == 'NavPic') {
               NavChild.style.display = 'none';
           }
           if (NavChild.className == 'NavContent') {
               NavChild.style.display = 'none';
           }
           NavToggle.firstChild.data = NavigationBarShow;
       }

   } else if (NavToggle.firstChild.data == NavigationBarShow) {
       for (
               var NavChild = NavFrame.firstChild;
               NavChild != null;
               NavChild = NavChild.nextSibling
           ) {
           if (NavChild.className == 'NavPic') {
               NavChild.style.display = 'block';
           }
           if (NavChild.className == 'NavContent') {
               NavChild.style.display = 'block';
           }
           NavToggle.firstChild.data = NavigationBarHide;
       }
   }
}

function createNavigationBarToggleButton()
{
   var indexNavigationBar = 0;
   var subdiv;

   for(
           var i=0;
           NavFrame = document.getElementsByTagName("div")[i];
           i++
       ) {

       if (NavFrame.className == "NavFrame") {

           indexNavigationBar++;
           var NavToggle = document.createElement("a");
           NavToggle.className = 'NavToggle';
           NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
           NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');

           var NavToggleText = document.createTextNode(NavigationBarHide);
           NavToggle.appendChild(NavToggleText);
           for(var ih=0; subdiv = NavFrame.childNodes[ih]; ih++ ) {
              if (subdiv.className == "NavHead") {
                subdiv.appendChild(NavToggle);
                break;
              }
           }

           NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
       }
   }

   if (NavigationBarShowDefault < indexNavigationBar) {
       for(
               var i=1;
               i<=indexNavigationBar;
               i++
       ) {
           toggleNavigationBar(i);
       }
   }

   //修正折迭后定位变化
   if(location.hash)location.href=location.hash;
}

addLoadEvent(createNavigationBarToggleButton);*/

/*</pre>

=== 首页变化效果 ===
<pre>*/
var mpTitleHans = "首页";
var mpTitleHant = "首页";
var isMainPage = ((document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitleHant) || (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitleHans));
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));

if (isMainPage && !isDiff) 
{
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, #contentSub/*, h1.firstHeading { display: none !important; }*/ /*]]>*/</style>');

var mpSmallEnabled;
var mpMinWidth = 700;

function mainPageTransform()
{
       if ((isMainPage || (/[\/=:]{{urlencode:首页}}/.test(document.location) || /[\/=:]{{urlencode:首页}}/.test(document.location))) && document.getElementById('ca-nstab-main'))     
       document.getElementById('ca-nstab-main').firstChild.innerHTML = '首页';
	var mpContentEl = document.getElementById("bodyContent");
	var mpBrowseEl = document.getElementById("EnWpMpBrowse");
	var mpContainEl = document.getElementById("EnWpMpBrowseContainer");
	var mpMarginEl = document.getElementById("EnWpMpMargin");
	var mpEl = document.getElementById("EnWpMainPage");

	if (!mpContentEl || !mpBrowseEl || !mpContainEl || !mpMarginEl || !mpEl)
		return;

	if (!mpSmallEnabled && mpContentEl.offsetWidth < mpMinWidth)
	{
		mpContainEl.insertBefore(mpBrowseEl, mpContainEl.firstChild);
		mpBrowseEl.className = "EnWpMpBrowseBottom";
		mpMarginEl.style.marginRight = 0;
		mpSmallEnabled = true;
	}
	else if (mpSmallEnabled && mpContentEl.offsetWidth > mpMinWidth)
	{
		mpEl.insertBefore(mpBrowseEl, mpEl.firstChild);
		mpBrowseEl.className = "EnWpMpBrowseRight";
		mpMarginEl.style.marginRight = "13.8em";
		mpSmallEnabled = false;
	}
}

var onloadFuncts = [ mainPageTransform ];

if (window.addEventListener) 
  window.addEventListener("resize", mainPageTransform, false);
else if (window.attachEvent) 
  window.attachEvent("onresize", mainPageTransform);

}

//</pre>

/* 记住保持[[MediaWiki:Standard.js]]与本脚本同步 */

/* Any JavaScript here will be loaded for all users on every page load.
==可摺疊範本==
<pre><nowiki>*/

// ============================================================
// BEGIN Dynamic Navigation Bars (experimantal)
// Documentation on wikipedia at [[Wikipedia:NavFrame|NavFrame]]
 
// set up the words in your language
var NavigationBarHide = '[隱藏]';
var NavigationBarShow = '[顯示]';
 
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;
 
 
// shows and hides content and picture (if available) of navigation bars
// Parameters:
//     indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
 
    if (!NavFrame || !NavToggle) {
        return false;
    }
 
    // if shown now
    if (NavToggle.firstChild.data == NavigationBarHide) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild != null;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'none';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    // if hidden now
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild != null;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'block';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'block';
            }
        }
    NavToggle.firstChild.data = NavigationBarHide;
    }
}
 
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
    var indexNavigationBar = 0;
    // iterate over all < div >-elements
    for(
            var i=0; 
            NavFrame = document.getElementsByTagName("div")[i]; 
            i++
        ) {
        // if found a navigation bar
        if (NavFrame.className == "NavFrame") {
 
            indexNavigationBar++;
            var NavToggle = document.createElement("a");
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
            
            var NavToggleText = document.createTextNode(NavigationBarHide);
            NavToggle.appendChild(NavToggleText);
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
            for(
              var j=0; 
              j < NavFrame.childNodes.length; 
              j++
            ) {
              if (NavFrame.childNodes[j].className == "NavHead") {
                NavFrame.childNodes[j].appendChild(NavToggle);
              }
            }
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
    // if more Navigation Bars found than Default: hide all
    if (NavigationBarShowDefault < indexNavigationBar) {
        for(
                var i=1; 
                i<=indexNavigationBar; 
                i++
        ) {
            toggleNavigationBar(i);
        }
    }
 
}
 
addOnloadHook(createNavigationBarToggleButton);

// END Dynamic Navigation Bars
// ============================================================

/*</nowiki></pre>*/
/*
== 編輯首段 ==
<pre><nowiki>*/

if (wgIsArticle) {
	onloadFuncts.push(function(){
		var caEdit=document.getElementById&&document.getElementById('ca-edit');
		if (!caEdit){return;}
		var caEdit0 = document.createElement('LI');
		var id = caEdit0.id = 'ca-edit-0';
		ta[id] = ['0', '編輯首段'];
		caEdit0.className = caEdit.className;
		caEdit.className = 'istalk';
		var link = document.createElement('A');
		if (caEdit.children) {
			link.href = caEdit.children[0].href + '&section=0';
		} else {
			link.href = caEdit.childNodes[0].href + '&section=0';
		}
		link.appendChild(document.createTextNode('0'));
		caEdit0.appendChild(link); +
		caEdit.parentNode.insertBefore(caEdit0,caEdit.nextSibling);

		var pref;
		if (is_safari || navigator.userAgent.toLowerCase().indexOf('mac') + 1
			|| navigator.userAgent.toLowerCase().indexOf('konqueror') + 1 ) {
			pref = 'control-';
		} else if (is_opera) {
			pref = 'shift-esc-';
		} else if (is_ff2_x11) {
			pref = 'ctrl-shift-';
		} else if (is_ff2_win) {
			pref = 'alt-shift-';
		} else {
			pref = 'alt-';
		}
		link.accessKey = ta[id][0];
		caEdit0.title= ta[id][1]+' ['+pref+ta[id][0]+']';
		//updateTooltipAccessKeys([caEdit0]);
		//akeytt([id]);
	});
}

/*</nowiki></pre>
==導入模塊==
<pre><nowiki>*/
function getWikiPath(page,prep){
        prep.ctype=prep.ctype||'text';
        prep.dontcountme=prep.dontcountme||'s';
        prep.action=prep.action||'raw';
        var url = wgScriptPath + '/index.php?title=' + encodeURI( page.replace( ' ', '_' ) );
        for(var k in prep){url += '&' + k + '=' + prep[k]; }
        return url;
}
function importScript( page ) {
        var url= /^https?:\/\//.test(page) ? page : getWikiPath(page,{'ctype':'text/javascript'});
        var scriptElem = document.createElement( 'script' );
        scriptElem.setAttribute( 'src' , url );
        scriptElem.setAttribute( 'type' , 'text/javascript' );
        document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
}
function importStylesheet( page ) {
        var url= /^https?:\/\//.test(page) ? page : getWikiPath(page,{'ctype':'text/css'});
        var styleElem = document.createElement( 'style' );
        styleElem.setAttribute( 'type' , 'text/css' );
        styleElem.appendChild( document.createTextNode( '@import "' + sheet +'";' ) );
        document.getElementsByTagName( 'head' )[0].appendChild( styleElem );
}
/*</nowiki></pre>
==“返回上一页”模板==
<pre><nowiki>*/
function addBackPage() {
	// iterate over all < span >-elements
	for (var i=0; backLinkSpan = document.getElementsByTagName("span")[i]; i++) {
		if (backLinkSpan.className == "backpage") {
			var link = document.createElement("a");
			link.setAttribute('href', 'javascript:history.back();');
			while (backLinkSpan.childNodes.length > 0) {
				link.appendChild(backLinkSpan.firstChild);
			}
			backLinkSpan.appendChild(link);
		}
	}
}

addOnloadHook(addBackPage);
/*</nowiki></pre>

==USERNAME模板==
<pre><nowiki>*/

function UserNameReplace() {
if(typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace) return;
   for(var i=0; UserName = document.getElementsByTagName("span")[i]; i++) {
       if ((wgUserName)&&(UserName.className == "insertusername")) {
           UserName.innerHTML = wgUserName;
       }
   }
}

addOnloadHook(UserNameReplace);
/*</nowiki></pre>*/


/*
==LogoChange模板==
*/

function noLogo() {
   if (document.getElementById('nologo')) document.getElementById('p-logo').style.display = 'none';
}
addOnloadHook(noLogo);