User:BZPN/RfD.js: Difference between revisions

From Test Wiki
Content deleted Content added
BZPN (talk | contribs)
Created page with "// Simple English Wikipedia Deletion Gadget // This gadget helps users nominate pages for deletion according to Simple English Wikipedia's policy. (function() { if (mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgIsArticle') === false) return; // Check if page is already tagged for deletion if (document.getElementById('delete-tag')) { alert('This page is already nominated for deletion.'); return; } // Create deletion proc..."
Tags: Mobile edit Mobile web edit
 
BZPN (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
Line 1: Line 1:
// Simple English Wikipedia Deletion Gadget
// Simple English Wikipedia Deletion Gadget with Popup
// This gadget helps users nominate pages for deletion according to Simple English Wikipedia's policy.
// This gadget adds a "Nominate for deletion" button to the toolbar, opening a popup for deletion nomination.


(function() {
(function() {
if (mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgIsArticle') === false) return;
if (mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgIsArticle') === false) return;


// Check if page is already tagged for deletion
// Add "Nominate for deletion" button to the toolbar
mw.util.addPortletLink(
if (document.getElementById('delete-tag')) {
'p-cactions',
alert('This page is already nominated for deletion.');
return;
'#',
'Nominate for deletion',
}
'ca-nominate-deletion',
'Nominate this page for deletion'
);


// Add click event for the deletion nomination button
// Create deletion process UI elements
$('#ca-nominate-deletion').on('click', function(e) {
const deletionBtn = document.createElement('button');
e.preventDefault();
deletionBtn.textContent = 'Nominate for deletion';
openDeletionPopup();
deletionBtn.style.margin = '10px';
});
deletionBtn.onclick = initiateDeletionProcess;


// Function to create and open the deletion popup
// Append button to page
function openDeletionPopup() {
document.getElementById('mw-content-text').prepend(deletionBtn);
// Create the popup overlay
const overlay = $('<div>').attr('id', 'deletion-popup-overlay').css({
'position': 'fixed',
'top': '0',
'left': '0',
'width': '100%',
'height': '100%',
'background-color': 'rgba(0, 0, 0, 0.5)',
'z-index': '1000',
}).appendTo('body');


// Create the popup container
// Function to initiate deletion process
const popup = $('<div>').attr('id', 'deletion-popup').css({
function initiateDeletionProcess() {
'width': '400px',
const reason = prompt('Please provide a reason for deletion:', 'Not a notable topic');
'margin': '10% auto',
if (!reason) {
'padding': '20px',
alert('Deletion process canceled.');
'background-color': '#fff',
return;
'border-radius': '8px',
'box-shadow': '0 4px 8px rgba(0, 0, 0, 0.2)',
}
'text-align': 'left',
'position': 'relative'
}).appendTo(overlay);


// Close button
$('<span>').text('×').css({
'position': 'absolute',
'top': '10px',
'right': '15px',
'cursor': 'pointer',
'font-size': '18px',
'font-weight': 'bold'
}).on('click', closeDeletionPopup).appendTo(popup);

// Title
$('<h3>').text('Nominate for deletion').appendTo(popup);

// Short reason input
$('<label>').attr('for', 'deletion-short-reason').text('Short reason:').appendTo(popup);
const shortReasonInput = $('<input>').attr({
'type': 'text',
'id': 'deletion-short-reason',
'placeholder': 'Enter short reason...'
}).css({
'width': '100%',
'padding': '8px',
'margin': '10px 0'
}).appendTo(popup);

// Detailed reason input
$('<label>').attr('for', 'deletion-detailed-reason').text('Detailed reason for discussion:').appendTo(popup);
const detailedReasonInput = $('<textarea>').attr({
'id': 'deletion-detailed-reason',
'placeholder': 'Enter detailed reason...'
}).css({
'width': '100%',
'padding': '8px',
'height': '80px',
'margin': '10px 0'
}).appendTo(popup);

// Submit button
$('<button>').text('Submit nomination').css({
'width': '100%',
'padding': '10px',
'background-color': '#0073e6',
'color': '#fff',
'border': 'none',
'border-radius': '5px',
'cursor': 'pointer'
}).on('click', function() {
const shortReason = shortReasonInput.val().trim();
const detailedReason = detailedReasonInput.val().trim();
if (shortReason && detailedReason) {
initiateDeletionProcess(shortReason, detailedReason);
} else {
alert('Please provide both a short and detailed reason.');
}
}).appendTo(popup);
}

// Function to close the deletion popup
function closeDeletionPopup() {
$('#deletion-popup-overlay').remove();
}

// Function to initiate deletion process
function initiateDeletionProcess(shortReason, detailedReason) {
// Step 1: Tagging the article with deletion notice
// Step 1: Tagging the article with deletion notice
tagPageForDeletion(reason);
tagPageForDeletion(shortReason);


// Step 2: Creating the deletion discussion page
// Step 2: Creating the deletion discussion page
createDiscussionPage(reason);
createDiscussionPage(detailedReason);


// Step 3: Adding the discussion link to the deletion list
// Step 3: Adding the discussion link to the deletion list
addToDeletionList();
addToDeletionList();

// Close the popup
closeDeletionPopup();
}
}