MediaWiki:Common.js

出自【暗黑百科】DiabloWiki_凯恩之角

(修订版本间的差异)
跳转到: 导航, 搜索
 
(16个中途的修订版本没有显示)
第1行: 第1行:
-
/*
+
var hasClass = (function () {
-
所有用戶在加載任何頁面時,這裡的JavaScript都會加載
+
     var reCache = {};
-
*/
+
     return function (element, className) {
-
window.addPortletLink = mw.util.addPortletLink;
+
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
-
window.getParamValue = mw.util.getParamValue;
+
-
 
+
-
(function ($, mw) {
+
-
     /* Search Engine variant hack */
+
-
     if (/\.google\./.test(document.referrer) && /\.wikipedia\.org\/zh(-[^/]+)?\//.test(document.location.href)) {
+
-
        document.location = document.location.href.replace(/\.wikipedia\.org\/zh(-[^/]+)?\//, ".wikipedia.org/wiki/");
+
-
    }
+
-
 
+
-
    /* Cookies */
+
-
    window.setCookie = function (cookieName, cookieValue, expiryDay) {
+
-
        $.cookie(cookieName, cookieValue, {
+
-
            expires: expiryDay,
+
-
            path: '/'
+
-
        });
+
     };
     };
 +
})();
-
    window.getCookie = function (cookieName) {
 
-
        return $.cookie(cookieName);
 
-
    };
 
-
    window.deleteCookie = function (cookieName) {
+
/** Collapsible tables *********************************************************
-
        $.cookie(cookieName, null);
+
*
-
    };
+
*  Description: Allows tables to be collapsed, showing only the header. See
-
    /* overwrite the original script loaders with mw.loader.load
+
*               [[Wikipedia:NavFrame]].
-
    window.importScript = function (page) {
+
*  Maintainers: [[User:R. Koot]]
-
        mw.loader.load(wgServer + wgScript + '?title=' + mw.util.wikiUrlencode(page) + '&action=raw&ctype=text/javascript');
+
*/
-
    };
+
-
    window.importScriptCallback = function (page, ready) {
+
var autoCollapse = 2;
-
        importScriptURICallback(wgServer + wgScript + '?title=' + mw.util.wikiUrlencode(page) + '&action=raw&ctype=text/javascript', ready);
+
-
    };
+
-
    window.importScriptURI = function (url) {
+
var collapseCaption = "隐藏▲";
-
        mw.loader.load(url);
+
var expandCaption = "显示▼";
-
    };
+
-
    window.importScriptURICallback = function (url, ready) {
+
-
        $.ajax({
+
function collapseTable( tableIndex )
-
            'url': url,
+
{
-
            'cache': true,
+
    var Button = document.getElementById( "collapseButton" + tableIndex );
-
            'dataType': 'script',
+
-
            'success': ready
+
-
        });
+
-
    };
+
-
     window.importStylesheet = function (page) {
+
     var Table = document.getElementById( "collapsibleTable" + tableIndex );
-
        mw.loader.load(wgServer + wgScript + '?title=' + mw.util.wikiUrlencode(page) + '&action=raw&ctype=text/css', 'text/css');
+
-
    };
+
-
     window.importStylesheetURI = function (url) {
+
-
         mw.loader.load(url, 'text/css');
+
     if ( !Table || !Button ) {
-
    };*/
+
         return false;
-
    /* 中文處理 */
 
-
    /* 1. 设置中文语言页 */
 
-
    $('html').attr('lang', wgUserVariant).attr('xml:lang', wgUserVariant);
 
-
 
-
    /* 2. 返回繁簡字串 */
 
-
    var wgUXS = function (wg, hans, hant, cn, tw, hk, sg, zh, mo, my) {
 
-
        var ret = {
 
-
            'zh': zh || hans || hant || cn || tw || hk || sg || mo || my,
 
-
            'zh-hans': hans || cn || sg || my,
 
-
            'zh-hant': hant || tw || hk || mo,
 
-
            'zh-cn': cn || hans || sg || my,
 
-
            'zh-sg': sg || hans || cn || my,
 
-
            'zh-tw': tw || hant || hk || mo,
 
-
            'zh-hk': hk || hant || tw || mo
 
-
        }
 
-
        return ret[wg] || zh || hans || hant || cn || tw || hk || sg || mo || my; //保證每一語言有值
 
     }
     }
 +
 +
    var Rows = Table.rows;
 +
 +
    if ( Button.firstChild.data == collapseCaption ) {
-
    window.wgULS = function (hans, hant, cn, tw, hk, sg, zh, mo, my) {
+
        for ( var i = 1; i < Rows.length; i++ ) {
-
        return wgUXS(wgUserLanguage, hans, hant, cn, tw, hk, sg, zh, mo, my);
+
            Rows[i].oldDisplayValue = Rows[i].style.display;
-
    };
+
            Rows[i].style.display = "none";
-
    window.wgUVS = function (hans, hant, cn, tw, hk, sg, zh, mo, my) {
 
-
        return wgUXS(wgUserVariant, hans, hant, cn, tw, hk, sg, zh, mo, my);
 
-
    };
 
-
 
-
    /* 當需要時載入對應的 scripts */
 
-
    if (wgAction == "edit" || wgAction == "submit" || wgCanonicalSpecialPageName == 'Search') { //scripts specific to editing pages
 
-
        importScript('MediaWiki:Common.js/edit.js');
 
-
    }
 
-
 
-
    /* 辅助处理 */
 
-
    /* 1. 功能設定 */
 
-
    window.JSConfig = window.JSconfig || {};
 
-
    window.JSConfig.collapseText = wgULS('隐藏▲', '隱藏▲'); //指示折叠收缩的默认文字
 
-
    window.JSConfig.expandText = wgULS('显示▼', '顯示▼'); //指示折叠展开的默认文字
 
-
    window.JSConfig.autoCollapse = 2; //文章少于 autoCollapse 个折叠块时,不自动折叠
 
-
    // window.JSConfig.SpecialSearchEnhancedDisabled=false; //是否禁止增加其它搜索引擎
 
-
    /* 2. 用jQuery实现的getElementsByClassName(需不需要返回DOM对象?) */
 
-
    window.getElementsByClassName = function (elm, tag, className) {
 
-
        return $(tag + '.' + className, elm);
 
-
    };
 
-
 
-
    /* 3. 遍历 */
 
-
    window.applyEach = function (callback, array) {
 
-
        var i = 0,
 
-
            j = array.length;
 
-
        while (i < j) {
 
-
            callback(array[i++]);
 
         }
         }
-
     };
+
        Button.firstChild.data = expandCaption;
 +
     } else {
-
    /* 4. 移動元素 */
+
         for ( var i = 1; i < Rows.length; i++ ) {
-
    window.elementMoveto = function (node, refNode, pos) { //默认位置为refNode前
+
-
         if (node && refNode) {
+
-
            if (pos && pos == 'after') {
+
-
                $(refNode).after(node);
+
-
            } else {
+
-
                $(refNode).before(node);
+
-
            }
+
-
        }
+
-
    };
+
-
    /* 5. 创建元素 */
+
             Rows[i].style.display = Rows[i].oldDisplayValue;
-
    window.createElement = function (tag, children, props) {
+
-
        var element = document.createElement(tag);
+
-
        if (!(children instanceof Array)) {
+
-
             children = [children];
+
-
        }
+
-
        applyEach(function (child) {
+
-
            if (typeof child == 'string') {
+
-
                child = document.createTextNode(child);
+
-
            }
+
-
            if (child) {
+
-
                element.appendChild(child);
+
-
            }
+
-
        }, children);
+
-
        if (typeof props == 'object') {
+
-
            for (var k in props) {
+
-
                switch (k) {
+
-
                case 'styles':
+
-
                    var styles = props.styles;
+
-
                    for (var s in styles) {
+
-
                        element.style[s] = styles[s];
+
-
                    }
+
-
                    break;
+
-
                case 'events':
+
-
                    var events = props.events;
+
-
                    for (var e in events) {
+
-
                        addHandler(element, e, events[e]);
+
-
                    }
+
-
                    break;
+
-
                case 'class':
+
-
                    element.className = props[k];
+
-
                    break;
+
-
                default:
+
-
                    element.setAttribute(k, props[k]);
+
-
                }
+
-
            }
+
-
        }
+
-
        return element;
+
-
    };
+
-
    //wiki URL
 
-
    window.wgProjectURL = {
 
-
        en: 'http://en.wikipedia.org',
 
-
        de: 'http://de.wikipedia.org',
 
-
        fr: 'http://fr.wikipedia.org',
 
-
        pl: 'http://pl.wikipedia.org',
 
-
        ja: 'http://ja.wikipedia.org',
 
-
        it: 'http://it.wikipedia.org',
 
-
        nl: 'http://nl.wikipedia.org',
 
-
        pt: 'http://pt.wikipedia.org',
 
-
        es: 'http://es.wikipedia.org',
 
-
        sv: 'http://sv.wikipedia.org',
 
-
        //僅列前十名其它語言百科
 
-
        m: 'http://meta.wikimedia.org',
 
-
        b: 'http://zh.wikibooks.org',
 
-
        q: 'http://zh.wikiquote.org',
 
-
        n: 'http://zh.wikinews.org',
 
-
        wikt: 'http://zh.wiktionary.org',
 
-
        mw: 'http://www.mediawiki.org',
 
-
        commons: 'http://commons.wikimedia.org'
 
-
    };
 
-
    /**
 
-
    * 将页面名称转换为URL
 
-
    *
 
-
    * @param page 页面名称
 
-
    * @param paras 附加后缀对象,用空对象{}做参数可以取得源码
 
-
    */
 
-
    window.getWikiPath = function (page, paras) {
 
-
        var reg = /^[a-z]+:/;
 
-
        var pre = page.match(reg);
 
-
        pre = pre && wgProjectURL[pre[0].replace(/:$/, '').toLowerCase()];
 
-
        if (pre) {
 
-
            page = page.replace(reg, '');
 
-
        } else {
 
-
            pre = wgServer;
 
-
        } //保障没有相对路径,以照顾在线代理。
 
-
        var url = pre + wgScript + '?title=' + encodeURI(page.replace(' ', '_'));
 
-
        if (typeof paras == 'object') {
 
-
            paras.ctype = paras.ctype || 'text';
 
-
            paras.dontcountme = paras.dontcountme || 's';
 
-
            paras.action = paras.action || 'raw';
 
-
            for (var k in paras) {
 
-
                url += '&' + k + '=' + paras[k];
 
-
            }
 
         }
         }
-
         return url;
+
         Button.firstChild.data = collapseCaption;
-
    };
+
-
 
+
-
    //引入[[Special:Gadgets]]要求的腳本和樣式
+
-
    if (window.requireScripts instanceof Array) {
+
-
        applyEach(importScript, requireScripts);
+
     }
     }
-
    if (window.requireStylesheets instanceof Array) {
 
-
        applyEach(importStylesheet, requireStylesheets);
 
-
    }
 
-
    window.requireScripts = [];
 
-
    window.requireScripts.push = function (script) {
 
-
        importScript(script);
 
-
    };
 
-
    window.requireStylesheets = [];
 
-
    window.requireStylesheets.push = function (style) {
 
-
        importStylesheet(style);
 
-
    };
 
-
    /* 测试元素中是否含有指定的样式 */
+
}
-
    window.hasClass = function (elem, cls) {
+
-
        return $(elem).hasClass(cls);
+
function createCollapseButtons()
-
     };
+
{
 +
     var tableIndex = 0;
-
/*
+
    var NavigationBoxes = new Object();
-
== IE兼容性修正 ==
+
    var Tables = document.getElementsByTagName( "table" );
-
*/
+
-
    if ($.browser.msie) {
+
-
        /** Internet Explorer bug fix **************************************************
+
-
        *
+
-
        *  Description: Fixes IE horizontal scrollbar bug
+
-
        *  Maintainers: [[User:fdcn]]
+
-
        */
+
-
        var oldWidth;
+
-
        var docEl = document.documentElement;
+
-
        function fixIEScroll() {
+
-
            if (!oldWidth || docEl.clientWidth > oldWidth) {
+
    for ( var i = 0; i < Tables.length; i++ ) {
-
                doFixIEScroll();
+
        var parent = Tables[i].parentNode.parentNode.parentNode.parentNode;
-
            } else {
+
        if ( hasClass( Tables[i], "collapsible" ) || (hasClass(parent, "navbox") && hasClass(Tables[i], "navbox")) ) {
-
                setTimeout(doFixIEScroll, 1);
+
-
            }
+
-
            oldWidth = docEl.clientWidth;
+
-
        }
+
-
        function doFixIEScroll() {
+
-
             docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
+
             /* only add button and increment count if there is a header row to work with */
-
        }
+
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
-
        document.attachEvent("onreadystatechange", fixIEScroll);
+
            if (!HeaderRow) continue;
-
        attachEvent("onresize", fixIEScroll);
+
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
-
        //Import scripts specific to Internet Explorer 6
+
            if (!Header) continue;
-
        if (navigator.appVersion.substr(22, 1) == "6") {
+
-
             importScript("MediaWiki:Common.js/IE60Fixes.js")
+
             NavigationBoxes[ tableIndex ] = Tables[i];
-
        }
+
-
    }
+
-
/*
+
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
-
== 特色條目優良與條目鏈接顯示==
+
-
*/
+
-
    $(function () {
+
-
        $('#p-lang li').each(function () {
+
             var Button    = document.createElement( "span" );
-
             if ($('#' + this.className + '-fa').length) {
+
-
                this.className += " FA"
+
-
                this.title = wgULS("此条目在此语言版本中为特色条目", "此條目在此語言版本中為特色條目");
+
-
            } else if ($('#' + this.className + '-ga').length) {
+
-
                this.className += " GA"
+
-
                this.title = wgULS("此条目在此语言版本中为优良条目", "此條目在此語言版本中為優良條目");
+
-
            }
+
-
        });
+
-
    });
+
-
/*
+
            var ButtonLink = document.createElement( "a" );
-
== 增加摺疊功能 ==
+
            var ButtonText = document.createTextNode( collapseCaption );
-
*/
+
-
    /** 摺疊 div table *****************************
+
-
    *  Description: 实现div.NavFrame和table.collapsible的可折叠性。
+
-
    *  JSConfig的collapseText、expandText、autoCollapse属性定义默认文字和默认最少自动折叠块
+
-
    *  Maintainers: User:fdcn
+
-
    */
+
-
    function cancelBubble(e) {
+
-
        e = e || window.event;
+
             Button.className = "collapseButton"; //Styles are declared in Common.css
-
        if (e.stopPropagation) {
+
-
             e.stopPropagation();
+
-
        } else {
+
-
            e.cancelBubble = true;
+
-
        }
+
-
    }
+
-
    function createToggleButton(head) {
+
-
        var parent = head;
+
             ButtonLink.style.color = Header.style.color;
-
        if (head.tagName.toLowerCase() == 'tr') { //对表格特别处理
+
             ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
-
             if (head.getElementsByTagName("th").length) {
+
-
                parent = head.cells[parent.cells.length - 1];
+
-
            } else {
+
-
                return;
+
-
            }
+
-
        }
+
-
        var textS, textH, button = getElementsByClassName(head, "span", "NavToggle")[0];
+
-
        if (button) {
+
-
            parent = button.parentNode;
+
-
        } else {
+
-
            textS = createElement("span", [JSConfig.expandText], {
+
-
                'class': 'toggleShow'
+
-
            });
+
-
            textH = createElement("span", [JSConfig.collapseText], {
+
-
                'class': 'toggleHide'
+
-
            });
+
-
            button = createElement("span", [textS, textH], {
+
-
                'class': 'NavToggle',
+
-
                styles: {
+
-
                    'width': "6em"
+
-
                }
+
-
            });
+
-
        }
+
-
        button.style.display = "inline";
+
-
        head.className += " uncollapse toggleHotspot";
+
-
        parent.insertBefore(button, parent.childNodes[0]);
+
-
    }
+
-
    window.wgCollapse = function (head, container, defaultCollapse) {
+
-
        if (head) {
+
-
             createToggleButton(head);
+
-
        }
+
-
        var self = this;
+
-
        this.state = 0;
+
-
        this.container = container;
+
-
        applyEach(function (h) {
+
-
            if (h.nodeType == 1 && !hasClass(h, "uncollapse") && !hasClass(h, "toggleShow") && !hasClass(h, "toggleHide")) {
+
-
                h.className += " toggleHide";
+
-
            }
+
-
        }, defaultCollapse); //预设的隐藏元素
+
 +
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
-
        function getArray(clsname) {
+
             ButtonLink.appendChild( ButtonText );
-
             var r = [],
+
-
                i = 0,
+
             Button.appendChild( document.createTextNode( "[" ) );
-
                e, ea = getElementsByClassName(container, "*", clsname);
+
-
            while (e = ea[i++]) {
+
-
                var parent = e.parentNode;
+
-
                while (!hasClass(parent, 'NavFrame') && !hasClass(parent, 'collapsible')) {
+
-
                    parent = parent.parentNode;
+
-
                }
+
-
                if (parent == container) {
+
-
                    r.push(e);
+
-
                }
+
-
             }
+
-
            return r;
+
-
        }
+
-
        var toggleA = getArray("toggleShow");
+
-
        var toggleB = getArray("toggleHide");
+
-
        var hotspots = getArray("toggleHotspot");
+
-
 
+
-
        function _toggle(list, state) {
+
-
            var i = 0,
+
-
                e;
+
-
            while (e = list[i++]) {
+
-
                e.style.display = state ? e.showStyle || '' : 'none';
+
-
            }
+
-
        }
+
-
        this.toggle = function (state) {
+
-
            self.state = (typeof state == 'undefined') ? 1 - self.state : state;
+
-
            _toggle(toggleA, self.state);
+
-
            _toggle(toggleB, 1 - self.state);
+
-
        }
+
-
        var i = 0,
+
-
            h;
+
-
        while (h = hotspots[i++]) {
+
-
            applyEach(function (link) {
+
-
                addClickHandler(link, cancelBubble);
+
-
            }, h.getElementsByTagName("A"));
+
-
            h.style.cursor = "pointer";
+
-
            $(h).attr('tabindex', '0').keydown(function (event) {
+
-
                if (event.which == 13) { // Enter
+
-
                    self.toggle();
+
-
                }
+
-
            });
+
-
            addClickHandler(h, function () {
+
-
                self.toggle();
+
-
            });
+
-
        }
+
-
    };
+
-
 
+
-
    $(function () {
+
-
        if (!window.disableCollapse) {
+
-
            //init
+
-
            var items = [];
+
-
            applyEach(function (NavFrame) {
+
-
                var i = 0,
+
-
                    child = NavFrame.childNodes,
+
-
                    head;
+
-
                while (head = child[i++]) {
+
-
                    if (head.className && hasClass(head, "NavHead")) {
+
-
                        break;
+
-
                    }
+
-
                }
+
-
                items.push(new wgCollapse(head, NavFrame, NavFrame.childNodes));
+
-
            }, getElementsByClassName(document, "div", "NavFrame"));
+
-
            applyEach(function (table) {
+
-
                var rows = table.rows;
+
-
                items.push(new wgCollapse(rows[0], table, rows));
+
-
            }, getElementsByClassName(document, "table", "collapsible"));
+
-
            var item, i = 0,
+
-
                count = items.length;
+
-
            while (item = items[i++]) {
+
-
                item.toggle(
+
-
                hasClass(item.container, "collapsed") || (count >= JSConfig.autoCollapse && hasClass(item.container, "autocollapse")));
+
-
            }
+
-
        }
+
-
    });
+
-
    //修正摺疊後定位變化
+
-
    hookEvent("load", function () {
+
-
        if (location.hash) {
+
-
            location.href = location.hash;
+
-
        }
+
-
    });
+
-
/*
+
            Button.appendChild( ButtonLink );
 +
            Button.appendChild( document.createTextNode( "]" ) );
-
== 取消討論頁的[+]按鈕 ==
+
-
*/
+
            Header.insertBefore( Button, Header.childNodes[0] );
-
    $(function () {
+
             tableIndex++;
-
        if ($('#no-newsection').length) {
+
-
             $('#ca-addsection').css('display', 'none');
+
         }
         }
-
    });
 
-
 
-
/*
 
-
 
-
==WikiMiniAtlas世界地圖==
 
-
*/
 
-
    /** WikiMiniAtlas *******************************************************
 
-
    *
 
-
    *  描述:WikiMiniAtlas是一個popup而可點選與拖曳的世界地圖。
 
-
    *              這個腳本將會讓所有的經緯度標示中顯示WikiMiniAtlas的popup開啟按鈕。
 
-
    *              由於被許多計畫使用,因此腳本放置在元維基中。
 
-
    *              更多資訊請詳見[[Meta:WikiMiniAtlas]]。
 
-
    *  創建者:[[:en:User:Dschwen]]
 
-
    */
 
-
 
-
    var metaBase = 'http://meta.wikimedia.org';
 
-
    if (mw.config.get('wgServer') == 'https://secure.wikimedia.org') {
 
-
        var metaBase = 'https://secure.wikimedia.org/wikipedia/meta';
 
     }
     }
-
     mw.loader.load(metaBase + '/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
+
 +
     for ( var i = 0;  i < tableIndex; i++ ) {
-
/*
+
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
-
==保護選項校正==
+
-
*/
+
-
    if (wgAction == "protect") {
+
            collapseTable( i );
 +
        }
 +
        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
-
        $(function () {
+
             var element = NavigationBoxes[i];
-
             var pform = document.getElementById("mw-Protect-Form");
+
             while (element = element.parentNode) {
-
             var timeoptions;
+
-
            timeoptions = pform["wpProtectExpirySelection-edit"].options;
+
                if ( hasClass( element, "outercollapse" ) ) {
-
            if (timeoptions[0].value != "existing") {
+
-
                timeoptions[timeoptions.length - 1].selected = true;
+
-
                ProtectionForm.updateExpiryList(pform["wpProtectExpirySelection-edit"]);
+
-
            }
+
-
            timeoptions = pform["wpProtectExpirySelection-move"].options;
+
                    collapseTable ( i );
-
            if (timeoptions[0].value != "existing") {
+
                     break;
-
                timeoptions[timeoptions.length - 1].selected = true;
+
-
                ProtectionForm.updateExpiryList(pform["wpProtectExpirySelection-move"]);
+
-
            }
+
-
 
+
-
        });
+
-
 
+
-
    }
+
-
 
+
-
/*
+
-
==擷取選單文字按鈕==
+
-
*/
+
-
 
+
-
    $(function () {
+
-
 
+
-
        var addGetMenuTextButton = function (id, srcMenu, targetText, tiptext, afterSelIdx) {
+
-
            var btnAdd = createElement("input", "", {
+
-
                'id': id,
+
-
                'type': 'button',
+
-
                'value': ((!tiptext) ? "(+)" : tiptext)
+
-
            });
+
-
 
+
-
            btnAdd.srcMenu = srcMenu;
+
-
            btnAdd.targetText = targetText;
+
-
            btnAdd.afterSelIdx = (!afterSelIdx || isNaN(afterSelIdx)) ? 0 : afterSelIdx;
+
-
 
+
-
            addHandler(btnAdd, "click", function () {
+
-
                this.targetText.value += this.srcMenu.options[this.srcMenu.selectedIndex].value;
+
-
                this.srcMenu.selectedIndex = this.afterSelIdx;
+
-
            });
+
-
 
+
-
            elementMoveto(btnAdd, srcMenu, "after");
+
-
        }
+
-
 
+
-
        var useForm;
+
-
 
+
-
        if (wgAction == "protect" || wgAction == "unprotect") { //保護理由
+
-
            useForm = document.getElementById("mw-Protect-Form");
+
-
            addGetMenuTextButton("wpProtectReasonSelectionAdd", useForm.wpProtectReasonSelection, useForm["mwProtect-reason"], "加到附加的理由", 0);
+
-
 
+
-
        } else if (("" + wgCanonicalSpecialPageName).toLowerCase() == "blockip") { //封禁理由
+
-
            useForm = document.getElementById("blockip");
+
-
            addGetMenuTextButton("wpBlockReasonListAdd", useForm.wpBlockReasonList, useForm.wpBlockReason, wgULS("加到附带原因", "加到附帶原因"), 0);
+
-
 
+
-
        }
+
-
 
+
-
    });
+
-
 
+
-
/*
+
-
 
+
-
==避免在主條目中出現捲軸框==
+
-
 
+
-
*/
+
-
 
+
-
    if (!wgCanonicalNamespace) $(function () {
+
-
 
+
-
        var disableDivOverflowScroll = function (obj) {
+
-
            var targetdiv;
+
-
 
+
-
            for (var i = obj.children.length; i-- > 0;) if (obj.children[i].tagName.toLowerCase() == "div") {
+
-
                targetdiv = obj.children[i];
+
-
 
+
-
                if (targetdiv.className.indexOf("noprint") == -1 && targetdiv.className.indexOf("thumb") == -1) {
+
-
                     if ( !! (targetdiv.style.overflow) || !! (targetdiv.style.overflowY)) with(targetdiv.style) {
+
-
                        overflowY = "visible";
+
-
                        padding = "";
+
-
                        border = "";
+
-
                        height = "";
+
-
                    }
+
-
 
+
-
                    disableDivOverflowScroll(targetdiv);
+
                 }
                 }
-
            }
 
-
        }
 
-
 
-
        disableDivOverflowScroll(document.getElementsByTagName("body")[0]);
 
-
    });
 
-
 
-
/*
 
-
== metaBox ==
 
-
 
-
HERE STARTS THE WORKING-CODE OF "METABOXES"*/
 
-
 
-
/* Funcionament de la Plantilla:Metacaixa
 
-
Implementat per: Usuari:Peleguer.
 
-
Actualitzat per Joanjoc seguint les indicacions d'en Martorell
 
-
*/
 
-
 
-
    function MetaCaixaInit() {
 
-
        //S'executa al carregar-se la pàgina, si hi ha metacaixes,
 
-
        // s'assignen els esdeveniments als botons
 
-
        //alert("MetaCaixaInit");
 
-
        var i = 0 //Inicialitzem comptador de caixes
 
-
        for (i = 0; i <= 9; i++) {
 
-
            var vMc = document.getElementById("mc" + i);
 
-
            if (!vMc) break;
 
-
            //alert("MetaCaixaInit, trobada Metacaixa mc"+i);
 
-
            var j = 1 //Inicialitzem comptador de botons dins de la caixa
 
-
            var vPsIni = 0 //Pestanya visible inicial
 
-
            for (j = 1; j <= 9; j++) {
 
-
                var vBt = document.getElementById("mc" + i + "bt" + j);
 
-
                if (!vBt) break;
 
-
                //alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j);
 
-
                vBt.onclick = MetaCaixaMostraPestanya; //A cada botó assignem l'esdeveniment onclick
 
-
                //alert (vBt.className);
 
-
                if (vBt.className == "mcBotoSel") vPsIni = j; //Si tenim un botó seleccionat, en guardem l'index
 
-
            }
 
-
            //alert ("mc="+i+", ps="+j+", psini="+vPsIni );
 
-
            if (vPsIni == 0) { //Si no tenim cap botó seleccionat, n'agafem un aleatòriament
 
-
                vPsIni = 1 + Math.floor((j - 1) * Math.random());
 
-
                //alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_");
 
-
                document.getElementById("mc" + i + "ps" + vPsIni).style.display = "block";
 
-
                document.getElementById("mc" + i + "ps" + vPsIni).style.visibility = "visible";
 
-
                document.getElementById("mc" + i + "bt" + vPsIni).className = "mcBotoSel";
 
             }
             }
         }
         }
     }
     }
 +
}
 +
 +
