User:BZPN/RfD.js: Difference between revisions

From Test Wiki
Content deleted Content added
BZPN (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
BZPN (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
Line 20: Line 20:
// === Wstaw ten fragment PRZED openDeletionPopup ===
// === Wstaw ten fragment PRZED openDeletionPopup ===


// Dodanie zakładki Quick Delete do popupu
// Dodaj zakładkę Quick Delete do popupu
function addQuickDeleteTab(popup) {
function addQuickDeleteTab(popup) {
const quickDeleteTab = $('<div>').attr('id', 'quick-delete-tab').css({
const quickDeleteTab = $('<div>').attr('id', 'quick-delete-tab').css({
Line 37: Line 37:
}).appendTo(quickDeleteTab);
}).appendTo(quickDeleteTab);


// Checkbox potwierdzający zapoznanie się z zasadami usuwania
const consentCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'consent-checkbox').css('margin-right', '10px');
const consentCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'consent-checkbox').css('margin-right', '10px');
const consentLabel = $('<label>').attr('for', 'consent-checkbox').text('I have read and understand the deletion policy.');
const consentLabel = $('<label>').attr('for', 'consent-checkbox').text('I have read and understand the deletion policy.');
Line 47: Line 46:
}).appendTo(quickDeleteTab);
}).appendTo(quickDeleteTab);


// Lista wyboru powodu QD
const quickDeleteSelect = $('<select>').attr('id', 'quick-delete-reason').css({
const quickDeleteSelect = $('<select>').attr('id', 'quick-delete-reason').css({
'width': '100%',
'width': '100%',
Line 55: Line 53:
}).appendTo(quickDeleteTab);
}).appendTo(quickDeleteTab);


// Dodaj powody do listy
const reasons = [
const reasons = [
{ value: 'A1', text: 'Little or no meaning' },
{ value: 'A1', text: 'Little or no meaning' },
Line 67: Line 64:
$.each(reasons, function(index, reason) {
$.each(reasons, function(index, reason) {
quickDeleteSelect.append($('<option>').attr('value', reason.value).text(reason.text));
quickDeleteSelect.append($('<option>').attr('value', reason.value).text(reason.text));
});

// Przycisk do szybkiego usunięcia
$('<button>').text('Quick Delete').css({
'width': '100%',
'padding': '10px',
'background-color': '#d9534f',
'color': '#fff',
'border': 'none',
'border-radius': '5px',
'cursor': 'pointer',
'font-size': '16px'
}).on('click', function() {
const reason = quickDeleteSelect.val();
const consent = consentCheckbox.is(':checked');
if (reason && consent) {
tagPageForQuickDeletion(reason);
} else if (!consent) {
alert('Please confirm you have read the deletion policy.');
} else {
alert('Please choose a reason for quick deletion.');
}
}).appendTo(quickDeleteTab);
}

// Funkcja do oznaczania strony do szybkiego usunięcia
function tagPageForQuickDeletion(reason) {
const tag = `{{qd|${reason}}}`;
const editSummary = 'Nominating for quick deletion ([[User :BZPN/RfD.js|QD]])';

new mw.Api().postWithToken('csrf', {
action: 'edit',
title: mw.config.get('wgPageName'),
prependtext: tag + '\n',
summary: editSummary,
watchlist: 'watch',
}).done(function() {
alert('Page tagged for quick deletion.');
closeDeletionPopup(); // Zamknij popup po pomyślnym oznaczeniu
}).fail(function() {
alert('Failed to tag the page for quick deletion. Please try again.');
});
});
}
}