/* LayerNX © – LNX Search, alle Seiten: Konto-Link oben rechts (accounts.layernx.de). ES5. */ (function () { "use strict"; var host = location.hostname; var accounts = /(^|\.)layernx\.systems$/.test(host) ? "https://accounts.layernx.systems" : /(^|\.)layernx\.de$/.test(host) ? "https://accounts.layernx.de" : location.protocol + "//" + host + ":3509"; window.LNX_ACCOUNTS = accounts; var acc = document.getElementById("lnxAccount"); if (acc) acc.href = accounts + "/login?next=" + encodeURIComponent(location.href); var xhr = new XMLHttpRequest(); xhr.open("GET", accounts + "/api/me"); xhr.withCredentials = true; xhr.timeout = 2500; function done(me) { window.LNX_ME = me; if (me && me.logged_in && acc) { var label = acc.querySelector("span"); if (label) label.textContent = me.display || me.first_name || me.name || "Konto"; acc.href = accounts + "/konto"; acc.classList.add("is-in"); } var ev; try { ev = new CustomEvent("lnx:me", { detail: me }); } catch (e) { ev = document.createEvent("CustomEvent"); ev.initCustomEvent("lnx:me", false, false, me); } document.dispatchEvent(ev); } xhr.onload = function () { var me = null; try { me = JSON.parse(xhr.responseText); } catch (e) { /* kein JSON */ } done(me); }; xhr.onerror = xhr.ontimeout = function () { done(null); }; xhr.send(); })();