addOnloadHook( createCollapseButtons );
 +
//</source>
-
    function MetaCaixaMostraPestanya() {
+
//wowtips
-
        //S'executa al clicar una pestanya,
+
function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); }  function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) {  c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; }  function setStoredValue(key, value, expiredays) { if (typeof(localStorage) == "undefined") { setCookie(key, value, expiredays); } else { localStorage[key] = value; } } function getStoredValue(key, defaultValue) { if (typeof(localStorage) == "undefined") { var value = getCookie(key); return value == "" ? defaultValue : value; } return localStorage[key] == null ? defaultValue : localStorage[key]; }  article = "";  // See [[Help:Tooltips]] // default setting to turn tooltips on var tooltipsOn = true;  // allow users to specify an external db to change links to var extDB = "http://www.wowpedia.org/";  var $tfb; var $ttfb; var $htt; var activeHoverLink = null; var tipCache = new Object();  // hides the tooltip function hideTip() { $tfb.html("").removeClass("tooltip-ready").addClass("hidden").css("visibility","hidden");  activeHoverLink = null; }  // displays the tooltip function displayTip(e) { $htt.not(":empty").removeClass("hidden").addClass("tooltip-ready"); moveTip(e); $htt.not(":empty").css("visibility","visible"); moveTip(e); }  // moves the tooltip function moveTip(e) { $ct = $htt.not(":empty"); var newTop = e.clientY + ((e.clientY > ($(window).height()/2)) ? -($ct.innerHeight()+20):20); var newLeft = e.clientX + ((e.clientX > ($(window).width()/2)) ? -($ct.innerWidth()+20):20); $ct.css({"position":"fixed","top":newTop + "px","left":newLeft + "px"}); }  // AJAX tooltips function showTip(e) { var $t=$(this); activeHoverLink = $t; $p=$t.parent(); if ($p.hasClass("selflink")==false) { $t.removeAttr("title"); $p.removeAttr("title"); var url = "/index.php?title="+$t.data("tt").replace(/ /g,"_").replace(/\?/g,"%3F")+"&action=render div.tooltip-content"; if (tipCache[url] != null) {  $tfb.html(tipCache[url]);  displayTip(e);  return; } $tfb.load(url,function () { if ($t != activeHoverLink) return; if ($tfb.html() == "") $tfb.html('<div class="tooltip-content"><b>Error</b><br />This target either has no tooltip<br />or was not intended to have one.</div>'); $tfb.find(".tooltip-content").css("display",""); tipCache[url] = $tfb.html(); displayTip(e); }); } }  // quick tooltips function hideTemplateTip() { $ttfb.html("").removeClass("tooltip-ready").addClass("hidden");  }  function showTemplateTip(e) { $ttfb.html('<div class="tooltip-content">' + $(this).next().html() + '</div>'); displayTip(e); }  // add the tooltip calls to the page function eLink(db,nm) { dbs = new Array("http://us.battle.net/wow/en/search?f=wowitem&q=","http://www.wowhead.com/?search="); dbTs = new Array("Armory","Wowhead"); dbHs = new Array("&real; ","&omega; "); el = '<a href="'+ dbs[db]+nm + '" target="_blank" title="'+ dbTs[db] +'">'+ dbHs[db] + '</a>'; return el; }  function bindTT() { $t=$(this); $p=$t.parent(); if ($p.hasClass("selflink") == false) { $t.data("tt", $p.attr("title").replace(" (page does not exist)","").replace("?","%3F")).hover(showTip,hideTip).mousemove(moveTip); if ($p.hasClass("new")) { els = '<sup><span class="plainlinks">'; y=($t.hasClass("itemlink"))?0:1; z=($t.hasClass("achievementlink"))?2:2; for (x=y;x<z;x++) els += eLink(x,$t.data("tt").replace("Quest:","")); $p.after(els+'</span></sup>'); } if (extDB != "http://www.wowpedia.org/") {  fullextURL = extDB + $t.data("tt"); $p.attr("href",fullextURL); } } }  // check to see if it is active then do it function ttMouseOver() { if (tooltipsOn && getCookie("wiki-tiploader") != "no") { $(article).append('<div id="tfb" class="htt"></div><div id="templatetfb" class="htt"></div>'); $tfb = $("#tfb"); $ttfb = $("#templatetfb"); $htt = $("#tfb,#templatetfb"); $(article+" span.ajaxttlink").each(bindTT); $(article+" span.tttemplatelink").hover(showTemplateTip,hideTemplateTip).mousemove(moveTip); } }  // collapsible tables var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show";  function collapseTable(i, isAutomated) { var Button = $("#collapseButton" + i); var Table = $("#collapsibleTable" + i); if (Table.length<1 || Button.length<1) return false; if (Button.text() == collapseCaption) { Table.find("tr").not(":has('#collapseButton"+i+"')").hide(); if (isAutomated == null) setStoredValue("hideTable-" + wgArticleId + "-" + i,1,30); Button.text(expandCaption); } else { Table.find("tr").not(":has('#collapseButton"+i+"')").show(); if (isAutomated == null) setStoredValue("hideTable-" + wgArticleId + "-" + i,0,30);  Button.text(collapseCaption); } }  function createCollapseButtons() { var tch = $("table.collapsible tr th:last-child"); tch.each(function (i) { $(this).closest("table").attr("id", "collapsibleTable" + i); $(this).prepend('<span style="float:right; font-weight:normal; text-align:right; width:6em">[<a href="javascript:collapseTable('+i+');" style="color:'+$(this).css("color")+';" id="collapseButton'+i+'">'+collapseCaption+'</a>]</span>'); if ($(this).closest("table").hasClass("collapsed") || (getStoredValue("hideTable-" + wgArticleId + "-" + i) == 1) || (tch.length >= autoCollapse && $(this).closest("table").hasClass("autocollapse"))) collapseTable(i, 1); }); }  var nbh = '['+collapseCaption+']'; var nbs = '['+expandCaption+']'; function toggleNavigationBar(i) { var NavToggle = $("#NavToggle" + i); var NavFrame = $("#NavFrame" + i); if (NavFrame.length<1 || NavToggle.length<1) return false;  ncd=(NavToggle.text()==nbh)?'none':'block'; NavFrame.children(".NavPic,.NavContent").css("display",ncd); nct=(NavToggle.text()==nbh)?nbs:nbh; NavToggle.text(nct); }  // adds show/hide-button to navigation bars function createNavigationBarToggleButton() { $("div.NavFrame").each(function (i) { NavToggleText = ($(this).children(".NavPic:visible,.NavContent:visible").length>0)?nbh:nbs; $(this).children(".NavHead").append('<a href="javascript:toggleNavigationBar('+i+');" id="NavToggle'+i+'" class="NavToggle">'+NavToggleText+'</a>'); $(this).attr("id","NavFrame"+i); }); }  // extract a URL parameter from the current URL // From wikipedia:User:Lupin/autoedit.js // paramName  : the name of the parameter to extract  function getParamValue(paramName) { var cmdRe=RegExp( '[&?]' + paramName + '=([^&]*)' ); var h = document.location.href; var m=cmdRe.exec(h); if (m) { try { return decodeURIComponent(m[1]); } catch (someError) {} } return null; }  // patching in changes to table sorting and alt rows function changeTS() { window['ts_alternate'] = function (table) { $(table).find("tbody").find("tr:odd").removeClass("alt"); $(table).find("tbody").find("tr:even").addClass("alt"); } window['ts_makeSortable'] = function (table) { if ($(table).find("tr").length>0) firstRow = ($(table).find("th").length>0)?$(table).find("tr:has(th)").eq(0):$(table).find("tr").eq(0); if (!firstRow) return; firstRow.children(":not('.unsortable')").append('&nbsp;&nbsp;<a href="javascript:;" class="sortheader" onclick="ts_resortTable(this); return false;"><span class="sortarrow"><img src="'+ts_image_path+ts_image_none+'" alt="&darr;"/></span></a>'); if (ts_alternate_row_colors) ts_alternate(table); } }  // add scribblemap processing function wwScribbleMaps() { $(article+" div.wwSM").each(function () { mapID = $(this).attr("class").replace("wwSM map-",""); if (mapID.length > 20) mapID = ""; $(this).html('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="smwidget" align="middle"><param name="allowFullScreen" value="true" /><param name="FlashVars" value="id='+mapID+'&p=true&mt=false&d=true&z=true" /><param name="movie" value="http://widgets.scribblemaps.com/wowsmwidget.swf"/><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="http://widgets.scribblemaps.com/wowsmwidget.swf" FlashVars="id='+mapID+'&p=true&mt=false&d=true&z=true" "quality="high" bgcolor="#000000" width="550" height="400" name="smwidget" align="middle" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'); }); }  function requireImageLicense() { if (wgPageName == "Special:Upload" && getParamValue("wpDestFile") == null) { $wpu = $("#mw-upload-form").find("[name=wpUpload]").not("#wpUpload"); $wpu.attr("disabled","true"); $("#wpLicense").change(function () { if ($("#wpLicense").val()) { $wpu.removeAttr("disabled"); } else { $wpu.attr("disabled","true"); } }); } }  function aCharLoad() { $(article+" .aChar").each(function () { data = $(this).text().split(";"); realm = data[0]; loc = (data[1].toLowerCase()=="eu")?"eu":"www"; character = data[2]; height = (data[3])?588:444; $(this).html('<iframe src="http://'+loc+'.wowarmory.com/character-model-embed.xml?r='+realm+'&amp;cn='+character+'&amp;rhtml=true" scrolling="no" height="'+height+'" width="321" frameborder="0"></iframe>'); }); $(article+" .aChar").css("display","block"); }  function sortDays(a, b) { return b.substring(b.indexOf(";")+1)-a.substring(a.indexOf(";")+1); }  function loadGSList(){ if ($("#gslist").length>0) { var timestamp = 0; var today = new Date(); var tsDate = new Date(); var dateRE = /(\d{4})-(\d\d)-(\d\d).*/; var pArr = new Array(); $.getJSON("http://www.wowpedia.org/api.php?action=query&generator=categorymembers&gcmlimit=500&gcmsort=timestamp&gcmdir=desc&gcmtitle=Category:Guild_stubs&prop=revisions&rvprop=timestamp&format=json&callback=?", function(data) { if (data.query) { pages = data.query.pages; for (pageID in pages) { timestamp = pages[pageID].revisions[0].timestamp; dateREd = dateRE.exec(timestamp); tsDate.setFullYear(dateREd[1],dateREd[2]-1,dateREd[3]); daysElapsed = Math.round((today - tsDate) / 86400000); pArr[pArr.length] = pages[pageID].title + ";" + daysElapsed; } pArr2 = pArr.sort(sortDays); gslBuffer = "<ul>"; for (n in pArr2) { guild = pArr2[n].substring(0,pArr2[n].indexOf(";")); daysE = pArr2[n].substring(pArr2[n].indexOf(";")+1); daysE = (daysE < 0)?0:daysE; daysE = (daysE > 29)?'<span style="color:red;">('+daysE+' days)</span>':'('+daysE+' days)'; gslBuffer += '<li><a href="/'+guild+'" title="'+guild+'">'+guild+'</a> ' + daysE + ' - <a href="/'+guild+'?action=history">History</a> &bull; <a href="/'+guild+'?action=delete">Delete</a></li>'; } gslBuffer += "</ul>"; $("#gslist").html(gslBuffer); } }); } }  // AJAX RC var ajaxPages = new Array("Special:RecentChanges"); var ajaxRCOverride = false; var rcTimer; var doRefresh = true; var rcRefresh = 30000; ajaxRCCookie = (getCookie("ajaxRC")=="on"||ajaxRCOverride) ? true:false;  function ajaxRC() { appTo = $(".firstHeading"); appTo.append('&nbsp;<span style="font-size: xx-small; border-bottom: 1px dotted; cursor:help;" title="Enable auto-refreshing page loads">AJAX:</span><input type="checkbox" id="ajaxToggle"><span style="position:relative; top:5px; left:5px;" id="ajaxRCprogress"><img src="http://www.wowpedia.org/images/0/0e/Progressbar.gif" border="0" alt="AJAX operation in progress" /></span>'); $("#ajaxRCprogress").bind("ajaxSend", function (){ $(this).show(); }).bind("ajaxComplete", function (){ $(this).hide(); }); $("#ajaxToggle").click(toggleRC); $("#ajaxRCprogress").hide(); $("#ajaxToggle").attr("checked", ajaxRCCookie); if (ajaxRCCookie) loadRCData(); }  function toggleRC() { if ($("#ajaxToggle").attr("checked") == true) { setCookie("ajaxRC", "on", 30); doRefresh = true; loadRCData(); } else { setCookie("ajaxRC", "off", 30); doRefresh = false; clearTimeout(rcTimer); } }  function loadRCData() { $(article).load(location.href + " "+article+" > *", function (data) {  if (doRefresh) rcTimer = setTimeout("loadRCData();", rcRefresh); }); }  // tab switch var ptabs; var ffc; function doTabs() { cTab = $("#ptabs .activetab").parent().prevAll().length + 1; ptabs = $("#ptabs>*"); ptabs.css("cursor","pointer"); ptabs.click(function (e) { $pt = $(e.target); if ($pt.hasClass("inactivetab")) e.preventDefault(); if (ffc != 1 && $(".fswitch").length) { if ($pt.text().indexOf("Alliance") != -1) { setStoredValue("fspref","Alliance",30);} else { setStoredValue("fspref","Horde",30); } } if ($pt.parent().not("#ptabs").html()) $pt = $pt.parent(); sp = $pt.prevAll().length; ptabs.eq(cTab-1).children("*").removeClass("activetab").addClass("inactivetab"); $("#ptab"+cTab).hide().children(".toc").removeAttr("id"); cTab = sp+1; ptabs.eq(sp).children("*").removeClass("inactivetab").addClass("activetab"); $("#ptab"+cTab).show().children(".toc").attr("id","toc"); }); }  // AJAX tables ahClass = new RegExp('class="ajaxHide"', "gim"); crlf = new RegExp("\r\n", "g")  function getTableData(tablePage, tableNum) { $("body").bind("ajaxSend", function (){ $(this).css("cursor","wait"); }).bind("ajaxComplete", function (){ $(this).css("cursor","auto"); }); $.get('http://' + location.hostname + '/' + tablePage + '?action=render', function (data) { if (data) { data = data.replace(crlf, "").replace(ahClass, 'class="ajaxHide-active"').replace('class="darktable"', ""); $("#ajaxTable" + tableNum).find("td").eq(0).html(data); $("#ajaxTable" + tableNum).find("td").eq(0).find("table.sortable").each(function (i) { ts_makeSortable($(this)); zebraAJAX = $(this).find("tr"); if (zebraAJAX.eq(2).css("background-color") == "transparent" && zebraAJAX.eq(3).css("background-color") == "transparent") { zebraAJAX.find(".sortheader").click(function () { $(article+" table.zebra > tbody > tr").css("background-color","transparent"); ac = (skin=="monobook")?"#e9e9ff":"#2c2c2c"; $(article+" table.zebra > tbody > tr:nth-child(2n+1)").css("background-color",ac); }); } }); zebraAJAX = $(article+" .ajax td > table.zebra > tbody > tr"); if (zebraAJAX.eq(1).css("background-color") == "transparent" && zebraAJAX.eq(2).css("background-color") == "transparent") { $(article+" .ajax td > table.zebra > tbody > tr:nth-child(2n+1)").css("background-color","#2c2c2c"); if (skin == "monobook") $("#bodyContent .ajax td > table.zebra > tbody > tr:nth-child(2n+1)").css("background-color","#e9e9ff"); } $("#stl" + tableNum).html('[<a href="/'+tablePage+'?action=edit">edit</a>]&nbsp;[<a href="javascript:;" id="htl' + tableNum + '" onClick="hideTable(' + tableNum + ');">hide</a>]'); ttMouseOver(); } }); }  function hideTable(tableNum) { $("#ajaxTable" + tableNum).find("tr").eq(1).hide(); $("#htl" + tableNum).click(function() { showTable(tableNum); }); $("#htl" + tableNum).text("show"); }  function showTable(tableNum) { $("#ajaxTable" + tableNum).find("tr").eq(1).show(); $("#htl" + tableNum).click(function() { hideTable(tableNum); }); $("#htl" + tableNum).text("hide"); }  function loadTableData(tableNum) { thisTable = document.getElementById("ajaxTable" + tableNum); loadPage = thisTable.className.substring(thisTable.className.indexOf("targetPage-") + 11); getTableData(loadPage, tableNum); }  function addAjaxDisplayLink() { $(article+" table.ajax").each(function (i) { $(this).attr("id", "ajaxTable" + i); $(this).find("td").eq(1).parent().hide(); $(this).find("td").eq(0).parent().show(); if (this.getElementsByTagName("th").length > 0) this.getElementsByTagName("th")[0].innerHTML = '<span style="float:right;" id="stl' + i + '"></span>' + this.getElementsByTagName("th")[0].innerHTML; if ($(this).find("td").eq(0).hasClass("showLinkHere")) { $(this).find("td").eq(0).html($(this).find("td").eq(0).html().replace("[link]", '<a href="javascript:;" onClick="loadTableData(' + i + ')">').replace("[/link]","</a>")); } else { $("#stl" + i).html('[<a href="javascript:;" onClick="loadTableData(' + i + ')">show data</a>]'); } }); }  function toggleSMWFacts() { if ($("#SMWFactToggle").text() == "hide") { $("#mw-data-after-content table.smwfacttable tr").hide(); setCookie("hideSMWFacts","true"); $("#SMWFactToggle").text("show"); } else { $("#mw-data-after-content table.smwfacttable tr").show(); setCookie("hideSMWFacts","false"); $("#SMWFactToggle").text("hide"); } }  dil = new Array(); function findDupImages(gf) { output = ""; url = "/api.php?action=query&generator=allimages&prop=duplicatefiles&gailimit=500&format=json"; if (gf) url += "&gaifrom=" + gf; $.getJSON(url,function (data) { if (data.query) { pages = data.query.pages; for (pageID in pages) { dils = ","+dil.join(); if (dils.indexOf(","+pages[pageID].title) == -1 && pages[pageID].title.indexOf("File::") == -1 && pages[pageID].duplicatefiles) { output += "<h3><a href='/" + pages[pageID].title + "'>"+pages[pageID].title+"</a></h3>\n<ul>\n"; for (x=0;x<pages[pageID].duplicatefiles.length;x++) { output += "<li><a href='/File:" + pages[pageID].duplicatefiles[x].name + "'>File:"+pages[pageID].duplicatefiles[x].name+"</a></li>\n"; dil.push("File:"+pages[pageID].duplicatefiles[x].name.replace(/_/g," ")); } output += "</ul>\n\n" } } $("#mw-dupimages").append(output); if (data["query-continue"]) setTimeout("findDupImages('"+data["query-continue"].allimages.gaifrom+"');",5000); } }); }  function createPageInCategory() { page = prompt("Page name"); if (page) location.href = "/" + page + "?action=edit&redlink=1&category="+wgTitle; }  cls = ""; function classNav() { clses = new Array("death knight","druid","hunter","mage","paladin","priest","rogue","shaman","warlock","warrior"); for (x=0;x<10;x++) { if (wgTitle.toLowerCase().indexOf(clses[x]) != -1) { cls = clses[x].replace(" ",""); break; } } if (cls) { $("table.classnav tr>*:not(:first-child):not(:has('.cc-"+cls+"')),.cc-"+cls+" .short").hide(); $("table.classnav .cc-"+cls+" .long").show(); if (!$("table.classnav .classNavShow").length) $("table.classnav th:has('.cc-"+cls+"')").append('<span class="classNavShow" style="cursor:pointer;"></span>'); $("table.classnav .classNavShow").html("&nbsp;&gt;&gt;").click(classNavShowAll); } }  function classNavShowAll() { $("table.classnav *:not('.cc-"+cls+" *'):not('.long')").show(); $("table.classnav .classNavShow").html("&nbsp;&lt;&lt;").click(classNav); }  $(function() { article = "#bodyContent"; for (x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) ajaxRC(); } if ($("table.classnav").length) classNav(); if ($("#ptabs").length) doTabs(); if ($(".fswitch").length) { $("#ptab1,#ptab2").addClass("fswitched"); $("#ptabs").appendTo("#firstHeading").css("display", ''); $("#toc").clone().attr("id","toc2").insertBefore("#ptab2 :header:first"); var lpt1; $("#toc ul > li > a").each(function () { if (!$("#ptab1 "+$(this).attr("href")).length) $(this).parent().remove(); }); $("#toc2 ul > li > a").each(function (i) {  if ($("#ptab1 "+$(this).attr("href")).length) { $(this).parent().remove(); } else { var tocNumber = $(this).children(".tocnumber").text().split("."); if (lpt1 == null) lpt1 = tocNumber[0]-1; tocNumber[0] = tocNumber[0] - lpt1; $(this).children(".tocnumber").text(tocNumber.join(".")); } }); f = ["Alliance","Horde"]; faction = getStoredValue("fspref", f[Math.round(Math.random())]); ffc = 1; $("#ptabs span.inactivetab:contains('"+faction+"')").click(); if (location.hash && $(".fswitched:visible "+location.hash).length == 0) {  $("#ptabs span.inactivetab:contains('"+$("#firstHeading .inactivetab").text()+"')").click(); h = location.hash; location.hash = "#top"; location.hash = h; } ffc = 0; } $(window).error(function(){ return true; }); if (wgNamespaceNumber==14 && wgAction=="view") addPortletLink('p-views', 'javascript:createPageInCategory();', "Create", 'ca-create-category-page', "Create a page in this category", '',document.getElementById("ca-history")); if (getParamValue("category") && wgAction=="edit") $("#wpTextbox1").val("\n\n[" + "[Category:"+getParamValue("category")+"]]"); ttMouseOver(); addAjaxDisplayLink(); createCollapseButtons(); createNavigationBarToggleButton(); changeTS(); wwScribbleMaps(); requireImageLicense(); //aCharLoad(); loadGSList(); if ($("#mw-dupimages").length) findDupImages(); if (wgUserName != null) $("span.insertusername").html(wgUserName); $(article+" .quote").prepend("<span class='quotemark' style='float:right;'>&#8221;</span><span class='quotemark' style='float:left;'>&#8220;</span>").css("max-width","75%").after("<br clear='left' />"); $(".mw-mpt-link").html("<a href='/Special:WhatLinksHere/"+$(".firstHeading").text().replace("Move ","").replace(/'/g,"%27")+"'>Links to the old page title</a>"); });
-
        //aquella es fa visible i les altres s'oculten
