MediaWiki:Common.js: Difference between revisions
From Heroes of Might and Magic: Olden Era Official Wiki
No edit summary Tag: Reverted |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 43: | Line 43: | ||
var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({ | var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({ | ||
title: 'MediaWiki:HeroPlanner.js', | title: 'MediaWiki:HeroPlanner.js', | ||
action: 'raw', | |||
ctype: 'text/javascript', | |||
version: VERSION | |||
}); | |||
mw.loader.load(scriptUrl); | |||
} | |||
}); | |||
/* Load the Data:Update logic. */ | |||
mw.hook('wikipage.content').add(function () { | |||
if (mw.config.get('wgPageName').includes('Data:Update')) { | |||
var VERSION = '1'; // Bump this string when you need to ensure no cache | |||
var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({ | |||
title: 'MediaWiki:UpdateTool.js', | |||
action: 'raw', | action: 'raw', | ||
ctype: 'text/javascript', | ctype: 'text/javascript', | ||
| Line 53: | Line 67: | ||
/* Load the Data:Diff logic. */ | /* Load the Data:Diff logic. */ | ||
mw.hook('wikipage.content').add(function () { | mw.hook('wikipage.content').add(function () { | ||
if (mw.config.get('wgPageName').includes('Diff')) { | if (mw.config.get('wgPageName').includes('Data:Diff')) { | ||
var VERSION = '1'; // Bump this string when you need to ensure no cache | var VERSION = '1'; // Bump this string when you need to ensure no cache | ||
var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({ | var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({ | ||
Latest revision as of 14:25, 13 October 2026
/* Any JavaScript here will be loaded for all users on every page load. */
$(function() {
var $box = $('#spellboxv-display');
$('.spell-link').hover(
function() {
var spellName = $(this).data('spell');
var apiUrl = mw.util.wikiScript('api');
$.post(apiUrl, {
action: 'parse',
format: 'json',
text: '{{#invoke:SpellTableUtil|spellBoxV|name=' + spellName + '}}',
contentmodel: 'wikitext'
}, function(data) {
var html = data.parse.text['*'];
$box.html(html).show();
});
},
function() {
$box.hide().empty();
}
);
});
/* Purge cache button for the toolbox sidebar. */
mw.loader.using('mediawiki.util').then(function () {
mw.util.addPortletLink(
'p-tb',
mw.util.getUrl(null, {
action: 'purge',
forcelinkupdate: 1
}),
'Update page cache',
't-purge'
);
});
/* Load the HeroPlanner logic. */
mw.hook('wikipage.content').add(function () {
if (mw.config.get('wgPageName').includes('Hero_Planner')) {
var VERSION = '1'; // Bump this string when you need to ensure no cache
var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({
title: 'MediaWiki:HeroPlanner.js',
action: 'raw',
ctype: 'text/javascript',
version: VERSION
});
mw.loader.load(scriptUrl);
}
});
/* Load the Data:Update logic. */
mw.hook('wikipage.content').add(function () {
if (mw.config.get('wgPageName').includes('Data:Update')) {
var VERSION = '1'; // Bump this string when you need to ensure no cache
var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({
title: 'MediaWiki:UpdateTool.js',
action: 'raw',
ctype: 'text/javascript',
version: VERSION
});
mw.loader.load(scriptUrl);
}
});
/* Load the Data:Diff logic. */
mw.hook('wikipage.content').add(function () {
if (mw.config.get('wgPageName').includes('Data:Diff')) {
var VERSION = '1'; // Bump this string when you need to ensure no cache
var scriptUrl = mw.util.wikiScript('index') + '?' + $.param({
title: 'MediaWiki:DiffTool.js',
action: 'raw',
ctype: 'text/javascript',
version: VERSION
});
mw.loader.load(scriptUrl);
}
});


