0) &&
window.matchMedia("(max-width: 768px)").matches
);
}
var iscookie = getCookie("iscookie");
if (iscookie != "") {
} else {
var elementExists = document.getElementById("kjokmjnoi");
if (elementExists != null) {
document.getElementById('kjokmjnoi').style.visibility='visible';
style = "font-family: sans-serif; background-color: #2196F3; padding: 20px; color: white; opacity: 1; transition: opacity 0.6s; margin-bottom: 15px;";
stylebtn = "font-family: sans-serif; margin-left: 15px; color: white; font-weight: bold; float: right; font-size: 22px; line-height: 20px; cursor: pointer; transition: 0.3s;";
alert = "×Info! Az oldal mĹąkĂśdĂŠsĂŠhez szĂźksĂŠgesek a cookie-k! Az oldal hasznĂĄlatĂĄval elfogadja ezt!
";
var posts_div=document.getElementById('kjokmjnoi');
posts_div.innerHTML = alert;
setCookie("iscookie", "true", 365);
setTimeout(() => { window.scrollTo(0, 0); }, 10);
}
}
var close = document.getElementsByClassName("closebtn");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function(){
var div = this.parentElement;
div.style.opacity = "0";
setTimeout(function(){ div.style.display = "none"; }, 600);
}
}
/* Window Funkció */
const win = document.getElementById("win");
const wintitle = document.getElementById("wintitle");
const winapp = document.getElementById("winapp");
const winloading = document.getElementById("winloading");
function openwin() {
win.classList.remove("closed");
}
function closewin() {
win.classList.add("closed");
}
function fullscrn(isfull = null) {
if (isfull == null) {
if(document.getElementById("fullscrnbtn").classList.contains("close")) {
win.classList.remove("fullscrn");
document.getElementById("fullscrnbtn").classList.remove("close");
} else {
win.classList.add("fullscrn");
document.getElementById("fullscrnbtn").classList.add("close");
}
} else if (isfull) {
win.classList.add("fullscrn");
document.getElementById("fullscrnbtn").classList.add("close");
} else {
win.classList.remove("fullscrn");
document.getElementById("fullscrnbtn").classList.remove("close");
}
}
function Loading(isloading = true) {
if (isloading) {
document.getElementById("winloading").classList.remove("hidden");
document.getElementById("loadingBG").classList.add("active")
} else {
document.getElementById("winloading").classList.add("hidden")
document.getElementById("loadingBG").classList.remove("active")
}
}
/* Alert funkciók */
function GenerateID(length = 8) {
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let randomId = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
randomId += characters[randomIndex];
}
return randomId;
}
function GenerateAlerts(type, message, disappearing = true) {
const errorElements = document.querySelectorAll('#errorDIV');
let spanstyle = "'none'";
errorElements.forEach(function(element) {
const randomId = type + GenerateID(16);
let alertHtml = '';
if (type == "error") {
alertHtml = '×Hiba! '+message+'
';
} else if (type == "success") {
alertHtml = '×Siker! '+message+'
';
} else if (type == "info") {
alertHtml = '×Info! '+message+'
';
} else if (type == "warning") {
alertHtml = '×Figyelem! '+message+'
';
}
element.innerHTML += alertHtml;
if (disappearing) {
setTimeout(() => {
const alertElement = document.getElementById(randomId);
if (alertElement) {
alertElement.remove();
}
}, 10000);
}
});
}
/* Név korrektálás */
function adjustFontSize() {
const container = document.getElementById("userNameDiv");
const text = document.getElementById("userNameP");
let fontSize = 16;
text.style.fontSize = "16px";
while (text.scrollHeight > container.clientHeight || text.scrollWidth > container.clientWidth) {
fontSize--;
text.style.fontSize = fontSize + "px";
if (fontSize <= 8) {
break;
}
}
}
if (document.getElementById("userNameP") !== null && document.getElementById("userNameDiv") !== null) {
window.onload = adjustFontSize;
window.onresize = adjustFontSize;
}
/* LogOut timer és vissza LogIn */
let reLogInPopup;
function ReLogIn() {
reLogInPopup = window.open(window.location.origin + '?noredirect=1', 'Belépés', 'width=860,height=860');
}
function ReLogInClose() {
try {
reLogInPopup.location.href = window.location.origin + '/managers/template/loggedin.html';
reLogInPopup.close();
} catch (e) {
console.error('Close error:', e.message);
}
reLogInPopup = null;
}
if (document.getElementById("TimeBeforeLogOutSpan") !== null) {
const timerSpan = document.getElementById('TimeBeforeLogOutSpan');
var theAlertedSessionEnd = null;
const update = () => {
const authTimer = getCookie('auth_timer');
if (!authTimer || isNaN(authTimer)) {
return;
}
const expiry = parseInt(authTimer) * 1000;
const now = Date.now();
const remaining = Math.max(0, Math.floor((expiry - now) / 1000));
if (remaining <= 0) {
timerSpan.textContent = 'Lejárt munkamenet';
timerSpan.style.opacity = '1';
timerSpan.style.right = '210px';
timerSpan.style.color = 'red';
if (theAlertedSessionEnd == null) {
const html = `Az ön munkamenete lejárt!
Kérjük, jelentkezzen be újra!
`;
theAlertedSessionEnd = CreateAlertBox('Lejárt munkamenet', html, false);
}
return;
}
if (theAlertedSessionEnd != null) {
CloseAlertBox(theAlertedSessionEnd);
theAlertedSessionEnd = null;
}
if (reLogInPopup != null && !reLogInPopup.closed) {
ReLogInClose();
}
const minutes = Math.floor(remaining / 60);
const seconds = remaining % 60;
timerSpan.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;
timerSpan.style.opacity = '0.4';
timerSpan.style.right = '10px';
timerSpan.style.color = 'var(--panelcolor)';
};
update();
setInterval(update, 1000);
}
/* Feedback Státusz */
function FeedbackButtonStatus(status = "loading", id) {
var FeedbackButton = document.getElementById(id);
if (status == "loading") {
FeedbackButton.disabled = true;
FeedbackButton.classList.add('loading');
} else if (status == "complete") {
FeedbackButton.classList.add('complete');
setTimeout(() => {
FeedbackButton.classList.remove("loading");
FeedbackButton.classList.remove("complete");
FeedbackButton.disabled = false;
}, 6000);
} else {
FeedbackButton.classList.add('failed');
setTimeout(() => {
FeedbackButton.classList.remove("loading");
FeedbackButton.classList.remove("failed");
FeedbackButton.disabled = false;
}, 6000);
}
}
/* Typing szimuláció */
var TypingMax = 0;
var isSimulateTyping = false;
function getRandomNumber(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min;}
function SimulateTypingProtector(text, elementId) {
if (isSimulateTyping) {
setTimeout(function() {
SimulateTyping(text, elementId);
}, TypingMax);
} else {
SimulateTyping(text, elementId);
}
}
function SimulateTyping(text, elementId) {
var element = document.getElementById(elementId);
var delaymin = 20;
var delaymax = 40;
var index = 0;
TypingMax = text.length * delaymax;
isSimulateTyping = true;
var timer = setInterval(function() {
if (index < text.length) {
var char = text.charAt(index);
element.innerHTML += char;
index++;
} else {
clearInterval(timer);
isSimulateTyping = false;
}
}, getRandomNumber(delaymin, delaymax));
}
/* Kanban board */
if (document.querySelector('.kanban-board') !== null) {
document.addEventListener('DOMContentLoaded', () => {
const board = document.querySelector('.kanban-board');
let isDown = false;
let startX;
let scrollLeft;
board.addEventListener('mousedown', (e) => {
isDown = true;
board.classList.add('active');
startX = e.pageX - board.offsetLeft;
scrollLeft = board.scrollLeft;
});
board.addEventListener('mouseleave', () => {
isDown = false;
board.classList.remove('active');
});
board.addEventListener('mouseup', () => {
isDown = false;
board.classList.remove('active');
});
board.addEventListener('mousemove', (e) => {
if (!isDown) return;
e.preventDefault();
const x = e.pageX - board.offsetLeft;
const walk = (x - startX) * 1.5;
board.scrollLeft = scrollLeft - walk;
});
});
}
/* AlertBox */
function CreateAlertBox(title, html, closeable = true) {
// Overlay létrehozása
const overlay = document.createElement('div');
overlay.className = 'alert-overlay';
overlay.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(3px);
display: flex;
justify-content: center;
align-items: center;
z-index: ${1000 + document.querySelectorAll('.alert-overlay').length};
`;
// AlertBox div létrehozása
const alertBox = document.createElement('div');
alertBox.className = 'alert-box';
alertBox.style.cssText = `
width: 25%;
min-width: 300px;
max-width: 600px;
max-height: 600px;
background: var(--toppanel);
border-radius: 4px;
box-shadow: 1 5px 10px #aaaaaa;
position: relative;
overflow: hidden;
display: flex;
flex-direction: column;
`;
// Header létrehozása
const header = document.createElement('div');
header.style.cssText = `
padding: 8px 20px;
border-bottom: 1px solid #bdc3c7;
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
background-color: var(--panelcolor);
`;
// Title h2 elem
const titleElement = document.createElement('h2');
titleElement.textContent = title;
titleElement.style.cssText = `
margin: 0;
font-size: 18px;
color: #f5f5f5;
`;
header.appendChild(titleElement);
// Close gomb ha closeable
if (closeable) {
const closeButton = document.createElement('button');
closeButton.innerHTML = '×';
closeButton.style.cssText = `
background: none;
border: none;
font-size: 24px;
color: #f5f5f5;
cursor: pointer;
padding: 0;
margin: 0;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
transition: background-color 0.2s;
`;
closeButton.onmouseover = () => closeButton.style.backgroundColor = '#f0f0f0';
closeButton.onmouseout = () => closeButton.style.backgroundColor = 'transparent';
closeButton.onclick = () => CloseAlertBox(overlay);
header.appendChild(closeButton);
}
// Content terület
const content = document.createElement('div');
content.innerHTML = html;
content.style.cssText = `
padding: 0px 20px 20px 20px;
overflow-y: auto;
flex-grow: 1;
text-align: justify;
`;
// Összeállítás
alertBox.appendChild(header);
alertBox.appendChild(content);
overlay.appendChild(alertBox);
// DOM-hoz hozzáadás
document.body.appendChild(overlay);
// Animáció
overlay.style.opacity = '0';
alertBox.style.transform = 'scale(0.8)';
requestAnimationFrame(() => {
overlay.style.transition = 'opacity 0.3s ease';
alertBox.style.transition = 'transform 0.3s ease';
overlay.style.opacity = '1';
alertBox.style.transform = 'scale(1)';
});
return overlay;
}
function CloseAlertBox(overlay) {
if (!overlay) return;
overlay.style.transition = 'opacity 0.3s ease';
overlay.querySelector('.alert-box').style.transition = 'transform 0.3s ease';
overlay.style.opacity = '0';
overlay.querySelector('.alert-box').style.transform = 'scale(0.8)';
setTimeout(() => {
if (overlay.parentNode) {
overlay.parentNode.removeChild(overlay);
}
}, 300);
}