+
-
        var vMcNom = this.id.substr(0, 3); //A partir del nom del botó, deduïm el nom de la caixa
+
-
        var vIndex = this.id.substr(5, 1); //I l'index
+
-
        var i = 1
+
-
        for (i = 1; i <= 9; i++) { //busquem totes les pestanyes d'aquella caixa
+
-
            //alert(vMcNom+"ps"+i);
+
-
            var vPsElem = document.getElementById(vMcNom + "ps" + i);
+
-
            if (!vPsElem) break;
+
-
            if (vIndex == i) { //Si és la pestanya bona la mostrem i canviem la classe de botó
+
-
                vPsElem.style.display = "block";
+
-
                vPsElem.style.visibility = "visible";
+
-
                document.getElementById(vMcNom + "bt" + i).className = "mcBotoSel";
+
-
            } else { //Sinó, l'ocultem i canviem la classe de botó
+
-
                vPsElem.style.display = "none";
+
-
                vPsElem.style.visibility = "hidden";
+
-
                document.getElementById(vMcNom + "bt" + i).className = "mcBoto";
+
-
            }
+
-
        }
+
-
        return false; //evitem la recàrrega de la pàgina
+
-
    }
+
-
 
+
-
    addOnloadHook(MetaCaixaInit);
+
-
 
