Show density warning near input

This commit is contained in:
2026-04-14 17:14:27 +02:00
parent 11dd8896fc
commit d694f8f49f
2 changed files with 49 additions and 1 deletions
+28 -1
View File
@@ -3063,6 +3063,33 @@ function StoppingCoefficients(Element, flag)
}
}
let transientWarningTimeout = null;
function showTransientWarning(message, targetElement, duration = 4000) {
let warning = document.getElementById('transientWarning');
if (!warning) {
warning = document.createElement('div');
warning.id = 'transientWarning';
warning.className = 'transient-warning';
document.body.appendChild(warning);
}
warning.textContent = message;
if (targetElement) {
const rect = targetElement.getBoundingClientRect();
warning.style.left = `${Math.max(12, rect.left + window.scrollX)}px`;
warning.style.top = `${rect.bottom + window.scrollY + 8}px`;
}
warning.classList.add('visible');
if (transientWarningTimeout) {
clearTimeout(transientWarningTimeout);
}
transientWarningTimeout = setTimeout(() => {
warning.classList.remove('visible');
}, duration);
}
function rho_fun()
{
@@ -3114,7 +3141,7 @@ function rho_fun()
rho = total_molar_mass / total_molar_volume;
}
if (rho > 0) {
alert("Warning: Estimated density from additive elemental molar volumes; please verify manually.");
showTransientWarning("Warning: Estimated density from additive elemental molar volumes; please verify manually.", document.getElementById(rhoLi));
}
}
}
+21
View File
@@ -71,6 +71,27 @@ td {
display: table;
}
.transient-warning {
position: fixed;
max-width: 360px;
padding: 10px 14px;
background-color: #fff4cc;
border: 1px solid #c5a100;
border-radius: 8px;
color: #4d3b00;
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
font-size: 0.95rem;
line-height: 1.35;
opacity: 0;
pointer-events: none;
transition: opacity 0.25s ease;
z-index: 1000;
}
.transient-warning.visible {
opacity: 1;
}
.group_name {
padding-left:1em;
padding-right:1em;