X-Git-Url: https://git.rvb.name/esp-clock.git/blobdiff_plain/c8479d5c8f2df8ff0395a0b49da752328581e5b1..6d3be4253d91ef9289fa4f3b7e280b2258fabaf1:/data/web/script.js
diff --git a/data/web/script.js b/data/web/script.js
index cb4fa7e..247126c 100644
--- a/data/web/script.js
+++ b/data/web/script.js
@@ -214,12 +214,12 @@ function getWiFi(id) {
return;
}
var json = JSON.parse(this.responseText)
- var table = '
'
+ var table = ''
if (!json.length) {
setTimeout(getWiFi(id),5000);
}
for (idx in json) {
- var encryption = json[idx].secure == 2? "TKIP" : json[idx].secure == 5? "WEP" : json[idx].secure == 4? "CCMP" : json[idx].secure == 7? "неÑ" : json[idx].secure == 8? "ÐвÑомаÑиÑеÑки" : "Ðе опÑеделено";
+ var encryption = json[idx].secure == 2? "TKIP" : json[idx].secure == 5? "WEP" : json[idx].secure == 4? "CCMP" : json[idx].secure == 7? "неÑ" : json[idx].secure == 8? "ÐвÑо" : "Ðеизв.";
table += ''+json[idx].ssid+' | '+json[idx].bssid+' | '+json[idx].rssi+' | '+json[idx].channel+' | '+encryption+' |
'
}
@@ -251,6 +251,25 @@ function sendTime(id) {
}
}
+function downloadFile(url, name) {
+ const a = document.createElement('a')
+ a.href = url
+ a.download = name?name:url.split('/').pop()
+ document.body.appendChild(a)
+ a.click()
+ document.body.removeChild(a)
+}
+
+function uploadConfig() {
+ var elem = document.getElementById('_config_file')
+ if (elem.value) {
+ var data = elem.files[0]
+ console.log(data)
+ fetch('/config/put', {method:'PUT',body:data});
+ elem.value = null
+ }
+}
+
function elementHTML(element) {
var value
if (parameters[element.id] || !isNaN(parameters[element.id])) {
@@ -326,8 +345,8 @@ function elementHTML(element) {
now.setMinutes(now.getMinutes() - now.getTimezoneOffset())
value = now.toISOString().slice(0, -1);
return ''
- +'
'
+ +''
+ + '→
'
case 'text':
return '' + encode(value) + '
'
case 'number':
@@ -340,6 +359,13 @@ function elementHTML(element) {
+ ''
+ case 'config':
+ return ''
case 'table':
default:
return ''
@@ -432,9 +458,11 @@ GetUI()
function initES() {
if (!!window.EventSource) {
var source = new EventSource('/events');
+ openMsg('Соединение ÑÑÑановлено')
source.onerror = function(e) {
if (source.readyState == 2) {
+ openMsg('Соединение пÑеÑвано')
setTimeout(initES, 5000);
}
};
|