Skip to content

Commit

Permalink
getting ready for height previews
Browse files Browse the repository at this point in the history
  • Loading branch information
knzai committed Aug 11, 2024
1 parent 5e0d242 commit e36bbad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<h3>${key}</h3>`
container.innerHTML = `<h2>${key}</h2>`
images.forEach(src => container.appendChild(new PreviewItem(src)));
wrapper.appendChild(container);
}
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/wasm/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
let palette = parser.image_type().default_color_palette();
data.width_previews(parser)
Expand Down

0 comments on commit e36bbad

Please sign in to comment.