MediaWiki: Common.js: Difference between revisions
From Psalms: Layer by Layer
(Created page with "ββAny JavaScript here will be loaded for all users on every page load.: console.log("Hello world!");") |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
console.log("Hello world!"); | //console.log("Hello world!"); | ||
// Check if the current page has the specific body class | |||
if (document.body.classList.contains('page-ResourceSite_Welcome-Mike')) { | |||
// Select the .index container | |||
const indexContainer = document.querySelector('.index'); | |||
// Apply grid styles to the container | |||
if (indexContainer) { | |||
indexContainer.style.display = 'grid'; | |||
indexContainer.style.gridTemplateColumns = 'repeat(7, 1fr)'; // Create 7 columns | |||
indexContainer.style.gap = '10px'; // Add spacing between items | |||
// Optionally center-align each item (if not done in CSS) | |||
const indexItems = indexContainer.querySelectorAll('.index-item'); | |||
indexItems.forEach(item => { | |||
item.style.textAlign = 'center'; | |||
}); | |||
} | |||
} |
Revision as of 17:34, 22 November 2024
/* Any JavaScript here will be loaded for all users on every page load. */ //console.log("Hello world!"); // Check if the current page has the specific body class if (document.body.classList.contains('page-ResourceSite_Welcome-Mike')) { // Select the .index container const indexContainer = document.querySelector('.index'); // Apply grid styles to the container if (indexContainer) { indexContainer.style.display = 'grid'; indexContainer.style.gridTemplateColumns = 'repeat(7, 1fr)'; // Create 7 columns indexContainer.style.gap = '10px'; // Add spacing between items // Optionally center-align each item (if not done in CSS) const indexItems = indexContainer.querySelectorAll('.index-item'); indexItems.forEach(item => { item.style.textAlign = 'center'; }); } }