/* AGS 92 – B2B: dátumy v maďarskom formáte (HU) * Súbor: /buxus/docs/datum-hu.js.txt (Container 22 → Content after) * Čo robí: na stránkach /hu/ (okrem účtu /hu/fiokom…) prepíše dátumy typu 4.3.2026 / 04.03.2026 na 2026. 03. 04. * – aby dátum dostupnosti nebol nejednoznačný (4. marec vs. 3. apríl). Mení iba zobrazený text, nie dáta. * – „31.5.2024-től“ → „2024. 05. 31-től“ (maďarská prípona bez bodky). * – sleduje aj produkty dočítané neskôr (AJAX, lazy načítanie). * Vypnutie: zmazať riadok s datum-hu.js.txt v Container 22. */ (function () { 'use strict'; if (window.__agsDatumHu) { return; } window.__agsDatumHu = true; var p = location.pathname; if (!/^\/hu(\/|$)/i.test(p) || /^\/hu\/fiokom(\/|$)/i.test(p)) { return; } var RE = /(^|[^\d.])(\d{1,2})\.\s?(\d{1,2})\.\s?((?:19|20)\d{2})(?![\d])(\.?)(-)?/g; var SKIP = { SCRIPT: 1, STYLE: 1, TEXTAREA: 1, INPUT: 1, SELECT: 1, OPTION: 1, NOSCRIPT: 1, CODE: 1, PRE: 1 }; function pad(n) { return (n < 10 ? '0' : '') + n; } function conv(s) { return s.replace(RE, function (all, pre, d, mo, y, dot, dash) { d = +d; mo = +mo; if (d < 1 || d > 31 || mo < 1 || mo > 12) { return all; } return pre + y + '. ' + pad(mo) + '. ' + pad(d) + (dash ? '-' : '.'); }); } function skip(el) { for (var e = el; e && e !== document.body; e = e.parentNode) { if (e.nodeType !== 1) { continue; } if (SKIP[e.tagName] || e.isContentEditable) { return true; } if (e.id && /^ags-(reklamacia|splat)/.test(e.id)) { return true; } if (e.classList && (e.classList.contains('ags-splat-md') || e.classList.contains('ags-splat-bar') || e.classList.contains('adresa'))) { return true; } } return false; } function run(root) { if (!root) { return; } if (root.nodeType === 3) { fix(root); return; } if (root.nodeType !== 1 || skip(root)) { return; } var w = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false), n, list = []; while ((n = w.nextNode())) { if (/\d\.\s?\d{1,2}\.\s?(19|20)\d{2}/.test(n.nodeValue)) { list.push(n); } } list.forEach(fix); } function fix(n) { if (!n.parentNode || skip(n.parentNode)) { return; } var v = n.nodeValue, c = conv(v); if (c !== v) { n.nodeValue = c; } } function start() { run(document.body); if (window.MutationObserver) { new MutationObserver(function (ms) { ms.forEach(function (m) { if (m.type === 'characterData') { fix(m.target); return; } for (var i = 0; i < m.addedNodes.length; i++) { run(m.addedNodes[i]); } }); }).observe(document.body, { childList: true, subtree: true, characterData: true }); } } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', start); } else { start(); } })();