function promiseXHR(a,b,g){var n="XMLHttpRequest",h="setRequestHeader",k="constructor",t="hasOwnProperty",u="POST",v="content-type",w="x-requested-with",x=Object,y=function(d){return encodeURIComponent(d).replace(/%20/g,"+")},c,e,f,l,z,m; if(b)switch(b[k]){case self.FormData:l=1;break;case x:for(p in m="_="+(new Date).getTime(),b)if(b[t](p))for(b[p]&&b[p][k]==Array||(b[p]=[b[p]]),c=0;cc.indexOf("?")?"?":"&")+b);a=new self[n]; a.open(e,c);for(p in f)f[t](p)&&(a[h](c=p.toLowerCase(),f[p]),c==v&&(l=1),c==w&&(z=1));z||a[h](w,n);l||e==u&&a[h](v,"application/x-www-form-urlencoded")}return new Promise(function(A,B){a.onreadystatechange=function(){4==a.readyState&&A(a)};g|0&&setTimeout(function(){B("timeout");a.abort()},g);a.send(b)})}self.Promise||document.write("") // // TIME=HHMMDDMMYY const topNav = document.getElementById("topnav") function selTab(evt, id) { var tabcontent, tablinks tablinks = document.getElementsByClassName("tablinks") tabcontent = document.getElementsByClassName("tabcontent") for (let tab of tabcontent) { tab.style.display = "none" var link = tab.dataset.src if (link) { tab.getElementsByTagName("iframe")[0].setAttribute("src", "") } } for(let link of tablinks) link.className = "tablinks" var act = document.getElementById(id) act.style.display = "flex" evt.currentTarget.className += " active" var link = act.dataset.src if(link) { act.getElementsByTagName("iframe")[0].setAttribute("src", link) } topNav.className = "topnav" } function toggleResponsive() { topNav.className = topNav.className === "topnav" ? "topnav responsive" : "topnav" //topNav.className = ["topnav","responsive"].slice(0,1+(x.className === "topnav")).join(" ") } let contactsData = [] function delContact(i) { contactsData.splice(i, 1); storeContacts() window.location.reload() } function addContact(doReloadAfter) { contactsData.push({ r: parseInt(document.querySelector('#newcon_r').value), f: parseInt(document.querySelector('#newcon_f').value), tl: parseInt(document.querySelector('#newcon_tl').value), n: document.querySelector('#newcon_n').value, t: document.querySelector('#newcon_t').value, }) storeContacts() if (doReloadAfter) window.location.reload() } function resetContacts() { if (confirm("do you want to delete all contacts?")) { promiseXHR("/contacts.json", JSON.stringify([])) .then(() => alert("reset contacts")) } } function storeContacts() { promiseXHR("/contacts.json", JSON.stringify(contactsData)) .then(() => alert("stored contacts")) } let firstFetch = true function fetchCfgVals() { if (!firstFetch) return firstFetch = false promiseXHR("/config.json").then(j=>{ const res = JSON.parse(j.responseText) console.log(res) for (let key in res) { let e = document.getElementById(key) || document.getElementsByName(key)[0] if (!!e) { if (e.type == 'checkbox') { e.checked = res[key]; } else { e.value = res[key] } } } }) promiseXHR("/contacts.json").then(j=>{ const contactlist = document.getElementById("contactlist") contactsData = JSON.parse(j.responseText) console.log("received contacts from esp", contactsData) for (let contactI in contactsData) { const contact = contactsData[contactI] const li = document.createElement("li") li.innerHTML = `

${ contact.n }

RIC=${ contact.r } F=${ contact.f } TL=${ contact.tl }
` contactlist.appendChild(li) } }) } document.getElementById("defaultTab").click() for (let i of document.getElementsByTagName("input")) i.placeholder = i.name function calculateTimeToTxTxt(type) { document.querySelector("input[name='text']").value = calculateTime(type) } function calculateTime(type) { const now = new Date(); // Extract date components const hh = String(now.getHours()).padStart(2, '0'); const mm = String(now.getMinutes()).padStart(2, '0'); const DD = String(now.getDate()).padStart(2, '0'); const MM = String(now.getMonth() + 1).padStart(2, '0'); // Months are 0-based const YY = String(now.getFullYear()).slice(-2); // Get last two digits of the year // Construct the formatted string const formattedTime = `${hh}${mm}${DD}${MM}${YY}`; switch (type) { case 'tpl': return `#ZEIT=${formattedTime}#ZEIT=${formattedTime}`; case 'swissphone': return `;TIME=${formattedTime};TIME=${formattedTime}`; default: return 'Invalid type'; } } function populateTimezones() { const timezones = Intl.supportedValuesOf('timeZone'); const select = document.getElementById("time_zone"); timezones.forEach(zone => { const option = document.createElement("option"); option.value = zone; option.textContent = zone; select.appendChild(option); }); } populateTimezones();