MediaWiki:Common.js

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

(修订版本间的差异)
跳转到: 导航, 搜索
 
(15个中途的修订版本没有显示)
第1行: 第1行:
-
/** Cookies *****************************************************************************
+
var hasClass = (function () {
-
  */
+
    var reCache = {};
 +
    return function (element, className) {
 +
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
 +
    };
 +
})();
-
function setCookie(cookieName, cookieValue, expiryDay) {
 
-
var today = new Date();
 
-
var expire = new Date();
 
-
var nDays = (!expiryDay || isNaN(expiryDay) )?30:expiryDay;
 
-
expire.setTime( today.getTime() + (3600000 * 24 * nDays) );
 
-
document.cookie = cookieName + "=" + escape(cookieValue)
 
-
                + ";path=/w"
 
-
                + ";expires="+expire.toGMTString();
 
-
document.cookie = cookieName + "=" + escape(cookieValue)
 
-
                + ";path=/wiki"
 
-
                + ";expires="+expire.toGMTString();
 
-
}
 
-
function getCookie(cookieName) {
+
/** Collapsible tables *********************************************************
-
  var start = document.cookie.indexOf( cookieName + "=" );
+
*
-
  if ( start == -1 ) return "";
+
*  Description: Allows tables to be collapsed, showing only the header. See
-
  var len = start + cookieName.length + 1;
+
-
  if ( ( !start ) &&
+
-
    ( cookieName != document.cookie.substring( 0, cookieName.length ) ) )
+
-
      {
+
-
        return "";
+
-
      }
+
-
  var end = document.cookie.indexOf( ";", len );
+
-
  if ( end == -1 ) end = document.cookie.length;
+
-
  return unescape( document.cookie.substring( len, end ) );
+
-
}
+
-
function deleteCookie(cookieName) {
+
*              [[Wikipedia:NavFrame]].
-
  if ( getCookie(cookieName) ) {
+
*  Maintainers: [[User:R. Koot]]
-
    document.cookie = cookieName + "=" + ";path=/w" +
+
*/
-
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
+
-
    document.cookie = cookieName + "=" + ";path=/wiki" +
+
-
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
+
-
  }
+
-
}
+
-
deleteCookie('usedacc'); // drop the cookie which probably is a privacy violation
+
var autoCollapse = 2;
-
/*
+
var collapseCaption = "隐藏▲";
-
==定期強制用戶更新cache==
+
var expandCaption = "显示▼";
-
*/
+
 +
