Skip to content

Commit

Permalink
drop extra wrapping map and make $ shortcut more general
Browse files Browse the repository at this point in the history
  • Loading branch information
knzai committed Aug 11, 2024
1 parent 511b7ae commit 9cac811
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
/>
<script data-trunk src="./file-byte-reader.js"></script>
<script>
let $ = (query) => document.querySelector(query);
let $ = (query, ele = document) => ele.querySelector(query);

function fileLoaded(array) {
let hash = new Map(Object.entries(window.wasmBindings.previews(array)));
hash.forEach((images, key) => {
let wrapper = $('preview-wrapper');
wrapper.textContent = "";

let parser_images = window.wasmBindings.previews(array);
for (const [key, images] of Object.entries(parser_images)) {
const container = document.createElement("preview-area");
images.forEach(src => container.appendChild(new PreviewItem(src)));
$('preview-wrapper').appendChild(container);
})
wrapper.appendChild(container);
}
}

document.addEventListener("DOMContentLoaded", () => {
Expand All @@ -33,8 +36,8 @@
super();
const shadow = this.attachShadow({mode: "open"});
const fragment = document.createRange().createContextualFragment('<h3></h3><img/>');
const h3 = fragment.querySelector('h3');
this.img = fragment.querySelector("img");
const h3 = $('h3', fragment);
this.img = $('img', fragment);

this.img.onload = function () {
h3.innerText = this.width;
Expand Down

0 comments on commit 9cac811

Please sign in to comment.