1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-24 02:10:55 +00:00

Changes to support processing a file to display

This commit is contained in:
Martin 2024-02-10 13:52:06 -05:00
parent ea8de92246
commit d2ccf83874

35
data/js/controls.js vendored
View File

@ -223,10 +223,10 @@ function handleVisibilityChange() {
} }
function start() { function start() {
// let location = window.location.hostname; let location = window.location.hostname;
// let port = window.location.port; let port = window.location.port;
let location = "192.168.10.219"; // let location = "192.168.10.219";
let port = ""; // let port = "";
document.addEventListener("visibilitychange", handleVisibilityChange, false); document.addEventListener("visibilitychange", handleVisibilityChange, false);
if ( if (
@ -785,14 +785,29 @@ function start() {
websock.onmessage = handleEvent; websock.onmessage = handleEvent;
} }
function FileDisplayUploadFile(data) async function FileDisplayUploadFile(data)
{ {
let text = downloadFile(data.value); let text = await downloadFile(data.value);
let ItemToUpdateId = "fd" + data.id;
// console.info("ItemToUpdateId: " + ItemToUpdateId);
// console.info(" text: " + text);
// populate the text object // populate the text object
$("#" + ItemToUpdateId).val(text);
$("#" + ItemToUpdateId).css("textAlign", "left");
$("#" + ItemToUpdateId).css("white-space", "nowrap");
$("#" + ItemToUpdateId).css("overflow", "scroll");
$("#" + ItemToUpdateId).css("overflow-y", "scroll");
$("#" + ItemToUpdateId).css("overflow-x", "scroll");
$("#" + ItemToUpdateId).scrollTop($("#" + ItemToUpdateId).val().length);
// scroll the page to the updated control
// $("#" + ItemToUpdateId).focus();
} // FileDisplayUploadFile } // FileDisplayUploadFile
async function downloadFile(filename) { async function downloadFile(filename)
let response = await fetch(filename); {
let response = await fetch(filename);
if(response.status != 200) { if(response.status != 200) {
throw new Error("File Read Server Error: '" + response.status + "'"); throw new Error("File Read Server Error: '" + response.status + "'");
@ -970,6 +985,7 @@ var addToHTML = function (data) {
elementHTML(data) + elementHTML(data) +
"</div>"; "</div>";
break; break;
case UI_SEPARATOR: case UI_SEPARATOR:
html = "<div id='id" + data.id + "' " + panelStyle + " class='sectionbreak columns'>" + html = "<div id='id" + data.id + "' " + panelStyle + " class='sectionbreak columns'>" +
"<h5>" + data.label + "</h5><hr/></div>"; "<h5>" + data.label + "</h5><hr/></div>";
@ -996,6 +1012,9 @@ var elementHTML = function (data) {
case UI_LABEL: case UI_LABEL:
return "<span id='l" + id + "' " + elementStyle + return "<span id='l" + id + "' " + elementStyle +
" class='label label-wrap'>" + data.value + "</span>"; " class='label label-wrap'>" + data.value + "</span>";
case UI_FILEDISPLAY:
return "<textarea id='fd" + id + "' rows='4' " + elementStyle +
" class='label label-wrap'>" + "</textarea>";
case UI_BUTTON: case UI_BUTTON:
return "<button id='btn" + id + "' " + elementStyle + return "<button id='btn" + id + "' " + elementStyle +
" onmousedown='buttonclick(" + id + ", true)'" + " onmousedown='buttonclick(" + id + ", true)'" +