XTools/ArticleInfo.js: Difference between revisions
< XTools
Content deleted Content added
MusikAnimal (talk | contribs) updates following more recent changes from Vector-2022; upstream isn't fixed yet so this is a hotfix |
MusikAnimal (talk | contribs) sync with https://xtools.wmcloud.org/articleinfo-gadget.js though this may not completely fix it |
||
Line 4: | Line 4: | ||
* Documentation: mediawiki.org/wiki/XTools/ArticleInfo_gadget |
* Documentation: mediawiki.org/wiki/XTools/ArticleInfo_gadget |
||
* Released under GPL 3.0+ license |
* Released under GPL 3.0+ license |
||
* For updates, please copy and paste from https://xtools. |
* For updates, please copy and paste from https://xtools.wmcloud.org/articleinfo-gadget.js |
||
*/ |
*/ |
||
$(function () { |
$(function () { |
||
Line 16: | Line 16: | ||
markup = "<div id='xtools' style='font-size:84%; line-height:1.2em;" + |
markup = "<div id='xtools' style='font-size:84%; line-height:1.2em;" + |
||
"width:auto;'><span id='xtools_result'>.</span></div>"; |
"width:auto;'><span id='xtools_result'>.</span></div>"; |
||
⚫ | |||
⚫ | |||
$result = $('#xtools_result'); |
$result = $('#xtools_result'); |
||
Line 31: | Line 30: | ||
$.get( |
$.get( |
||
'https://xtools. |
'https://xtools.wmcloud.org/api/page/articleinfo/' + |
||
mw.config.get('wgServerName') + '/' + |
mw.config.get('wgServerName') + '/' + |
||
mw.config.get('wgPageName').replace(/["?%&+\\]/g, escape) + '?format=html' + |
mw.config.get('wgPageName').replace(/["?%&+\\]/g, escape) + '?format=html' + |
Revision as of 03:27, 20 April 2023
/**
* 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.wmcloud.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 current revision
mw.config.get('wgAction') !== 'view') { // only when viewing a page, not editing
return;
}
var $result,
markup = "<div id='xtools' style='font-size:84%; line-height:1.2em;" +
"width:auto;'><span id='xtools_result'>.</span></div>";
$(markup).insertBefore('#contentSub');
$result = $('#xtools_result');
var loadinganimation = window.setInterval(function () {
if ($result.html() === '. ') {
$result.html(' . ');
} else if ($result.html() === ' . ') {
$result.html(' .');
} else {
$result.html('. ');
}
}, 300);
$.get(
'https://xtools.wmcloud.org/api/page/articleinfo/' +
mw.config.get('wgServerName') + '/' +
mw.config.get('wgPageName').replace(/["?%&+\\]/g, escape) + '?format=html' +
'&uselang=' + mw.config.get('wgUserLanguage')
).done(function (result) {
$result.html(result);
clearInterval(loadinganimation);
});
});