MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Created page with "var ts_image_path = stylepath+"/common/images/"; var ts_image_up = "sort_up.gif"; var ts_image_down = "sort_down.gif"; var ts_image_none = "sort_none.gif"; var ts_europeandate...")
 
No edit summary
}
};
 
$(function() {
var $cargoFields = $('.mw-special-CargoTables #mw-content-text > ul');
if (!$cargoFields.length) return;
var tableName = mw.config.get('wgTitle').match(/\/([^\/]+)$/)[1];
if (!tableName) return;
return new mw.Api().postWithToken('csrf', {
action : 'expandtemplates',
prop : 'wikitext',
text : '{{#invoke:CargoDeclare|main|' + tableName + '|forgadget=yes}}'
}).then(function(data) {
var wikitext = data.expandtemplates.wikitext;
var dict = wikitext.split(';!;!;');
var lookup = {};
dict.forEach(function(entry) {
var tbl = entry.split(':::');
lookup[tbl[0]] = tbl[1];
});
$cargoFields.find('li').each(function() {
var field = $(this).find('strong').html();
var el = document.createElement('span');
if (lookup[field] !== undefined) {
$(el).html(' - ' + lookup[field]);
}
this.appendChild(el);
});
});
});
 
$(function() {
if (!$('.mw-special-Movepage').length) return;
var title = mw.config.get('wgTitle').replace('MovePage/', '');
return new mw.Api().get({
action : 'query',
prop:'info',
titles:'Data:' + title
}).then(function(data) {
if (data.query.pages["-1"] !== undefined) return;
var el = document.createElement('div');
var url = mw.config.get('wgServer') + '/Data:' + title;
$(el).html('Warning! A <a href="' + url + '">Data page</a> exists for this page!');
$(el).addClass('important-notice');
$(el).insertAfter(document.getElementById('wpReason'));
});
});
 
/**

Navigation menu