Toggle menu
2
16
18
151
The My Singing Monsters Modding Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
This wiki has had no edits or log actions made within the last 45 days and has been automatically marked as inactive. If you would like to prevent this wiki from being closed, please start showing signs of activity here. If there are no signs of this wiki being used within the next 15 days, this wiki will be closed in accordance to the Dormancy Policy (which all wiki founders accept when requesting a wiki). If this wiki is closed and no one reopens it 135 days from now, this wiki will become eligible for deletion. Note: If you are a bureaucrat, you can go to Special:ManageWiki and uncheck "inactive" yourself.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
Content added Content deleted
m (fix?)
(completely different code for syntax highlighting)
Line 1:
// syntax highlighter
var syntaxCodesyntaxElements = document.querySelectorAll("pre");
// for each element do an action
syntaxCodesyntaxElements.forEach((code) => {
if (code.indexOf('game.') > -1) // if the keyword exists in the code
// check if it has the specified keyword
{
if (code.textContent.indexOf('game.') > -1) {
code.replace("game", "<span style='color: #9cdcfe;'>game</span>"); // insert element (technically) that colors the keyword
// (technically) insert elements for specified keywords to color them
code.replace(".", "<span style='color: #b1ac8b;'>.</span>"); // ditto
code.innerHTML = code.textContent.replace(".", "<span style='color: #b1ac8b;'>.</span>").replace("game", "<span style='color: #9cdcfe;'>game</span>");
}
}
});

Revision as of 15:02, 3 November 2023

// syntax highlighter
var syntaxElements = document.querySelectorAll("pre");
// for each element do an action
syntaxElements.forEach((code) => {
	// check if it has the specified keyword
    if (code.textContent.indexOf('game.') > -1) {
    	// (technically) insert elements for specified keywords to color them
        code.innerHTML = code.textContent.replace(".", "<span style='color: #b1ac8b;'>.</span>").replace("game", "<span style='color: #9cdcfe;'>game</span>");
    }
});
Cookies help us deliver our services. By using our services, you agree to our use of cookies.