User:WikiDwarf/ArticleInfo.js: Difference between revisions
(Created page with "→* * XTools ArticleInfo gadget * Based on meta.wikimedia.org/wiki/User:Hedonil/XTools * Documentation: mediawiki.org/wiki/XTools/ArticleInfo_gadget * Released under GPL 3.0+ license * For updates, please copy and paste from https://xtools.wmflabs.org/articleinfo-gadget.js: $(function () { if (mw.config.get('wgArticleId') === 0 || // no deleted articles, no special pages mw.config.get('wgCurRevisionId') !== mw.config.get('wgRevisionId') || // only...") |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
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 | |||
$("<div id='xtools' style='font-size:84%; line-height:1.2em; margin:0 0 0.4em 0.2em; width:auto;'><span id='xtoolsresult'></span><span id='xtoolsloading'>.</span></div>").insertBefore("#contentSub"); | |||
loadinganimation = window.setInterval( function() { if ($("#xtoolsloading").html() == ". ") $("#xtoolsloading").html(" . "); else if ($("#xtoolsloading").html() == " . ") $("#xtoolsloading").html(" ."); else $("#xtoolsloading").html(". "); }, 300); | |||
mw.loader.load("//tools.wmflabs.org/xtools/api.php?pageid=" + mw.config.get('wgArticleId') + "&pagetitle=" + mw.config.get('wgPageName') + "&project=" + mw.config.get('wgServer').slice(2) + "&uselang=" + mw.config.get('wgContentLanguage') ); | |||
}, | |||
resultloaded : function( res ) { | |||
$("#xtoolsresult").html(res); | |||
this.stoploading(); | |||
}, | |||
stoploading : function() { | |||
clearInterval(loadinganimation); | |||
$('#xtoolsloading').remove(); | |||
} | |||
}; | |||
if ( (mw.config.get('wgAction') == "view") ) $( xpagehistory.execute ); | |||
}); |
Revision as of 11:43, 21 February 2022
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
$("<div id='xtools' style='font-size:84%; line-height:1.2em; margin:0 0 0.4em 0.2em; width:auto;'><span id='xtoolsresult'></span><span id='xtoolsloading'>.</span></div>").insertBefore("#contentSub");
loadinganimation = window.setInterval( function() { if ($("#xtoolsloading").html() == ". ") $("#xtoolsloading").html(" . "); else if ($("#xtoolsloading").html() == " . ") $("#xtoolsloading").html(" ."); else $("#xtoolsloading").html(". "); }, 300);
mw.loader.load("//tools.wmflabs.org/xtools/api.php?pageid=" + mw.config.get('wgArticleId') + "&pagetitle=" + mw.config.get('wgPageName') + "&project=" + mw.config.get('wgServer').slice(2) + "&uselang=" + mw.config.get('wgContentLanguage') );
},
resultloaded : function( res ) {
$("#xtoolsresult").html(res);
this.stoploading();
},
stoploading : function() {
clearInterval(loadinganimation);
$('#xtoolsloading').remove();
}
};
if ( (mw.config.get('wgAction') == "view") ) $( xpagehistory.execute );