Toggle menu
2
16
17
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.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
Content added Content deleted
(completely different code for syntax highlighting)
(javascript version is older so code must be compatible with the older version)
Line 2: Line 2:
var syntaxElements = document.querySelectorAll("pre");
var syntaxElements = document.querySelectorAll("pre");
// for each element do an action
// for each element do an action
syntaxElements.forEach((code) => {
syntaxElements.forEach(checkSyntax);
function checkSyntax() {
// check if it has the specified keyword
// check if it has the specified keyword
if (code.textContent.indexOf('game.') > -1) {
if (code.textContent.indexOf("game.") > -1) {
// (technically) insert elements for specified keywords to color them
// (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>");
code.innerHTML = code.textContent
}
.replace(".", "<span style='color: #b1ac8b;'>.</span>")
});
.replace("game", "<span style='color: #9cdcfe;'>game</span>");
}
}

Revision as of 16:11, 4 November 2023

// syntax highlighter
var syntaxElements = document.querySelectorAll("pre");
// for each element do an action
syntaxElements.forEach(checkSyntax);
function checkSyntax() {
  // 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.