Stitching things up

This commit is contained in:
2025-12-03 12:04:48 +03:00
parent 79bad39bd9
commit 4e37cd1ef8
37 changed files with 2183 additions and 2154 deletions

26
static/js/utils.js Normal file
View File

@@ -0,0 +1,26 @@
// Color utilities
const getCSSVar = (varName) => {
return getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
}
function getColorWithOpacity(className) {
const element = document.createElement('div');
element.className = className;
element.style.opacity = '1'; // Force opacity
element.textContent = '.';
document.body.appendChild(element);
const computedColor = window.getComputedStyle(element).color;
document.body.removeChild(element);
return computedColor;
}
// Utility function to calculate mean and standard deviation
function calculateStats(data) {
if (!data || data.length === 0) return { mean: 0, std: 0 };
const mean = data.reduce((a, b) => a + b, 0) / data.length;
const variance = data.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / data.length;
const std = Math.sqrt(variance);
return { mean, std };
}