(function () { var menu_pages = ['education', 'hotels', 'hub', 'ice', 'kiosk', 'laundry', 'logistic', 'outgate', 'park', 'paygate', 'rent', 'sport', 'tollroad']; var tab_pages = ['kiosk', 'laundry', 'park', 'parknavigation', 'snail', 'squid']; var diagram_pages = ['park', 'laundry', 'parknavigation']; var park_labels = [[225, 240], [240, 275], [45, 455], [0, 555], [150, 110], [980, 330], [1000, 0], [980, 310], [1070, 350]]; var tab_group = 0; function MoveImages (images, media) { images.forEach (function (image) { var link = document.createElement ('a'); link.href = image.src; image.loading = 'lazy'; link.appendChild (image); media.appendChild (link); }); } function AddTabs (titles) { var list = document.createElement ('ul'); list.className = 'point_list'; list.setAttribute ('role', 'tablist'); var title = titles[0].previousElementSibling; while (title && title.tagName !== 'H2') title = title.previousElementSibling; if (title) list.setAttribute ('aria-label', title.textContent.trim ()); titles[0].parentNode.insertBefore (list, titles[0]); var buttons = []; var panels = []; var group_id = 'article-tabs-' + (++tab_group); function Select (selected) { buttons.forEach (function (button, index) { var active = index === selected; button.classList.toggle ('active', active); button.setAttribute ('aria-selected', active); button.tabIndex = active ? 0 : -1; panels[index].hidden = !active; }); } titles.forEach (function (heading, index) { var item = document.createElement ('li'); item.setAttribute ('role', 'presentation'); var button = document.createElement ('button'); button.type = 'button'; button.className = 'item'; button.textContent = heading.textContent.trim (); button.id = group_id + '-tab-' + index; button.setAttribute ('role', 'tab'); button.setAttribute ('aria-controls', group_id + '-panel-' + index); item.appendChild (button); list.appendChild (item); buttons.push (button); button.onclick = function () { Select (index); }; button.onkeydown = function (event) { var selected; if (event.key === 'ArrowLeft') selected = (index + titles.length - 1) % titles.length; else if (event.key === 'ArrowRight') selected = (index + 1) % titles.length; else if (event.key === 'Home') selected = 0; else if (event.key === 'End') selected = titles.length - 1; else return; event.preventDefault (); Select (selected); buttons[selected].focus (); }; var panel = document.createElement ('div'); panel.className = 'article-tab-panel'; panel.id = group_id + '-panel-' + index; panel.setAttribute ('role', 'tabpanel'); panel.setAttribute ('aria-labelledby', button.id); var node = heading.nextElementSibling; heading.parentNode.insertBefore (panel, heading); heading.remove (); while (node && !/^H[123]$/.test (node.tagName)) { var next = node.nextElementSibling; panel.appendChild (node); node = next; } panels.push (panel); var paragraph = panel.firstElementChild; if (paragraph && paragraph.tagName === 'P' && paragraph.firstElementChild && paragraph.firstElementChild.tagName === 'IMG') { var images = Array.prototype.slice.call (paragraph.querySelectorAll (':scope > img')); var media = document.createElement ('div'); media.className = 'article-tab-media'; media.dataset.gallery = 'images'; panel.insertBefore (media, paragraph); MoveImages (images, media); if (!paragraph.textContent.trim () && !paragraph.children.length) paragraph.remove (); } }); Select (0); } function FormatDiagrams (article) { Array.prototype.forEach.call (article.querySelectorAll (':scope > p > img:only-child'), function (image) { var paragraph = image.parentNode; var labels = paragraph.nextElementSibling; if (paragraph.textContent.trim () || !labels || labels.tagName !== 'UL') return; if (!/^(arch|wash_complex_mini|parknavigator0[12]_mini)$/i.test (image.alt.replace (/\\/g, ''))) return; var diagram = document.createElement ('figure'); diagram.className = 'article-diagram'; article.insertBefore (diagram, paragraph); diagram.appendChild (image); if (article.dataset.page === 'park' && labels.children.length === park_labels.length) { diagram.classList.add ('park-diagram'); Array.prototype.forEach.call (labels.children, function (item, index) { var label = document.createElement ('span'); label.className = index < 5 ? 'rnuance' : 'lnuance'; label.style.left = park_labels[index][0] + 'px'; label.style.top = park_labels[index][1] + 'px'; label.textContent = item.textContent.trim (); diagram.appendChild (label); }); labels.remove (); } else { diagram.appendChild (labels); } paragraph.remove (); }); } function FormatCatalog (article) { Array.prototype.forEach.call (article.querySelectorAll (':scope > ul'), function (list) { var items = Array.prototype.slice.call (list.children); var links = items.map (function (item) { var links = item.querySelectorAll ('a[href]'); var link = links[0]; return links.length === 1 && /\/(?:cproduct|product)_\d+\.html$/.test (link.pathname) ? link : null; }); var first = links.findIndex (Boolean); if (first < 0 || !links.slice (first).every (Boolean)) return; // Markdown can merge the products with the preceding bullet list. var catalog = list; if (first) { catalog = document.createElement ('ul'); list.after (catalog); } catalog.classList.add ('article-catalog'); items.slice (first).forEach (function (item, index) { var link = links[first + index]; var image = item.querySelector ('img'); var name = link.textContent.trim (); var details = item.textContent.trim ().slice (name.length).replace (/^\s*—\s*/, '').trim (); var title = document.createElement ('strong'); while (link.firstChild) title.appendChild (link.firstChild); item.textContent = ''; if (image) { var media = document.createElement ('span'); media.className = 'catalog-image'; image.loading = 'lazy'; media.appendChild (image); link.appendChild (media); } link.appendChild (title); if (details) { var description = document.createElement ('span'); description.textContent = details; link.appendChild (description); } item.appendChild (link); if (first) catalog.appendChild (item); }); }); } function FormatProduct (article) { var node = article.firstElementChild; var intro = document.createElement ('div'); intro.className = 'article-product'; var details = document.createElement ('div'); var media = document.createElement ('div'); media.dataset.gallery = 'images'; while (node && node.tagName === 'P') { var next = node.nextElementSibling; var images = Array.prototype.slice.call (node.querySelectorAll (':scope > img')); MoveImages (images, media); if (node.textContent.trim () || node.children.length) details.appendChild (node); else node.remove (); node = next; } if (details.children.length) intro.appendChild (details); if (media.children.length) intro.appendChild (media); if (intro.children.length) article.insertBefore (intro, node); } function FormatContacts (article) { var list = article.firstElementChild; var heading = article.querySelector (':scope > h2'); if (!list || list.tagName !== 'UL' || !heading) return; var contacts = document.createElement ('div'); contacts.className = 'article-contacts'; var directions = document.createElement ('div'); article.insertBefore (contacts, list); contacts.appendChild (list); contacts.appendChild (directions); while (heading) { var next = heading.nextElementSibling; directions.appendChild (heading); heading = next; } var map_links = directions.querySelectorAll ('a[href^="https://api-maps.yandex.ru/services/constructor/1.0/js/"]'); Array.prototype.forEach.call (map_links, function (link) { var src = new URL (link.href); var sid = src.searchParams.get ('sid'); if (!sid) return; src.pathname = '/services/constructor/1.0/static/'; src.searchParams.set ('lang', 'ru_RU'); src.searchParams.set ('sourceType', 'constructor'); var image = document.createElement ('img'); image.alt = ''; image.loading = 'lazy'; image.width = 600; image.height = 450; image.src = src.href; link.href = 'https://yandex.ru/maps/?um=' + encodeURIComponent ('constructor:' + sid) + '&source=constructorStatic'; link.classList.add ('directions-map'); link.prepend (image); }); } function FormatLocations (article) { var coordinates = /\((-?\d+\.\d+),\s*(-?\d+\.\d+)\)/; var list = Array.prototype.find.call (article.querySelectorAll (':scope > ul'), function (item) { return coordinates.test (item.textContent); }); if (!list) return; var locations = document.createElement ('details'); locations.className = 'article-locations'; var summary = document.createElement ('summary'); summary.textContent = 'Показать адреса (' + list.children.length + ')'; locations.appendChild (summary); article.insertBefore (locations, list); locations.appendChild (list); Array.prototype.forEach.call (list.children, function (item) { var match = coordinates.exec (item.textContent); if (!match) return; var link = document.createElement ('a'); link.href = 'https://yandex.ru/maps/?ll=' + encodeURIComponent (match[2] + ',' + match[1]) + '&z=16'; link.textContent = 'На карте'; item.appendChild (link); }); } function FormatSportSections (article) { var first_image = Array.prototype.find.call (article.querySelectorAll (':scope > p > img:first-child'), function (image) { return image.parentNode.textContent.trim (); }); if (!first_image) return; var node = first_image.parentNode.previousElementSibling; while (node && node.tagName !== 'H2') node = node.previousElementSibling; if (!node) return; var details = document.createElement ('div'); details.className = 'sport-details'; article.insertBefore (details, node); var section; var copy; while (node) { var next = node.nextElementSibling; if (node.tagName === 'H2') { section = document.createElement ('section'); copy = document.createElement ('div'); section.appendChild (copy); details.appendChild (section); } if (node.tagName === 'P' && section.children.length === 1) { var image = node.firstElementChild; if (image && image.tagName === 'IMG' && node.textContent.trim ()) section.prepend (image); } copy.appendChild (node); node = next; } } Array.prototype.forEach.call (document.querySelectorAll ('.editor[data-page], .article-box > .text[data-page]'), function (article) { var page = article.dataset.page; if (/^(?:cproduct|product)_index_\d+$/.test (page)) { FormatCatalog (article); return; } if (/^(?:cproduct|product)_\d+$/.test (page)) { FormatProduct (article); return; } if (!article.classList.contains ('editor')) return; if (menu_pages.indexOf (page) !== -1) { var menu = article.querySelector (':scope > ul'); if (menu && menu.querySelectorAll (':scope > li > a').length === menu.children.length) { menu.classList.add ('menu_side', 'right'); var first = article.firstElementChild; if (first.tagName !== 'P' || !first.querySelector ('img:only-child') || first.textContent.trim ()) article.insertBefore (menu, article.firstChild); } } if (diagram_pages.indexOf (page) !== -1) FormatDiagrams (article); Array.prototype.forEach.call (article.querySelectorAll (':scope > h2'), function (heading) { var node = heading.nextElementSibling; if (/^(Галерея|Скриншоты конфигурации)/i.test (heading.textContent.trim ())) { var gallery = document.createElement ('div'); gallery.dataset.gallery = 'carousel'; article.insertBefore (gallery, node); while (node && !/^(H[12]|HR)$/.test (node.tagName)) { var next = node.nextElementSibling; gallery.appendChild (node); node = next; } } else if (tab_pages.indexOf (page) !== -1) { var titles = []; for (; node && !/^H[12]$/.test (node.tagName); node = node.nextElementSibling) if (node.tagName === 'H3') titles.push (node); if (titles.length) AddTabs (titles); } }); if (page === 'park') FormatLocations (article); else if (page === 'contacts') FormatContacts (article); else if (page === 'sport') FormatSportSections (article); }); }) ();