import { Coord } from "./wwa_data" ; export var $id = ( id ) : HTMLElement => { return document . getElementById ( id ) ; } ; export var $class = ( className ) => { return document . getElementsByClassName ( className ) ; } ; export var $tag = ( tagName ) => { return document . getElementsByTagName ( tagName ) ; } ; export var $qs = ( selector ) : Element => { return document . querySelector ( selector ) ; } ; export var $qsh = ( selector ) : HTMLElement => { return < HTMLElement > document . querySelector ( selector ) ; } ; export var $qsAll = ( selector ) : NodeList => { return document . querySelectorAll ( selector ) ; } ; export var $localPos = ( mouseX , mouseY ) : Coord => { var cx , cy ; var sx = window . pageXOffset || document . body . scrollLeft || document . documentElement . scrollLeft ; var sy = window . pageYOffset || document . body . scrollTop || document . documentElement . scrollTop ; cx = mouseX - $id ( "wwa-wrapper" ) . offsetLeft + sx ; cy = mouseY - $id ( "wwa-wrapper" ) . offsetTop + sy ; return new Coord ( cx , cy ) ; } ; export var $escapedURI = ( uri ) : string => { if ( uri . match ( /^https?:\/\// ) || uri . match ( /^\.\.\// ) ) { return uri ; } else { return ( location . href = "./" + uri ) ; } } ; export var arr2str4save = ( x ) : string => { var txt = "" ; if ( x instanceof Array ) { for ( var i = 0 ; i < x . length ; i ++ ) { txt += arr2str4save ( x [ i ] ) + "/" ; } return txt ; } else { return x + "" ; } } ;