diff --git a/mar/urb.hoon b/mar/urb.hoon index f5bb65b2e5..80b20dbe3a 100644 --- a/mar/urb.hoon +++ b/mar/urb.hoon @@ -5,14 +5,6 @@ /= urb-wasp-data-js /: /%/wasp-data /js/ !: |_ {{dep/@uvH hed/marl} {dep-bod/@uvH bod/marl}} -++ linked-deps-js - ''' - urb.waspAll = function(sel){ - [].map.call(document.querySelectorAll(sel), urb.waspElem) - } - urb.waspAll('script'); urb.waspAll('link') - - ''' ++ grow :: convert to |% ++ mime [/text/html (taco html)] :: convert to %mime @@ -30,11 +22,12 @@ :~ ;script@"/~/on/{}.js"(urb_injected "", async "", onload "setTimeout(urb.onDep,2000)"); ;script(urb_injected "") ;- (trip urb-wasp-data-js) - ; window.urb = window.urb || \{} + ; urb.waspWait = [] + ; urb.wasp = urb.wasp || [].push.bind(urb.waspWait) ; urb.onDep = function()\{ - ; urb.waspDeps(); - ; urb.waspData({(pojo %s (scot %uv dep-bod))}); - ;- (trip linked-deps-js) + ; urb.waspWait.map(urb.wasp) + ; urb.onLoadUrbJS() + ; urb.waspData({(pojo %s (scot %uv dep-bod))}) ; } == == diff --git a/mar/urb/wasp-data.js b/mar/urb/wasp-data.js index 5ff8f8bccf..a402301294 100644 --- a/mar/urb/wasp-data.js +++ b/mar/urb/wasp-data.js @@ -1,7 +1,11 @@ +window.urb = window.urb || {} + +urb.waspWait = [] +urb.wasp = urb.wasp || [].push.bind(urb.waspWait) + // debugging urb.verb = false urb.sources = {} - urb.waspDeps = function(){ urb.deps.map(function(a){urb.sources[a] = "dep"}) } @@ -33,12 +37,21 @@ urb.waspData = function(dep){ urb.datadeps[dep] = true urb.wasp(dep) } -urb.ondataupdate = urb.onupdate // overridable -var _onupdate = urb.onupdate -urb.onupdate = function(dep){ - if(urb.verb) - console.log("update", urb.datadeps[dep] ? "data" : "full", dep, urb.sources[dep]) - if(urb.datadeps[dep]) urb.ondataupdate(dep) - else _onupdate(dep) +urb.onLoadUrbJS = function(){ + urb.ondataupdate = urb.ondataupdate || urb.onupdate // overridable + + var _onupdate = urb.onupdate + urb.onupdate = function(dep){ + if(urb.verb) + console.log("update", urb.datadeps[dep] ? "data" : "full", dep, urb.sources[dep]) + if(urb.datadeps[dep]) urb.ondataupdate(dep) + else _onupdate(dep) + } + urb.waspDeps() + + urb.waspAll = function(sel){ + [].map.call(document.querySelectorAll(sel), urb.waspElem) + } + urb.waspAll('script'); urb.waspAll('link') }