From 04792563e216f57984219e582de491947e2d7f40 Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Sat, 25 May 2019 02:40:00 +0200 Subject: Manipulate DOM --- WebInterface/wasm/asm-paint/Cargo.toml | 1 + WebInterface/wasm/asm-paint/src/lib.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/WebInterface/wasm/asm-paint/Cargo.toml b/WebInterface/wasm/asm-paint/Cargo.toml index c0a7c68..5713415 100644 --- a/WebInterface/wasm/asm-paint/Cargo.toml +++ b/WebInterface/wasm/asm-paint/Cargo.toml @@ -9,3 +9,4 @@ crate-type = ["cdylib"] [dependencies] wasm-bindgen = "0.2" +web-sys = {version="0.3.22", features=["Window", "Document", "HtmlElement", "Node", "Element"]} diff --git a/WebInterface/wasm/asm-paint/src/lib.rs b/WebInterface/wasm/asm-paint/src/lib.rs index 52ddc8f..462a89d 100644 --- a/WebInterface/wasm/asm-paint/src/lib.rs +++ b/WebInterface/wasm/asm-paint/src/lib.rs @@ -12,5 +12,16 @@ extern "C" { #[wasm_bindgen(start)] pub fn entry() { + use web_sys; console_log!("hello {} wasm", 42); + + let window = web_sys::window().unwrap(); + + let document = window.document().unwrap(); + + let body = document.body().unwrap(); + + //body.set_inner_html("

Hello from WASM

"); + + body.set_inner_html("oho"); } -- cgit v1.2.3-54-g00ecf