X-Git-Url: https://git.rvb.name/esp-clock.git/blobdiff_plain/c8479d5c8f2df8ff0395a0b49da752328581e5b1..refs/remotes/github/master:/data/web/script.js?ds=inline diff --git a/data/web/script.js b/data/web/script.js index cb4fa7e..ee43439 100644 --- a/data/web/script.js +++ b/data/web/script.js @@ -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 '
' @@ -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); } }; |