-(function (window, document) {
-
- // we fetch the elements each time because docusaurus removes the previous
- // element references on page navigation
- function getElements() {
- return {
- layout: document.getElementById('layout'),
- menu: document.getElementById('menu'),
- menuLink: document.getElementById('menuLink')
- };
- }
-
- function toggleClass(element, className) {
- var classes = element.className.split(/\s+/);
- var length = classes.length;
- var i = 0;
-
- for (; i < length; i++) {
- if (classes[i] === className) {
- classes.splice(i, 1);
- break;
- }
- }
- // The className is not found
- if (length === classes.length) {
- classes.push(className);
- }
-
- element.className = classes.join(' ');
- }
-
- function toggleAll() {
- var active = 'active';
- var elements = getElements();
+var pages
+var parameters = {}
+var daynames = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']
- toggleClass(elements.layout, active);
- toggleClass(elements.menu, active);
- toggleClass(elements.menuLink, active);
+function toggleMenu(e) {
+ active = (document.getElementById('menuLink').className.indexOf('active') !== -1)
+ if (active || e.target.id == 'menuLink' || e.target.id == 'menuBtn') {
+ elements = [ document.getElementById('layout'), document.getElementById('menu'), document.getElementById('menuLink') ]
+ for (const element of elements) {
+ if (!active) {
+ element.classList.add('active')
+ } else {
+ element.classList.remove('active')
+ }
}
-
- function handleEvent(e) {
- var elements = getElements();
-
- if (e.target.id === elements.menuLink.id) {
- toggleAll();
- e.preventDefault();
- } else if (elements.menu.className.indexOf('active') !== -1) {
- toggleAll();
- }
+ if (e.target.id == 'menuLink' || e.target.id == 'menuBtn') {
+ e.preventDefault()
}
-
- document.addEventListener('click', handleEvent);
+ e.stopPropagation()
+ }
+}
-}(this, this.document));
-
-var pages
-var parameters = {}
-var daynames = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']
+document.getElementById('layout').addEventListener('click', toggleMenu)
function encode(r){
r = String(r)
return '<div class="pure-u-1 pure-u-md-1-3"><label for="_ui_element_' + element.id + '">' + encode(element.label) + '</label>'
+ '<input data-ui_class="password" type="password" id="_ui_element_' + element.id + '" value="' + encode(value)
+ '" class="pure-u-1" style="display:inline-block" maxlength="99" oninput="sendUpdate(\'' + element.id + '\')" />'
- + '<div class="hint" onclick="ShowPwd(\'' + element.id + '\')">👁</div></div>'
+ + '<div class="hint" onclick="ShowPwd(\'' + element.id + '\')"></div></div>'
case 'input':
var pattern = ""
if (element.pattern) {
return '<div class="pure-u-1 pure-u-md-1-3"><label for="_ui_element_' + element.id + '">' + encode(element.label) + '</label>'
+ '<input data-ui_class="input" type="text" id="_ui_element_' + element.id + '" value="' + encode(value) +'"'+ pattern
+ ' class="pure-u-1" style="display:inline-block" maxlength="99" oninput="sendUpdate(\'' + element.id + '\')" />'
- + '<div class="hint" onclick="OpenSelect(\'' + element.id+ '\'); getWiFi(\'' + element.id + '\')">📶</div>'
+ + '<div class="hint" onclick="OpenSelect(\'' + element.id+ '\'); getWiFi(\'' + element.id + '\')"></div>'
+ '<div class="modal" id="_ui_elemmodal_' + element.id + '" hidden>'
+ '<div class="modal-content">'
+ '<div id="_ui_elemselect_' + element.id + '"></div>'
return options
case 'week':
days = '<div class="pure-u-1 pure-u-md-1-3"><label for="_ui_element_' + element.id + '">' + encode(element.label) + '</label>'
- + '<table data-ui_class="week" data-value="' + value + '" id="_ui_element_' + element.id + '" cellpadding="5" border="0" align="left"><tbody><tr>'
+ + '<table data-ui_class="week" data-value="' + value + '" id="_ui_element_' + element.id + '" cellpadding="5" border="0" class="week"><tbody><tr>'
for (i=0; i<7; i++) {
a_enabled = (value[i] == "1")
days = days + '<td><div class="weekday' + (a_enabled?"-selected":"") + '" id="_ui_elpart_'+i+'_'+element.id+'" onclick="ClickDay(\'' + element.id + '\', ' + i + ')">'+ daynames[i] + '</div></td>'
var page_content = document.getElementById("_ui_page_content");
var content = ''
for (const element of pages[idx].elements) {
- content = content + ElementHTML(element)
+ content = content + ElementHTML(element) + '\n'
}
page_content.innerHTML = content
- window.location.hash = '#'+id
+ window.location.hash = id
}
function DrawNavigator(project, pages) {
for (const page of pages) {
list = list + '<li id="_ui_pglink_' + page.id
+ '" class="pure-menu-item"><a class="pure-menu-link" onclick="DrawPage(\''+ page.id +'\')" href="#' + page.id + '">'
+ + (page.icon?'<span class="icon">'+page.icon+'</span>':'')
+ page.title+'</a></li>'
}
menu.innerHTML = list
}
+function DrawContacts(contacts) {
+ if (!contacts) return;
+ var contact_list = '<hr><h4 class="pure-u1">Контакты</h4>'
+ for (contact of contacts) {
+ const url = new URL(contact)
+ var ref
+ switch (url.protocol) {
+ case 'http':
+ case 'https:':
+ ref = '<span class="icon"></span>'+url.hostname
+ break
+ case 'mailto:':
+ ref = '<span class="icon"></span>'+url.pathname
+ break
+ case 'tg:':
+ ref = '<span class="icon"></span>'+url.pathname
+ contact = 'tg://resolve?domain='+url.pathname
+ break
+ default:
+ ref = '<span class="icon"></span>'+url.pathname
+ }
+ contact_list += '<a href="'+contact+'">'+ref+'</a>'
+ }
+ var footer = document.getElementById('_ui_contacts');
+ footer.innerHTML = contact_list
+}
+
function DrawUI(ui) {
DrawHeader(ui.project)
pages = ui.pages
DrawNavigator(ui.project, pages)
+ DrawContacts(ui.project.contacts)
var anchor = getAnchor()
if (anchor) {
DrawPage(anchor)