From 2a729f8969b496e3c19d73288af09f82d5660dc9 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Tue, 10 May 2022 11:02:15 +0200 Subject: [PATCH] support loading logs through postMessage in logviewer --- scripts/logviewer/index.html | 15 +++++++++++++++ scripts/logviewer/main.js | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/logviewer/index.html b/scripts/logviewer/index.html index 08ba2f3c..109cf8d1 100644 --- a/scripts/logviewer/index.html +++ b/scripts/logviewer/index.html @@ -218,5 +218,20 @@
+ diff --git a/scripts/logviewer/main.js b/scripts/logviewer/main.js index 3ae860b2..e552a094 100644 --- a/scripts/logviewer/main.js +++ b/scripts/logviewer/main.js @@ -164,7 +164,11 @@ function getRootItemHeader(prevItem, item) { async function loadFile() { const file = await openFile(); document.getElementById("filename").innerText = file.name; - const json = await readFileAsText(file); + await loadBlob(file); +} + +export async function loadBlob(blob) { + const json = await readFileAsText(blob); const logs = JSON.parse(json); logs.items.sort((a, b) => itemStart(a) - itemStart(b)); rootItem = {c: logs.items}; @@ -181,6 +185,7 @@ async function loadFile() { return fragment; }, document.createDocumentFragment()); main.replaceChildren(fragment); + main.scrollTop = main.scrollHeight; } // TODO: make this use processRecursively