//This Script is a tweak to recover from broken api calls resulting in ('maintenance') being showed
// The source of this js is from:
//* https://meta.wikimedia.org/w/index.php?title=User:Hedonil/XTools/XTools.js&oldid=12240985
//
//All credits shall go to Hedonil, /MusikAnimal et all as per:
//* https://github.com/x-tools/xtools/graphs/contributors
//
//Version 1.1 - db parameter shall be replaced with project name (<wikidomainname>.wikipedia.org)
// also the interface lannguage is set to farsi, you may change variables under 'Initial Configuration'
//
//Initial Configuration
var uselang= "en"; //mw.config.get('wgContentLanguage');
var project=mw.config.get('wgServer').slice(2);
var xpagehistory = {
loadinganimation : 0
,
execute : function ()
{
if (mw.config.get('wgArticleId') === 0)
return; // no deleted articles, no special pages
if (mw.config.get('wgCurRevisionId') != mw.config.get('wgRevisionId'))
return; // only current revision
var headerline =
"<div "
+"id='xtools' "
+"style='font-size:84%; "
+"line-height:1.2em; "
+"margin:0 0 0.4em 0.2em; "
+"direction: rtl; "
+"width:auto;'"
+
">"
+"<span id='xtoolsresult'></span>"
+"<span id='xtoolsloading'>.</span>"
+"</div>";
$(headerline).insertBefore("#contentSub");
loadinganimation
= window.setInterval(
function() {
if ($("#xtoolsloading").html() == " ")
$("#xtoolsloading").html(" >");
else if ($("#xtoolsloading").html() == " >")
$("#xtoolsloading").html(" - ");
else if ($("#xtoolsloading").html()==" - ")
$("#xtoolsloading").html("< ");
else
$("#xtoolsloading").html(" ");
} , 300);
var toolRoot =
"//tools.wmflabs.org/xtools/api.php"
+"?pageid=" + mw.config.get('wgArticleId')
+ "&nsid=" + mw.config.get('wgNamespaceNumber')
+ "&pagetitle=" + mw.config.get('wgPageName')
+ "&wditemid=" + mw.config.get('wgWikibaseItemId')
+ "&project="+project
+"&uselang="+uselang;
mw.loader.load(toolRoot);
}
,
resultloaded : function( res )
{
var pure=res
.replace(/Results:/, "نتایج")
.replace(/شده توسط:/g,"سازنده")
//.replace(/کنندگان/g,"کننده")
.replace(/کنندگان/g,"")
.replace(/ایجاد/g,"")
.replace(/XAgent configuration/g, "تنظیمات")
.replace(/Wikidata:/g, "ویکی"+String.fromCharCode(0x200C)+"داده")
.replace(/LanguageTool:/g, "ابزار"+String.fromCharCode(0x0020)+"زبانی")
.replace(/Dead links:/g, "پیوند"+String.fromCharCode(0x0020)+"خراب")
.replace(/Checkwiki:/g, "چک"+String.fromCharCode(0x200C)+"ویکی")
.replace(/\(/g,String.fromCharCode(0x00AB))
.replace(/\)/g,String.fromCharCode(0x00BB))
.replace(/\,/g,String.fromCharCode(0x060C))
//.replace(/\+/g," بیش از ")
.replace(/·/g,String.fromCharCode(0x002E))
.replace(/[^-&=]\s*\d{0,4}\+\d{0,4}[^\/]/g,function(x) {
return x.replace(/\d/g, function(t) {
return String.fromCharCode(t.charCodeAt(0) + 0x06C0);
}).replace(/\+/g, "قدمت بیش از ");
})
.replace(/(«)(\d{1,3})( روز)/g,function(x, a, v, c) {
return a
+v.replace(/\d/g, function(t) {
return String.fromCharCode(t.charCodeAt(0) + 0x06C0);
})
+c;
})
.replace(/[^\d="]{0,3}30[^\d^=^"]{0,3}/g, function(f, x) {
return f.replace(/\d/g, function(t) {
return String.fromCharCode(t.charCodeAt(0) + 0x06C0);
});
})
.replace(/<a style="border-bottom:1px dotted "/g, "<a style=\"direction: rtl; border-bottom:1px dotted \"")
.replace(/<a href/g, "<a style=\"direction: rtl;\" href")
.replace(/«test»/g, "«آز»")
.replace(/ها،/g, "،")
.replace(/< ۳۰/g, "کمتر از ۳۰")
.replace(/۳۰ >/g, "کمتر از ۳۰")
.replace(/، –/g, "،")
.replace(/– ،/g, "،")
.replace(/<\/a> «<a/g, "</a> شمار ویرایش «<a")
.replace(/–/g, "")
.replace(/قدمت بیش از ۰ دقیقه/g, "داغ")
;
var rePure = pure.replace(/Revisions/g,"نسخه")
.replace(/Authors/g,"نویسنده")
.replace(/Created by/g,"سازنده")
.replace(/Pageviews/g,"نمایش")
.replace(/Created by/g,"سازنده")
.replace(/Created by/g,"سازنده")
;
var split = res.Split (" ()\\-,");
$("#xtoolsresult").html(rePure);
this.stoploading();
}
,
stoploading : function()
{
clearInterval(loadinganimation);
$('#xtoolsloading').remove();
}
};
if ( (mw.config.get('wgAction') == "view") )
$( xpagehistory.execute );