User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
fix Tag: Reverted |
||
| Line 4: | Line 4: | ||
const currentPage = mw.config.get('wgPageName').replace(/_/g, ' '); |
const currentPage = mw.config.get('wgPageName').replace(/_/g, ' '); |
||
// Allow main VfD page AND subpages, block everything else |
|||
| ⚫ | |||
if (!(currentPage === pagePrefix || currentPage.startsWith(pagePrefix + '/')) |
|||
| ⚫ | |||
const api = new mw.Api(); |
const api = new mw.Api(); |
||
| Line 89: | Line 91: | ||
// Create UI buttons for each heading |
// Create UI buttons for each heading |
||
function createButtonsForHeading(heading, |
function createButtonsForHeading(heading, defaultTargetPage) { |
||
let targetPage = null; |
|||
// If we're on the main VfD page, always close the subpage link |
|||
if (currentPage === pagePrefix) { |
|||
const link = $(heading).find('a').first().attr('title'); |
|||
if (link && link.startsWith(pagePrefix + '/')) { |
|||
targetPage = link; // close the subpage, not main page |
|||
} |
|||
} else { |
|||
targetPage = defaultTargetPage; // on subpage, close itself |
|||
} |
|||
if (!targetPage) return; |
|||
const container = document.createElement('span'); |
const container = document.createElement('span'); |
||
container.style.marginLeft = '6px'; |
container.style.marginLeft = '6px'; |
||