User:BZPN/RfD.js: Difference between revisions

From Test Wiki
Content deleted Content added
BZPN (talk | contribs)
No edit summary
Tags: Manual revert Mobile edit Mobile web edit
BZPN (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
Line 4: Line 4:
// Dodaj przycisk "Nominate for deletion" do paska narzędzi
// Dodaj przycisk "Nominate for deletion" do paska narzędzi
mw.util.addPortletLink(
mw.util.addPortletLink(
'p-cactions',
'p-tb', // Pasek narzędzi
'#',
'#',
'Nominate for deletion',
'Nominate for deletion',
Line 63: Line 63:
'font-size': '14px',
'font-size': '14px',
'color': '#0073e6',
'color': '#0073e6',
'text-decoration': 'underline'
'text-decoration': 'underline',
'display': 'block',
'margin-bottom': '10px'
}).appendTo(popup);
}).appendTo(popup);


// Pole na krótki powód
// Pole na krótki powód
$('<label>').attr('for', 'deletion-short-reason').text('Short reason:').appendTo(popup);
$('<label>').attr('for', 'deletion-short-reason').text('Short reason:').css({
'display': 'block',
'margin-top': '10px'
}).appendTo(popup);
const shortReasonInput = $('<input>').attr({
const shortReasonInput = $('<input>').attr({
'type': 'text',
'type': 'text',
Line 74: Line 79:
}).css({
}).css({
'width': '100%',
'width': '100%',
'padding': '8px',
'padding': '6px',
'margin': '10px 0'
'margin-bottom': '10px'
}).appendTo(popup);
}).appendTo(popup);


// Pole na szczegółowy powód
// Pole na szczegółowy powód
$('<label>').attr('for', 'deletion-detailed-reason').text('Detailed reason for discussion:').appendTo(popup);
$('<label>').attr('for', 'deletion-detailed-reason').text('Detailed reason for discussion:').css({
'display': 'block',
'margin-top': '10px'
}).appendTo(popup);
const detailedReasonInput = $('<textarea>').attr({
const detailedReasonInput = $('<textarea>').attr({
'id': 'deletion-detailed-reason',
'id': 'deletion-detailed-reason',
Line 85: Line 93:
}).css({
}).css({
'width': '100%',
'width': '100%',
'padding': '8px',
'padding': '6px',
'height': '100px',
'height': '80px',
'margin': '10px 0'
'margin-bottom': '10px'
}).appendTo(popup);

// Checkbox potwierdzenia zapoznania się z polityką
const policyCheckbox = $('<input>').attr({
'type': 'checkbox',
'id': 'policy-confirmation'
}).css({
'margin-right': '5px'
});
const policyLabel = $('<label>').attr('for', 'policy-confirmation').text('I have read and understand the deletion policy.');
$('<div>').append(policyCheckbox, policyLabel).css({
'margin-bottom': '15px'
}).appendTo(popup);
}).appendTo(popup);


Line 102: Line 122:
const shortReason = shortReasonInput.val().trim();
const shortReason = shortReasonInput.val().trim();
const detailedReason = detailedReasonInput.val().trim();
const detailedReason = detailedReasonInput.val().trim();
if (shortReason && detailedReason) {
const policyConfirmed = policyCheckbox.is(':checked');
if (shortReason && detailedReason && policyConfirmed) {
initiateDeletionProcess(shortReason, detailedReason);
initiateDeletionProcess(shortReason, detailedReason);
} else if (!policyConfirmed) {
alert('Please confirm you have read the deletion policy.');
} else {
} else {
alert('Please provide both a short and detailed reason.');
alert('Please provide both a short and detailed reason.');
Line 127: Line 150:
function tagPageForDeletion(reason) {
function tagPageForDeletion(reason) {
const tag = `{{rfd|${reason}}}`;
const tag = `{{rfd|${reason}}}`;
const editSummary = 'Nominating for deletion';
const editSummary = 'Nominating for deletion ([[User:BZPN/RfD.js|RfD]])';


new mw.Api().postWithToken('csrf', {
new mw.Api().postWithToken('csrf', {
Line 151: Line 174:
title: discussionPageTitle,
title: discussionPageTitle,
text: discussionContent,
text: discussionContent,
summary: 'Starting deletion discussion',
summary: 'Starting deletion discussion ([[User:BZPN/RfD.js|RfD]])',
watchlist: 'watch',
watchlist: 'watch',
}).done(function() {
}).done(function() {
Line 168: Line 191:
return {
return {
text: discussionLink + '\n' + revision.content,
text: discussionLink + '\n' + revision.content,
summary: 'Adding new deletion discussion',
summary: 'Adding new deletion discussion ([[User:BZPN/RfD.js|RfD]])',
watchlist: 'watch',
watchlist: 'watch',
};
};
Line 187: Line 210:
title: `User talk:${creator}`,
title: `User talk:${creator}`,
appendtext: '\n' + notification,
appendtext: '\n' + notification,
summary: 'Notifying page creator about deletion nomination',
summary: 'Notifying page creator about deletion nomination ([[User:BZPN/RfD.js|RfD]])',
watchlist: 'watch',
watchlist: 'watch',
}).done(function() {
}).done(function() {