mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Function also needed in common.js
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user