function collapseTable( tableIndex )
 +
{
 +
    var Button = document.getElementById( "collapseButton" + tableIndex );
-
var today=new Date();
+
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
-
if( (""+wgUserGroups).indexOf("user")!=-1 && (wgAction=="view") ){
+
 +
    if ( !Table || !Button ) {
 +
        return false;
-
  if(!getCookie("lastload") || isNaN(getCookie("lastload")) ){
+
    }
-
  setCookie("lastload", today.getTime());
+
   
-
  }else{
+
    var Rows = Table.rows;
 +
   
 +
    if ( Button.firstChild.data == collapseCaption ) {
-
  if( today.getTime()-getCookie("lastload") >= 7*24*60*60*1000 ){
+
        for ( var i = 1; i < Rows.length; i++ ) {
-
  setCookie("lastload", today.getTime());
+
            Rows[i].oldDisplayValue = Rows[i].style.display;
-
  if( getCookie("lastload")==today.getTime() ) window.location.reload(true);
+
            Rows[i].style.display = "none";
-
  }else if( today.getTime()-getCookie("lastload") < 0 ){
+
-
  setCookie("lastload", today.getTime());
+
-
  }
+
-
}
+
        }
 +
        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" );
-
if( (""+wgUserGroups).indexOf("user")!=-1 && (wgAction=="edit") ){
+
 +
    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")) ) {
-
  if(!getCookie("editlastload") || isNaN(getCookie("editlastload")) ){
+
   
-
  setCookie("editlastload", today.getTime());
+
            /* only add button and increment count if there is a header row to work with */
-
}else{
+
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
-
  if( today.getTime()-getCookie("editlastload") >= 7*24*60*60*1000 ){
+
            if (!HeaderRow) continue;
-
  setCookie("editlastload", today.getTime());
+
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
-
  if( getCookie("editlastload")==today.getTime() ) window.location.reload(true);
+
-
  }else if( today.getTime()-getCookie("editlastload") < 0 ){
+
-
  setCookie("editlastload", today.getTime());
+
-
  }
+
-
  }
+
            if (!Header) continue;
 +
   
 +
            NavigationBoxes[ tableIndex ] = Tables[i];
-
}
+
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
-
/* 
+
-
* ImportScriptHttp.模块
+
-
* 版本: r1
+
-
*/
+
-
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(7(){3(c.2!=S)8;2=k W();c.2=2;2.d={};2.C=7(9,6){3(2.d[9]){8(a)}2.d[9]=z;7 y(){f A;q{A=k 17()}o(e){q{A=k Q("15.P")}o(e){q{A=k Q("11.P")}o(14){A=a}}}3(!A)E("13 16 19 10 18.");8 A}f x=y();x.j=7(){3(5.N==4){3(5.n==1a||5.n==X){3((5.B!=a)){f s=l.u("v");s.U="i";s.G="h/i";s.T=p;s.h=5.B;l.J(\'L\')[0].M(s);3(6)6()}}I{E(\'Y Z V: \'+5.12+\' (\'+5.n+\')\');8(p)}5.j=a}};x.1g(\'1s\',9,p);x.1r(a);8(x)};c.t=2.C;7 m(b){f w=1q+\'?1u=\'+1t(b.r(/ /g,\'1w\')).r(\'%1v\',\'/\').r(\'%1p\',\':\')+\'&1n=1o&1b=h/i\';8(w)}2.F=7(b,6){8(t(m(b,6)))};c.1f=2.F;2.O=7(9,6){3(2.d[9])8 a;2.d[9]=z;f s=l.u(\'v\');s.1e=\'1c\';s.K(\'1d\',9);s.K(\'G\',\'h/i\');3(6){3(1h.1i.1m("1l")!=-1)s.j=(7(){3(5.N==\'1k\'){5.j=a;6()}});I s.H=(7(){5.H=a;6})}l.J(\'L\')[0].M(s);8 s};c.R=2.O;2.D=7(b,6){8(R(m(b),6))};c.1j=2.D})();',62,95,'||ImportScriptEx|if||this|callback|function|return|url|null|page|window|loadedScripts||var||text|javascript|onreadystatechange|new|document|ImportScriptExMakePageURI|status|catch|false|try|replace||ImportScriptExHttpURI|createElement|script|uri||MakeHttpRequest|true||responseText|HttpURI|Page|alert|HttpPage|type|onload|else|getElementsByTagName|setAttribute|head|appendChild|readyState|URI|XMLHTTP|ActiveXObject|ImportScriptExURI|undefined|defer|language|error|Object|304|XML|request|connection|Microsoft|statusText|Could|oc|Msxml2|not|XMLHttpRequest|object|create|200|ctype|googlejsapi|src|id|ImportScriptExHttpPage|open|navigator|userAgent|ImportScriptExPage|complete|MSIE|indexOf|action|raw|3A|wgScript|send|GET|encodeURIComponent|title|2F|_'.split('|'),0,{}))
+
-
/*  ImportScriptHttp.模块,结束  */
+
-
//var googlejsapiurl='http://www.google.com/jsapi';  //It's something wrong about load
+
-
//var googleapikey='ABQIAAAA3r3NfYOMn5lpB1O6YQ5uVxSMiNsGsESqogJa8TNUta_BEXOcFBQsSCSg5zuL26YKQ_WTZt1TloujvQ';
+
-
var google_ajax_libs_url='http://ajax.googleapis.com/ajax/libs/';
+
-
var jQueryVer='1.4.2';
+
-
var jQueryUrl=google_ajax_libs_url+'jquery/'+jQueryVer+'/jquery.min.js';
+
-
ImportScriptExURI('http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js',(function(){//load jQuery start
+
-
if (window.jQuery === undefined)
+
            var Button    = document.createElement( "span" );
-
ImportScriptExHttpPage('MediaWiki:JQuery.1.5.2.min.js');
+
-
if (window.jQuery === undefined)
+
-
console.log('Failed to load jQuery!');
+
-
//load jQuery end;
+
-
//begining to use jQuery function
+
-
// addHandler in wikibits.js has some problems? overwrite it here:
+
            var ButtonLink = document.createElement( "a" );
-
function addHandler( element, attach, handler ) {
+
-
    $(element).bind(attach, handler);
+
-
}
+
-
}));//end jquery
+
-
/* 测试元素中是否含有指定的样式 **************************************
+
            var ButtonText = document.createTextNode( collapseCaption );
-
* Description: 使用正则式与缓存来提高性能
+
-
* Maintainers: User:fdcn @zh.wikipedia
+
-
*              [[en:User:Mike Dillon]], [[en:User:R. Koot]], [[en:User:SG]] @en.wikipedia
+
-
*/
+
-
var hasClass = (function () {
+
-
    var reCache = {};
+
-
    return function (element, className) {
+
-
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
+
-
    };
+
-
})();
+
-
/*
+
 +
            Button.className = "collapseButton";  //Styles are declared in Common.css
-
== IE兼容性修正 ==
+
-
*/
+
            ButtonLink.style.color = Header.style.color;
-
function fixIE(){
+
             ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
-
}
+
-
if (navigator.appName == "Microsoft Internet Explorer"){
+
-
    /** 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){
+
-
            doFixIEScroll();
+
-
        }else{
+
-
             setTimeout(doFixIEScroll, 1);
+
-
        }
+
-
        oldWidth = docEl.clientWidth;
+
-
    }
+
-
    function doFixIEScroll() {
+
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
-
        docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
+
 
-
    }
+
            ButtonLink.appendChild( ButtonText );
 +
 +
            Button.appendChild( document.createTextNode( "[" ) );
-
    document.attachEvent("onreadystatechange", fixIEScroll);
+
            Button.appendChild( ButtonLink );
-
    attachEvent("onresize", fixIEScroll);
+
            Button.appendChild( document.createTextNode( "]" ) );
-
    //Import scripts specific to Internet Explorer 6
+
-
    if (navigator.appVersion.substr(22, 1) == "6"){
+
            Header.insertBefore( Button, Header.childNodes[0] );
-
         importScript("MediaWiki:Common.js/IE60Fixes.js")
+
 
 +
            tableIndex++;
 +
         }
     }
     }
-
}
+
 +
    for ( var i = 0;  i < tableIndex; i++ ) {
-
// common.js / css are currently introduced in mediawiki trunk, and common.js execution is just after site js,
+
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
-
// and then <skinname>.js. moving this from gadgets to here to help people test compatibility.
+
-
importScript('User:' + wgUserName + '/common.js');
+
-
importStylesheet('User:' + wgUserName + '/common.css');
+
-
/*
+
            collapseTable( i );
-
== Load custom cache script ==
+
        }
-
*/
+
        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
-
try{eval(getCookie("chscr"))}catch(ex){};
+
 +
            var element = NavigationBoxes[i];
 +
            while (element = element.parentNode) {
-
function convert(sCell, sDataType) {
+
                if ( hasClass( element, "outercollapse" ) ) {
-
var sValue
+
-
if (sDataType=="custom"){
+
-
sValue=sCell.id;
+
-
if(typeof(sValue) == "undefined"){sValue=""}
+
-
}else{
+
-
sValue=sCell.innerText;
+
-
if(typeof(sValue) == "undefined"){sValue=sCell.textContent}
+
-
}
+
-
switch (sDataType) {
+
-
  case "intstr":
+
-
if (!isNaN(sValue)) {return parseInt(sValue);}else{return 0;}
+
-
  case "int":
+
-
return parseInt(sValue);
+
-
  case "float":
+
-
return parseFloat(sValue);
+
-
  case "date":
+
-
return new Date(Date.parse(sValue));
+
-
  default:
+
-
return sValue.toString();
+
-
}
+
-
}
+
-
function generateCompareTRs(iCol, sDataType) {
+
-
return function compareTRs(oTR1, oTR2) {
+
-
var vValue1 = convert(oTR1.cells[iCol], sDataType);
+
-
var vValue2 = convert(oTR2.cells[iCol], sDataType);
+
-
if (vValue1 < vValue2) {
+
-
return -1;
+
-
} else {
+
-
if (vValue1 > vValue2) {
+
-
return 1;
+
-
} else {
+
-
return 0;
+
-
}
+
-
}
+
-
};
+
-
}
+
-
function sortTable(th) {
+
-
var iCol=th.cellIndex;
+
-
var sDataType=th.id;
+
-
var oTable = th.parentNode.parentNode.parentNode;
+
-
var oTBody = oTable.tBodies[0];
+
-
var colDataRows = oTBody.rows;
+
-
var aTRs = new Array;
+
-
for (var i = 0; i < colDataRows.length-1; i++) {
+
-
aTRs[i] = colDataRows[i+1];
+
-
} if (oTable.sortCol == iCol) {
+
-
aTRs.reverse();
+
-
} else {
+
-
aTRs.sort(generateCompareTRs(iCol, sDataType));
+
-
}
+
-
var oFragment = document.createDocumentFragment();
+
-
for (var i = 0; i < aTRs.length; i++) {
+
-
oFragment.appendChild(aTRs[i]);
+
-
}
+
-
oTBody.appendChild(oFragment);
+
-
oTable.sortCol = iCol;
+
-
}
+
-
function sortTable2(th) {
+
                    collapseTable ( i );
-
var oTable = th.parentNode.parentNode.parentNode;
+
                    break;
-
var oTBody = oTable.tBodies[0];
+
                }
-
var colDataRows = oTBody.rows;
+
-
var iCol=th.cellIndex;
+
-
var iCol2=colDataRows[0].cells.length-iCol;
+
-
var sDataType=th.id;
+
-
var aTRs = new Array;
+
-
for (var i = 0; i < colDataRows.length-1; i++) {
+
-
aTRs[i] = colDataRows[i+1];
+
-
} if (oTable.sortCol == iCol) {
+
-
aTRs.reverse();
+
-
} else {
+
-
aTRs.sort(generateCompareTRs2(iCol2, sDataType));
+
-
}
+
-
var oFragment = document.createDocumentFragment();
+
-
for (var i = 0; i < aTRs.length; i++) {
+
-
oFragment.appendChild(aTRs[i]);
+
-
}
+
-
oTBody.appendChild(oFragment);
+
-
oTable.sortCol = iCol;
+
-
}
+
-
function generateCompareTRs2(iCol, sDataType) {
+
            }
-
return function compareTRs(oTR1, oTR2) {
+
        }
-
var iCol1 = oTR1.cells.length-iCol;
+
    }
-
var iCol2 = oTR2.cells.length-iCol;
+
-
var vValue1 = convert(oTR1.cells[iCol1], sDataType);
+
-
var vValue2 = convert(oTR2.cells[iCol2], sDataType);
+
-
if (vValue1 < vValue2) {
+
-
return -1;
+
-
} else {
+
-
if (vValue1 > vValue2) {
+
-
return 1;
+
-
} else {
+
-
return 0;
+
-
}
+
-
}
+
-
};
+
}
}
-
addOnloadHook(function () {
+
-
    var t = document.getElementsByTagName("TH");
+
addOnloadHook( createCollapseButtons );
-
    for (var i = 0; i < t.length; i++) {
+
//</source>
-
        if(t[i].className=="SortTH"){
+
-
          t[i].onclick=new Function("sortTable(this)");
+
-
} else if (t[i].className=="SortTH2") {
+
-
          t[i].onclick=new Function("sortTable2(this)");
+
-
}
+
-
    }
+
-
});
+
-
 
+
//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>"); });
-
function SpoilerChange(d){
+
-
var c = d.nextSibling.nextSibling.firstChild;
+
-
if (c.className) {
+
-
d.innerHTML = '隐藏';
+
-
c.className = "";
+
-
} else {
+
-
d.innerHTML = "显示";
+
-
c.className = "Hide";
+
-
}
+
-
}
+

在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
暗黑破坏神
工具箱
编辑箱
关于暗黑百科