MediaWiki:LAPI.js

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 06:40, 23 April 2021 by Vish (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
var LAPI_file_store,LAPI;void 0===window.LAPI_file_store&&(LAPI_file_store="(https?:)?//static\\.jojowiki\\.com/"),Object.clone=function(e,t){if(!e)return null;var n,r={};for(n in e)(t||e.hasOwnProperty(n))&&(r[n]=e[n]);return r},Object.merge=function(e,t,n){if(!e)return t;for(var r in e)(n||e.hasOwnProperty(r))&&(t[r]=e[r]);return t},Object.mergeSome=function(e,t,n,r){if(!e)return t;if(!r)return Object.merge(e,t,n);for(var i in e)(n||e.hasOwnProperty(i))&&r(e,t,i)&&(t[i]=e[i]);return t},Object.mergeSet=function(e,t,n){return Object.mergeSome(e,t,n,function(e,t,n){return null!==e[n]})},String.prototype.trimLeft||(String.prototype.trimLeft=function(e){return e?this.replace(new RegExp("^["+e.escapeRE()+"]+"),""):this.replace(/^\s\s*/,"")}),String.prototype.trimFront=String.prototype.trimLeft,String.prototype.trimRight||(String.prototype.trimRight=function(e){return e?this.replace(new RegExp("["+e.escapeRE()+"]+$"),""):this.replace(/\s\s*$/,"")}),String.prototype.trimEnd=String.prototype.trimRight,String.prototype.startsWith||(String.prototype.startsWith=function(e){return 0===this.indexOf(e)}),String.prototype.endsWith||(String.prototype.endsWith=function(e){return this.lastIndexOf(e)+e.length===this.length}),String.prototype.contains=function(e){return 0<=this.indexOf(e)},String.prototype.replaceAll=function(e,t){return this.split(e).join(t)},String.prototype.stringifyJS=function(){return this.replace(/([\\'"]|%5C|%27|%22)/g,"\\$1").replace(/\n/g,"\\n")},String.prototype.escapeRE=function(){return this.replace(/([\\{}()|.?*+^$[\]])/g,"\\$1")},String.prototype.escapeXML=function(e,t){var n=this.replace(/&/g,"&amp;").replace(/\xa0/g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return e&&(n=n.replace(/"/g,"&quot;")),t&&(n=n.replace(/'/g,"&apos;")),n},String.prototype.decodeXML=function(){return this.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&nbsp;/g," ").replace(/&amp;/g,"&")},String.prototype.capitalizeFirst=function(){return this.substring(0,1).toUpperCase()+this.substring(1)},String.prototype.lowercaseFirst=function(){return this.substring(0,1).toLowerCase()+this.substring(1)},String.prototype.getParamValue=function(e){e=new RegExp("[&?]"+e.escapeRE()+"=([^&#]*)").exec(this);return e&&2<=e.length?decodeURIComponent(e[1]):null},String.getParamValue=function(e,t){t=t||document.location.href;try{return t.getParamValue(e)}catch(e){return null}},Function.prototype.bind||(Function.prototype.bind=function(e){var t=this,n=e,r=Array.prototype.slice,i=r.call(arguments,1);return function(){return t.apply(n,i.concat(r.call(arguments)))}}),Array.filter||(Array.filter=function(e,t,n){if(null===e)return null;if("function"==typeof e.filter)return e.filter(t,n);if("function"!=typeof t)throw new Error("Array.filter: predicate must be a function");var r=e.length,i=[];n&&(t=t.bind(n));for(var o,a=0;a<r;a++)a in e&&(t(o=e[a],a,e)&&(i[i.length]=o));return i}),Array.select=Array.filter,Array.forEach||(Array.forEach=function(e,t,n){if(null!==e)if("function"!=typeof e.forEach){if("function"!=typeof t)throw new Error("Array.forEach: iterator must be a function");var r=e.length;n&&(t=t.bind(n));for(var i=0;i<r;i++)i in e&&t(e[i],i,e)}else e.forEach(t,n)}),Array.every||(Array.every=function(e,t,n){if(null===e)return!0;if("function"==typeof e.every)return e.every(t,n);if("function"!=typeof t)throw new Error("Array.every: predicate must be a function");var r=e.length;n&&(t=t.bind(n));for(var i=0;i<r;i++)if(i in e&&!t(e[i],i,e))return!1;return!0}),Array.forAll=Array.every,Array.some||(Array.some=function(e,t,n){if(null===e)return!1;if("function"==typeof e.some)return e.some(t,n);if("function"!=typeof t)throw new Error("Array.some: predicate must be a function");var r=e.length;n&&(t=t.bind(n));for(var i=0;i<r;i++)if(i in e&&t(e[i],i,e))return!0;return!1}),Array.exists=Array.some,Array.map||(Array.map=function(e,t,n){if(null===e)return null;if("function"==typeof e.map)return e.map(t,n);if("function"!=typeof t)throw new Error("Array.map: mapper must be a function");var r=e.length,i=[];n&&(t=t.bind(n));for(var o=0;o<r;o++)o in e&&(i[o]=t(e[o],o,e));return i}),Array.indexOf||(Array.indexOf=function(e,t,n){if(null===e)return-1;if("function"==typeof e.indexOf)return e.indexOf(t,n);if(!e.length)return-1;var r=e.length;for((n=(n=!isNaN(n)&&n||0)<0?Math.ceil(n):Math.floor(n))<0&&(n+=r),n<0&&(n=0);n<r;){if(n in e&&e[n]===t)return n;n+=1}return-1}),Array.remove=function(e,t){t=Array.indexOf(e,t);0<=t&&e.splice(t,1)},Array.contains=function(e,t){return 0<=Array.indexOf(e,t)},Array.flatten=function(e){var t=[];return Array.forEach(e,function(e){t=t.concat(e)}),t},Array.any=function(e,t,n){if(null===e)return null;if("function"!=typeof t)throw new Error("Array.any: selector must be a function");var r,i=e.length;n&&(t=t.bind(n));for(var o=0;o<i;o++)if(o in e&&null!==(r=t(e[o],o,e)))return r;return null},Array.make=function(e){if(!e||!e.length)return null;for(var t=[],n=e.length,r=0;r<n;r++)r in e&&(t[t.length]=e[r]);return t},window.LAPI||(LAPI=window.LAPI={Ajax:{getRequest:function(){var t=null;try{t=new XMLHttpRequest}catch(e){if(t=null,window.ActiveXObject)if(LAPI.Ajax.getRequest.msXMLHttpID)LAPI.Ajax.getRequest.msXMLHttpID&&(t=new ActiveXObject(LAPI.Ajax.getRequest.msXMLHttpID));else{for(var n=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],r=0;r<n.length&&!t;r++)try{(t=new ActiveXObject(n[r]))&&(LAPI.Ajax.getRequest.msXMLHttpID=n[r])}catch(e){t=null}t||(LAPI.Ajax.getRequest.msXMLHttpID=null)}}return t}},$:function(e,t,n){return e&&e.length?(t=t||document,"string"==typeof e?("#"===e[0]&&(e=e.substring(1)),0<e.length?t.getElementById(e):null):n?Array.map(e,function(e){return LAPI.$(e,t)}):Array.any(e,function(e){return LAPI.$(e,t)})):null},make:function(e,t,n,r){if(r=r||document,!e||!e.length)throw new Error("No tag for LAPI.make");r=r.createElement(e);return Object.mergeSet(t,r),Object.mergeSet(n,r.style),/^(form|input|button|select|textarea)$/.test(e)&&r.id&&0<r.id.length&&!r.name&&(r.name=r.id),r},formatException:function(e,t){var n=e.name||"",r=e.message||"",i=null,o=null;if(r&&0<r.length&&"#"===r[0]?r=r.substring(1):(i=e.fileName||e.sourceURL||null,o=e.lineNumber||e.line||null),n||r){if(t){t=LAPI.make("div");return t.appendChild(document.createTextNode("Exception "+n+": "+r)),i&&(t.appendChild(LAPI.make("br")),t.appendChild(document.createTextNode("File "+i+(o?" ("+o+")":"")))),t}return"Exception "+n+": "+r+(i?"\nFile "+i+(o?" ("+o+")":""):"")}return null}}),LAPI.Browser||(LAPI.Browser=function(e){var t,n={},r=(n.client=e).match(/applewebkit\/(\d+)/);return n.is_webkit=null!==r,n.is_safari=n.is_webkit&&!e.contains("spoofer"),n.webkit_version=r?parseInt(r[1]):0,n.is_khtml="KDE"===navigator.vendor||document.childNodes&&!document.all&&!navigator.taintEnabled&&navigator.accentColorName,n.is_gecko=e.contains("gecko")&&!/khtml|spoofer|netscape\/7\.0/.test(e),n.is_ff_1=e.contains("firefox/1"),n.is_ff_2=e.contains("firefox/2"),n.is_ff_ge_2=/firefox\/[2-9]|minefield\/3/.test(e),n.is_ie=e.contains("msie")||!!window.ActiveXObject,n.is_ie_lt_7=!1,n.is_ie&&(t=/msie ((\d|\.)+)/.exec(e),n.is_ie_lt_7=null!==t&&parseFloat(t[1])<7),n.is_opera=e.contains("opera"),n.is_opera_ge_9=!1,n.is_opera_95=!1,n.is_opera&&(r=/opera\/((\d|\.)+)/.exec(e),n.is_opera_95=r&&9.5<=parseFloat(r[1]),n.is_opera_ge_9=r&&9<=parseFloat(r[1])),n.is_mac=e.contains("mac"),n}(navigator.userAgent.toLowerCase())),LAPI.DOM||(LAPI.DOM={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12,cleanAttributeName:function(e){if(!LAPI.Browser.is_ie)return e;LAPI.DOM.cleanAttributeName._names||(LAPI.DOM.cleanAttributeName._names={class:"className",cellspacing:"cellSpacing",cellpadding:"cellPadding",colspan:"colSpan",maxlength:"maxLength",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",valign:"vAlign"});e=e.toLowerCase();return LAPI.DOM.cleanAttributeName._names[e]||e},importNode:function(t,e,n){if(!e)return null;if(t.importNode)return t.importNode(e,n);if(e.ownerDocument===t)return e.cloneNode(n);var r=null;switch(e.nodeType){case LAPI.DOM.ELEMENT_NODE:return r=t.createElement(e.nodeName),Array.forEach(e.attributes,function(e){e&&e.nodeValue&&0<e.nodeValue.length&&r.setAttribute(LAPI.DOM.cleanAttributeName(e.name),e.nodeValue)}),r.style.cssText=e.style.cssText,n&&Array.forEach(e.childNodes,function(e){e=LAPI.DOM.importNode(t,e,!0);e&&r.appendChild(e)}),r;case LAPI.DOM.TEXT_NODE:return t.createTextNode(e.nodeValue);case LAPI.DOM.CDATA_SECTION_NODE:return t.createCDATASection?t.createCDATASection(e.nodeValue):t.createTextNode(e.nodeValue);case LAPI.DOM.COMMENT_NODE:return t.createComment(e.nodeValue);default:return null}},parse:function(e,t){var n=null;try{n=function(e,t){if("undefined"!=typeof DOMParser){var n=new DOMParser;if(n&&n.parseFromString)return n.parseFromString(e,t)}if(LAPI.Browser.is_ie){var r=null;if(LAPI.DOM.parse.msDOMDocumentID)LAPI.DOM.parse.msDOMDocumentID&&(r=new ActiveXObject(LAPI.DOM.parse.msDOMDocumentID));else{for(var i=["MSXML6.DOMDocument","MSXML5.DOMDocument","MSXML4.DOMDocument","MSXML3.DOMDocument","MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DomDocument","Microsoft.XmlDom"],o=0;o<i.length&&!r;o++)try{(r=new ActiveXObject(i[o]))&&(LAPI.DOM.parse.msDOMDocumentID=i[o])}catch(e){r=null}r||(LAPI.DOM.parse.msDOMDocumentID=null)}if(r)return r.async=!1,r.loadXML(e),r}return t=t||"application/xml",(n=LAPI.Ajax.getRequest())?(n.open("GET","data:"+t+";charset=utf-8,"+encodeURIComponent(e),!1),n.overrideMimeType&&n.overrideMimeType(t),n.send(null),n.responseXML):null}(e,t)}catch(e){n=null}return((!n||!n.documentElement)&&(0<=e.search(/^\s*(<xml[^>]*>\s*)?<!doctype\s+html/i)||0<=e.search(/^\s*<html/i))||n&&LAPI.Browser.is_ie&&!n.documentElement&&n.parseError&&0!==n.parseError.errorCode&&n.parseError.reason.contains("Error processing resource")&&n.parseError.reason.contains("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"))&&(n=LAPI.DOM.fakeHTMLDocument(e)),n},parseHTML:function(e){return LAPI.DOM.fakeHTMLDocument(e)},fakeHTMLDocument:function(e){var t=/<body.*?>/.exec(e);if(!t||!t.length)return null;t=t.index+t[0].length;var n=e.lastIndexOf("</body>");if(n<0)return null;n=(n=e.substring(t,n)).replace(/<script(.|\s)*?\/script>/g,"");return new LAPI.DOM.DocumentFacade(n)},isValid:function(e){if(!e)return e;if(e.parseError){if(0!==e.parseError.errorCode)throw new Error("XML parse error: "+e.parseError.reason+" line "+e.parseError.line+" col "+e.parseError.linepos+"\nsrc = "+e.parseError.srcText)}else{var t=e.documentElement;if(/^parsererror$/i.test(t.tagName))throw new Error("XML parse error: "+t.getInnerText())}return e},hasClass:function(e,t){return!!e&&(" "+e.className+" ").contains(" "+t+" ")},setContent:function(e,t){return null===t||(LAPI.DOM.removeChildren(e),t.nodeName?e.appendChild(t):void 0!==e.innerHTML?e.innerHTML=t.toString():e.appendChild(document.createTextNode(t.toString()))),e},makeImage:function(e,t,n,r,i){return LAPI.make("img",{src:e,width:String(t),height:String(n),title:r},i)},makeButton:function(e,t,n,r,i){return LAPI.make("input",{id:e||"",type:r?"submit":"button",value:t,onclick:n},i)},makeLabel:function(e,t,n,r){r=LAPI.make("label",{id:e||"",htmlFor:n},null,r);return LAPI.DOM.setContent(r,t)},makeLink:function(e,t,n,r,i){i=LAPI.make("a",{href:e,title:n,onclick:r},null,i);return LAPI.DOM.setContent(i,t||e)},getInnerText:function(e){if(e.textContent)return e.textContent;if(e.innerText)return e.innerText;var t="";return e.nodeType===LAPI.DOM.TEXT_NODE?t=e.nodeValue:Array.forEach(e.childNodes,function(e){switch(e.nodeType){case LAPI.DOM.ELEMENT_NODE:t+=LAPI.DOM.getInnerText(e);break;case LAPI.DOM.TEXT_NODE:t+=e.nodeValue}}),t},removeNode:function(e){return e.parentNode&&e.parentNode.removeChild(e),e},removeChildren:function(e){for(;e.firstChild;)e.removeChild(e.firstChild);return e},insertNode:function(e,t){return t.parentNode.insertBefore(e,t),e},insertAfter:function(e,t){var n=t.nextSibling;return t.parentNode.insertBefore(e,n),e},replaceNode:function(e,t){return e.parentNode.replaceChild(e,t),t},isParentOf:function(e,t){for(;t&&t!==e&&t.parentNode;)t=t.parentNode;return t===e},currentStyle:function(e,t){function n(e){if("cssFloat"===e)return"styleFloat";e=e.split("-");return(e=(e=Array.map(e,function(e){return e&&e.capitalizeFirst()})).join("")).lowercaseFirst()}if(e.ownerDocument.defaultView&&e.ownerDocument.defaultView.getComputedStyle)return"cssFloat"===t&&(t="float"),e.ownerDocument.defaultView.getComputedStyle(e,null).getPropertyValue(t);var r,i=e.currentStyle?e.currentStyle[t]||e.currentStyle[n(t)]:e.style[t]||e.style[n(t)];!/^\d+(px)?$/i.test(i)&&/^\d/.test(i)&&e.runtimeStyle&&(r=e.style.left,t=e.runtimeStyle.left,e.runtimeStyle.left=e.currentStyle.left,e.style.left=i||0,i=e.style.pixelLeft+"px",e.style.left=r,e.runtimeStyle.left=t)},loadImage:function(e,t,n,r,i,o,a){var s,l;i&&t?(s=null,n?0<=(i=t.lastIndexOf("/"))&&(s=t.substring(0,i)+t.substring(i).replace(/^\/\d+px-/,"/"+n+"px-")):t&&(s=t),s?(l=LAPI.make("img",{src:s},{position:"absolute",top:"0px",left:"0px",display:"none"}),n&&(l.width=String(n)),r&&(l.height=String(r)),LAPI.Evt.attach(l,"load",function(){o(l)}),document.body.appendChild(l)):a("Cannot load image from url "+t)):LAPI.Ajax.parseWikitext("[["+e+(n?"|"+n+"px":"")+"]]",function(e){var t=LAPI.make("div",null,{position:"absolute",top:"0px",left:"0px",display:"none"});document.body.appendChild(t),t.innerHTML=e;var n=t.getElementsByTagName("img");LAPI.Evt.attach(n[0],"load",function(){o(n[0]),LAPI.DOM.removeNode(t)})},function(e){a("Image loading failed: "+e.status+" "+e.statusText)},!1,null,null,3600)}},LAPI.DOM.DocumentFacade=function(){this.initialize.apply(this,arguments)},LAPI.DOM.DocumentFacade.prototype={initialize:function(e){this.documentElement=LAPI.make("div",null,{display:"none",position:"absolute"}),this.body=LAPI.make("div",null,{position:"relative"}),this.documentElement.appendChild(this.body),document.body.appendChild(this.documentElement),this.body.innerHTML=e;var e=document.getElementsByTagName("form"),t=this;this.forms=Array.select(e,function(e){return LAPI.DOM.isParentOf(t.body,e)}),LAPI.Browser.is_khtml?this.dispose=function(){LAPI.DOM.removeNode(this.documentElement)}:LAPI.DOM.removeNode(this.documentElement),this.allIDs={},this.isFake=!0},createElement:function(e){return document.createElement(e)},createDocumentFragment:function(){return document.createDocumentFragment()},createTextNode:function(e){return document.createTextNode(e)},createComment:function(e){return document.createComment(e)},createCDATASection:function(e){return document.createCDATASection(e)},createAttribute:function(e){return document.createAttribute(e)},createEntityReference:function(e){return document.createEntityReference(e)},createProcessingInstruction:function(e,t){return document.createProcessingInstruction(e,t)},getElementsByTagName:function(e){var i=[];return function e(t,n){t.nodeName.toLowerCase()===n&&(i[i.length]=t);for(var r=t.firstChild;r;)e(r,n),r=r.nextSibling}(this.body,e.toLowerCase()),i},getElementById:function(e){return this.allIDs[e]||(this.allIDs[e]=function e(t,n){if(t.id===n)return t;for(var r=null,i=t.firstChild;i&&!r;)r=e(i,n),i=i.nextSibling;return r}(this.body,e)),this.allIDs[e]}},document.importNode&&(LAPI.DOM.DocumentFacade.prototype.importNode=function(e,t){document.importNode(e,t)})),LAPI.WP||(LAPI.WP={getContentDiv:function(e){return LAPI.$(["bodyContent","mw_contentholder","article"],e)},fullImageSizeFromPage:function(e){var t={width:0,height:0};if(!(n=LAPI.$("mw-imagepage-section-filehistory",e)))return t;try{var n,r=$?$(n).find("td.filehistory-selected"):document.getElementsByClassName(n,"td","filehistory-selected");(n=LAPI.DOM.getInnerText(r[0].nextSibling)).contains("×")||(n=LAPI.DOM.getInnerText(r[0].nextSibling.nextSibling)).contains("×")||(n=null)}catch(e){return t}return n&&(n=n.split("×",2),t.width=parseInt(n.shift().replace(/[^0-9]/g,""),10),n=(n=(n=n.pop()).replace(/(\d)\s*(\d)/g,"$1$2")).split(" ",2).shift().replace(/[^0-9]/g,""),t.height=parseInt(n,10),(isNaN(t.width)||isNaN(t.height))&&(t={width:0,height:0})),t},getPreviewImage:function(e,t){t=LAPI.$("file",t);if(!t)return null;var n=t.getElementsByTagName("img");e=e||mw.config.get("wgTitle");for(var r=0;r<n.length;r++){var i=n[r].getAttribute("src",2);if(i&&i.search(/^data/)&&!(i=decodeURIComponent(i).replace("%26","&")).search(new RegExp("^"+LAPI_file_store+".*/"+e.replace(/ /g,"_").escapeRE()+"(/.*)?$")))return n[r]}return null},pageFromLink:function(e){if(!e)return null;var t=e.getAttribute("href",2);if(!t)return null;e=mw.config.get("wgScript")+"?";if(t.startsWith(e)||t.startsWith(mw.config.get("wgServer")+e)||mw.config.get("wgServer").startsWith("//")&&t.startsWith(document.location.protocol+mw.config.get("wgServer")+e))return t.getParamValue("title");e=mw.config.get("wgArticlePath").replace("$1","");if(t.startsWith(e)||(e=mw.config.get("wgServer")+e),!t.startsWith(e)&&e.startsWith("//")&&(e=document.location.protocol+e),t.startsWith(e))return decodeURIComponent(t.substring(e.length));e=mw.config.get("wgVariantArticlePath");if(e&&0<e.length){e=new RegExp(e.escapeRE().replace("\\$2","[^\\/]*").replace("\\$1","(.*)")).exec(t);if(e&&1<e.length)return decodeURIComponent(e[e.length-1])}var n=mw.config.get("wgActionPaths");if(n)for(var r=0;r<n.length;r++){var i=n[r];if(i&&0<i.length&&(i=i.replace("$1",""),t.startsWith(i)||(i=mw.config.get("wgServer")+i),!t.startsWith(i)&&i.startsWith("//")&&(i=document.location.protocol+i),t.startsWith(i)))return decodeURIComponent(t.substring(i.length))}return null},revisionFromHtml:function(e){var t=null;return t=(t=window.RLCONF?e.match(/RLCONF=\{.*"wgCurRevisionId"\s*:\s*(\d+),/):window.mediaWiki?e.match(/(?:mediaWiki|mw).config.set\(\{.*"wgCurRevisionId"\s*:\s*(\d+),/):e.match(/wgCurRevisionId\s*=\s*(\d+)[;,]/))&&parseInt(t[1],10)}}),LAPI.Ajax.doAction||(mw.loader.load("/index.php?title=MediaWiki:AjaxSubmit.js&action=raw&ctype=text/javascript"),LAPI.Ajax.getXML=function(t,n){var r=null;if(t.responseXML&&t.responseXML.documentElement)r=t.responseXML;else try{r=LAPI.DOM.parse(t.responseText,"text/xml")}catch(e){"function"==typeof n&&n(t,e),r=null}if(r)try{r=LAPI.DOM.isValid(r)}catch(e){"function"==typeof n&&n(t,e),r=null}return r},LAPI.Ajax.getHTML=function(t,n,e){var r=null;try{if(!(r=LAPI.DOM.parseHTML(t.responseText,e)))throw new Error("#Could not understand request result")}catch(e){"function"==typeof n&&n(t,e),r=null}if(r)try{r=LAPI.DOM.isValid(r)}catch(e){"function"==typeof n&&n(t,e),r=null}if(null===r)return r;if(!LAPI.Ajax.getHTML.extraNewlineRE){LAPI.Ajax.getHTML.extraNewlineRE=null;try{var i='<textarea id="test">\nTest</textarea>',o=LAPI.DOM.parseHTML('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">\n<head><title>Test</title></head><body><form><textarea id="test">\nTest</textarea></form></body>\n</html>',"test"),a=String(o.getElementById("test").value);o.dispose&&o.dispose();o=LAPI.make("div",null,{display:"none"});document.body.appendChild(o),o.innerHTML=i,o.firstChild.value!==a&&(LAPI.Ajax.getHTML.extraNewlineRE=/^\r?\n/,o.firstChild.value!==a.replace(LAPI.Ajax.getHTML.extraNewlineRE,"")&&(LAPI.Ajax.getHTML.extraNewlineRE=null)),LAPI.DOM.removeNode(o)}catch(e){LAPI.Ajax.getHTML.extraNewlineRE=null}}if(!r.isFake&&null!==LAPI.Ajax.getHTML.extraNewlineRE)for(var s=r.getElementsByTagName("textarea"),l=0,u=s.length;l<u;l++)s[l].value=s[l].value.replace(LAPI.Ajax.getHTML.extraNewlineRE,"");return r},LAPI.Ajax.get=function(e,t,n,r,i){var o=r;if(r&&"function"==typeof r||(r=function(){}),!n||"function"!=typeof n)throw new Error("No success function supplied for LAPI.Ajax.get "+e+" with arguments "+t.toString());var a=LAPI.Ajax.getRequest();if(a){var s,l="",u=e.indexOf("?");if(u&&(l=e.substring(u+1),e=e.substring(0,u)),null!==t)if("string"==typeof t&&0<t.length)l+=(0<l.length?"&":"")+("&"===t[0]||"?"===t[0]?t.substring(1):t);else for(var c in t)l+=(0<l.length?"&":"")+c,null!==t[c]&&(l+="="+encodeURIComponent(t[c]));if(e.startsWith("//")&&(e=document.location.protocol+e),e.length+l.length+1<(LAPI.Browser.is_ie?2040:4080)?(s="GET",e+="?"+l,l=null):s="POST",a.open(s,e,!0),a.setRequestHeader("Pragma","cache=yes"),a.setRequestHeader("Cache-Control","no-transform"+(t&&t.maxage?", max-age="+t.maxage:"")+(t&&t.smaxage?", s-maxage="+t.smaxage:"")),i)for(var f in i)"overrideMimeType"===f?i[f]&&0<i[f].length&&a.overrideMimeType&&a.overrideMimeType(i[f]):a.setRequestHeader(f,i[f]);l&&a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.onreadystatechange=function(){if(4===a.readyState){try{if(200!==a.status)throw new Error("#Request to server failed. Status: "+a.status+" "+a.statusText+" URI: "+e);if(!a.responseText)throw new Error("#Empty response from server for request "+e)}catch(e){return void r(a,e)}n(a,o)}},a.send(l)}else r(a)},LAPI.Ajax.getPage=function(e,t,n,r,i){t=mw.config.get("wgServer")+mw.config.get("wgScript")+"?title="+encodeURIComponent(e)+(t?"&action="+t:"");LAPI.Ajax.get(t,n,r,i,{overrideMimeType:"application/xml"})},LAPI.Ajax.doAction=function(e,t,a,s,n){if(!e||!t||!s||"function"!=typeof s)throw new Error("Parameter inconsistency in LAPI.Ajax.doAction.");var l=n;n&&"function"==typeof n||(n=function(){}),LAPI.Ajax.getPage(e,t,null,function(t,n){var e=null,r=null,i=null;try{if(!(e=LAPI.Ajax.getHTML(t,n,a)))return;var o=LAPI.$("permissions-errors",e);if(o)throw new Error("#"+LAPI.DOM.getInnerText(o));if(a){if(!(r=LAPI.$(a,e)))throw new Error("#Server reply does not contain mandatory form.");r.wpWatchthis.checked=!!document.getElementById("ca-unwatch")}i=LAPI.WP.revisionFromHtml(t.responseText)}catch(e){return void n(t,e)}s(e,r,l,i)},n)},LAPI.Ajax.submit=function(e,t){try{ajaxSubmit(e,null,t,!0)}catch(e){t(null,e)}},LAPI.Ajax.editPage=function(e,t,n){LAPI.Ajax.doAction(e,"edit","editform",t,n)},LAPI.Ajax.checkEdit=function(e){if(!e)return!0;try{var t=LAPI.Ajax.getHTML(e,function(){throw new Error("Cannot check HTML")});return t?null===LAPI.$(["wikiPreview","editform"],t):!1}catch(e){return!1}},LAPI.Ajax.submitEdit=function(e,r,i){r&&"function"==typeof r||(r=function(){}),i&&"function"==typeof i||(i=function(){}),LAPI.Ajax.submit(e,function(t,e){if(e)i(t,e);else{var n=!1;try{n=t&&200===t.status&&LAPI.Ajax.checkEdit(t)}catch(e){return void i(t,e)}(n?r:i)(t)}})},LAPI.Ajax.apiGet=function(action,params,success,failure){var original_failure=failure;if(failure&&"function"==typeof failure||(failure=function(){}),!success||"function"!=typeof success)throw new Error("No success function supplied for LAPI.Ajax.apiGet "+action+" with arguments "+params.toString());var is_json=!1;null!==params&&(is_json="string"==typeof params?(/format=[^&]+/.test(params)||(params+="&format=json"),/format=json(&|$)/.test(params)):("string"==typeof params.format&&params.format.length||(params.format="json"),"json"===params.format));var uri=mw.config.get("wgServer")+mw.config.get("wgScriptPath")+"/api.php"+(action?"?action="+action:"");LAPI.Ajax.get(uri,params,function(request,failureFunc){if(is_json&&"{"!==request.responseText.trimLeft()[0])failureFunc(request);else{var json;try{json=is_json?eval("("+request.responseText.trimLeft()+")"):null}catch(e){json=null}success(request,json,original_failure)}},failure)},LAPI.Ajax.parseWikitext=function(e,r,t,n,i,o,a){if(t&&"function"==typeof t||(t=function(){}),!r||"function"!=typeof r)throw new Error("No success function supplied for parseWikitext");if(!e&&!o)throw new Error("No wikitext or page supplied for parseWikitext");var s=null;(s=e?{pst:null,text:(n?'<div style="border:1px solid red; padding:0.5em;"><div class="previewnote">{{MediaWiki:Previewnote/'+(i||mw.config.get("wgUserLanguage"))+"}}</div><div>\n":"")+e+(n?'</div><div style="clear:both;"></div></div>':""),title:o||mw.config.get("wgPageName")||"API"}:{pst:null,page:o}).prop="text",s.uselang=i||mw.config.get("wgUserLanguage"),a&&/^\d+$/.test(a=a.toString())&&(s.maxage=a,s.smaxage=a),LAPI.Ajax.apiGet("parse",s,function(e,t,n){t&&t.parse&&t.parse.text?r(t.parse.text["*"],n):n(e,t)},t)},LAPI.Ajax.injectSpinner=function(){},LAPI.Ajax.removeSpinner=function(){},window.jQuery&&window.mediaWiki&&mw.loader?mw.loader.using("jquery.spinner",function(){LAPI.Ajax.injectSpinner=function(e,t){$(e).injectSpinner(t)},LAPI.Ajax.removeSpinner=function(e){$.removeSpinner(e)}}):(window.injectSpinner&&(LAPI.Ajax.injectSpinner=window.injectSpinner),window.removeSpinner&&(LAPI.Ajax.removeSpinner=window.removeSpinner))),LAPI.Pos||(LAPI.Pos={mousePosition:function(e){if(!e||!e.pageX&&!e.clientX)return null;if(e.pageX.evt)return{x:e.pageX,y:e.pageY};var t=LAPI.Pos.scrollOffset(),n=LAPI.Pos.mouse_offset();return{x:e.clientX+t.x-n.x,y:e.clientY+t.y-n.y}},scrollOffset:function(){return{x:LAPI.Pos.getScroll("Left"),y:LAPI.Pos.getScroll("Top")}},getScroll:function(e){e="scroll"+e;return(document.documentElement?document.documentElement[e]:0)||document.body[e]||0},viewport:function(){return{x:LAPI.Pos.getViewport("Width"),y:LAPI.Pos.getViewport("Height")}},getViewport:function(e){if(LAPI.Browser.is_opera_95&&"Height"===e||LAPI.Browser.is_safari&&!document.evaluate)return window["inner"+e];e="client"+e;return LAPI.Browser.is_opera?document.body[e]:(document.documentElement?document.documentElement[e]:0)||document.body[e]||0},position:function(){var c=null;function f(){c={};var e=document.body,t=document.createElement("div");Object.merge({position:"absolute",visibility:"hidden",top:0,left:0,margin:0,border:0,width:"1px",height:"1px"},t.style),t.innerHTML='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>',e.insertBefore(t,e.firstChild);var n=t.firstChild,r=n.firstChild,i=n.nextSibling.firstChild.firstChild;c.doesNotAddBorder=5!==r.offsetTop,c.doesAddBorderForTableAndCells=5===i.offsetTop,n.style.overflow="hidden",n.style.position="relative",c.subtractsBorderForOverflowNotVisible=-5===r.offsetTop;r=e.style.marginTop;e.style.marginTop="1px",c.doesNotIncludeMarginInBodyOffset=0===e.offsetTop,e.style.marginTop=r,e.removeChild(t)}return function(e){if(e===e.ownerDocument.body)return function(e){c||f();var t=e.offsetTop,n=e.offsetLeft;c.doesNotIncludeMarginInBodyOffset&&(t+=parseInt(LAPI.DOM.currentStyle(e,"margin-top"),10)||0,n+=parseInt(LAPI.DOM.currentStyle(e,"margin-left"),10)||0);return{x:n,y:t}}(e);if(e.getBoundingClientRect){var t=e.getBoundingClientRect(),n=LAPI.Pos.scrollOffset();return{x:t.left+n.x,y:t.top+n.y}}c||f();for(var r,i=e,o=i.offsetParent,a=i.ownerDocument,s=a.defaultView.getComputedStyle(i,null),l=i.offsetTop,u=i.offsetLeft;(i=i.parentNode)&&i!==a.body&&i!==a.documentElement;)r=a.defaultView.getComputedStyle(i,null),l-=i.scrollTop,u-=i.scrollLeft,i===o&&(l+=i.offsetTop,u+=i.offsetLeft,!c.doesNotAddBorder||c.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(i.tagName)||(l+=parseInt(r.borderTopWidth,10)||0,u+=parseInt(r.borderLeftWidth,10)||0),o=i.offsetParent),c.subtractsBorderForOverflowNotVisible&&"visible"!==r.overflow&&(l+=parseInt(r.borderTopWidth,10)||0,u+=parseInt(r.borderLeftWidth,10)||0),s=r;return"relative"!==s.position&&"static"!==s.position||(l+=a.body.offsetTop,u+=a.body.offsetLeft),"fixed"===s.position&&(l+=Math.max(a.documentElement.scrollTop,a.body.scrollTop),u+=Math.max(a.documentElement.scrollLeft,a.body.scrollLeft)),{x:u,y:l}}}(),isWithin:function(e,t,n){if(!e||!e.parentNode)return!1;var r=LAPI.Pos.position(e);return(null===t||t>r.x&&t<r.x+e.offsetWidth)&&(null===n||n>r.y&&n<r.y+e.offsetHeight)},mouse_offset:function(){if(LAPI.Browser.is_ie){var e=document.documentElement;if(e){if("function"!=typeof e.getBoundingClientRect)return{x:e.clientLeft,y:e.clientTop};e=e.getBoundingClientRect();return{x:e.left,y:e.top}}}return{x:0,y:0}}}),LAPI.Evt||(LAPI.Evt={listenTo:function(e,t,n,r,i){r=LAPI.Evt.makeListener(e,r);LAPI.Evt.attach(t,n,r,i)},attach:function(e,t,n,r){e.attachEvent?e.attachEvent("on"+t,n):e.addEventListener?e.addEventListener(t,n,r):e["on"+t]=n},remove:function(e,t,n,r){e.detachEvent?e.detachEvent("on"+t,n):e.removeEventListener?e.removeEventListener(t,n,r):e["on"+t]=null},makeListener:function(e,t){var n=e,r=t;return function(e){return r.apply(n,[e||window.event])}},kill:function(e){return"function"==typeof e.preventDefault?(e.stopPropagation(),e.preventDefault()):e.cancelBubble.evt&&(e.cancelBubble=!0),!1}}),LAPI.Edit||(LAPI.Edit=function(){this.initialize.apply(this,arguments)},LAPI.Edit.SAVE=1,LAPI.Edit.PREVIEW=2,LAPI.Edit.REVERT=4,LAPI.Edit.CANCEL=8,LAPI.Edit.prototype={initialize:function(e,t,n,r,i){var o={box:null,preview:null,save:"Save",cancel:"Cancel",nullsave:null,revert:null,post:null};r&&(o=Object.merge(r,o)),this.labels=o,this.timestamp=(new Date).getTime(),this.id="simpleedit_"+this.timestamp,this.view=LAPI.make("div",{id:this.id},{marginRight:"1em"}),this.form=LAPI.make("form",{id:this.id+"_form",action:"",onsubmit:function(){}}),o.box&&((r=LAPI.make("div")).appendChild(LAPI.DOM.makeLabel(this.id+"_label",o.box,this.id+"_text")),this.form.appendChild(r)),this.textarea=LAPI.make("textarea",{id:this.id+"_text",cols:t,rows:n,value:e?e.toString():""}),LAPI.Evt.attach(this.textarea,"keyup",LAPI.Evt.makeListener(this,this.text_changed)),LAPI.Evt.attach(this.textarea,"mouseout",LAPI.Evt.makeListener(this,this.text_changed)),LAPI.Evt.attach(this.textarea,"blur",LAPI.Evt.makeListener(this,this.text_changed)),this.form.appendChild(this.textarea),this.form.appendChild(LAPI.make("br")),this.preview_section=LAPI.make("div",null,{borderBottom:"1px solid #88a",display:"none"}),this.view.insertBefore(this.preview_section,this.view.firstChild),this.save=LAPI.DOM.makeButton(this.id+"_save",o.save,LAPI.Evt.makeListener(this,this.do_save)),this.form.appendChild(this.save),o.preview&&(this.preview=LAPI.DOM.makeButton(this.id+"_preview",o.preview,LAPI.Evt.makeListener(this,this.do_preview)),this.form.appendChild(this.preview)),this.cancel=LAPI.DOM.makeButton(this.id+"_cancel",o.cancel,LAPI.Evt.makeListener(this,this.do_cancel)),this.form.appendChild(this.cancel),this.view.appendChild(this.form),o.post&&(this.post_text=LAPI.DOM.setContent(LAPI.make("div"),o.post),this.view.appendChild(this.post_text)),i&&Object.merge(i,this),"function"!=typeof this.ongettext&&(this.ongettext=function(e){return e}),this.current_mask=LAPI.Edit.SAVE+LAPI.Edit.PREVIEW+LAPI.Edit.REVERT+LAPI.Edit.CANCEL,e&&e.trim().length||!this.preview||(this.preview.disabled=!0),o.revert&&(this.revert=LAPI.DOM.makeButton(this.id+"_revert",o.revert,LAPI.Evt.makeListener(this,this.do_revert)),this.form.insertBefore(this.revert,this.cancel)),this.original_text=""},getView:function(){return this.view},getText:function(){return this.ongettext(this.textarea.value)},setText:function(e){this.textarea.value=e,this.original_text=e,this.text_changed()},changeText:function(e){this.textarea.value=e,this.text_changed()},hidePreview:function(){this.preview_section.style.display="none",this.onpreview&&this.onpreview(this)},showPreview:function(){this.preview_section.style.display="",this.onpreview&&this.onpreview(this)},setPreview:function(e){e.nodeName?(LAPI.DOM.removeChildren(this.preview_section),this.preview_section.appendChild(e)):this.preview_section.innerHTML=e},busy:function(e){e?LAPI.Ajax.injectSpinner(this.cancel,this.id+"_spinner"):LAPI.Ajax.removeSpinner(this.id+"_spinner")},do_save:function(){return this.onsave&&this.onsave(this),!0},do_revert:function(){return this.changeText(this.original_text),!0},do_cancel:function(){return this.oncancel&&this.oncancel(this),!0},do_preview:function(){var t=this;return this.busy(!0),LAPI.Ajax.parseWikitext(this.getText(),function(e){t.busy(!1),t.setPreview(e),t.showPreview()},function(){t.busy(!1)},!0,mw.config.get("wgUserLanguage")||null,mw.config.get("wgPageName")||null),!0},enable:function(e){var t=!1;this.current_mask=e,this.save.disabled=0==(e&LAPI.Edit.SAVE),this.cancel.disabled=0==(e&LAPI.Edit.CANCEL),this.preview&&(0==(e&LAPI.Edit.PREVIEW)?this.preview.disabled=!0:t=!0),this.revert&&(0==(e&LAPI.Edit.REVERT)?this.revert.disabled=!0:t=!0),t&&this.text_changed()},text_changed:function(){var e=this.textarea.value,t=(e=e.trim()).length;return this.preview&&0!=(this.current_mask&LAPI.Edit.PREVIEW)&&(this.preview.disabled=t<=0),this.labels.nullsave&&(this.save.value=0<t?this.labels.save:this.labels.nullsave),this.revert&&(this.revert.disabled=e===this.original_text||this.textarea.value===this.original_text),!0}});