![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/brickabois.com/public_html/assets/js/ |
/**
* Theme Randomizer - Cycle through beautiful color themes
*/
(function() {
'use strict';
// Available color themes
const colorThemes = [
'earth',
'ocean',
'forest',
'sunset',
'purple',
'teal',
'amber',
'indigo',
'emerald',
'rose',
'cyan',
'brown',
'bluegrey',
'deeporange',
'lime',
'pink'
];
// Theme names for display
const themeNames = {
'earth': '๐ Earth',
'ocean': '๐ Ocean',
'forest': '๐ฒ Forest',
'sunset': '๐
Sunset',
'purple': '๐ Purple',
'teal': '๐ Teal',
'amber': '๐ฅ Amber',
'indigo': '๐ Indigo',
'emerald': '๐ Emerald',
'rose': '๐น Rose',
'cyan': '๐ Cyan',
'brown': '๐ซ Brown',
'bluegrey': '๐ซ๏ธ Blue Grey',
'deeporange': '๐งก Deep Orange',
'lime': '๐ Lime',
'pink': '๐ธ Pink'
};
// Get current color theme
function getCurrentColorTheme() {
return document.documentElement.getAttribute('data-color-theme') || 'forest';
}
// Set color theme
function setColorTheme(theme) {
if (!colorThemes.includes(theme)) {
theme = 'forest';
}
document.documentElement.setAttribute('data-color-theme', theme);
localStorage.setItem('colorTheme', theme);
updateThemeButton(theme);
}
// Get random theme (excluding current)
function getRandomTheme() {
const current = getCurrentColorTheme();
let available = colorThemes.filter(t => t !== current);
if (available.length === 0) {
available = colorThemes;
}
const randomIndex = Math.floor(Math.random() * available.length);
return available[randomIndex];
}
// Randomize theme
function randomizeTheme() {
const newTheme = getRandomTheme();
setColorTheme(newTheme);
// Add animation effect
document.body.style.transition = 'background-color 0.5s ease, color 0.5s ease';
setTimeout(() => {
document.body.style.transition = '';
}, 500);
}
// Cycle through themes sequentially
function cycleTheme() {
const current = getCurrentColorTheme();
const currentIndex = colorThemes.indexOf(current);
const nextIndex = (currentIndex + 1) % colorThemes.length;
setColorTheme(colorThemes[nextIndex]);
}
// Update theme button text
function updateThemeButton(theme) {
const button = document.getElementById('colorThemeRandomizer');
if (button) {
const themeName = themeNames[theme] || theme;
button.setAttribute('title', `Current: ${themeName}. Click to randomize!`);
button.innerHTML = `<span class="theme-icon">๐จ</span><span class="theme-text">${themeName}</span>`;
}
}
// Initialize theme on load
function initTheme() {
const savedTheme = localStorage.getItem('colorTheme');
if (savedTheme && colorThemes.includes(savedTheme)) {
setColorTheme(savedTheme);
} else {
setColorTheme('forest');
}
}
// Add theme randomizer button to navbar
function addThemeButton() {
const navbar = document.querySelector('.navbar .nav-links');
if (!navbar) return;
// Check if button already exists
if (document.getElementById('colorThemeRandomizer')) return;
const button = document.createElement('button');
button.id = 'colorThemeRandomizer';
button.className = 'color-theme-randomizer';
button.setAttribute('title', 'Click to randomize color theme!');
button.innerHTML = '<span class="theme-icon">๐จ</span><span class="theme-text">Theme</span>';
// Add click handler
button.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
randomizeTheme();
});
// Add double-click to cycle
let clickTimer = null;
button.addEventListener('dblclick', function(e) {
e.preventDefault();
e.stopPropagation();
if (clickTimer) {
clearTimeout(clickTimer);
clickTimer = null;
}
cycleTheme();
});
// Insert before light theme switcher if it exists, otherwise append
const lightSwitcher = document.getElementById('lightThemeSwitcher');
if (lightSwitcher && lightSwitcher.parentNode) {
navbar.insertBefore(button, lightSwitcher);
} else {
navbar.appendChild(button);
}
}
// Initialize on DOM ready
document.addEventListener('DOMContentLoaded', function() {
initTheme();
addThemeButton();
});
// Expose functions globally for manual control
window.randomizeColorTheme = randomizeTheme;
window.cycleColorTheme = cycleTheme;
window.setColorTheme = setColorTheme;
window.getColorTheme = getCurrentColorTheme;
})();