summaryrefslogtreecommitdiff
path: root/WebInterface/wasm/asm-paint/src/site.rs
blob: 740cb90d537bb6eddcbdb1b8af03b04140bf2f6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use web_sys;

pub struct Site {
    window: web_sys::Window,
    document: web_sys::Document,
}

impl Site {
    pub fn from_current() -> Option<Self> {
        let window = web_sys::window()
            .or_else(|| {error!("unable to query window"); None})?;
        let document = window.document()
            .or_else(|| {error!("unable to query document"); None})?;
        Some(Self { 
            window, document
        })
    }
}