Difference between revisions of "User:HiddenKnowledge/monobook.js"
Jump to navigation
Jump to search
m (If this doesn't work.. Ah, hell. It won't, there's no jquery here.) |
m (Let's hope we have resourceloader.) |
||
Line 7: | Line 7: | ||
* @stat [[File:Krinkle_AjaxPatrolLinks.js]] | * @stat [[File:Krinkle_AjaxPatrolLinks.js]] | ||
*/ | */ | ||
jQuery( document ).ready( function( $ ) { | |||
function kAjaxPatrolLinks() { | function kAjaxPatrolLinks() { | ||
var $patrollinks = $('.patrollink a'); | var $patrollinks = $('.patrollink a'); | ||
Line 38: | Line 39: | ||
// dom ready: | // dom ready: | ||
$(kAjaxPatrolLinks); | $(kAjaxPatrolLinks); | ||
} ); |
Latest revision as of 23:26, 5 May 2012
/**
* Makes patrollinks for edits or new pages excecute without an additional page load.
* Including self-closing bookmarklet option.
* @author Krinkle, 2010 - 2012
* @version 0.2.1 (2012-01-29)
* @documentation meta.wikimedia.org/wiki/User:Krinkle/Scripts/AjaxPatrolLinks
* @stat [[File:Krinkle_AjaxPatrolLinks.js]]
*/
jQuery( document ).ready( function( $ ) {
function kAjaxPatrolLinks() {
var $patrollinks = $('.patrollink a');
if ($patrollinks.length > 0) {
$patrollinks.click(function (e) {
e.preventDefault();
var href = $(this).attr('href');
$patrollinks.text('Marking as patrolled...');
$patrollinks = $patrollinks.parent();
$.get(
href,
null,
function (data, status, request) {
if (status === 'success') {
// MediaWiki:Markedaspatrolled
$patrollinks.html('<span style="color: green;">Marked as patrolled</span>');
if (window.kAjaxPatrolLinks_closeafter === true) {
window.close();
// Firefox 2+ doesn't allow closing normal windows. If we're still here, open up the selfclosing page.
window.open('//toolserver.org/~krinkle/close.html', '_self');
}
} else {
// MediaWiki:Markedaspatrollederror
$patrollinks.html('<span style="color: red;">Cannot mark as patrolled</span>');
}
}
);
});
}
}
// dom ready:
$(kAjaxPatrolLinks);
} );