MediaWiki:Common.js: Difference between revisions

From Galaxypedia
No edit summary
No edit summary
Line 23: Line 23:
             header.style.textDecoration = 'underline dashed';
             header.style.textDecoration = 'underline dashed';
             header.style.cursor = "help";
             header.style.cursor = "help";
             header.title = "The cost section is meant to be taken with a grain of salt. Price fluctuates based on the economy, and the cost section is meant to be a rough estimate of the price of the item.";
             header.title = "The Cost section is meant to be taken with a grain of salt. Price fluctuates based on the economy, and the cost section is meant to be a rough estimate of the price of the item.\nIn addition, KetchupBot does not automatically update this section";
         console.log("Added styling to Cost section on infobox");
         console.log("Added styling to Cost section on infobox");
         }
         }

Revision as of 01:25, 20 September 2023

/* Any JavaScript here will be loaded for all users on every page load. */

//Note that while loading content, appending "/wiki" or "/w" before the "/index..." statement may cause 404 errors or mime type mismatch errors (403)

//Import the Navbox.js scripts for the navbox price/name sorting functionality
mw.loader.load( '/index.php?title=MediaWiki:Navbox.js&action=raw&ctype=text/javascript' );

// Sitenotice
var sitenotice = document.querySelector('#siteNotice .mw-dismissable-notice');
if (!sitenotice) sitenotice = document.querySelector('#siteNotice');
if (sitenotice) {
	sitenotice.classList.add('sitenoticestyling');
}

// Add extra info to infobox's cost header to notify users to take it with a grain of salt
const headers = document.querySelectorAll('.pi-header');

if (headers) {
    headers.forEach(function(header) {
        const paragraph = header.querySelector('p');

        if (paragraph.textContent.includes('Cost')) {
            header.style.textDecoration = 'underline dashed';
            header.style.cursor = "help";
            header.title = "The Cost section is meant to be taken with a grain of salt. Price fluctuates based on the economy, and the cost section is meant to be a rough estimate of the price of the item.\nIn addition, KetchupBot does not automatically update this section";
        	console.log("Added styling to Cost section on infobox");
        }
    })
} else {
	console.log("Did not find an infobox");
}