m |
m |
||
Line 3: | Line 3: | ||
// Image de fond | // Image de fond | ||
$('body').css({ | $('body').css({ | ||
− | 'background-image': 'url("https:// | + | 'background-image': 'url("https://static.wikia.nocookie.net/atom-rpg/images/0/0e/Background-atom.jpg")', |
'background-size': 'cover', | 'background-size': 'cover', | ||
'background-attachment': 'fixed', | 'background-attachment': 'fixed', | ||
'background-repeat': 'no-repeat' | 'background-repeat': 'no-repeat' | ||
}); | }); | ||
− | + | ||
// Ajoute un div pour le fond semi-transparent | // Ajoute un div pour le fond semi-transparent | ||
$('body').append('<div class="overlay"></div>'); | $('body').append('<div class="overlay"></div>'); | ||
Line 23: | Line 23: | ||
'z-index': '-1' // Met le fond derrière le texte | 'z-index': '-1' // Met le fond derrière le texte | ||
}); | }); | ||
− | |||
− | |||
− | $( | + | // Ajoute un conteneur pour le texte afin de le rendre plus lisible |
− | + | $('body').append('<div class="content-container"></div>'); | |
− | $(' | + | $('.content-container').css({ |
+ | 'position': 'relative', | ||
+ | 'padding': '20px', // Ajuste les marges intérieures si besoin | ||
+ | 'z-index': '1', // Assure que le texte est au-dessus de l'overlay | ||
+ | }); | ||
+ | |||
+ | // Déplace le contenu dans le nouveau conteneur | ||
+ | $('#content').appendTo('.content-container'); | ||
} | } | ||
}); | }); | ||
+ | |||
// Charger le module collapsible de MediaWiki pour rendre la section repliable. | // Charger le module collapsible de MediaWiki pour rendre la section repliable. |
$(document).ready(function() { if (mw.config.get('wgPageName') === 'Main_Page1') { // Image de fond $('body').css({ 'background-image': 'url("https://static.wikia.nocookie.net/atom-rpg/images/0/0e/Background-atom.jpg")', 'background-size': 'cover', 'background-attachment': 'fixed', 'background-repeat': 'no-repeat' }); // Ajoute un div pour le fond semi-transparent $('body').append('<div class="overlay"></div>'); // Style pour le fond semi-transparent $('.overlay').css({ 'position': 'absolute', 'top': '0', 'left': '0', 'width': '100%', 'height': '100%', 'background-color': '#181d23', 'opacity': '0.9', // Ajuste l'opacité ici si besoin 'z-index': '-1' // Met le fond derrière le texte }); // Ajoute un conteneur pour le texte afin de le rendre plus lisible $('body').append('<div class="content-container"></div>'); $('.content-container').css({ 'position': 'relative', 'padding': '20px', // Ajuste les marges intérieures si besoin 'z-index': '1', // Assure que le texte est au-dessus de l'overlay }); // Déplace le contenu dans le nouveau conteneur $('#content').appendTo('.content-container'); } }); // Charger le module collapsible de MediaWiki pour rendre la section repliable. mw.loader.load('mediawiki.collapsible'); // Cette fonction affiche ou masque un élément avec l'ID spécifié. // Si l'élément est masqué ('none' ou vide), il est affiché en tant que 'table-row-group'. // Sinon, il est masqué. function toggleContent(id) { var element = document.getElementById(id); if (element.style.display === 'none' || element.style.display === '') { element.style.display = 'table-row-group'; } else { element.style.display = 'none'; } } /* ----------------------------- */ /* Custom Script for Highlighting Backticks */ /* Applies custom visual styles to text wrapped in backticks without altering the content */ /* ----------------------------- */ // This script waits for the document to fully load, and applies a visual style // to any text that is surrounded by backticks (` `), without altering the content. document.addEventListener('DOMContentLoaded', function () { // Check if we are in edit mode (to avoid changing the editor content) if (document.querySelector('#wpTextbox1') !== null) { return; // Do nothing in edit mode } /** * Function to highlight text between backticks by wrapping it in a span element * @param {string} text * @returns {string} */ function highlightBackticks(text) { const backtickRegex = /`([^`]+)`/g; // Matches text between backticks const styledText = text.replace(backtickRegex, function (match, p1) { return '<span class="backtick-style">' + p1 + '</span>'; }); return styledText; } /** * Traverse all text nodes and apply the backtick highlighting * @param {Node} node */ function traverseTextNodes(node) { if (node.nodeType === 3 && node.nodeValue.includes('`')) { // Only process text nodes const span = document.createElement('span'); span.innerHTML = highlightBackticks(node.nodeValue); node.parentNode.replaceChild(span, node); } else if (node.nodeType === 1 && node.childNodes) { // Traverse element children node.childNodes.forEach(traverseTextNodes); } } // Apply the changes to the entire body traverseTextNodes(document.body); }); console.log('Backtick script loaded');