From e36bbad7e826d56992e1ef9a4ac8b8207a9a4b46 Mon Sep 17 00:00:00 2001 From: Kenzi Connor Date: Sun, 11 Aug 2024 16:08:08 -0700 Subject: [PATCH] getting ready for height previews --- src/wasm/index.html | 8 ++++++-- src/wasm/main.rs | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/wasm/index.html b/src/wasm/index.html index 2411a7d..0a5ce85 100644 --- a/src/wasm/index.html +++ b/src/wasm/index.html @@ -20,7 +20,7 @@ let parser_images = window.wasmBindings.previews(array); for (const [key, images] of Object.entries(parser_images)) { const container = D.createElement("preview-area"); - container.innerHTML = `

${key}

` + container.innerHTML = `

${key}

` images.forEach(src => container.appendChild(new PreviewItem(src))); wrapper.appendChild(container); } @@ -54,7 +54,11 @@ shadow.appendChild(fragment); } onClick() { - $('#width').value = this.img.width; + let width = this.img.width; + let parser = $('h2', this.parentElement).innerText; + $('#width').value = width; + $('#parser').value = parser + //alert(window.wasmBindings.tile_previews(parser, width)); } } customElements.define("preview-item", PreviewItem); diff --git a/src/wasm/main.rs b/src/wasm/main.rs index 0c22b92..36faa93 100644 --- a/src/wasm/main.rs +++ b/src/wasm/main.rs @@ -34,6 +34,11 @@ pub fn previews(data: &[u8]) -> JsValue { JsValue::from_serde(&hm).unwrap() } +// #[wasm_bindgen] +// pub fn tile_previews(data: &[u8], parser: String, width: usize) -> String { +// format!("{} {}", parser, width) +// } + pub fn preview(data: &Raw, parser: ParserType) -> Vec { let palette = parser.image_type().default_color_palette(); data.width_previews(parser)