User:Locke/common.js
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+R (Command+R on a Mac)
- Google Chrome: press Ctrl+Shift+R (Command+Shift+R on a Mac)
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl+F5
- Konqueror: click Reload or press F5
- Opera: clear the cache in Tools → Preferences
if (mw.user.tokens.exists('patrolToken')) { // add patrol link under diff-multi notice var $diffMultiNotice = $('td.diff-multi'); if ($diffMultiNotice.length > 0) { var $patrolAllLink = $('<a href="#">Mark all as patrolled</a>'); $diffMultiNotice.append('<br>').append($patrolAllLink); // patrol link click handler $patrolAllLink.click(function() { mw.loader.load('jquery.spinner'); mw.loader.load('mediawiki.notification'); // replace text with spinner var $spinner = $.createSpinner({ size :'small', type: 'inline' }); $(this).hide().after($spinner); // find bounding revision ids var oldid = mw.util.getParamValue('oldid', $('#mw-diff-otitle1 strong a').attr('href')); var newid = mw.util.getParamValue('oldid', $('#mw-diff-ntitle1 strong a').attr('href')); var title = mw.util.getParamValue('title', $('#mw-diff-ntitle1 strong a').attr('href')); // call api for all revisions in that span var api = new mw.Api(); api.get({ action: 'query', prop: 'revisions', rvprop: 'ids', rvstartid: newid, rvendid: oldid, titles: title } ).done( function ( data ) { console.log( data ); /* apiRequest.postWithToken('patrol', { formatversion: 2, action: 'patrol', rcid: rcid }) .done(function(data) { $patrolLinks.closest('.patrollink').remove(); if(data.patrol !== undefined) { var title = new mw.Title(data.patrol.title); mw.notify(mw.msg('markedaspatrollednotify', title.toText())); } else { mw.notify(mw.msg('markedaspatrollederrornotify'), { type: 'error' }); } }) .fail(function(error) { $spinner.remove(); $patrolLinks.show(); if (error === 'noautopatrol') { mw.notify(mw.msg('markedaspatrollederror-noautopatrol'), { type: 'warn' }); } else { mw.notify(mw.msg('markedaspatrollederrornotify'), { type: 'error' }); } }); */ } ); e.preventDefault(); /*{"markedaspatrollederror-noautopatrol":"You are not allowed to mark your own changes as patrolled.","markedaspatrollederrornotify":"Marking as patrolled failed.","markedaspatrollednotify":"This change to $1 has been marked as patrolled."});*/ }); } }