const createGlobalReactive = ( id = "" , prefix = "gr-" ) => { if ( id [ 0 ] == "#" ) id = id . replace ( '#' , '' ); const _root = id ? document . getElementById ( id ) : document ; if ( ! _root ) throw new Error ( `The id ' ${ id } ' you give to the globalReactive app is invalid as it can't find the root element!` ); const nodes = { _root }; _root . querySelectorAll ( '*' ). forEach ( n => { n . classList . forEach ( c => { if ( c . startsWith ( prefix )) { const key = c . replace ( prefix , '' ); if ( nodes [ key ]){ nodes [ key ]. push ( n ); } else { ...
function createJApp ( setting = {}){ const _root = setting . root ? setting . root : document ; const data = {}; const registeredApps = {}; const storagePrefix = "jData-" ; let els = prepareEls (); function setData ( key , value , toUpdateViewAndStorage = 1 ){ if ( getData ( key ) == value ) return ; data [ key ] = value ; if ( ! toUpdateViewAndStorage ) return ; sessionStorage . setItem ( storagePrefix + key , JSON . stringify ( value )); updateView ( key ); } function getData ( key ){ return data [ key ]; } function prepareEls (){ let obj = { ht...