1var loginwindow = null; 2window.inputRND = ""; 3window.forceLoginLayerRedirect = false; 4 5 6const isLocalhost = window.location.host.toLowerCase() === "localhost"; 7const dokinetbase = `${(isLocalhost ? "http://localhost" : `https://www.doki.net${(window.location.port == "" ? "": (":" + window.location.port))}`)}`; 8const webapibase = dokinetbase + "/webapiservices/"; 9 10document.addEventListener('DOMContentLoaded', function () { 11 window.inputRND = "_" + Math.floor(Math.random() * 99999); 12 document.querySelectorAll("input[name='username'],input[name='pwd']").forEach(function (el) { 13 var name = el.getAttribute('name'); 14 el.setAttribute('name', name + window.inputRND); 15 el.value = ''; 16 el.setAttribute('value', ''); 17 }); 18}); 19 20function _parseUrl(urlString, base) { 21 return new URL(urlString, base || window.location.href); 22} 23 24function _setUrlParam(urlString, key, value) { 25 var url = _parseUrl(urlString); 26 url.searchParams.set(key, value); 27 return url.toString(); 28} 29 30function _removeUrlParam(urlString, key) { 31 var url = _parseUrl(urlString); 32 url.searchParams.delete(key); 33 return url.toString(); 34} 35 36function _deduplicateUrlParams(urlString) { 37 var url = _parseUrl(urlString); 38 var seen = {}; 39 var pairs = []; 40 41 url.searchParams.forEach(function (value, key) { 42 if (!seen[key]) { 43 seen[key] = true; 44 pairs.push([key, value]); 45 } 46 }); 47 48 var newParams = new URLSearchParams(); 49 for (var i = 0; i < pairs.length; i++) { 50 newParams.append(pairs[i][0], pairs[i][1]); 51 } 52 url.search = newParams.toString(); 53 return url.toString(); 54} 55 56function CleanQueryString(url) { 57 return _deduplicateUrlParams(url); 58} 59 60function GetTopParentWindow(win) { 61 return (win.parent && win.parent !== win) ? GetTopParentWindow(win.parent) : win; 62} 63 64function CloseWindowOpenerWindow() { 65 if (window.LoginCmdWindow && !window.LoginCmdWindow.IsOpened) { 66 window.LoginCmdWindow.close(); 67 window.LoginCmdWindow = null; 68 } 69} 70 71function getQueryStringValue(key, win) { 72 return new URL((win || window.parent).location.href).searchParams.get(key); 73} 74 75function GetCurrentQueryString(targetWindow) { 76 return (targetWindow || window.parent).location.search.replace(/^\?/, ''); 77} 78 79function GetCurrentUrlWithoutWebId() { 80 return _removeUrlParam(window.parent.location.href, 'web_id'); 81} 82 83function RemoveWebIdFromUrl(url) { 84 if (!url) return ""; 85 return _removeUrlParam(url, 'web_id'); 86} 87 88function _navigateWindowWithWebId(pWindow, webId) { 89 try { 90 var url = _parseUrl(pWindow.location.href); 91 92 if (url.searchParams.get('c') === 'url' && url.searchParams.has('u')) { 93 var targetUrl = _parseUrl(url.searchParams.get('u'), pWindow.location.href); 94 targetUrl.searchParams.set('web_id', webId); 95 setTimeout(function () { pWindow.location.href = targetUrl.toString(); }, 250); 96 return; 97 } 98 99 if (url.pathname.toLowerCase().indexOf('loginlayer.aspx') !== -1 && url.searchParams.has('currenturl')) { 100 var targetUrl = _parseUrl(url.searchParams.get('currenturl'), pWindow.location.href); 101 targetUrl.searchParams.set('web_id', webId); 102 setTimeout(function () { pWindow.location.href = targetUrl.toString(); }, 250); 103 return; 104 } 105 106 url.searchParams.set('web_id', webId); 107 setTimeout(function () { pWindow.location.href = url.toString(); }, 250); 108 } catch (ex) { } 109} 110 111function AppendWebIdToQuery(pWindow, webId) { 112 _navigateWindowWithWebId(pWindow, webId); 113} 114 115function ReloadWithWebId(webId) { 116 if (!webId || webId.length === 0) return; 117 118 var win = GetTopParentWindow(window); 119 _navigateWindowWithWebId(win, webId); 120 121 try { 122 if (win.opener && win.opener !== win) { 123 _navigateWindowWithWebId(GetTopParentWindow(win.opener), webId); 124 } 125 } catch (ex) { } 126} 127 128var _win1250High = { 129 '\u20AC': 0x80, '\u201A': 0x82, '\u201E': 0x84, '\u2026': 0x85, '\u2020': 0x86, 130 '\u2021': 0x87, '\u2030': 0x89, '\u0160': 0x8A, '\u2039': 0x8B, '\u015A': 0x8C, 131 '\u0164': 0x8D, '\u017D': 0x8E, '\u0179': 0x8F, '\u2018': 0x91, '\u2019': 0x92, 132 '\u201C': 0x93, '\u201D': 0x94, '\u2022': 0x95, '\u2013': 0x96, '\u2014': 0x97, 133 '\u2122': 0x99, '\u0161': 0x9A, '\u203A': 0x9B, '\u015B': 0x9C, '\u0165': 0x9D, 134 '\u017E': 0x9E, '\u017A': 0x9F 135}; 136 137function _win1250CharCode(ch) {
138 var code = ch.charCodeAt(0); 139 if (code < 0x80) 140 return code; 141 142 if (_win1250High[ch] !== undefined) 143 return _win1250High[ch]; 144 145 return code; 146} 147 148function EncodeASCIIToHex(input) { 149 if (!input || input.length < 1) 150 return ""; 151 152 var result = ""; 153 for (var i = 0; i < input.length; i++) { 154 result += _win1250CharCode(input[i]).toString(16).toUpperCase().padStart(2, '0'); 155 } 156 157 return result; 158} 159 160function _buildLoginPageUrl(currentUrl) { 161 var url = new URL(currentUrl); 162 163 var pathParts = url.pathname.split('/'); 164 var cleanTarget = new URL(currentUrl); 165 cleanTarget.searchParams.delete('web_id'); 166 var relativeTarget = pathParts[pathParts.length - 1] + cleanTarget.search + cleanTarget.hash; 167 168 pathParts[pathParts.length - 1] = 'bejelentkezes.aspx'; 169 url.pathname = pathParts.join('/'); 170 url.search = ''; 171 url.hash = ''; 172 url.searchParams.set('c', 'eurl'); 173 url.searchParams.set('eu', EncodeASCIIToHex(relativeTarget)); 174 return url.toString(); 175} 176 177function _buildLoginLayerIframeUrl(currentUrl, extraparam) { 178 var url = new URL(currentUrl); 179 var pathParts = url.pathname.split('/'); 180 181 var filteredParts = []; 182 for (var i = 0; i < pathParts.length; i++) { 183 if (pathParts[i] !== 'dpsystem' && pathParts[i] !== 'elearn') { 184 filteredParts.push(pathParts[i]); 185 } 186 } 187 188 filteredParts[filteredParts.length - 1] = 'loginlayer.aspx'; 189 url.pathname = filteredParts.join('/'); 190 url.search = ''; 191 url.hash = ''; 192 193 if (extraparam) { 194 new URLSearchParams(extraparam).forEach(function (value, key) { 195 url.searchParams.set(key, value); 196 }); 197 } else { 198 url.searchParams.set('currenturl', currentUrl); 199 } 200 201 return url.toString(); 202} 203 204function _getOrCreateLoginBox() { 205 var loginBox = document.getElementById('loginBox'); 206 if (!loginBox) { 207 loginBox = document.createElement('div'); 208 loginBox.id = 'loginBox'; 209 document.body.appendChild(loginBox); 210 } 211 return loginBox; 212} 213 214function _createLoginIframe(url) { 215 var iframe = document.createElement("iframe"); 216 iframe.src = url; 217 iframe.width = '100%'; 218 iframe.height = '100%'; 219 iframe.frameBorder = '0'; 220 iframe.style.cssText = 'position:fixed;top:0;left:0;'; 221 return iframe; 222} 223 224function ShowLoginLayerDialog(extraparam) { 225 var currentUrl = window.location.toString().toLowerCase(); 226 227 if (window.innerWidth < 800 || window.forceLoginLayerRedirect) { 228 document.location = _buildLoginPageUrl(currentUrl); 229 return; 230 } 231 232 var iframeUrl = _buildLoginLayerIframeUrl(currentUrl, extraparam); 233 234 var loginBox = _getOrCreateLoginBox(); 235 loginBox.innerHTML = ''; 236 237 var iframe = _createLoginIframe(iframeUrl); 238 loginBox.appendChild(iframe); 239 240 loginBox.style.cssText = 'opacity:0;display:block;z-index:1000;position:fixed;top:0;left:0;width:100%;height:100%;'; 241 loginBox.onclick = function () { CloseLoginLayer(); }; 242 243 iframe.onload = function () { SetLoginLayerToVisible(); }; 244} 245 246function CloseLoginLayer() { 247 SetLoginLayerToInvisible(); 248 setTimeout(function () { 249 var loginBox = window.parent.document.getElementById('loginBox'); 250 if (loginBox) { 251 loginBox.style.display = "none"; 252 loginBox.innerHTML = ""; 253 } 254 }, 500); 255} 256 257function SetLoginLayerToVisible() { 258 var el = document.getElementById('loginBox'); 259 if (!el) return; 260 el.style.transition = 'opacity 0.5s'; 261 el.style.opacity = '0'; 262 requestAnimationFrame(function () { 263 requestAnimationFrame(function () { el.style.opacity = '1'; }); 264 }); 265} 266 267function SetLoginLayerToInvisible() { 268 var el = document.getElementById('loginBox'); 269 if (!el) return; 270 el.style.transition = 'opacity 0.5s'; 271 el.style.opacity = '0'; 272} 273 274function _getInputValue(fieldBaseName, placeholders) { 275 var elements = document.getElementsByName(fieldBaseName + window.inputRND); 276 for (var i = 0; i < elements.length; i++) { 277 var val = elements[i].value; 278 if (val !== "" && placeholders.indexOf(val) === -1) return val; 279 } 280 return ""; 281} 282 283function SubmitLogin(rootDirectory) { 284 var userName = _getInputValue('username', ["Username", "Felhasználó név"]); 285 var password = _getInputValue('pwd', ["Password", "Jelszó"]); 286 var rememberEl = document.getElementsByName('RememberMe')[0]; 287 var rememberMe = rememberEl ? rememberEl.checked : false;
288 289 StartLogin(userName, password, rememberMe, rootDirectory); 290 return false; 291} 292 293function SubmitOnKeyPressEvent(rootDirectory, evt) { 294 var e = evt || event || window.event; 295 if ((e.keyCode || e.which) === 13) { 296 e.preventDefault(); 297 e.stopPropagation(); 298 SubmitLogin(rootDirectory); 299 } 300} 301 302function GetTargetUrl(rootDirectory) { 303 var url = new URL(`/tarsasag/${rootDirectory}/info.aspx?sp=0`, dokinetbase); 304 url.searchParams.set('rnd', new Date().getTime()); 305 306 if (window.location.search) { 307 var cmd = (getQueryStringValue("cmd", window) || "").toLowerCase(); 308 if (cmd !== "") { 309 var cmdUrl = getQueryStringValue("url", window) || ""; 310 url.searchParams.set('cmd', cmd); 311 url.searchParams.set('url', cmdUrl.replace("?", "[qm]")); 312 313 window.LoginCmd = cmd; 314 window.LoginCmdUrl = cmdUrl; 315 316 if (cmd === "open") { 317 window.LoginCmdWindow = window.open('about:blank', '_blank'); 318 } 319 } 320 } 321 322 return url.toString(); 323} 324 325function getCookie(cname) { 326 var name = cname + "="; 327 var ca = document.cookie.split(';'); 328 for (var i = 0; i < ca.length; i++) { 329 var c = ca[i].trim(); 330 if (c.indexOf(name) === 0) return c.substring(name.length); 331 } 332 return ""; 333} 334 335function setCookie(cname, cvalue, exdays) { 336 var expires = ""; 337 if (exdays) { 338 expires = "expires=" + new Date().addDays(exdays).toUTCString(); 339 } 340 document.cookie = cname + "=" + cvalue + ";" + expires; 341 Promise.resolve().then(() => setCrossDoaminCookie(cname, cvalue, exdays)); 342} 343 344var ParentCrossDomainMessageEvent = null; 345var ReceivedCrossDomainMessage = []; 346 347function GetHost() { 348 return window.location.host.replace("www.", "").toLowerCase(); 349} 350 351function GUID() { 352 var d = new Date().getTime(); 353 var d2 = (typeof performance !== 'undefined' && performance.now) ? (performance.now() * 1000) : 0; 354 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 355 var r = Math.random() * 16; 356 if (d > 0) { r = (d + r) % 16 | 0; d = Math.floor(d / 16); } 357 else { r = (d2 + r) % 16 | 0; d2 = Math.floor(d2 / 16); } 358 return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); 359 }); 360} 361 362function ThreadSleep(ms) { 363 return new Promise(function (resolve) { setTimeout(resolve, ms); }); 364} 365 366function getMessage(messageId, prop) { 367 return new Promise(function (resolve) { 368 var attempts = 0; 369 370 function poll() { 371 if (ReceivedCrossDomainMessage[messageId]) { 372 resolve(ReceivedCrossDomainMessage[messageId][prop]); 373 return; 374 } 375 if (attempts >= 300) { resolve(null); return; } 376 attempts++; 377 ThreadSleep(10).then(poll); 378 } 379 380 poll(); 381 }); 382} 383 384function getCrossDomainCookie(cname) { 385 if (GetHost() !== "doki.net") { 386 var msgid = GUID(); 387 sendMessage({ messageId: msgid, eventType: "getCookie", cookie_name: cname, cookie_value: "" }); 388 return getMessage(msgid, "cookie_value"); 389 } else { 390 return Promise.resolve(getCookie(cname) || null); 391 } 392} 393 394function setCrossDoaminCookie(cname, cvalue, exdays) { 395 var expires = exdays ? new Date().addDays(exdays).toUTCString() : ''; 396 397 if (GetHost() !== "doki.net") { 398 sendMessage({ messageId: GUID(), eventType: "setcookie", cookie_name: cname, cookie_value: cvalue, cookie_expires: expires }); 399 return Promise.resolve(); 400 } else { 401 var cookieStr = cname + "=" + cvalue + "; SameSite=None; Secure; domain=doki.net; path=/"; 402 if (expires) cookieStr += "; expires=" + expires; 403 document.cookie = cookieStr; 404 return Promise.resolve(); 405 } 406} 407 408function ReceiveCrossDomainMessage(evt) { 409 ParentCrossDomainMessageEvent = evt; 410 try { 411 var data = JSON.parse(evt.data); 412 413 switch (data.eventType) { 414 case "setCookie": 415 setCrossDoaminCookie(data.cookie_name, data.cookie_value, data.cookie_expiresdays); 416 break; 417 case "getCookie": 418 if (data.cookie_value === "") { 419 getCrossDomainCookie(data.cookie_name).then(function (val) { 420 SendCrossDomainMessage({ 421 messageId: data.messageId, 422 eventType: "getCookie", 423 cookie_name: data.cookie_name, 424 cookie_value: val 425 }); 426 }); 427 } 428 break; 429 } 430 431 if (data.messageId) { 432 ReceivedCrossDomainMessage[data.messageId] = data; 433 } 434 } catch (e) { } 435} 436 437function SendCrossDomainMessage(data) { 438 if (ParentCrossDomainMessageEvent) { 439 ParentCrossDomainMessageEvent.source.postMessage( 440 JSON.stringify(data), 441 ParentCrossDomainMessageEvent.origin 442 ); 443 } 444} 445 446function sendMessage(message) { 447 var receiver = window.CrossDomainReceiverIframe; 448 if (!receiver) { 449 CreateCrossDomainReceiverIframe().then(function (iframe) { 450 iframe.onload = function () { 451 iframe.contentWindow.postMessage(JSON.stringify(message), '*'); 452 }; 453 }); 454 } else { 455 receiver.contentWindow.postMessage(JSON.stringify(message), '*'); 456 } 457} 458 459function CreateCrossDomainReceiverIframe() { 460 var iframe = document.getElementById("CrossDomainReceiverIframe"); 461 if (!iframe) 462 { 463 iframe = document.createElement("iframe"); 464 iframe.id = "CrossDomainReceiverIframe"; 465 iframe.src = dokinetbase + "/webidcookie.html"; 466 iframe.style.display = "none"; 467 document.body.appendChild(iframe); 468 } 469 470 return Promise.resolve(iframe); 471} 472 473function InitCrossDomain() { 474 if (!document.body) { 475 setTimeout(InitCrossDomain, 100); 476 return; 477 } 478 setTimeout(function () { 479 CreateCrossDomainReceiverIframe(); 480 }, 500); 481} 482 483if (window.addEventListener) { 484 window.addEventListener("message", ReceiveCrossDomainMessage, false); 485} else { 486 window.attachEvent("onmessage", ReceiveCrossDomainMessage); 487} 488 489InitCrossDomain(); 490 491function CheckLogin(targetUrl, societyId) { 492 if (targetUrl.toLowerCase().indexOf("/tarsasag/") !== -1 && 493 window.location.toString().toLowerCase().indexOf("/tarsasag/") !== -1) { 494 var parsed = _parseUrl(targetUrl); 495 parsed.protocol = window.location.protocol; 496 parsed.host = window.location.host; 497 targetUrl = parsed.toString(); 498 } 499 500 if (getCookie('RemCookieState_' + societyId) !== '') return; 501 502 var url = new URL(targetUrl); 503 url.searchParams.set('checklogincookie', '1'); 504 505 fetch(url.toString(), { credentials: 'include' }) 506 .then(function (r) { return r.json(); }) 507 .then(function (response) { ProcessLoginResponse(response); }) 508 .catch(function () {}); 509} 510 511function StartLogin(userName, password, rememberMe, rootDirectory, badLoginFunction) { 512 window.LoginCmd = null; 513 window.LoginCmdUrl = null; 514 515 var targetUrl = GetTargetUrl(rootDirectory); 516 var postData = new URLSearchParams(); 517 postData.set('username', encodeURIComponent(userName)); 518 postData.set('pwd', encodeURIComponent(password)); 519 postData.set('RememberMe', (rememberMe === true || rememberMe === 'on') ? 'on' : 'off'); 520 521 var loginLoaderId = "start-login-loader"; 522 523 function createLoginLoader() { 524 var div = document.createElement('div'); 525 div.id = loginLoaderId; 526 div.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100vh;display:flex;align-items:center;justify-content:center;z-index:9999;background:rgba(0,0,0,0.7);'; 527 var inner = document.createElement('div'); 528 inner.id = loginLoaderId + '-content'; 529 div.appendChild(inner); 530 document.body.appendChild(div); 531 } 532 533 function removeLoginLoader() { 534 var el = document.getElementById(loginLoaderId); 535 if (el) el.parentNode.removeChild(el); 536 } 537 538 function onResponse(response) { 539 ProcessLoginResponse(response).then(function () { 540 if (!response.LoginStatus) { 541 removeLoginLoader(); 542 _handleBadLogin(response, badLoginFunction); 543 } 544 }); 545 } 546 547 createLoginLoader(); 548 549 fetch(targetUrl, { 550 method: 'POST', 551 headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=windows-1250' }, 552 credentials: 'include', 553 body: postData.toString() 554 }) 555 .then(function (r) { return r.arrayBuffer(); }) 556 .then(function (buffer) { 557 var decoder = new TextDecoder('windows-1250'); 558 var text = decoder.decode(buffer); 559 var data = JSON.parse(text); 560 onResponse(data); 561 }) 562 .catch(function () { 563 removeLoginLoader(); 564 alert('Hiba történt a bejelentkezés során!'); 565 }); 566} 567 568function StartLogout(rootDirectory) { 569 var url = new URL(GetTargetUrl(rootDirectory)); 570 url.searchParams.set('sp', '0'); 571 url.searchParams.set('logout', '1'); 572 url.searchParams.set('web_id', getQueryStringValue('web_id')); 573 574 fetch(url.toString(), { credentials: 'include' }) 575 .then(function (r) { return r.json(); }) 576 .then(function (response) { ProcessLogout(response); }) 577 .catch(function () {}); 578} 579 580function ProcessLoginResponse(response) { 581 if (!(response && response.LoginStatus)) {
582 setCookie("RemCookieState_" + response.Sid, "-1"); 583 return Promise.resolve(); 584 } 585 else if (response?.WebIdCookie?.Name && response?.WebIdCookie?.Value) { 586 setCookie(response.WebIdCookie.Name, response.WebIdCookie.Value); 587 } 588 589 590 function afterCookiesSet() { 591 _applyLoginRedirect(response); 592 } 593 594 if (response.SecureCookie && response.SecureCookie.Name && response.SecureCookie.Value) { 595 setCookie(response.SecureCookie.Name, response.SecureCookie.Value, 365); 596 return setCrossDoaminCookie(response.SecureCookie.Name, response.SecureCookie.Value, 365) 597 .then(afterCookiesSet); 598 } else { 599 afterCookiesSet(); 600 return Promise.resolve(); 601 } 602} 603 604function _applyLoginRedirect(response) { 605 var targetWindow = window.parent; 606 607 if (targetWindow.location.hash && response.OpenUrl) { 608 response.OpenUrl += targetWindow.location.hash; 609 } 610 611 if (response.PostValues) { 612 _submitPostRedirect(targetWindow, response.OpenUrl, response.PostValues); 613 return; 614 } 615 616 if (window.LoginCmd !== null && window.LoginCmdUrl !== null) { 617 response.OpenUrl = _setUrlParam(window.LoginCmdUrl, 'web_id', response.ResultMessage); 618 response.OpenNewWindow = (window.LoginCmd === "open"); 619 } 620 621 if (response.OpenUrl) { 622 response.OpenUrl = _deduplicateUrlParams(response.OpenUrl); 623 624 if (response.OpenNewWindow) { 625 if (window.LoginCmdWindow) { 626 window.LoginCmdWindow.location.href = response.OpenUrl; 627 window.LoginCmdWindow.IsOpened = true; 628 } 629 } 630 631 CloseWindowOpenerWindow(); 632 var win = GetTopParentWindow(window); 633 _navigateWindowWithWebId(win.opener || win, response.ResultMessage); 634 return; 635 } 636 637 CloseWindowOpenerWindow(); 638 ReloadWithWebId(response.ResultMessage); 639} 640 641function _submitPostRedirect(targetWindow, actionUrl, postValues) { 642 var params = postValues.split('&'); 643 if (!params.length) return; 644 645 var form = targetWindow.document.createElement("form"); 646 form.action = actionUrl.replace(';', ''); 647 form.method = 'POST'; 648 649 for (var i = 0; i < params.length; i++) { 650 var kvp = params[i].split('='); 651 if (kvp.length === 2) { 652 var input = targetWindow.document.createElement("input"); 653 input.type = "hidden"; 654 input.name = kvp[0]; 655 input.value = kvp[1]; 656 form.appendChild(input); 657 } 658 } 659 660 targetWindow.document.body.appendChild(form); 661 form.submit(); 662} 663 664function _handleBadLogin(response, badLoginFunction) { 665 if (badLoginFunction) { 666 badLoginFunction(response); 667 return; 668 } 669 670 var errorDiv = document.createElement('div'); 671 errorDiv.className = 'login-error-popup'; 672 errorDiv.style.display = 'none'; 673 errorDiv.innerHTML = response.ResultMessage; 674 document.body.insertBefore(errorDiv, document.body.firstChild); 675 676 var targetWindow = window.parent; 677 if (targetWindow.initmb) { 678 targetWindow.initmb('badlogin'); 679 targetWindow.sm('badlogin_popup_div', 630, 165, 'badlogin'); 680 } else { 681 var msg = "Hibás bejelentkezés"; 682 if (response.ResultMessage) { 683 var parser = new DOMParser(); 684 var doc = parser.parseFromString(response.ResultMessage, 'text/html'); 685 var loginText = doc.getElementById('login-text'); 686 if (loginText) msg = loginText.innerHTML; 687 } 688 alert(msg); 689 } 690} 691 692function ProcessLogout(response) { 693 const _webid = getQueryStringValue("web_id"); 694 695 setCookie("LOGIN_" + response.Sid, "-1", -1);
696 setCookie("EXTERNALLOGIN", "-1", -1); 697 setCookie(`_webid_${_webid}`, "-1", -1); 698 699 setCrossDoaminCookie("EXTERNALLOGIN", "-1", -1).then(function () { 700 setCrossDoaminCookie(`_webid_${_webid}`, "-1", -1); 701 }); 702 703 setCrossDoaminCookie("LOGIN_" + response.Sid, "-1", -1).then(function () { 704 window.parent.location.replace(GetCurrentUrlWithoutWebId()); 705 }); 706} 707 708function CheckExternalLogin(evt, modulid, username_selector, password_selector) { 709 if (evt) evt.preventDefault(); 710 711 var usernameEl = document.querySelector(username_selector); 712 var passwordEl = document.querySelector(password_selector); 713 var login = { 714 UserName: usernameEl ? usernameEl.value : "", 715 Password: passwordEl ? passwordEl.value : "", 716 ModulId: modulid 717 }; 718 719 setCookie("EXTERNALLOGIN", btoa(JSON.stringify(login))); 720 721 fetch(window.location.href, { credentials: 'include' }) 722 .then(function (r) { return r.json(); }) 723 .then(function (response) { 724 if (response && response.LoginStatus) { 725 setCrossDoaminCookie("EXTERNALLOGIN", btoa(JSON.stringify(login))); 726 window.location.reload(true); 727 } else { 728 setCookie("EXTERNALLOGIN", "", -1); 729 alert("Hibás bejelentkezés"); 730 } 731 }) 732 .catch(function () { 733 setCookie("EXTERNALLOGIN", "", -1); 734 alert("Hibás bejelentkezés"); 735 }); 736} 737 738function SetExternalLoginData(modulid, data, reload, isAsync) { 739 if (reload === undefined) reload = true; 740 if (isAsync === undefined) isAsync = true; 741 742 var cookieValue = getCookie("EXTERNALLOGIN"); 743 var login = cookieValue 744 ? JSON.parse(atob(cookieValue)) 745 : { UserName: data.UserName || "", Password: data.Password || "", ModulId: modulid }; 746 747 if (!login.ExtendedDatas) login.ExtendedDatas = {}; 748 749 var source = data.ExtendedDatas || data; 750 for (var code in source) { 751 if (source.hasOwnProperty(code)) login.ExtendedDatas[code] = source[code]; 752 } 753 754 setCookie("EXTERNALLOGIN", btoa(JSON.stringify(login))); 755 756 if (!isAsync) { 757 var xhr = new XMLHttpRequest(); 758 xhr.open("POST", window.location.href, false); 759 xhr.withCredentials = true; 760 xhr.send(); 761 try { 762 var resp = JSON.parse(xhr.responseText); 763 if (resp && resp.LoginStatus) { 764 if (reload) window.location.reload(true); 765 } else { 766 setCookie("EXTERNALLOGIN", "", -1); 767 alert("Hibás bejelentkezés"); 768 } 769 } catch (e) {} 770 return; 771 } 772 773 fetch(window.location.href, { method: 'POST', credentials: 'include' }) 774 .then(function (r) { return r.json(); }) 775 .then(function (response) { 776 if (response && response.LoginStatus) { 777 if (reload) window.location.reload(true); 778 } else { 779 setCookie("EXTERNALLOGIN", "", -1); 780 alert("Hibás bejelentkezés"); 781 } 782 }) 783 .catch(function () { 784 setCookie("EXTERNALLOGIN", "", -1); 785 alert("Hibás bejelentkezés"); 786 }); 787} 788 789function DownloadSection(sectionId, web_id, sid) { 790 fetch(webapibase + "api/export/get-sectionmembers/" + sectionId, { 791 headers: { "Authorization": "WebID " + web_id + ":" + sid } 792 }) 793 .then(function (r) { return r.json(); }) 794 .then(function (response) { 795 if (!response || response.ResponseStatus !== 200) { 796 alert("Hiba a mûvelet végrehajtása során!"); 797 } else { 798 window.location.href = response.ResponseObject.DownloadUrl; 799 } 800 }) 801 .catch(function () { alert("Hiba a mûvelet végrehajtása során!"); }); 802} 803 804function GetDateString() { 805 var d = new Date(); 806 var pad = function (n) { return ("0" + n).slice(-2); }; 807 return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate()) 808 + " " + pad(d.getHours()) + ":" + pad(d.getMinutes()) + ":" + pad(d.getSeconds()); 809} 810 811Date.prototype.format = function (format) { 812 var date = this; 813 var pad = function (n) { return ("0" + n).slice(-2); }; 814 var formats = { 815 "yyyy": function () { return date.getFullYear(); }, 816 "yy": function () { return date.getFullYear().toString().slice(-2); }, 817 "MMMM": function () { return ["január","február","március","április","május","június","július","augusztus","szeptember","október","november","december"][date.getMonth()]; }, 818 "MMM": function () { return ["jan.","feb.","márc.","ápr.","máj.","jún.","júl.","aug.","szept.","okt.","nov.","dec."][date.getMonth()]; }, 819 "MM": function () { return pad(date.getMonth() + 1); }, 820 "dd": function () { return pad(date.getDate()); }, 821 "d": function () { return date.getDate().toString(); }, 822 "HH": function () { return pad(date.getHours()); }, 823 "H": function () { return date.getHours().toString(); }, 824 "mm": function () { return pad(date.getMinutes()); }, 825 "m": function () { return date.getMinutes().toString(); }, 826 "ss": function () { return pad(date.getSeconds()); }, 827 "s": function () { return date.getSeconds().toString(); } 828 }; 829 for (var pattern in formats) { 830 if (formats.hasOwnProperty(pattern)) { 831 format = format.replace(pattern, formats[pattern]); 832 } 833 } 834 return format; 835}; 836 837Date.format = function(format) { 838 return new Date().format(format); 839} 840 841Date.prototype.addDays = function (days) { 842 const result = new Date(this); 843 result.setDate(result.getDate() + days); 844 return result; 845}; 846 847Date.timestamp = function () { 848 var timestamp; 849 var xhr = new XMLHttpRequest(); 850 xhr.onreadystatechange = function () { 851 if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) { 852 timestamp = new Date(JSON.parse(xhr.response).timestamp); 853 } 854 }; 855 xhr.open("GET", webapibase + "api/public/timestamp", false); 856 xhr.send(); 857 return timestamp; 858};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.