849 lines
28 KiB
JavaScript
849 lines
28 KiB
JavaScript
/*!
|
||
* @license kjokmjnoi API
|
||
* Website: https://api.kjokmjnoi.hu
|
||
* Ver: 1.0.4
|
||
*/
|
||
|
||
/* Link funkciók */
|
||
function get_information(link, callback) {
|
||
var xhr = new XMLHttpRequest();
|
||
xhr.open("GET", link, true);
|
||
xhr.onreadystatechange = function() {
|
||
if (xhr.status == 200) {
|
||
if (xhr.responseText.startsWith('|$6b4ea69e17243db95f7b46c384d40370$|!<script type="text/javascript">window.location=')) {
|
||
var url = xhr.responseText.split('window.location="')[1];
|
||
url = url.split('";</script>')[0];
|
||
window.location= url;
|
||
} else {
|
||
callback(xhr.responseText);
|
||
}
|
||
} else {
|
||
errorCallback();
|
||
}
|
||
};
|
||
xhr.send(null);
|
||
}
|
||
function get_POST_information(link, jsonBody, callback, errorCallback) {
|
||
var xhr = new XMLHttpRequest();
|
||
xhr.open("POST", link);
|
||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||
xhr.onreadystatechange = function() {
|
||
if (xhr.readyState == 4) {
|
||
if (xhr.status == 200) {
|
||
if (xhr.responseText.startsWith('|$6b4ea69e17243db95f7b46c384d40370$|!<script type="text/javascript">window.location=')) {
|
||
var url = xhr.responseText.split('window.location="')[1];
|
||
url = url.split('";</script>')[0];
|
||
window.location= url;
|
||
} else {
|
||
callback(xhr.responseText);
|
||
}
|
||
} else {
|
||
errorCallback();
|
||
}
|
||
}
|
||
};
|
||
xhr.send(jsonBody);
|
||
}
|
||
|
||
/* Kódolók */
|
||
function htmlspecialchar(text) {
|
||
return text.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
|
||
}
|
||
function htmlEncode(s) {
|
||
return s.replace(' ', '%20')
|
||
.replace('/', '%2F')
|
||
.replace('!', '%21')
|
||
.replace('"', '%22')
|
||
.replace('#', '%23')
|
||
.replace('$', '%24')
|
||
.replace('%', '%25')
|
||
.replace('&', '%26')
|
||
.replace("'", "%27")
|
||
.replace('.', '%2E')
|
||
.replace(',', '%2C')
|
||
.replace('+', '%2B')
|
||
.replace('*', '%2A')
|
||
.replace(';', '%3B')
|
||
.replace('?', '%3F')
|
||
.replace('@', '%40')
|
||
.replace(':', '%3A');
|
||
}
|
||
var sha256 = function sha256(ascii) {
|
||
function rightRotate(value, amount) {
|
||
return (value>>>amount) | (value<<(32 - amount));
|
||
};
|
||
var mathPow = Math.pow;
|
||
var maxWord = mathPow(2, 32);
|
||
var lengthProperty = 'length'
|
||
var i, j;
|
||
var result = ''
|
||
var words = [];
|
||
var asciiBitLength = ascii[lengthProperty]*8;
|
||
var hash = sha256.h = sha256.h || [];
|
||
var k = sha256.k = sha256.k || [];
|
||
var primeCounter = k[lengthProperty];
|
||
var isComposite = {};
|
||
for (var candidate = 2; primeCounter < 64; candidate++) {
|
||
if (!isComposite[candidate]) {
|
||
for (i = 0; i < 313; i += candidate) {
|
||
isComposite[i] = candidate;
|
||
}
|
||
hash[primeCounter] = (mathPow(candidate, .5)*maxWord)|0;
|
||
k[primeCounter++] = (mathPow(candidate, 1/3)*maxWord)|0;
|
||
}
|
||
}
|
||
ascii += '\x80'
|
||
while (ascii[lengthProperty]%64 - 56) ascii += '\x00'
|
||
for (i = 0; i < ascii[lengthProperty]; i++) {
|
||
j = ascii.charCodeAt(i);
|
||
if (j>>8) return;
|
||
words[i>>2] |= j << ((3 - i)%4)*8;
|
||
}
|
||
words[words[lengthProperty]] = ((asciiBitLength/maxWord)|0);
|
||
words[words[lengthProperty]] = (asciiBitLength)
|
||
for (j = 0; j < words[lengthProperty];) {
|
||
var w = words.slice(j, j += 16);
|
||
var oldHash = hash;
|
||
hash = hash.slice(0, 8);
|
||
for (i = 0; i < 64; i++) {
|
||
var i2 = i + j;
|
||
var w15 = w[i - 15], w2 = w[i - 2];
|
||
var a = hash[0], e = hash[4];
|
||
var temp1 = hash[7]
|
||
+ (rightRotate(e, 6) ^ rightRotate(e, 11) ^ rightRotate(e, 25))
|
||
+ ((e&hash[5])^((~e)&hash[6]))
|
||
+ k[i]
|
||
+ (w[i] = (i < 16) ? w[i] : (
|
||
w[i - 16]
|
||
+ (rightRotate(w15, 7) ^ rightRotate(w15, 18) ^ (w15>>>3))
|
||
+ w[i - 7]
|
||
+ (rightRotate(w2, 17) ^ rightRotate(w2, 19) ^ (w2>>>10))
|
||
)|0
|
||
);
|
||
var temp2 = (rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22))
|
||
+ ((a&hash[1])^(a&hash[2])^(hash[1]&hash[2]));
|
||
hash = [(temp1 + temp2)|0].concat(hash);
|
||
hash[4] = (hash[4] + temp1)|0;
|
||
}
|
||
for (i = 0; i < 8; i++) {
|
||
hash[i] = (hash[i] + oldHash[i])|0;
|
||
}
|
||
}
|
||
for (i = 0; i < 8; i++) {
|
||
for (j = 3; j + 1; j--) {
|
||
var b = (hash[i]>>(j*8))&255;
|
||
result += ((b < 16) ? 0 : '') + b.toString(16);
|
||
}
|
||
}
|
||
return result;
|
||
};
|
||
var MD5 = function (string) {
|
||
|
||
function RotateLeft(lValue, iShiftBits) {
|
||
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
|
||
}
|
||
|
||
function AddUnsigned(lX,lY) {
|
||
var lX4,lY4,lX8,lY8,lResult;
|
||
lX8 = (lX & 0x80000000);
|
||
lY8 = (lY & 0x80000000);
|
||
lX4 = (lX & 0x40000000);
|
||
lY4 = (lY & 0x40000000);
|
||
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
|
||
if (lX4 & lY4) {
|
||
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
|
||
}
|
||
if (lX4 | lY4) {
|
||
if (lResult & 0x40000000) {
|
||
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
|
||
} else {
|
||
return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
|
||
}
|
||
} else {
|
||
return (lResult ^ lX8 ^ lY8);
|
||
}
|
||
}
|
||
|
||
function F(x,y,z) { return (x & y) | ((~x) & z); }
|
||
function G(x,y,z) { return (x & z) | (y & (~z)); }
|
||
function H(x,y,z) { return (x ^ y ^ z); }
|
||
function I(x,y,z) { return (y ^ (x | (~z))); }
|
||
|
||
function FF(a,b,c,d,x,s,ac) {
|
||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
|
||
return AddUnsigned(RotateLeft(a, s), b);
|
||
};
|
||
|
||
function GG(a,b,c,d,x,s,ac) {
|
||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
|
||
return AddUnsigned(RotateLeft(a, s), b);
|
||
};
|
||
|
||
function HH(a,b,c,d,x,s,ac) {
|
||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
|
||
return AddUnsigned(RotateLeft(a, s), b);
|
||
};
|
||
|
||
function II(a,b,c,d,x,s,ac) {
|
||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
|
||
return AddUnsigned(RotateLeft(a, s), b);
|
||
};
|
||
|
||
function ConvertToWordArray(string) {
|
||
var lWordCount;
|
||
var lMessageLength = string.length;
|
||
var lNumberOfWords_temp1=lMessageLength + 8;
|
||
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
|
||
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
|
||
var lWordArray=Array(lNumberOfWords-1);
|
||
var lBytePosition = 0;
|
||
var lByteCount = 0;
|
||
while ( lByteCount < lMessageLength ) {
|
||
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
||
lBytePosition = (lByteCount % 4)*8;
|
||
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
|
||
lByteCount++;
|
||
}
|
||
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
||
lBytePosition = (lByteCount % 4)*8;
|
||
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
|
||
lWordArray[lNumberOfWords-2] = lMessageLength<<3;
|
||
lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
|
||
return lWordArray;
|
||
};
|
||
|
||
function WordToHex(lValue) {
|
||
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
|
||
for (lCount = 0;lCount<=3;lCount++) {
|
||
lByte = (lValue>>>(lCount*8)) & 255;
|
||
WordToHexValue_temp = "0" + lByte.toString(16);
|
||
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
|
||
}
|
||
return WordToHexValue;
|
||
};
|
||
|
||
function Utf8Encode(string) {
|
||
string = string.replace(/\r\n/g,"\n");
|
||
var utftext = "";
|
||
|
||
for (var n = 0; n < string.length; n++) {
|
||
|
||
var c = string.charCodeAt(n);
|
||
|
||
if (c < 128) {
|
||
utftext += String.fromCharCode(c);
|
||
}
|
||
else if((c > 127) && (c < 2048)) {
|
||
utftext += String.fromCharCode((c >> 6) | 192);
|
||
utftext += String.fromCharCode((c & 63) | 128);
|
||
}
|
||
else {
|
||
utftext += String.fromCharCode((c >> 12) | 224);
|
||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||
utftext += String.fromCharCode((c & 63) | 128);
|
||
}
|
||
|
||
}
|
||
|
||
return utftext;
|
||
};
|
||
|
||
var x=Array();
|
||
var k,AA,BB,CC,DD,a,b,c,d;
|
||
var S11=7, S12=12, S13=17, S14=22;
|
||
var S21=5, S22=9 , S23=14, S24=20;
|
||
var S31=4, S32=11, S33=16, S34=23;
|
||
var S41=6, S42=10, S43=15, S44=21;
|
||
|
||
string = Utf8Encode(string);
|
||
|
||
x = ConvertToWordArray(string);
|
||
|
||
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
||
|
||
for (k=0;k<x.length;k+=16) {
|
||
AA=a; BB=b; CC=c; DD=d;
|
||
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
||
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
||
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
||
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
||
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
||
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
||
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
||
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
||
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
||
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
||
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
||
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
||
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
||
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
||
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
||
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
||
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
||
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
||
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
||
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
||
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
||
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
||
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
||
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
||
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
||
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
||
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
||
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
||
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
||
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
||
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
||
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
||
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
||
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
||
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
||
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
||
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
||
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
||
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
||
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
||
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
||
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
||
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
||
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
||
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
||
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
||
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
||
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
||
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
||
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
||
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
||
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
||
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
||
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
||
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
||
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
||
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
||
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
||
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
||
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
||
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
||
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
||
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
||
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
||
a=AddUnsigned(a,AA);
|
||
b=AddUnsigned(b,BB);
|
||
c=AddUnsigned(c,CC);
|
||
d=AddUnsigned(d,DD);
|
||
}
|
||
|
||
var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
|
||
|
||
return temp.toLowerCase();
|
||
}
|
||
function jsonSafeEncode(str) {
|
||
return str
|
||
.replace(/\\/g, '\\\\')
|
||
.replace(/"/g, '\\"')
|
||
.replace(/'/g, "\\'")
|
||
.replace(/\n/g, '\\n')
|
||
.replace(/\r/g, '\\r')
|
||
.replace(/\t/g, '\\t')
|
||
.replace(/\f/g, '\\f')
|
||
.replace(/%/g, '\\%')
|
||
.replace(/_/g, '\\_')
|
||
.replace(/`/g, '\\`');
|
||
}
|
||
function jsonSafeDecode(str) {
|
||
return str
|
||
.replace(/\\`/g, '`')
|
||
.replace(/\\_/g, '_')
|
||
.replace(/\\%/g, '%')
|
||
.replace(/\\f/g, '\f')
|
||
.replace(/\\t/g, '\t')
|
||
.replace(/\\r/g, '\r')
|
||
.replace(/\\n/g, '\n')
|
||
.replace(/\\"/g, '"')
|
||
.replace(/\\'/g, "'")
|
||
.replace(/\\\\/g, '\\');
|
||
}
|
||
|
||
function NumberToABC(n) {
|
||
const abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||
if (typeof n === 'string') {
|
||
const num = parseInt(n, 10);
|
||
if (isNaN(num) || num < 1 || num > 26) return null;
|
||
return abc.charAt(num - 1);
|
||
}
|
||
if (typeof n !== 'number' || n < 1 || n > 26) return null;
|
||
return abc.charAt(n - 1);
|
||
}
|
||
function padWithZero(str) {
|
||
if (str.length === 2) return str;
|
||
return str.toString().padStart(2, '0');
|
||
}
|
||
|
||
|
||
/* Sütikezelés */
|
||
function setCookie(cname, cvalue, exdays) {
|
||
var d = new Date();
|
||
d.setTime(d.getTime() + (exdays*24*60*60*1000));
|
||
var expires = "expires="+ d.toUTCString();
|
||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||
}
|
||
function getCookie(cname) {
|
||
var name = cname + "=";
|
||
var decodedCookie = decodeURIComponent(document.cookie);
|
||
var ca = decodedCookie.split(';');
|
||
for(var i = 0; i <ca.length; i++) {
|
||
var c = ca[i];
|
||
while (c.charAt(0) == ' ') {
|
||
c = c.substring(1);
|
||
}
|
||
if (c.indexOf(name) == 0) {
|
||
return c.substring(name.length, c.length);
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
var isMobile = {
|
||
Android: function() {
|
||
return navigator.userAgent.match(/Android/i);
|
||
},
|
||
BlackBerry: function() {
|
||
return navigator.userAgent.match(/BlackBerry/i);
|
||
},
|
||
iOS: function() {
|
||
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
||
},
|
||
Opera: function() {
|
||
return navigator.userAgent.match(/Opera Mini/i);
|
||
},
|
||
Windows: function() {
|
||
return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
|
||
},
|
||
any: function() {
|
||
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
||
}
|
||
};
|
||
|
||
function isMobileDevice() {
|
||
return (
|
||
('ontouchstart' in window || navigator.maxTouchPoints > 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 = "<div style='" + style + "'><span class='closebtn' style='" + stylebtn + "'>×</span><strong>Info!</strong> Az oldal mĹąkĂśdĂŠsĂŠhez szĂźksĂŠgesek a cookie-k! Az oldal hasznĂĄlatĂĄval elfogadja ezt!</div>";
|
||
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 = '<div class="erroralert" id="'+randomId+'"><span class="closebtn" onclick="this.parentElement.style.display='+spanstyle+';">×</span><strong>Hiba!</strong> '+message+'</div>';
|
||
} else if (type == "success") {
|
||
alertHtml = '<div class="successalert" id="'+randomId+'"><span class="closebtn" onclick="this.parentElement.style.display='+spanstyle+';">×</span><strong>Siker!</strong> '+message+'</div>';
|
||
} else if (type == "info") {
|
||
alertHtml = '<div class="infoalert" id="'+randomId+'"><span class="closebtn" onclick="this.parentElement.style.display='+spanstyle+';">×</span><strong>Info!</strong> '+message+'</div>';
|
||
} else if (type == "warning") {
|
||
alertHtml = '<div class="warningalert" id="'+randomId+'"><span class="closebtn" onclick="this.parentElement.style.display='+spanstyle+';">×</span><strong>Figyelem!</strong> '+message+'</div>';
|
||
}
|
||
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 = `<p><b>Az ön munkamenete lejárt!</b><br>Kérjük, jelentkezzen be újra!</p>
|
||
<br clear='all'>
|
||
<button id="AlertBtnNo" style="float: right; margin-left: 15px; width: 80;" onclick="location.reload();">Mégsem</button>
|
||
<button style="float: right; width: 80;" onclick="ReLogIn()">Bejelentkezés</button>`;
|
||
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);
|
||
}
|