Refactor PiDay feature: clean up comments, adjust element creation, and add background mode support

This commit is contained in:
CodeDevMLH
2026-02-24 19:23:33 +01:00
parent 892be062d3
commit de7e04c926

View File

@@ -1,13 +1,13 @@
// 1. Read Configuration
const config = window.SeasonalsPluginConfig?.PiDay || {};
const enabled = config.EnablePiDay !== undefined ? config.EnablePiDay : true;
const maxTrails = config.SymbolCount || 25; // Directly mapped, smaller default
const maxTrails = config.SymbolCount || 25;
const backgroundMode = config.EnablePiDayBackground !== undefined ? config.EnablePiDayBackground : false;
let msgPrinted = false;
let isHidden = false;
// 2. Toggle Function
// Toggle Function
function togglePiDay() {
const container = document.querySelector('.piday-container');
if (!container) return;
@@ -38,7 +38,6 @@ function togglePiDay() {
}
}
// 3. MutationObserver
const observer = new MutationObserver(togglePiDay);
observer.observe(document.body, {
childList: true,
@@ -46,13 +45,13 @@ observer.observe(document.body, {
attributes: true
});
// 4. Element Creation
function createElements() {
const container = document.querySelector('.piday-container') || document.createElement('div');
if (!document.querySelector('.piday-container')) {
container.className = 'piday-container';
container.setAttribute('aria-hidden', 'true');
if (backgroundMode) container.style.zIndex = '5';
document.body.appendChild(container);
}
@@ -155,7 +154,6 @@ function createElements() {
});
}
// 5. Initialization
function initializePiDay() {
if (!enabled) return;
createElements();