User:IagoQnsi/OgreGalleryUpdater.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.
This user script seems to have a documentation page at User:IagoQnsi/OgreGalleryUpdater. |
mw.loader.using( ['mediawiki.util'] , function () {
$(document).ready( function () {
// find the existing update link
var link = $('#mw-content-text').find('a[href^="//tools.wmflabs.org/magog/update-report.php?type="]:first');
if (link.length == 1) {
var href = link.attr('href');
// pull out the parameters
var start = mw.util.getParamValue('start', link.attr('href'));
var type = mw.util.getParamValue('type', link.attr('href'));
// which type of report is this link for?
var postUrl;
if (type == 'report') {
postUrl = '//tools.wmflabs.org/magog/UpdateNewUploads.php';
} else if (type == 'uploads') {
postUrl = '//tools.wmflabs.org/magog/UpdateUploadReport.php';
} else {
postUrl = false;
console.log("OgreGalleryUpdater.js: Found link with unknown report type '"+type+"'. Leave a note on IagoQnsi's talk page about this (and include the name of the page you saw this message on).");
}
if (start && postUrl !== false ) {
// make a new link to appear beside the old one
var ajaxLink = $("<a class='ogre-gallery-updater-link' style='margin-left:10px'>(Ajax)</a>");
ajaxLink.attr('href', href);
ajaxLink.click(function(event) {
event.preventDefault();
mw.notify('Sending update request to OgreBot...', { tag: 'OgreGalleryUpdater' });
$.ajax({
url: postUrl,
method: 'POST',
data: {
project: 'commons.wikimedia',
start: start
},
complete: function(jqXHR, textStatus) {
mw.notify('Update request complete! Reloading now...', { tag: 'OgreGalleryUpdater' });
location.reload();
}
});
});
// show the button now that we've finished executing everything
link.after(ajaxLink);
}
}
});
});