Function also needed in common.js

This commit is contained in:
phl0
2025-11-25 09:56:21 +01:00
parent 3e976a2d20
commit dc2911ee0e

View File

@@ -1377,6 +1377,24 @@ function showToast(title, text, type = 'bg-success text-white', delay = 3000) {
toastEl.addEventListener('hidden.bs.toast', () => toastEl.remove());
}
function hexToRgba(hex, alpha = 1) {
if (!hex) return null;
// Remove the leading "#"
hex = hex.replace(/^#/, '');
// Expand short form (#f0a → #ff00aa)
if (hex.length === 3) {
hex = hex.split('').map(c => c + c).join('');
}
const num = parseInt(hex, 16);
const r = (num >> 16) & 255;
const g = (num >> 8) & 255;
const b = num & 255;
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
}
/**
* Cookie Management Utilities
*/