User:Abbe98/warper-viewer.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Abbe98/warper-viewer. |
(function(mw, $) {
// stuff should only happen in the File namespace
if (mw.config.values.wgCanonicalNamespace === 'File') {
// use the Mediawiki API to check for the use of Template:Map on this page
$.ajax({
url: 'https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=templates&redirects=1&tllimit=100&pageids=' + mw.config.values.wgArticleId,
success: function(result) {
var templates = result.query.pages[mw.config.values.wgArticleId].templates;
for (var key in templates) {
if (templates[key].title === 'Template:Map') {
var map = 'https://tools.wmflabs.org/warped-to-iframe/map.php?opacity=true&lang=' + mw.config.values.wgUserLanguage + '&pageid=' + mw.config.values.wgArticleId;
$('#mw-content-text')
.append('<h2>Georeferenced Map</h2>')
.append('<iframe src="' + map + '" width="640" height="480" style="border:0;"></iframe>');
break;
}
}
}
});
}
})(mediaWiki, jQuery);