let lastMsgTime = 0;
let lastMsgContent = '';
const MSG_COOLDOWN = 500;
function fadeOutDiv(div) {
div.removeClass('show');
setTimeout(() => div.remove(), 1500);
}
let $msgDiv = $('.msgDiv');
jQuery(document).ready(function ($) {
if ($msgDiv.length > 1) {
$msgDiv.not(':first').remove();
$msgDiv = $msgDiv.first();
}
if ($msgDiv.length === 0) {
$msgDiv = $('
');
$('body').append($msgDiv);
}
});
const colors = ["rgb(255, 0, 0)", "rgb(0, 255, 0)", "#ff9d00"];
function displayMsg(type, msg) {
const now = Date.now();
if ($msgDiv.length === 0) {
$msgDiv = $('.msgDiv');
}
if (now - lastMsgTime < MSG_COOLDOWN && lastMsgContent === msg) {
return; // ignore spam
}
lastMsgTime = now;
lastMsgContent = msg;
if (type !== 0 && type !== 1 && type !== 2) return;
const d = new Date();
console.group("MsgDivLog:");
console.log("Type:", type);
console.log("Nachricht:", msg);
console.log("Timestamp:", d);
console.groupEnd();
const $div = $('')
.css({ 'border-color': colors[type] })
.text(msg);
$msgDiv.append($div);
setTimeout(() => $div.addClass('show'), 50);
setTimeout(() => fadeOutDiv($div), 5000);
}
function displayConfirm(msg = null) {
return new Promise((resolve) => {
// Created clean layout references
const $heading = $('', { class: 'confirmImportantHeading', text: 'Bitte bestätige diese Aktion' });
const $text = $('
', { class: 'confirmImportantText', text: msg || 'Diese Aktion ist unumkehrbar.' });
const $submitBtn = $('