User:Euphoria/common.js: Difference between revisions

From Test Wiki
Content deleted Content added
fix
fix
Line 65: Line 65:
});
});
}
}

});
});
});
});
Line 77: Line 78:
if (categories.includes('VfD archive entries')) return;
if (categories.includes('VfD archive entries')) return;


const link = $(heading).find('a').first();
// Get target page from heading text
if (!link.length) return;
const headingText = $(heading).text().trim();
if (!headingText) return;

const targetPage = link.attr('title') || link.text().trim();
const targetPage = headingText;
if (!targetPage) return;


// Container for buttons
const container = document.createElement('span');
const container = document.createElement('span');
container.style.marginLeft = '6px';
container.style.marginLeft = '6px';
Line 116: Line 117:
});
});


btn.addEventListener('mouseenter', () => { btn.style.filter = 'brightness(1.3)'; btn.style.transform = 'scale(1.2)'; });
btn.addEventListener('mouseenter', () => {
btn.addEventListener('mouseleave', () => { btn.style.filter = 'brightness(1)'; btn.style.transform = 'scale(1)'; });
btn.style.filter = 'brightness(1.3)';
btn.style.transform = 'scale(1.2)';
});
btn.addEventListener('mouseleave', () => {
btn.style.filter = 'brightness(1)';
btn.style.transform = 'scale(1)';
});


btn.addEventListener('click', e => {
btn.addEventListener('click', e => {
e.preventDefault();
e.preventDefault();
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;

btn.style.opacity = '0.5';
btn.style.cursor = 'not-allowed';
// Disable all buttons in this heading
$(heading).find('.vfd-action-link').each((i, b) => {
b.style.opacity = '0.5';
b.style.cursor = 'not-allowed';
});

handleAction(targetPage, actionObj.name);
handleAction(targetPage, actionObj.name);
});
});
Line 133: Line 145:
});
});
});
});

});
});
//</nowiki>
//</nowiki>