2023-08-11 20:06:09 +00:00
|
|
|
// @ts-check
|
|
|
|
|
2023-08-02 20:08:17 +00:00
|
|
|
import * as base64 from "../common/vendor/base64-js.js";
|
2023-08-12 03:40:30 +00:00
|
|
|
import parseGif from "./parseGif.js";
|
|
|
|
import getNodeUi from "./getNodeUi.js";
|
|
|
|
import explorer from "../common/explorer.js";
|
|
|
|
|
|
|
|
const errorEl = document.getElementById("error");
|
|
|
|
const explorerEl = document.getElementById("explorer");
|
|
|
|
if (!errorEl || !explorerEl) throw new Error("HTML is not set up correctly");
|
2023-08-11 20:06:09 +00:00
|
|
|
|
|
|
|
const main = () => {
|
|
|
|
// TODO: We may want a better UI here.
|
2023-08-02 20:08:17 +00:00
|
|
|
// TODO: Handle errors.
|
|
|
|
const fileDataBase64 = window.sessionStorage.getItem("fileData");
|
|
|
|
if (!fileDataBase64) {
|
2023-08-11 20:06:09 +00:00
|
|
|
location.href = "..";
|
|
|
|
return;
|
|
|
|
}
|
2023-08-02 20:08:17 +00:00
|
|
|
const bytes = base64.toByteArray(fileDataBase64);
|
2023-08-11 20:06:09 +00:00
|
|
|
|
2023-08-12 03:40:30 +00:00
|
|
|
const rootNode = parseGif(bytes);
|
|
|
|
if (!rootNode) {
|
|
|
|
// TODO: Is there better UI than this?
|
|
|
|
errorEl.removeAttribute("hidden");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
explorerEl.innerHTML = "";
|
|
|
|
explorerEl.append(explorer(rootNode, getNodeUi));
|
|
|
|
explorerEl.removeAttribute("hidden");
|
2023-08-11 20:06:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
main();
|