MediaWiki:Gadget-robot.js
Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Internet Explorer / Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
- Opera: Pressione Ctrl-F5.
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:MatchSplit.js&action=raw&ctype=text/javascript');
/*
* Author: w:fr:Phe
*
* Add a diff button to compare the text layer and the current text in Page:, useful after a M&S to check
* if the scan and splitted text are of the same edition.
*
* TODO : open a jquery ui and get some feedback from the server to display a progress bar.
* Change the title of the Diff button if the Diff already exist and ask a confirmation in
* this case. Red tab, diff doesn't exist, blue tab diff exists + confirmation.
*/
window.verify_match = {
callback : function (data) {
if (data['error'] == 0) {
$('#wpRobot-verify-match > a').text('ok')
$('#wpRobot-verify-match > a').attr('href', '/w/index.php?title=' + encodeURIComponent("Discussion " + mw.config.get('wgPageName')) + '/Diff');
} else {
$('#wpRobot-verify-match > a').text(data['text']);
}
},
do_verify_match : function () {
var url = '//tools.wmflabs.org/phetools/verify_match.php?cmd=verify&title='
+ encodeURIComponent(mw.config.get('wgPageName')) + '&lang=' + mw.config.get('wgContentLanguage') + '&user=' + mw.config.get('wgUserName');
$.getJSON(url, function(data) { verify_match.callback(data); } );
},
add_verify_match_button : function () {
var id_name = self.skin == "vector" ? '#p-namespaces' : '#p-cactions';
var $a = $(id_name + ' ul');
if (!$a.length)
return false;
$a[0].innerHTML = $a[0].innerHTML + '<li id="ca-verify-match">' + '<span id="wpRobot-verify-match"><a href="javascript:window.verify_match.do_verify_match();"><span>Diff</span></a></span></li>';
},
setup : function () {
verify_match.add_verify_match_button();
},
};
if (mw.config.get("wgNamespaceNumber") == 'Index')
$(document).ready(window.verify_match.setup);