More actions
No edit summary |
No edit summary |
||
Line 68: | Line 68: | ||
// Define a mapping of categories to background images | // Define a mapping of categories to background images | ||
var categoryBackgrounds = { | var categoryBackgrounds = { | ||
'Call of Juarez': 'url("https://www.chromengine.com/images/c/c9/DIBackground.jpg")', | 'Call of Juarez': 'linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://www.chromengine.com/images/c/c9/DIBackground.jpg")', | ||
'Dying Light': 'url("https://www.chromengine.com/images/2/26/Background.png")' | 'Dying Light': ' linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://www.chromengine.com/images/2/26/Background.png")' | ||
}; | }; | ||
// Default background image if no category matches | // Default background image if no category matches | ||
var defaultBackground = 'url("https://www.chromengine.com/images/2/26/Background.png")'; | var defaultBackground = 'linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://www.chromengine.com/images/2/26/Background.png")'; | ||
// Variable to check if a category matches | // Variable to check if a category matches | ||
Line 81: | Line 81: | ||
categories.forEach(function(category) { | categories.forEach(function(category) { | ||
if (categoryBackgrounds[category]) { | if (categoryBackgrounds[category]) { | ||
$('body').css('background | $('body').css({ | ||
'background': categoryBackgrounds[category], | |||
'background-repeat': 'no-repeat', | |||
'background-position': 'top center', | |||
'background-size': 'cover', | |||
'background-attachment': 'fixed' | |||
}); | |||
backgroundImageSet = true; | backgroundImageSet = true; | ||
} | } | ||
Line 88: | Line 94: | ||
// If no category matched, apply the default background | // If no category matched, apply the default background | ||
if (!backgroundImageSet) { | if (!backgroundImageSet) { | ||
$('body').css('background-image', | $('body').css({ | ||
'background-image': defaultBackground, | |||
'background-repeat': 'no-repeat', | |||
'background-position': 'top center', | |||
'background-size': 'cover', | |||
'background-attachment': 'fixed' | |||
}); | |||
} | } | ||
}); | }); |
Revision as of 10:01, 5 January 2025
/* Any JavaScript here will be loaded for all users on every page load. */
$(function(){
$('.card').on('mousenter', function(event){
event.preventDefault();
$(this).toggleClass('hovered');
});
$('.card').on('mouseleave', function(event){
event.preventDefault();
$(this).toggleClass('hovered');
});
});
document.querySelectorAll('.sub-card').forEach(card => {
card.addEventListener('click', function(event) {
event.stopPropagation(); // Prevent event bubbling
// Toggle the expanded state of the clicked card
const isExpanded = card.getAttribute('data-expanded') === 'true';
// Flip the current sub-card
card.setAttribute('data-expanded', isExpanded ? 'false' : 'true');
// Hide all other sub-cards
document.querySelectorAll('.sub-card').forEach(otherCard => {
if (otherCard !== card) {
otherCard.setAttribute('data-expanded', 'false');
}
});
});
});
document.querySelectorAll('.card').forEach(card => {
card.addEventListener('mouseleave', function() {
// Collapse all sub-cards when mouse leaves the main card
document.querySelectorAll('.sub-card').forEach(subCard => {
subCard.setAttribute('data-expanded', 'false');
});
});
});
$(document).ready(function() {
// Click event for the header or the arrow
$('.mw-collapsible-header').click(function() {
var parentDiv = $(this).closest('.mw-collapsible');
var content = parentDiv.find('.mw-collapsible-content');
// Toggle the collapse/expand state
parentDiv.toggleClass('mw-collapsed');
// Toggle visibility of the content
content.stop(true, true).slideToggle(); // Stop any ongoing animation before toggling visibility
});
// Ensure that the arrow starts pointing up for expanded sections by default
$('.mw-collapsible').each(function() {
var parentDiv = $(this);
var content = parentDiv.find('.mw-collapsible-content');
if (!parentDiv.hasClass('mw-collapsed')) {
content.show(); // Ensure content is visible
}
});
});
$(document).ready(function() {
// Check if there are categories in the page
var categories = mw.config.get('wgCategories');
// Define a mapping of categories to background images
var categoryBackgrounds = {
'Call of Juarez': 'linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://www.chromengine.com/images/c/c9/DIBackground.jpg")',
'Dying Light': ' linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://www.chromengine.com/images/2/26/Background.png")'
};
// Default background image if no category matches
var defaultBackground = 'linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://www.chromengine.com/images/2/26/Background.png")';
// Variable to check if a category matches
var backgroundImageSet = false;
// Iterate through categories to find a matching background
categories.forEach(function(category) {
if (categoryBackgrounds[category]) {
$('body').css({
'background': categoryBackgrounds[category],
'background-repeat': 'no-repeat',
'background-position': 'top center',
'background-size': 'cover',
'background-attachment': 'fixed'
});
backgroundImageSet = true;
}
});
// If no category matched, apply the default background
if (!backgroundImageSet) {
$('body').css({
'background-image': defaultBackground,
'background-repeat': 'no-repeat',
'background-position': 'top center',
'background-size': 'cover',
'background-attachment': 'fixed'
});
}
});