User:BZPN/RfD.js: Difference between revisions
From Test Wiki
Content deleted Content added
No edit summary Tags: Mobile edit Mobile web edit |
No edit summary Tags: Mobile edit Mobile web edit |
||
| Line 17: | Line 17: | ||
openDeletionPopup(); |
openDeletionPopup(); |
||
}; |
}; |
||
} |
|||
}// === Wstaw ten fragment PRZED openDeletionPopup === |
|||
// Dodanie zakładki Quick Delete do popupu |
// Dodanie zakładki 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({ |
||
'display': 'none' // Domyślnie ukryty |
'display': 'none' // Domyślnie ukryty |
||
}).appendTo(popup); |
}).appendTo(popup); |
||
$('<h3>').text('Quick Delete').css({ |
$('<h3>').text('Quick Delete').css({ |
||
'font-size': '18px', |
'font-size': '18px', |
||
'margin-bottom': '10px' |
|||
}).appendTo(quickDeleteTab); |
|||
$('<p>').html('Before proceeding with Quick Deletion, please read the <a href="/wiki/Template:QD" target="_blank">Template:QD</a> documentation and the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.') |
|||
.css({ |
|||
'font-size': '14px', |
|||
'margin-bottom': '10px' |
'margin-bottom': '10px' |
||
}).appendTo(quickDeleteTab); |
}).appendTo(quickDeleteTab); |
||
$('<p>').html('Before proceeding with Quick Deletion, please read the <a href="/wiki/Template:QD" target="_blank">Template:QD</a> documentation and the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.') |
|||
const consentCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'consent-checkbox').css('margin-right', '10px'); |
|||
.css({ |
|||
const consentLabel = $('<label>').attr('for', 'consent-checkbox').text('I have read and understand the deletion policy.'); |
|||
'font-size': '14px', |
|||
$('<div>').append(consentCheckbox).append(consentLabel).appendTo(quickDeleteTab); |
|||
'margin-bottom': '10px' |
|||
}).appendTo(quickDeleteTab); |
|||
const consentCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'consent-checkbox').css('margin-right', '10px'); |
|||
$('<p>').text('Choose a reason for quick deletion from the list below:').css({ |
|||
const consentLabel = $('<label>').attr('for', 'consent-checkbox').text('I have read and understand the deletion policy.'); |
|||
'font-size': '14px', |
|||
$('<div>').append(consentCheckbox).append(consentLabel).appendTo(quickDeleteTab); |
|||
'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); |
|||
'margin-bottom': '10px' |
|||
}).appendTo(quickDeleteTab); |
|||
const quickDeleteSelect = $('<select>').attr('id', 'quick-delete-reason').css({ |
|||
const reasons = [ |
|||
'width': '100%', |
|||
'padding': '6px', |
|||
'font-size': '14px', |
|||
'margin-bottom': '10px' |
|||
}).appendTo(quickDeleteTab); |
|||
{ value: 'A5', text: 'Not in English' }, |
|||
{ value: 'A6', text: 'Hoax' } |
|||
]; |
|||
const reasons = [ |
|||
$.each(reasons, function(index, reason) { |
|||
{ value: 'A1', text: 'Little or no meaning' }, |
|||
quickDeleteSelect.append($('<option>').attr('value', reason.value).text(reason.text)); |
|||
{ 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' } |
|||
]; |
|||
$.each(reasons, function(index, reason) { |
|||
// Przycisk do szybkiego usunięcia |
|||
quickDeleteSelect.append($('<option>').attr('value', reason.value).text(reason.text)); |
|||
$('<button>').text('Quick Delete').css({ |
|||
}); |
|||
'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); |
|||
} |
|||
// Przycisk do szybkiego usunięcia |
|||
// === Koniec fragmentu PRZED openDeletionPopup === |
|||
$('<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); |
|||
} |
|||
// Tworzenie i otwarcie okna popup dla nominacji do usunięcia |
// Tworzenie i otwarcie okna popup dla nominacji do usunięcia |
||
| Line 100: | Line 98: | ||
'height': '100%', |
'height': '100%', |
||
'background-color': 'rgba(0, 0, 0, 0.5)', |
'background-color': 'rgba(0, 0, 0, 0.5)', |
||
'z-index': '1000' |
'z-index': '1000' |
||
}).appendTo('body'); |
}).appendTo('body'); |
||
// Tworzenie okna popup |
// Tworzenie okna popup |
||
const popup = $('<div>').attr('id', 'deletion-popup').css({ |
const popup = $('<div>').attr('id', 'deletion-popup').css({ |
||
' |
'position': 'fixed', |
||
' |
'top': '50%', |
||
' |
'left': '50%', |
||
' |
'transform': 'translate(-50%, -50%)', |
||
'background-color': '#fff', |
'background-color': '#fff', |
||
' |
'padding': '20px', |
||
' |
'border': '1px solid #ddd', |
||
' |
'border-radius': '5px', |
||
' |
'box-shadow': '0 0 10px rgba(0, 0, 0, 0.5)', |
||
'z-index': '1001' |
|||
}).appendTo('body'); |
|||
// === Wstaw ten fragment NA POCZĄTKU openDeletionPopup === |
|||
// Dodanie zakładki Request for Deletion |
|||
// Dodaj przyciski do przełączania między zakładkami RfD i QD |
|||
const requestDeletionTab = $('<div>').attr('id', 'request-deletion-tab').appendTo(popup); |
|||
$('<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); |
|||
$('<h3>').text('Request for Deletion').css({ |
|||
// Dodaj zakładkę Quick Delete do popupu |
|||
addQuickDeleteTab(popup); |
|||
// === Koniec fragmentu NA POCZĄTKU openDeletionPopup === |
|||
// Przycisk zamknięcia popup |
|||
$('<span>').text('×').css({ |
|||
'position': 'absolute', |
|||
'top': '10px', |
|||
'right': '15px', |
|||
'cursor': 'pointer', |
|||
'font-size': '18px', |
|||
'font-weight': 'bold' |
|||
}).on('click', closeDeletionPopup).appendTo(popup); |
|||
// Tytuł okna |
|||
$('<h3>').text('Nominate for deletion').css({ |
|||
'font-size': '18px', |
'font-size': '18px', |
||
'margin-bottom': '10px' |
'margin-bottom': '10px' |
||
}).appendTo( |
}).appendTo(requestDeletionTab); |
||
$('<p>').html('Before proceeding with Request for Deletion, please read the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.') |
|||
// Informacja o zasadach RfD |
|||
.css({ |
|||
$('<p>').text('Before nominating, please read the deletion policy and guidelines on the Wikipedia:Requests for deletion page.').css({ |
|||
'font-size': '14px', |
'font-size': '14px', |
||
'margin-bottom': '10px' |
'margin-bottom': '10px' |
||
}).appendTo( |
}).appendTo(requestDeletionTab); |
||
$('<a>').attr('href', '/wiki/Wikipedia:Requests_for_deletion').text('Go to Wikipedia:Requests for deletion').css({ |
|||
'font-size': '14px', |
|||
'color': '#0073e6', |
|||
'text-decoration': 'underline', |
|||
'display': 'block', |
|||
'margin-bottom': '10px' |
|||
}).appendTo(popup); |
|||
const reasonInput = $('<textarea>').attr('id', 'deletion-reason').css({ |
|||
// Pole na krótki powód - poprawka do krawędzi dolnej |
|||
$('<label>').attr('for', 'deletion-short-reason').text('Short reason:').css({ |
|||
'display': 'block', |
|||
'margin-top': '10px', |
|||
'font-size': '14px' |
|||
}).appendTo(popup); |
|||
const shortReasonInput = $('<input>').attr({ |
|||
'type': 'text', |
|||
'id': 'deletion-short-reason', |
|||
'placeholder': 'Enter short reason...' |
|||
}).css({ |
|||
'width': '100%', |
'width': '100%', |
||
' |
'height': '100px', |
||
' |
'padding': '10px', |
||
'font-size': '14px', |
'font-size': '14px', |
||
'box-sizing': 'border-box', |
|||
'line-height': '1.5', // poprawka dla dolnej krawędzi |
|||
}).appendTo(popup); |
|||
// Pole na szczegółowy powód |
|||
$('<label>').attr('for', 'deletion-detailed-reason').text('Detailed reason for discussion:').css({ |
|||
'display': 'block', |
|||
'margin-top': '10px' |
|||
}).appendTo(popup); |
|||
const detailedReasonInput = $('<textarea>').attr({ |
|||
'id': 'deletion-detailed-reason', |
|||
'placeholder': 'Detailed reason...' |
|||
}).css({ |
|||
'width': '100%', |
|||
'padding': '6px', |
|||
'font-size': '14px', |
|||
'height': '80px', |
|||
'margin-bottom': '10px' |
'margin-bottom': '10px' |
||
}).appendTo( |
}).appendTo(requestDeletionTab); |
||
// 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); |
|||
// Przycisk |
// Przycisk do nominacji do usunięcia |
||
$('<button>').text(' |
$('<button>').text('Nominate for Deletion').css({ |
||
'width': '100%', |
'width': '100%', |
||
'padding': '10px', |
'padding': '10px', |
||
'background-color': '# |
'background-color': '#337ab7', |
||
'color': '#fff', |
'color': '#fff', |
||
'border': 'none', |
'border': 'none', |
||
| Line 242: | Line 148: | ||
'font-size': '16px' |
'font-size': '16px' |
||
}).on('click', function() { |
}).on('click', function() { |
||
const |
const reason = reasonInput.val(); |
||
if (reason) { |
|||
tagPageForDeletion(reason); |
|||
if (shortReason && detailedReason && policyConfirmed) { |
|||
initiateDeletionProcess(shortReason, detailedReason); |
|||
} else if (!policyConfirmed) { |
|||
alert('Please confirm you have read the deletion policy.'); |
|||
} else { |
} else { |
||
alert('Please |
alert('Please enter a reason for deletion.'); |
||
} |
} |
||
}).appendTo( |
}).appendTo(requestDeletionTab); |
||
} |
|||
// Dodanie zakładki Quick Delete |
|||
// Funkcja zamykająca popup |
|||
addQuickDeleteTab(popup); |
|||
function closeDeletionPopup() { |
|||
$('#deletion-popup-overlay').remove(); |
|||
} |
|||
// Zamknięcie okna popup po kliknięciu poza nim |
|||
// Funkcja inicjująca proces usunięcia |
|||
overlay.on('click', function() { |
|||
function initiateDeletionProcess(shortReason, detailedReason) { |
|||
overlay.remove(); |
|||
popup.remove(); |
|||
}); |
|||
notifyPageCreator(); |
|||
closeDeletionPopup(); |
|||
} |
} |
||
// Funkcja |
// Funkcja oznaczająca stronę do usunięcia |
||
function tagPageForDeletion(reason) { |
function tagPageForDeletion(reason) { |
||
const tag = `{{ |
const tag = `{{db|${reason}}}`; |
||
const editSummary = 'Nominating for deletion ([[User:BZPN/RfD.js|RfD]])'; |
const editSummary = 'Nominating for deletion ([[User :BZPN/RfD.js|RfD]])'; |
||
new mw.Api().postWithToken('csrf', { |
new mw.Api().postWithToken('csrf', { |
||
| Line 287: | Line 184: | ||
} |
} |
||
// Funkcja |
// Funkcja tworząca stronę dyskusji o usunięciu |
||
function createDiscussionPage(reason) { |
function createDiscussionPage(reason) { |
||
const discussionPageTitle = `Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}`; |
const discussionPageTitle = `Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}`; |
||
| Line 296: | Line 193: | ||
title: discussionPageTitle, |
title: discussionPageTitle, |
||
text: discussionContent, |
text: discussionContent, |
||
summary: 'Starting deletion discussion ([[User:BZPN/RfD.js|RfD]])', |
summary: 'Starting deletion discussion ([[User :BZPN/RfD.js|RfD]])', |
||
watchlist: 'watch', |
watchlist: 'watch', |
||
}).done(function() { |
}).done(function() { |
||
| Line 308: | Line 205: | ||
function addToDeletionList() { |
function addToDeletionList() { |
||
const deletionListTitle = 'Wikipedia:Requests for deletion/Current discussions'; |
const deletionListTitle = 'Wikipedia:Requests for deletion/Current discussions'; |
||
const discussionLink = `{{Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}}}`; |
const discussionLink = `{{subst:Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}}}`; |
||
new mw.Api().edit(deletionListTitle, function(revision) { |
new mw.Api().edit(deletionListTitle, function(revision) { |
||
return { |
return { |
||
text: discussionLink + '\n' + revision.content, |
text: discussionLink + '\n' + revision.content, |
||
summary: 'Adding new deletion discussion ([[User:BZPN/RfD.js|RfD]])', |
summary: 'Adding new deletion discussion ([[User :BZPN/RfD.js|RfD]])', |
||
watchlist: 'watch', |
watchlist: 'watch', |
||
}; |
}; |
||
| Line 330: | Line 227: | ||
new mw.Api().postWithToken('csrf', { |
new mw.Api().postWithToken('csrf', { |
||
action: 'edit', |
action: 'edit', |
||
title: `User talk:${creator}` |
title: `User talk:${creator}`, |
||
appendtext: '\n' + notification, |
|||
summary: 'Notifying page creator about deletion nomination ([[User :BZPN/RfD.js|RfD]])', |
|||
watchlist: 'watch', |
watchlist: 'watch', |
||
}).done(function() { |
}).done(function() { |
||
alert('Page creator notified.'); |
alert('Page creator notified.'); |
||
}).fail(function() { |
}).fail(function() { |
||
alert('Failed to notify |
alert('Failed to notify the page creator. Please try again.'); |
||
}); |
}); |
||
} |
} |
||
} |
|||
// Funkcja oznaczająca stronę 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.'); |
|||
}).fail(function() { |
|||
alert('Failed to tag the page for quick deletion. Please try again.'); |
|||
}); |
|||
} |
} |
||
})(); |
})(); |
||