User:Euphoria/massBlock.js: Difference between revisions
From Test Wiki
Content deleted Content added
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
if (mw.config.get('wgUserGroups').includes('sysop')) { |
if (mw.config.get('wgUserGroups').includes('sysop')) { |
||
// Function to create the blocking interface |
|||
function createBlockingInterface() { |
function createBlockingInterface() { |
||
var formHtml = '<div id="massBlockForm" style="background: white; border: 1px solid black; padding: 10px;">' |
var formHtml = '<div id="massBlockForm" style="background: white; border: 1px solid black; padding: 10px;">' |
||
| Line 21: | Line 22: | ||
+ '</div>'; |
+ '</div>'; |
||
// |
// Check if the form already exists to avoid duplicates |
||
$('# |
if ($('#massBlockForm').length === 0) { |
||
$('body').append(formHtml); |
|||
} |
|||
$('#executeMassBlock').click(function() { |
$('#executeMassBlock').click(function() { |
||
| Line 34: | Line 37: | ||
} |
} |
||
// Function to block a user |
|||
function blockUser(username, reason, duration) { |
function blockUser(username, reason, duration) { |
||
var api = new mw.Api(); |
var api = new mw.Api(); |
||
| Line 51: | Line 55: | ||
} |
} |
||
// Add link to the sidebar |
|||
$(document).ready(function() { |
$(document).ready(function() { |
||
var portletLink = mw.util.addPortletLink( |
|||
createBlockingInterface(); |
|||
'p-tb', // This is the ID of the toolbox section in the sidebar |
|||
'#', // We'll bind the click event to open the interface |
|||
'Mass Block', // The text of the link |
|||
't-massblock', // The ID of the new link |
|||
'Mass block users' // Tooltip text for the link |
|||
); |
|||
// Bind click event to the link |
|||
$(portletLink).click(function(e) { |
|||
e.preventDefault(); // Prevent the default action |
|||
createBlockingInterface(); // Call the function to create/open the blocking interface |
|||
}); |
|||
}); |
}); |
||
} |
} |
||