+
-
    /*HERE FINISHES THE WORKING-CODE OF "METABOXES"*/
+
-
 
+
-
/*
+
-
== 智能讨论页编辑(新建) ==
+
-
 
+
-
*/
+
-
 
+
-
    $(function () {
+
-
        var catalk = $('#ca-talk');
+
-
        if (catalk.hasClass('new') && wgNamespaceNumber != 2) {
+
-
            var a = $('a:first', catalk);
+
-
            a.attr('href', a.attr('href') + '&section=new');
+
-
        }
+
-
    });
+
-
    //
+
-
    /** Magic editintros ****************************************************
+
-
    *
+
-
    *  Description: Adds editintros on disambiguation pages and BLP pages.
+
-
    *  Maintainers: [[:en:User:RockMFR]], [[User:PhiLiP]]
+
-
    */
+
-
 
+
-
    var addEditIntro = function (name) {
+
-
        $('#ca-edit,.editsection').each(function () {
+
-
            $('a', this).attr('href', $('a', this).attr('href') + '&editintro=' + name);
+
-
        });
+
-
    };
+
-
 
+
-
    if (wgNamespaceNumber == 0) {
+
-
        $(function () {
+
-
            if ($('#disambig').length || $('#disambigbox').length) {
+
-
                addEditIntro('Template:Disambig_editintro');
+
-
            }
+
-
        });
+
-
 
+
-
        $(function () {
+
-
            if ($.inArray('在世人物', wgCategories) !== -1) {
+
-
                addEditIntro('Template:BLP_editintro');
+
-
            }
+
-
        });
+
-
    }
