User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
No edit summary |
||
| 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 166: | Line 166: | ||
if (categories.includes('VfD archive entries')) return; |
if (categories.includes('VfD archive entries')) return; |
||
// ✅ Look for all h2 headings (works on both main page and subpages) |
|||
| ⚫ | |||
| ⚫ | |||
// 🔹 Main page: attach buttons to transcluded discussions |
|||
$( |
const headingText = $(this).text().trim(); |
||
| ⚫ | |||
let targetPage = headingText; |
|||
// On main page, detect the linked subpage if heading contains a link |
|||
| ⚫ | |||
const link = $(this).find('a').first().attr('title'); |
const link = $(this).find('a').first().attr('title'); |
||
if (link && link.startsWith(pagePrefix + '/')) { |
if (link && link.startsWith(pagePrefix + '/')) { |
||
targetPage = link.replace(pagePrefix + '/', ''); |
|||
const heading = $(this).find('h2').first()[0]; |
|||
if (heading) { |
|||
| ⚫ | |||
} |
|||
} |
} |
||
} |
} |
||
| ⚫ | |||
| ⚫ | |||
// 🔹 Subpages: original behavior |
|||
| ⚫ | |||
| ⚫ | |||
const headingText = $(this).text().trim(); |
|||
| ⚫ | |||
createButtonsForHeading(this, headingText); |
|||
}); |
|||
} |
|||
}); |
}); |
||
}); |
}); |
||