Status Messages
+Postmasters
+ +Hostname | +Version | +Attributes | +
---|
Status Messages
+Hostname | +Version | +Attributes | +
---|
File information: ${file.name} type: ${file.type}size: ${file.size} bytes
`); + } + + function UploadFile(file) { + var xhr = new XMLHttpRequest(); + if (xhr.upload) { + var o = $id("progress"); + var progress = o.appendChild(document.createElement("p")); + progress.appendChild(document.createTextNode("upload " + file.name)); + + xhr.upload.addEventListener("progress", function (e) { + var pc = parseInt(100 - (e.loaded / e.total * 100)); + progress.style.backgroundPosition = pc + "% 0"; + }, false); + + xhr.onreadystatechange = function (e) { + if (xhr.readyState == 4) { + progress.className = (xhr.status == 200 ? "success" : "failure"); + + if (xhr.status != 200) { + Output("Upload " + xhr.statusText + ": " + xhr.responseText + "
") + } + } + }; + + var target = $("#radio_target").prop("checked") ? "firmware/target" : "firmware/self"; + + xhr.open("POST", target, true); + xhr.send(file); + } + } + + function Init() { + var fileselect = $id("fileselect"), + filedrag = $id("filedrag"); + + fileselect.addEventListener("change", FileSelectHandler, false); + + var xhr = new XMLHttpRequest(); + if (xhr.upload) { + filedrag.addEventListener("dragover", FileDragHover, false); + filedrag.addEventListener("dragleave", FileDragHover, false); + filedrag.addEventListener("drop", FileSelectHandler, false); + filedrag.style.display = "block"; + } + } + + if (window.File && window.FileList && window.FileReader) { + Init(); + + let response = await fetch('configuration'); + let configuration = await response.json(); + var timer; + + $(".topnav li").each(function(i) { + if (i > 0) { $("#content").children("div:eq('" + i + "')").hide(); } + }); + + $(".topnav li > a").each(function(i) { + $(this).click(function() { + $(".topnav li > a").removeClass('active'); + $(this).addClass('active'); + $("#content").children("div:eq('" + i + "')").show().siblings().hide(); + }); + }); + + $('#about').on('show', function() { + $('#about h1').html($('#about h1').html().replace('${version}', configuration.version_full)) + }); + + $('#discovery').on('show', async function() { + timer = setInterval(async function() { + let response = await fetch('discovery'); + let discovery = await response.json(); + + $('#postmasters tbody').empty(); + discovery.devices.forEach((device) => { + $('#postmasters tbody').append(`