formats.exposed/public/png/png.js

33 lines
710 B
JavaScript
Raw Normal View History

2023-08-01 14:20:57 +00:00
// @ts-check
import parsePng from "./parsePng.js";
2023-08-01 14:20:57 +00:00
import parseHash from "./parseHash.js";
const errorEl = document.getElementById("error");
const explorerEl = document.getElementById("explorer");
if (!errorEl || !explorerEl) throw new Error("HTML is not set up correctly");
const main = () => {
// TODO: We may want a better UI here.
const parsedHash = parseHash(location.hash);
if (!parsedHash) {
location.href = "..";
return;
}
const { bytes } = parsedHash;
const rootNode = parsePng(bytes);
if (!rootNode) {
// TODO: Is there better UI than this?
errorEl.removeAttribute("hidden");
return;
}
2023-08-01 14:20:57 +00:00
// TODO: Actually do something!
console.log(rootNode);
2023-08-01 14:20:57 +00:00
};
main();