+
-
 
+
-
 
+
-
    // Top icon: [[Template:Topicon]]
+
-
    $(function () {
+
-
        // nostalgia, standard and cologneblue use .pagetitle
+
-
        // what's the problem on modern?
+
-
        $('<div />').css('float', 'right').append($('.topicon').css({
+
-
            'float': 'right',
+
-
            'position': 'static'
+
-
        }).show()).prependTo('#firstHeading, .pagetitle');
+
-
    });
+
-
 
+
-
/*
+
-
== 引用錯誤標籤名字解碼 ==
+
-
*/
+
-
 
+
-
    $(function () {
+
-
        $('.anchordecodeme').each(function () {
+
-
            $(this).text(decodeURIComponent($(this).text().replace(/\.([0-9A-F]{2})/g, '%$1')));
+
-
        });
+
-
    });
+
-
 
+
-
    /** extract a URL parameter from the current URL **********
+
-
    * From [[en:User:Lupin/autoedit.js]]
+
-
    *
+
-
    * paramName  : the name of the parameter to extract
+
-
    *
+
-
    * Local Maintainer: [[User:Dschwen]]
+
-
    */
+
-
 
+
-
    function getParamValue(paramName, url) {
+
-
        if (typeof(url) == 'undefined') url = document.location.href;
+
-
        var cmdRe = RegExp('[&?]' + paramName + '=([^&]*)');
+
-
        var m = cmdRe.exec(url);
+
-
        if (m) {
+
-
            try {
+
-
                return decodeURIComponent(m[1]);
+
-
            } catch (someError) {}
+
-
        }
+
-
        return null;
+
-
    }
+
-
    /** &withJS= URL parameter *******
+
-
    * Allow to try custom scripts on the MediaWiki namespace without
+
-
    * editing [[Special:Mypage/vector.js]]
+
-
    *
+
-
    * Maintainer: [[User:Platonides]]
+
-
    * [[User:PhiLiP]]移植自Commons
+
-
    */
+
-
    {
+
-
        var extraJS = getParamValue("withJS");
+
-
        if (extraJS) if (extraJS.match("^MediaWiki:[^&<>=%]*\.js$")) importScript(extraJS);
+
-
        else
+
-
        alert(extraJS + " javascript not allowed to be loaded.");
+
-
    }
+
-
 
+
-
    /** Advanced Site Notices ********
+
-
    * Allow to custom dynamic site notices
+
-
    * Maintainer: [[User:PhiLiP]]
+
-
    */
+
-
    if (typeof(window.closeASNForever) == 'undefined') {
+
-
        window.closeASNForever = false;
+
-
    }
+
-
    if (typeof(window.customASNInterval) == 'undefined') {
+
-
        window.customASNInterval = 15;
+
-
    }
+
-
    $(function () {
+
-
        $('#mw-dismissable-notice').css('display', 'none');
+
-
        if (closeASNForever || wgAction == 'edit' || wgAction == 'submit') {
+
-
            return;
+
-
        }
+
-
 
+
-
        var ln = $('#siteNotice');
+
-
        if (!ln.length) {
+
-
            return;
+
-
        }
+
-
        var cname = 'dismissASN';
+
-
        var cval = getCookie(cname);
+
-
        if (cval == '') {
+
-
            cval = 0;
+
-
        }
+
-
        var rev = 0;
+
-
        var toid = null;
+
-
 
+
-
        var tb = $('<table id="asn-dismissable-notice" width="100%" style="background: transparent;"/>');
+
-
        var ct = $('<div id="advancedSiteNotices"/>');
+
-
        var sd = $('<a href="#">' + wgUVS('关闭', '關閉') + '</a>');
+
-
        tb.append($('<tr/>').append($('<td/>').append(ct)).append($('<td/>').append('[').append(sd).append(']')));
+
-
        var nts = null;
+
-
 
+
-
        sd.click(function () {
+
-
            setCookie(cname, rev, 30);
+
-
            clearTimeout(toid);
+
-
            tb.remove();
+
-
            return false;
+
-
        });
+
-
 
+
-
        var getAttrs = function (nt) {
+
-
            var only = {
+
-
                sysop: nt.hasClass('only_sysop'),
+
-
                logged: nt.hasClass('only_logged'),
+
-
                anon: nt.hasClass('only_anon'),
+
-
                zh: nt.hasClass('only_zh')
+
-
            };
+
-
            only['usr'] = only['sysop'] || only['logged'] || only['anon'];
+
-
            only['vrt'] = only['zh'];
+
-
            var vrt = ['hans', 'hant', 'cn', 'hk', 'sg', 'tw']
+
-
            for (var i = 0; i < 6; i++) {
+
-
                v = 'zh-' + vrt[i];
+
-
                only[v] = nt.hasClass('only_zh_' + vrt[i]);
+
-
                only['vrt'] = only['vrt'] || only[v];
+
-
            }
+
-
            return only;
+
-
        };
+
-
 
+
-
        var loadNotices = function (pos) {
+
-
            if (!tb.length) {
+
-
                return;
+
-
            }
+
-
            var l = nts.length;
+
-
            var nt = null;
+
-
            var rt = 0;
+
-
            while (!nt || nt.attr('class')) {
+
-
                if (nt) {
+
-
                    var only = getAttrs(nt);
+
-
                    if ((!only['vrt'] || (only['vrt'] && only[wgUserVariant])) && (!only['usr'] || ($.inArray('sysop', wgUserGroups) && only['sysop']) || (wgUserName && only['logged']) || (!wgUserName && only['anon']))) {
+
-
                        break;
+
-
                    }
+
-
                }
+
-
                pos = pos % l;
+
-
                nt = $(nts[pos++]);
+
-
                rt++;
+
-
                if (rt == l) {
+
-
                    return;
+
-
                }
+
-
            }
+
-
            nt = nt.html();
+
-
            if (ct.html()) {
+
-
                ct.stop().fadeOut(function () {
+
-
                    ct.html(nt).fadeIn();
+
-
                });
+
-
            } else if (rev == cval) {
+
-
                return;
+
-
            } else {
+
-
                tb.appendTo(ln);
+
-
                ct.html(nt).fadeIn();
+
-
            }
+
-
            toid = setTimeout(function () {
+
-
                loadNotices(pos)
+
-
            }, customASNInterval * 1000);
+
-
        };
+
-
 
+
-
        $.get(wgScript, {
+
-
            title: 'Template:AdvancedSiteNotices',
+
-
            variant: wgUserVariant,
+
-
            printable: 'yes'
+
-
        }, function (d) {
+
-
            nts = $('ul.sitents li', d);
+
-
            rev = parseInt($('.nts_revision', d).text());
+
-
            var l = nts.length;
+
-
            loadNotices(Math.ceil(Math.random() * l));
+
-
        });
+
-
    });
