User:Euphoria/common.js: Difference between revisions

From Test Wiki
Content deleted Content added
No edit summary
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 163: Line 162:
// Initialize buttons on page load
// Initialize buttons on page load
$(function () {
$(function () {
const categories = mw.config.get('wgCategories') || [];
if (categories.includes('VfD archive entries')) return;

// Look for all h2 headings (works on both main page and subpages)
// Look for all h2 headings (works on both main page and subpages)
$('#mw-content-text').find('h2').each(function () {
$('#mw-content-text').find('h2').each(function () {
const heading = $(this);
const heading = $(this);

// Skip heading if inside an archived discussion div
if (heading.closest('.vfd').length) return;

const link = heading.find('a').first();
const link = heading.find('a').first();