User:Euphoria/common.js: Difference between revisions

From Test Wiki
Content deleted Content added
fix
Tag: Reverted
No edit summary
Tag: Manual revert
Line 33:
// Handle VfD action for a target page
function handleAction(targetPage, actionName) {
// If on main page, close the subpage instead
const pageToEdit = (currentPage === pagePrefix) ? pagePrefix + '/' + targetPage : currentPage;
 
Line 142 ⟶ 143:
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) => {
b.style.opacity = '0.5';
Line 164 ⟶ 166:
if (categories.includes('VfD archive entries')) return;
 
// Look atfor all h2 headings (works on both main page and subpages)
$('#mw-content-text').find('h2').each(function () {
const headingheadingText = $(this).text().trim();
if (!headingText) return;
 
let targetPage = headingText;
// On main page, show buttons only if heading contains a link to a subpage
if (currentPage === pagePrefix) {
const firstLink = heading.find('a').first();
if (!firstLink.length) return; // skip headings with no link
 
// On main page, constdetect linkTitlethe =linked firstLink.attr('title');subpage if heading contains a link
if (!linkTitlecurrentPage ||=== !linkTitle.startsWith(pagePrefix + '/')) return; // skip headings not linking to subpages{
const firstLinklink = heading$(this).find('a').first().attr('title');
 
constif targetPage(link =&& linkTitlelink.replacestartsWith(pagePrefix + '/', '');) {
createButtonsForHeading targetPage = link.replace(thispagePrefix + '/', targetPage'');
} else { }
// On subpages, original behavior
const headingText = heading.text().trim();
if (!headingText) return;
createButtonsForHeading(this, headingText);
}
 
createButtonsForHeading(this, headingTexttargetPage);
});
});