+
-
 
+
-
    /* 维基百科语言列表 */
+
-
    if (wgPageName == 'Wikipedia:首页' || wgPageName == 'Wikipedia_talk:首页' || wgPageName.indexOf("Wikipedia:首頁/自訂首頁設計/") == 0) {
+
-
        $(function () {
+
-
            mw.util.addPortletLink('p-lang', wgScriptPath + '/index.php?title=Wikipedia:维基百科语言列表', wgULS('维基百科语言列表', '維基百科語言列表'), 'interwiki-completelist', wgULS('维基百科的完整各语言列表', '維基百科的完整各語言列表'));
+
-
            var nstab = document.getElementById('ca-nstab-project');
+
-
            if (nstab && wgUserLanguage.indexOf("zh") > -1) {
+
-
                while (nstab.firstChild) nstab = nstab.firstChild
+
-
                nstab.nodeValue = wgULS('首页', '首頁')
+
-
            }
+
-
            //            nstab.firstChild.firstChild.nodeValue = wgULS('首页','首頁');
+
-
        });
+
-
    }
+
-
 
+
-
    /**
+
-
    * Workaround for bug 26117, flood flag
+
-
    *
+
-
    * Special:Userrights
+
-
    */
+
-
    $(function () {
+
-
        if (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Userrights" && wgUserGroups.indexOf("sysop") != -1 && $("input#username").val().replace(/_/g, " ") == wgUserName) {
+
-
            $("label[for=wpGroup-flood]").text($("label[for=wpGroup-flood]").text().replace("*", ""));
+
-
            if ($("input#wpGroup-flood").attr("disabled")) {
+
-
                $("input#wpGroup-flood").attr("disabled", false);
+
-
                var oldhtml = $("input#wpGroup-flood").parent().html();
+
-
                $("input#wpGroup-flood").parent().remove();
+
-
                $("table.mw-userrights-groups tbody tr:nth-child(2) td:nth-child(2)").append(oldhtml);
+
-
            }
+
-
        }
+
-
    });
+
-
 
+
-
    /**
+
-
    * 简单的API读写实现,避免重复使用代码
+
-
    *
+
-
    * Maintainer: [[User:PhiLiP]]
+
-
    */
+
-
    mw.api = { /* cache */
+
-
        cache: {},
+
-
 
+
-
        pass: function () {},
+
-
 
+
-
        normalized: {},
+
-
 
+
-
        /**
+
-
        * Send an API request to server and retrieve the result
+
-
        *
+
-
        * @param query: the query to be sent
+
-
        * @param ready: optional, callback function when API response is ready for using
+
-
        */
+
-
        request: function (method, query, ready) {
+
-
            if (typeof method != 'string' || !$.inArray(method, ['get', 'post'])) {
+
-
                ready = query;
+
-
                query = method;
+
-
                method = 'get';
+
-
            }
+
-
            ready = ready || mw.api.pass;
+
-
            query.format = 'json';
+
-
            $[method](wgScriptPath + '/api.php', query, ready, 'json');
+
-
        },
+
-
 
+
-
        /**
+
-
        * Get raw text of pages
+
-
        *
+
-
        * @param pages: require page(s), string or array
+
-
        * @param ready: optional, callback function receive raw content
+
-
        * @param purge: purge the cache? boolean
+
-
        */
+
-
        raw: function (pages, ready, purge) {
+
-
            if (typeof pages == 'string') {
+
-
                pages = [pages];
+
-
            }
+
-
            if (typeof ready == 'boolean') {
+
-
                purge = ready;
+
-
                ready = mw.api.pass;
+
-
            }
+
-
            ready = ready || mw.api.pass;
+
-
            purge = purge || false;
+
-
 
+
-
            var _raw_from_cache = function (pages) {
+
-
                var ret = {};
+
-
                var pagelen = pages.length;
+
-
                for (var id = 0; id < pagelen; id++) {
+
-
                    var page = pages[id];
+
-
                    var title = mw.api.normalized[page] || page;
+
-
                    if (typeof mw.api.cache[title] == 'object') {
+
-
                        ret[page] = mw.api.cache[title]['*'];
+
-
                    }
+
-
                }
+
-
                return ret;
+
-
            }
+
-
 
+
-
            var ready_data = {};
+
-
            var titles = [];
+
-
 
+
-
            if (!purge) {
+
-
                $.extend(ready_data, _raw_from_cache(pages));
+
-
                var pagelen = pages.length;
+
-
                for (var id = 0; id < pagelen; id++) {
+
-
                    var page = pages[id];
+
-
                    if (!ready_data[page]) {
+
-
                        titles.push(page);
+
-
                    }
+
-
                }
+
-
            } else {
+
-
                titles = pages;
+
-
            }
+
-
 
+
-
            if (titles.length) {
+
-
                mw.api.request({
+
-
                    'action': 'query',
+
-
                    'prop': 'revisions',
+
-
                    'titles': titles.join('|'),
+
-
                    'rvprop': 'timestamp|content'
+
-
                }, function (data) {
+
-
                    if (data.query.normalized) {
+
-
                        normlen = data.query.normalized.length;
+
-
                        for (var normid = 0; normid < normlen; normid++) {
+
-
                            var norm = data.query.normalized[normid];
+
-
                            mw.api.normalized[norm.from] = norm.to;
+
-
                        }
+
-
                    }
+
-
                    for (var pageid in data.query.pages) {
+
-
                        var page = data.query.pages[pageid];
+
-
                        var cache = mw.api.cache[page.title] = {};
+
-
                        cache.missing = pageid < 0;
+
-
                        if (cache.missing) {
+
-
                            cache.timestamp = null;
+
-
                            cache['*'] = null;
+
-
                        } else {
+
-
                            $.extend(cache, page.revisions[0]);
+
-
                        }
+
-
                    }
+
-
 
+
-
                    $.extend(ready_data, _raw_from_cache(titles));
+
-
                    ready(ready_data);
+
-
                });
+
-
            } else {
+
-
                ready(ready_data);
+
-
            }
+
-
        },
+
-
 
+
-
        /**
+
-
        * Edit a page with content
+
-
        */
+
-
        edit: function (page, text, summary, ready) {
+
-
            page = mw.api.normalized[page] || page;
+
-
 
+
-
            if (typeof summary == 'function') {
+
-
                ready = summary;
+
-
                summary = '';
+
-
            } else {
+
-
                summary = summary || '';
+
-
                ready = ready || mw.api.pass;
+
-
            }
+
-
 
+
-
            // request an edit token
+
-
            mw.api.request({
+
-
                'action': 'query',
+
-
                'prop': 'info',
+
-
                'intoken': 'edit',
+
-
                'titles': page
+
-
            }, function (data) {
+
-
                var token = '';
+
-
                var starttimestamp = '';
+
-
                for (var pageid in data.query.pages) {
+
-
                    token = data.query.pages[pageid].edittoken;
+
-
                    starttimestamp = data.query.pages[pageid].starttimestamp;
+
-
                }
+
-
 
+
-
                var query = {
+
-
                    'action': 'edit',
+
-
                    'title': page,
+
-
                    'starttimestamp': starttimestamp,
+
-
                    'summary': summary,
+
-
                    'text': text,
+
-
                    'token': token
+
-
                };
+
-
                if (mw.api.cache[page]) {
+
-
                    // use basetimestamp to prevent edit conflict
+
-
                    query.basetimestamp = mw.api.cache[page].timestamp;
+
-
                }
+
-
 
+
-
                mw.api.request('post', query, ready);
+
-
            });
+
-
        },
+
-
 
+
-
        /**
+
-
        * Parse a page content
+
-
        */
+
-
        parse: function (page, variant, ready) {
+
-
            if (typeof variant == 'function') {
+
-
                ready = variant;
+
-
                variant = window.wgUserVariant || false;
+
-
            } else {
+
-
                ready = ready || mw.api.pass;
+
-
                variant = variant || window.wgUserVariant || false;
+
-
            }
+
-
 
+
-
            var query = {
+
-
                'action': 'parse',
+
-
                'page': page
+
-
            }
+
-
            if (variant) {
+
-
                query.variant = variant;
+
-
            }
+
-
            mw.api.request(query, function (data) {
+
-
                ready(data.parse.text['*'], data.parse.displaytitle, data.parse.links);
+
-
            });
+
-
        }
+
-
    };
+
-
 
+
-
})(jQuery, mediaWiki);
+

在2011年5月28日 (六) 02:03的最新修订版本

var hasClass = (function () {
    var reCache = {};
    return function (element, className) {
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
    };
})();


/** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed, showing only the header. See

 *               [[Wikipedia:NavFrame]].
 *  Maintainers: [[User:R. Koot]]
 */

var autoCollapse = 2;

var collapseCaption = "隐藏▲";
var expandCaption = "显示▼";

 
function collapseTable( tableIndex )
{
    var Button = document.getElementById( "collapseButton" + tableIndex );

    var Table = document.getElementById( "collapsibleTable" + tableIndex );

 
    if ( !Table || !Button ) {
        return false;

    }
 
    var Rows = Table.rows;
 
    if ( Button.firstChild.data == collapseCaption ) {

        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].oldDisplayValue = Rows[i].style.display;
            Rows[i].style.display = "none";

        }
        Button.firstChild.data = expandCaption;
    } else {

        for ( var i = 1; i < Rows.length; i++ ) {

            Rows[i].style.display = Rows[i].oldDisplayValue;

        }
        Button.firstChild.data = collapseCaption;
    }

}
 
function createCollapseButtons()
{
    var tableIndex = 0;

    var NavigationBoxes = new Object();
    var Tables = document.getElementsByTagName( "table" );

 
    for ( var i = 0; i < Tables.length; i++ ) {
        var parent = Tables[i].parentNode.parentNode.parentNode.parentNode;
        if ( hasClass( Tables[i], "collapsible" ) || (hasClass(parent, "navbox") && hasClass(Tables[i], "navbox")) ) {

 
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];

            if (!HeaderRow) continue;
            var Header = HeaderRow.getElementsByTagName( "th" )[0];

            if (!Header) continue;
 
            NavigationBoxes[ tableIndex ] = Tables[i];

            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );

 
            var Button     = document.createElement( "span" );

            var ButtonLink = document.createElement( "a" );

            var ButtonText = document.createTextNode( collapseCaption );

 
            Button.className = "collapseButton";  //Styles are declared in Common.css

 
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );

            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );

            ButtonLink.appendChild( ButtonText );
 
            Button.appendChild( document.createTextNode( "[" ) );

            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );

 
            Header.insertBefore( Button, Header.childNodes[0] );

            tableIndex++;
        }
    }
 
    for ( var i = 0;  i < tableIndex; i++ ) {

        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {

            collapseTable( i );
        } 
        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {

            var element = NavigationBoxes[i];
            while (element = element.parentNode) {

                if ( hasClass( element, "outercollapse" ) ) {

                    collapseTable ( i );
                    break;
                }

            }
        }
    }
}
 
