User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
No edit summary Tag: Manual revert |
No edit summary Tag: Reverted |
||
| Line 33: | Line 33: | ||
// Handle VfD action for a target page |
// Handle VfD action for a target page |
||
function handleAction(targetPage, actionName) { |
function handleAction(targetPage, actionName) { |
||
// If on main page, close the subpage instead |
|||
const pageToEdit = (currentPage === pagePrefix) ? pagePrefix + '/' + targetPage : currentPage; |
const pageToEdit = (currentPage === pagePrefix) ? pagePrefix + '/' + targetPage : currentPage; |
||
| Line 143: | Line 142: | ||
if (!confirm(`Are you sure you want to close as ${actionObj.name}?`)) return; |
if (!confirm(`Are you sure you want to close as ${actionObj.name}?`)) return; |
||
// Disable all buttons under this heading |
|||
$(heading).find('.vfd-action-link').each((i, b) => { |
$(heading).find('.vfd-action-link').each((i, b) => { |
||
b.style.opacity = '0.5'; |
b.style.opacity = '0.5'; |
||
| Line 166: | Line 164: | ||
if (categories.includes('VfD archive entries')) return; |
if (categories.includes('VfD archive entries')) return; |
||
// |
// Look at all h2 headings |
||
$('#mw-content-text').find('h2').each(function () { |
$('#mw-content-text').find('h2').each(function () { |
||
const |
const heading = $(this); |
||
| ⚫ | |||
| ⚫ | |||
let targetPage = headingText; |
|||
| ⚫ | |||
if (currentPage === pagePrefix) { |
if (currentPage === pagePrefix) { |
||
const |
const firstLink = heading.find('a').first(); |
||
if ( |
if (!firstLink.length) return; // no link → skip |
||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
const linkTitle = firstLink.attr('title'); |
|||
| ⚫ | |||
if (!linkTitle || !linkTitle.startsWith(pagePrefix + '/')) return; // not a subpage → skip |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
// Subpages: original behavior |
|||
const headingText = heading.text().trim(); |
|||
| ⚫ | |||
createButtonsForHeading(this, headingText); |
|||
| ⚫ | |||
}); |
}); |
||
}); |
}); |
||