User:Euphoria/common.js: Difference between revisions

From Test Wiki
Content deleted Content added
fix
Tag: Reverted
fix
Tag: Reverted
Line 36: Line 36:
function handleAction(targetPage, actionName) {
function handleAction(targetPage, actionName) {
apiHelper.fetch(currentPage, discussionContent => {
apiHelper.fetch(currentPage, discussionContent => {
// Prompt user for an optional comment
const userComment = prompt('Add an additional comment (optional):', '');
const userComment = prompt('Add an additional comment (optional):', '');
const commentText = userComment ? ` ${userComment}` : '';
const commentText = userComment ? ` ${userComment}` : '';

const newDiscussion = `{{subst:vt|${actionName}.${commentText} --~~~~}}\n${discussionContent}\n{{subst:vb}}`;
const newDiscussion = `{{subst:vt|${actionName}.${commentText} --~~~~}}\n${discussionContent}\n{{subst:vb}}`;


Line 94: Line 92:
let targetPage = null;
let targetPage = null;


// If we're on the main VfD page, always close the subpage link
if (currentPage === pagePrefix) {
if (currentPage === pagePrefix) {
// On main page: extract the subpage from transclusion text
const link = $(heading).find('a').first().attr('title');
if (link && link.startsWith(pagePrefix + '/')) {
const headingText = $(heading).text().trim();
const match = headingText.match(/Wikiquote:Votes for deletion\/.+/);
targetPage = link; // close the subpage, not main page
if (match) {
targetPage = match[0]; // close this subpage
}
}
} else {
} else {
targetPage = defaultTargetPage; // on subpage, close itself
// On subpage: close itself
targetPage = defaultTargetPage;
}
}


Line 157: Line 157:
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';