addOnloadHook( createCollapseButtons );
//</source>

//wowtips
function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); }  function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) {  c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; }  function setStoredValue(key, value, expiredays) { if (typeof(localStorage) == "undefined") { setCookie(key, value, expiredays); } else { localStorage[key] = value; } } function getStoredValue(key, defaultValue) { if (typeof(localStorage) == "undefined") { var value = getCookie(key); return value == "" ? defaultValue : value; } return localStorage[key] == null ? defaultValue : localStorage[key]; }  article = "";  // See [[Help:Tooltips]] // default setting to turn tooltips on var tooltipsOn = true;  // allow users to specify an external db to change links to var extDB = "http://www.wowpedia.org/";  var $tfb; var $ttfb; var $htt; var activeHoverLink = null; var tipCache = new Object();  // hides the tooltip function hideTip() { $tfb.html("").removeClass("tooltip-ready").addClass("hidden").css("visibility","hidden");  activeHoverLink = null; }  // displays the tooltip function displayTip(e) { $htt.not(":empty").removeClass("hidden").addClass("tooltip-ready"); moveTip(e); $htt.not(":empty").css("visibility","visible"); moveTip(e); }  // moves the tooltip function moveTip(e) { $ct = $htt.not(":empty"); var newTop = e.clientY + ((e.clientY > ($(window).height()/2)) ? -($ct.innerHeight()+20):20); var newLeft = e.clientX + ((e.clientX > ($(window).width()/2)) ? -($ct.innerWidth()+20):20); $ct.css({"position":"fixed","top":newTop + "px","left":newLeft + "px"}); }  // AJAX tooltips function showTip(e) { var $t=$(this); activeHoverLink = $t; $p=$t.parent(); if ($p.hasClass("selflink")==false) { $t.removeAttr("title"); $p.removeAttr("title"); var url = "/index.php?title="+$t.data("tt").replace(/ /g,"_").replace(/\?/g,"%3F")+"&action=render div.tooltip-content"; if (tipCache[url] != null) {  $tfb.html(tipCache[url]);  displayTip(e);  return; } $tfb.load(url,function () { if ($t != activeHoverLink) return; if ($tfb.html() == "") $tfb.html('<div class="tooltip-content"><b>Error</b><br />This target either has no tooltip<br />or was not intended to have one.</div>'); $tfb.find(".tooltip-content").css("display",""); tipCache[url] = $tfb.html(); displayTip(e); }); } }  // quick tooltips function hideTemplateTip() { $ttfb.html("").removeClass("tooltip-ready").addClass("hidden");  }  function showTemplateTip(e) { $ttfb.html('<div class="tooltip-content">' + $(this).next().html() + '</div>'); displayTip(e); }  // add the tooltip calls to the page function eLink(db,nm) { dbs = new Array("http://us.battle.net/wow/en/search?f=wowitem&q=","http://www.wowhead.com/?search="); dbTs = new Array("Armory","Wowhead"); dbHs = new Array("&real; ","&omega; "); el = '<a href="'+ dbs[db]+nm + '" target="_blank" title="'+ dbTs[db] +'">'+ dbHs[db] + '</a>'; return el; }  function bindTT() { $t=$(this); $p=$t.parent(); if ($p.hasClass("selflink") == false) { $t.data("tt", $p.attr("title").replace(" (page does not exist)","").replace("?","%3F")).hover(showTip,hideTip).mousemove(moveTip); if ($p.hasClass("new")) { els = '<sup><span class="plainlinks">'; y=($t.hasClass("itemlink"))?0:1; z=($t.hasClass("achievementlink"))?2:2; for (x=y;x<z;x++) els += eLink(x,$t.data("tt").replace("Quest:","")); $p.after(els+'</span></sup>'); } if (extDB != "http://www.wowpedia.org/") {  fullextURL = extDB + $t.data("tt"); $p.attr("href",fullextURL); } } }  // check to see if it is active then do it function ttMouseOver() { if (tooltipsOn && getCookie("wiki-tiploader") != "no") { $(article).append('<div id="tfb" class="htt"></div><div id="templatetfb" class="htt"></div>'); $tfb = $("#tfb"); $ttfb = $("#templatetfb"); $htt = $("#tfb,#templatetfb"); $(article+" span.ajaxttlink").each(bindTT); $(article+" span.tttemplatelink").hover(showTemplateTip,hideTemplateTip).mousemove(moveTip); } }  // collapsible tables var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show";   function collapseTable(i, isAutomated) { var Button = $("#collapseButton" + i); var Table = $("#collapsibleTable" + i); if (Table.length<1 || Button.length<1) return false; if (Button.text() == collapseCaption) { Table.find("tr").not(":has('#collapseButton"+i+"')").hide(); if (isAutomated == null) setStoredValue("hideTable-" + wgArticleId + "-" + i,1,30); Button.text(expandCaption); } else { Table.find("tr").not(":has('#collapseButton"+i+"')").show(); if (isAutomated == null) setStoredValue("hideTable-" + wgArticleId + "-" + i,0,30);   Button.text(collapseCaption); } }   function createCollapseButtons() { var tch = $("table.collapsible tr th:last-child"); tch.each(function (i) { $(this).closest("table").attr("id", "collapsibleTable" + i); $(this).prepend('<span style="float:right; font-weight:normal; text-align:right; width:6em">[<a href="javascript:collapseTable('+i+');" style="color:'+$(this).css("color")+';" id="collapseButton'+i+'">'+collapseCaption+'</a>]</span>'); if ($(this).closest("table").hasClass("collapsed") || (getStoredValue("hideTable-" + wgArticleId + "-" + i) == 1) || (tch.length >= autoCollapse && $(this).closest("table").hasClass("autocollapse"))) collapseTable(i, 1); }); }  var nbh = '['+collapseCaption+']'; var nbs = '['+expandCaption+']'; function toggleNavigationBar(i) { var NavToggle = $("#NavToggle" + i); var NavFrame = $("#NavFrame" + i); if (NavFrame.length<1 || NavToggle.length<1) return false;  ncd=(NavToggle.text()==nbh)?'none':'block'; NavFrame.children(".NavPic,.NavContent").css("display",ncd); nct=(NavToggle.text()==nbh)?nbs:nbh; NavToggle.text(nct); }   // adds show/hide-button to navigation bars function createNavigationBarToggleButton() { $("div.NavFrame").each(function (i) { NavToggleText = ($(this).children(".NavPic:visible,.NavContent:visible").length>0)?nbh:nbs; $(this).children(".NavHead").append('<a href="javascript:toggleNavigationBar('+i+');" id="NavToggle'+i+'" class="NavToggle">'+NavToggleText+'</a>'); $(this).attr("id","NavFrame"+i); }); }   // extract a URL parameter from the current URL // From wikipedia:User:Lupin/autoedit.js // paramName  : the name of the parameter to extract  function getParamValue(paramName) { var cmdRe=RegExp( '[&?]' + paramName + '=([^&]*)' ); var h = document.location.href; var m=cmdRe.exec(h); if (m) { try { return decodeURIComponent(m[1]); } catch (someError) {} } return null; }  // patching in changes to table sorting and alt rows function changeTS() { window['ts_alternate'] = function (table) { $(table).find("tbody").find("tr:odd").removeClass("alt"); $(table).find("tbody").find("tr:even").addClass("alt"); } window['ts_makeSortable'] = function (table) { if ($(table).find("tr").length>0) firstRow = ($(table).find("th").length>0)?$(table).find("tr:has(th)").eq(0):$(table).find("tr").eq(0); if (!firstRow) return; firstRow.children(":not('.unsortable')").append('&nbsp;&nbsp;<a href="javascript:;" class="sortheader" onclick="ts_resortTable(this); return false;"><span class="sortarrow"><img src="'+ts_image_path+ts_image_none+'" alt="&darr;"/></span></a>'); if (ts_alternate_row_colors) ts_alternate(table); } }  // add scribblemap processing function wwScribbleMaps() { $(article+" div.wwSM").each(function () { mapID = $(this).attr("class").replace("wwSM map-",""); if (mapID.length > 20) mapID = ""; $(this).html('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="smwidget" align="middle"><param name="allowFullScreen" value="true" /><param name="FlashVars" value="id='+mapID+'&p=true&mt=false&d=true&z=true" /><param name="movie" value="http://widgets.scribblemaps.com/wowsmwidget.swf"/><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="http://widgets.scribblemaps.com/wowsmwidget.swf" FlashVars="id='+mapID+'&p=true&mt=false&d=true&z=true" "quality="high" bgcolor="#000000" width="550" height="400" name="smwidget" align="middle" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'); }); }  function requireImageLicense() { if (wgPageName == "Special:Upload" && getParamValue("wpDestFile") == null) { $wpu = $("#mw-upload-form").find("[name=wpUpload]").not("#wpUpload"); $wpu.attr("disabled","true"); $("#wpLicense").change(function () { if ($("#wpLicense").val()) { $wpu.removeAttr("disabled"); } else { $wpu.attr("disabled","true"); } }); } }  function aCharLoad() { $(article+" .aChar").each(function () { data = $(this).text().split(";"); realm = data[0]; loc = (data[1].toLowerCase()=="eu")?"eu":"www"; character = data[2]; height = (data[3])?588:444; $(this).html('<iframe src="http://'+loc+'.wowarmory.com/character-model-embed.xml?r='+realm+'&amp;cn='+character+'&amp;rhtml=true" scrolling="no" height="'+height+'" width="321" frameborder="0"></iframe>'); }); $(article+" .aChar").css("display","block"); }  function sortDays(a, b) { return b.substring(b.indexOf(";")+1)-a.substring(a.indexOf(";")+1); }  function loadGSList(){ if ($("#gslist").length>0) { var timestamp = 0; var today = new Date(); var tsDate = new Date(); var dateRE = /(\d{4})-(\d\d)-(\d\d).*/; var pArr = new Array(); $.getJSON("http://www.wowpedia.org/api.php?action=query&generator=categorymembers&gcmlimit=500&gcmsort=timestamp&gcmdir=desc&gcmtitle=Category:Guild_stubs&prop=revisions&rvprop=timestamp&format=json&callback=?", function(data) { if (data.query) { pages = data.query.pages; for (pageID in pages) { timestamp = pages[pageID].revisions[0].timestamp; dateREd = dateRE.exec(timestamp); tsDate.setFullYear(dateREd[1],dateREd[2]-1,dateREd[3]); daysElapsed = Math.round((today - tsDate) / 86400000); pArr[pArr.length] = pages[pageID].title + ";" + daysElapsed; } pArr2 = pArr.sort(sortDays); gslBuffer = "<ul>"; for (n in pArr2) { guild = pArr2[n].substring(0,pArr2[n].indexOf(";")); daysE = pArr2[n].substring(pArr2[n].indexOf(";")+1); daysE = (daysE < 0)?0:daysE; daysE = (daysE > 29)?'<span style="color:red;">('+daysE+' days)</span>':'('+daysE+' days)'; gslBuffer += '<li><a href="/'+guild+'" title="'+guild+'">'+guild+'</a> ' + daysE + ' - <a href="/'+guild+'?action=history">History</a> &bull; <a href="/'+guild+'?action=delete">Delete</a></li>'; } gslBuffer += "</ul>"; $("#gslist").html(gslBuffer); } }); } }  // AJAX RC var ajaxPages = new Array("Special:RecentChanges"); var ajaxRCOverride = false; var rcTimer; var doRefresh = true; var rcRefresh = 30000; ajaxRCCookie = (getCookie("ajaxRC")=="on"||ajaxRCOverride) ? true:false;  function ajaxRC() { appTo = $(".firstHeading"); appTo.append('&nbsp;<span style="font-size: xx-small; border-bottom: 1px dotted; cursor:help;" title="Enable auto-refreshing page loads">AJAX:</span><input type="checkbox" id="ajaxToggle"><span style="position:relative; top:5px; left:5px;" id="ajaxRCprogress"><img src="http://www.wowpedia.org/images/0/0e/Progressbar.gif" border="0" alt="AJAX operation in progress" /></span>'); $("#ajaxRCprogress").bind("ajaxSend", function (){ $(this).show(); }).bind("ajaxComplete", function (){ $(this).hide(); }); $("#ajaxToggle").click(toggleRC); $("#ajaxRCprogress").hide(); $("#ajaxToggle").attr("checked", ajaxRCCookie); if (ajaxRCCookie) loadRCData(); }  function toggleRC() { if ($("#ajaxToggle").attr("checked") == true) { setCookie("ajaxRC", "on", 30); doRefresh = true; loadRCData(); } else { setCookie("ajaxRC", "off", 30); doRefresh = false; clearTimeout(rcTimer); } }  function loadRCData() { $(article).load(location.href + " "+article+" > *", function (data) {  if (doRefresh) rcTimer = setTimeout("loadRCData();", rcRefresh); }); }  // tab switch var ptabs; var ffc; function doTabs() { cTab = $("#ptabs .activetab").parent().prevAll().length + 1; ptabs = $("#ptabs>*"); ptabs.css("cursor","pointer"); ptabs.click(function (e) { $pt = $(e.target); if ($pt.hasClass("inactivetab")) e.preventDefault(); if (ffc != 1 && $(".fswitch").length) { if ($pt.text().indexOf("Alliance") != -1) { setStoredValue("fspref","Alliance",30);} else { setStoredValue("fspref","Horde",30); } } if ($pt.parent().not("#ptabs").html()) $pt = $pt.parent(); sp = $pt.prevAll().length; ptabs.eq(cTab-1).children("*").removeClass("activetab").addClass("inactivetab"); $("#ptab"+cTab).hide().children(".toc").removeAttr("id"); cTab = sp+1; ptabs.eq(sp).children("*").removeClass("inactivetab").addClass("activetab"); $("#ptab"+cTab).show().children(".toc").attr("id","toc"); }); }  // AJAX tables ahClass = new RegExp('class="ajaxHide"', "gim"); crlf = new RegExp("\r\n", "g")  function getTableData(tablePage, tableNum) { $("body").bind("ajaxSend", function (){ $(this).css("cursor","wait"); }).bind("ajaxComplete", function (){ $(this).css("cursor","auto"); }); $.get('http://' + location.hostname + '/' + tablePage + '?action=render', function (data) { if (data) { data = data.replace(crlf, "").replace(ahClass, 'class="ajaxHide-active"').replace('class="darktable"', ""); $("#ajaxTable" + tableNum).find("td").eq(0).html(data); $("#ajaxTable" + tableNum).find("td").eq(0).find("table.sortable").each(function (i) { ts_makeSortable($(this)); zebraAJAX = $(this).find("tr"); if (zebraAJAX.eq(2).css("background-color") == "transparent" && zebraAJAX.eq(3).css("background-color") == "transparent") { zebraAJAX.find(".sortheader").click(function () { $(article+" table.zebra > tbody > tr").css("background-color","transparent"); ac = (skin=="monobook")?"#e9e9ff":"#2c2c2c"; $(article+" table.zebra > tbody > tr:nth-child(2n+1)").css("background-color",ac); }); } }); zebraAJAX = $(article+" .ajax td > table.zebra > tbody > tr"); if (zebraAJAX.eq(1).css("background-color") == "transparent" && zebraAJAX.eq(2).css("background-color") == "transparent") { $(article+" .ajax td > table.zebra > tbody > tr:nth-child(2n+1)").css("background-color","#2c2c2c"); if (skin == "monobook") $("#bodyContent .ajax td > table.zebra > tbody > tr:nth-child(2n+1)").css("background-color","#e9e9ff"); } $("#stl" + tableNum).html('[<a href="/'+tablePage+'?action=edit">edit</a>]&nbsp;[<a href="javascript:;" id="htl' + tableNum + '" onClick="hideTable(' + tableNum + ');">hide</a>]'); ttMouseOver(); } }); }  function hideTable(tableNum) { $("#ajaxTable" + tableNum).find("tr").eq(1).hide(); $("#htl" + tableNum).click(function() { showTable(tableNum); }); $("#htl" + tableNum).text("show"); }  function showTable(tableNum) { $("#ajaxTable" + tableNum).find("tr").eq(1).show(); $("#htl" + tableNum).click(function() { hideTable(tableNum); }); $("#htl" + tableNum).text("hide"); }  function loadTableData(tableNum) { thisTable = document.getElementById("ajaxTable" + tableNum); loadPage = thisTable.className.substring(thisTable.className.indexOf("targetPage-") + 11); getTableData(loadPage, tableNum); }  function addAjaxDisplayLink() { $(article+" table.ajax").each(function (i) { $(this).attr("id", "ajaxTable" + i); $(this).find("td").eq(1).parent().hide(); $(this).find("td").eq(0).parent().show(); if (this.getElementsByTagName("th").length > 0) this.getElementsByTagName("th")[0].innerHTML = '<span style="float:right;" id="stl' + i + '"></span>' + this.getElementsByTagName("th")[0].innerHTML; if ($(this).find("td").eq(0).hasClass("showLinkHere")) { $(this).find("td").eq(0).html($(this).find("td").eq(0).html().replace("[link]", '<a href="javascript:;" onClick="loadTableData(' + i + ')">').replace("[/link]","</a>")); } else { $("#stl" + i).html('[<a href="javascript:;" onClick="loadTableData(' + i + ')">show data</a>]'); } }); }  function toggleSMWFacts() { if ($("#SMWFactToggle").text() == "hide") { $("#mw-data-after-content table.smwfacttable tr").hide(); setCookie("hideSMWFacts","true"); $("#SMWFactToggle").text("show"); } else { $("#mw-data-after-content table.smwfacttable tr").show(); setCookie("hideSMWFacts","false"); $("#SMWFactToggle").text("hide"); } }  dil = new Array(); function findDupImages(gf) { output = ""; url = "/api.php?action=query&generator=allimages&prop=duplicatefiles&gailimit=500&format=json"; if (gf) url += "&gaifrom=" + gf; $.getJSON(url,function (data) { if (data.query) { pages = data.query.pages; for (pageID in pages) { dils = ","+dil.join(); if (dils.indexOf(","+pages[pageID].title) == -1 && pages[pageID].title.indexOf("File::") == -1 && pages[pageID].duplicatefiles) { output += "<h3><a href='/" + pages[pageID].title + "'>"+pages[pageID].title+"</a></h3>\n<ul>\n"; for (x=0;x<pages[pageID].duplicatefiles.length;x++) { output += "<li><a href='/File:" + pages[pageID].duplicatefiles[x].name + "'>File:"+pages[pageID].duplicatefiles[x].name+"</a></li>\n"; dil.push("File:"+pages[pageID].duplicatefiles[x].name.replace(/_/g," ")); } output += "</ul>\n\n" } } $("#mw-dupimages").append(output); if (data["query-continue"]) setTimeout("findDupImages('"+data["query-continue"].allimages.gaifrom+"');",5000); } }); }  function createPageInCategory() { page = prompt("Page name"); if (page) location.href = "/" + page + "?action=edit&redlink=1&category="+wgTitle; }  cls = ""; function classNav() { clses = new Array("death knight","druid","hunter","mage","paladin","priest","rogue","shaman","warlock","warrior"); for (x=0;x<10;x++) { if (wgTitle.toLowerCase().indexOf(clses[x]) != -1) { cls = clses[x].replace(" ",""); break; } } if (cls) { $("table.classnav tr>*:not(:first-child):not(:has('.cc-"+cls+"')),.cc-"+cls+" .short").hide(); $("table.classnav .cc-"+cls+" .long").show(); if (!$("table.classnav .classNavShow").length) $("table.classnav th:has('.cc-"+cls+"')").append('<span class="classNavShow" style="cursor:pointer;"></span>'); $("table.classnav .classNavShow").html("&nbsp;&gt;&gt;").click(classNavShowAll); } }  function classNavShowAll() { $("table.classnav *:not('.cc-"+cls+" *'):not('.long')").show(); $("table.classnav .classNavShow").html("&nbsp;&lt;&lt;").click(classNav); }  $(function() { article = "#bodyContent"; for (x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) ajaxRC(); } if ($("table.classnav").length) classNav(); if ($("#ptabs").length) doTabs(); if ($(".fswitch").length) { $("#ptab1,#ptab2").addClass("fswitched"); $("#ptabs").appendTo("#firstHeading").css("display", ''); $("#toc").clone().attr("id","toc2").insertBefore("#ptab2 :header:first"); var lpt1; $("#toc ul > li > a").each(function () { if (!$("#ptab1 "+$(this).attr("href")).length) $(this).parent().remove(); }); $("#toc2 ul > li > a").each(function (i) {  if ($("#ptab1 "+$(this).attr("href")).length) { $(this).parent().remove(); } else { var tocNumber = $(this).children(".tocnumber").text().split("."); if (lpt1 == null) lpt1 = tocNumber[0]-1; tocNumber[0] = tocNumber[0] - lpt1; $(this).children(".tocnumber").text(tocNumber.join(".")); } }); f = ["Alliance","Horde"]; faction = getStoredValue("fspref", f[Math.round(Math.random())]); ffc = 1; $("#ptabs span.inactivetab:contains('"+faction+"')").click(); if (location.hash && $(".fswitched:visible "+location.hash).length == 0) {  $("#ptabs span.inactivetab:contains('"+$("#firstHeading .inactivetab").text()+"')").click(); h = location.hash; location.hash = "#top"; location.hash = h; } ffc = 0; } $(window).error(function(){ return true; }); if (wgNamespaceNumber==14 && wgAction=="view") addPortletLink('p-views', 'javascript:createPageInCategory();', "Create", 'ca-create-category-page', "Create a page in this category", '',document.getElementById("ca-history")); if (getParamValue("category") && wgAction=="edit") $("#wpTextbox1").val("\n\n[" + "[Category:"+getParamValue("category")+"]]"); ttMouseOver(); addAjaxDisplayLink(); createCollapseButtons(); createNavigationBarToggleButton(); changeTS(); wwScribbleMaps(); requireImageLicense(); //aCharLoad(); loadGSList(); if ($("#mw-dupimages").length) findDupImages(); if (wgUserName != null) $("span.insertusername").html(wgUserName); $(article+" .quote").prepend("<span class='quotemark' style='float:right;'>&#8221;</span><span class='quotemark' style='float:left;'>&#8220;</span>").css("max-width","75%").after("<br clear='left' />"); $(".mw-mpt-link").html("<a href='/Special:WhatLinksHere/"+$(".firstHeading").text().replace("Move ","").replace(/'/g,"%27")+"'>Links to the old page title</a>"); });
个人工具
分享到: 更多
名字空间
变换
动作
网站地图
暗黑破坏神 III
暗黑破坏神 II
暗黑破坏神
工具箱
编辑箱
关于暗黑百科