User:Writ Keeper/Scripts/massRevdel.js: Difference between revisions

Content deleted Content added
nvm
swap for document.ready
 
(11 intermediate revisions by 2 users not shown)
Line 1:
mw.hook$("wikipage.content"document).addready( function()
{
mw.loader.using(["mediawiki.api","mediawiki.notify"]).then(function ()
{
var apiLimit = 500;
Line 7:
if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions")
{
wkContribsCheckboxInit = true;
$("ul.mw-contributions-list:first").before("<div style='display:inline-block;' id='revdelCP'><span id='revdelLabel' style='cursor:pointer;'>Revision deletion\
<img id='revdelLabelImg' src='/w/load.php?modules=oojs-ui.styles.icons-movement&image=expand&format=rasterized&lang=en' style='width:12px; transform:rotate(270deg);'/></span>\
<span id='revdelCPBody' style='display:none;'><input type='button' id='revdelSelectAll' value='Select all'><input type='button' id='revdelSelectNone' value='Select none'>\
<input type='button' id='revdelSelectInv' value='Invert selection'>\
<span style='white-space:nowrap;'><input type='checkbox' id='revdelContent' name='revdelOptions' value='content'> delete content</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='revdelName' name='revdelOptions' value='userName'> delete user name</span> \
Line 20 ⟶ 22:
<input type='button' class='revdelSubmit' id='oversightSubmit' value='Oversight selected entries'></span></div>");
$("ul.mw-contributions-list .mw-revdelundel-link").each(function(ind,el){
if($(this).children("a").length > 0)
{
var revId = /ids=(\d+)/.exec($(this).children("a").attr("href"))[1];
var pageTitle = /target=([^&]+)/.exec($(this).children("a").attr("href"))[1];
el.innerHTML = "<input type='checkbox' name='"+decodeURIComponent(pageTitle)+"' class='revdelIds' value='"+revId+"'>";
$(el).children(".revdelIds").data("index", ind);
}
});
$("ul.mw-contributions-list").after("</form>");
Line 36 ⟶ 41:
reasons = reasons.replace(/\* ([^<]+)([^\*]+)/g, '<optgroup label="$1">$2</optgroup>');
$('#wpRevDeleteReasonList').append(reasons);
}).done(function()
{
$.get("/w/index.php?title=MediaWiki:Revdelete-reason-dropdown-suppress&action=raw", function(data)
{
reasons = data.replace(/\*\* ([^\*]+)/g, '<option value="$1">$1</option>');
reasons = reasons.replace(/\* ([^<]+)([^\*]+)/g, '<optgroup label="$1">$2</optgroup>');
$('#wpRevDeleteReasonList').append(reasons);
});
});
Line 63 ⟶ 76:
$(this).prop("checked", true);
});
$("#revdelCP").data("lastSelectedIndex", -1);
}
);
Line 72 ⟶ 86:
$(this).prop("checked", false);
});
$("#revdelCP").data("lastSelectedIndex", -1);
}
);
 
$("#revdelSelectInv").click(
function()
{
$('input.revdelIds').each(function()
{
$(this).prop("checked", !($(this).prop("checked")));
});
$("#revdelCP").data("lastSelectedIndex", -1);
}
);
$("input.revdelIds").off("click").click(
function(ev)
{
Line 88 ⟶ 114:
for(var i = start; i < stop; i++)
{
if(i != lastSelectedRevdel)
$(checkboxArray[i]).prop("checked", true);
{
$(checkboxArray[i]).prop("checked", true!($(checkboxArray[i]).prop("checked")));
}
}
}
Line 95 ⟶ 124:
for(var i = start; i > stop; i--)
{
if(i != lastSelectedRevdel)
$(checkboxArray[i]).prop("checked", true);
{
$(checkboxArray[i]).prop("checked", true!($(checkboxArray[i]).prop("checked")));
}
}
}