User:BZPN/RfD.js: Difference between revisions
From Test Wiki
Content deleted Content added
Tags: Undo Mobile edit Mobile web edit |
No edit summary Tags: Mobile edit Mobile web edit |
||
| Line 18: | Line 18: | ||
}; |
}; |
||
} |
} |
||
// === Wstaw ten fragment PRZED openDeletionPopup === |
|||
// Dodanie zakładki Quick Delete do popupu |
|||
function addQuickDeleteTab(popup) { |
|||
// Tworzenie zakładki QD i formularza |
|||
const quickDeleteTab = $('<div>').attr('id', 'quick-delete-tab').css({ |
|||
'display': 'none' // Domyślnie ukryty, widoczny po przełączeniu na zakładkę QD |
|||
}).appendTo(popup); |
|||
$('<h3>').text('Quick Delete').css({ |
|||
'font-size': '18px', |
|||
'margin-bottom': '10px' |
|||
}).appendTo(quickDeleteTab); |
|||
$('<p>').text('Choose a reason for quick deletion from the list below:').css({ |
|||
'font-size': '14px', |
|||
'margin-bottom': '10px' |
|||
}).appendTo(quickDeleteTab); |
|||
// Lista wyboru powodu QD |
|||
const quickDeleteSelect = $('<select>').attr('id', 'quick-delete-reason').css({ |
|||
'width': '100%', |
|||
'padding': '6px', |
|||
'font-size': '14px', |
|||
'margin-bottom': '10px' |
|||
}).appendTo(quickDeleteTab); |
|||
// Dodanie opcji do listy |
|||
const reasons = [ |
|||
{ value: 'A1', text: 'Little or no meaning' }, |
|||
{ value: 'A2', text: 'No content' }, |
|||
{ value: 'A3', text: 'Article is transwikied' }, |
|||
{ value: 'A4', text: 'Does not say why it is notable' }, |
|||
{ value: 'A5', text: 'Not in English' }, |
|||
{ value: 'A6', text: 'Hoax' }, |
|||
// Dodaj inne powody według potrzeb |
|||
]; |
|||
reasons.forEach(reason => { |
|||
$('<option>').attr('value', reason.value).text(`${reason.value} - ${reason.text}`).appendTo(quickDeleteSelect); |
|||
}); |
|||
// Przycisk zatwierdzenia QD |
|||
$('<button>').text('Submit Quick Delete').css({ |
|||
'width': '100%', |
|||
'padding': '10px', |
|||
'background-color': '#d9534f', |
|||
'color': '#fff', |
|||
'border': 'none', |
|||
'border-radius': '5px', |
|||
'cursor': 'pointer', |
|||
'font-size': '16px', |
|||
'margin-top': '10px' |
|||
}).on('click', function() { |
|||
const selectedReason = quickDeleteSelect.val(); |
|||
if (selectedReason) { |
|||
insertQuickDeleteTag(selectedReason); |
|||
} else { |
|||
alert('Please select a reason for quick deletion.'); |
|||
} |
|||
}).appendTo(quickDeleteTab); |
|||
} |
|||
// Funkcja wstawiająca tag QD na górę strony |
|||
function insertQuickDeleteTag(reason) { |
|||
const tag = `{{QD|${reason}}}`; |
|||
const editSummary = `Tagging page for quick deletion (Reason: ${reason})`; |
|||
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.'); |
|||
}).fail(function() { |
|||
alert('Failed to tag the page for quick deletion. Please try again.'); |
|||
}); |
|||
} |
|||
// === Koniec fragmentu PRZED openDeletionPopup === |
|||
// Tworzenie i otwarcie okna popup dla nominacji do usunięcia |
// Tworzenie i otwarcie okna popup dla nominacji do usunięcia |
||
function openDeletionPopup() { |
function openDeletionPopup() { |
||
| Line 44: | Line 125: | ||
'position': 'relative' |
'position': 'relative' |
||
}).appendTo(overlay); |
}).appendTo(overlay); |
||
// === Wstaw ten fragment NA POCZĄTKU openDeletionPopup === |
|||
// Dodaj przyciski do przełączania między zakładkami RfD i QD |
|||
$('<div>').css({ |
|||
'display': 'flex', |
|||
'justify-content': 'space-around', |
|||
'margin-bottom': '10px' |
|||
}).append( |
|||
$('<button>').text('Request for Deletion').css({ |
|||
'flex': '1', |
|||
'padding': '6px', |
|||
'font-size': '14px', |
|||
'border': 'none', |
|||
'background-color': '#0073e6', |
|||
'color': '#fff', |
|||
'cursor': 'pointer' |
|||
}).on('click', function() { |
|||
$('#request-deletion-tab').show(); |
|||
$('#quick-delete-tab').hide(); |
|||
}), |
|||
$('<button>').text('Quick Delete').css({ |
|||
'flex': '1', |
|||
'padding': '6px', |
|||
'font-size': '14px', |
|||
'border': 'none', |
|||
'background-color': '#d9534f', |
|||
'color': '#fff', |
|||
'cursor': 'pointer' |
|||
}).on('click', function() { |
|||
$('#quick-delete-tab').show(); |
|||
$('#request-deletion-tab').hide(); |
|||
}) |
|||
).prependTo(popup); |
|||
// Dodaj zakładkę Quick Delete do popupu |
|||
addQuickDeleteTab(popup); |
|||
// === Koniec fragmentu NA POCZĄTKU openDeletionPopup === |
|||
// Przycisk zamknięcia popup |
// Przycisk zamknięcia popup |
||
$('<span>').text('×').css({ |
$('<span>').text('×').css({ |
||