From f7de17cf48d4c8f253071e79beaad76f8f8c75fd Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 6 May 2015 17:01:13 -0700 Subject: [PATCH] window.urb injection collision avoidance --- base/arvo/eyre.hoon | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index f4c08dff95..a59aec9b3e 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -234,7 +234,12 @@ :: ++ add-json :: inject window.urb |= [urb=json jaz=cord] ^- cord - (cat 3 (crip "window.urb = {(pojo urb)}\0a") jaz) + =- (cat 3 (crip -) jaz) + """ + var _urb = {(pojo urb)} + window.urb = window.urb || \{}; for(k in _urb) window.urb[k] = _urb[k] + + """ :: ++ ares-to-json |= err=ares ^- json @@ -266,7 +271,7 @@ urb.tries = 0 urb.call = function() { urb.wreq = new XMLHttpRequest() - urb.wreq.open('GET', urb.poll, true) + urb.wreq.open('GET', urb.wurl, true) urb.wreq.addEventListener('load', function() { // if(~~(this.status / 100) == 4) // return document.write(this.responseText) @@ -285,11 +290,11 @@ } urb.call() urb.wasp = function(deh){ - var old = /[^/]*$/.exec(urb.poll)[0] + var old = /[^/]*$/.exec(urb.wurl)[0] var deps = old.replace(/^on.json\?|.json$/,'').split('&') if (deps.indexOf(deh) !== -1) return; deps.push(deh) - urb.poll = "/~/on.json?"+deps.join('&') + urb.wurl = "/~/on.json?"+deps.join('&') urb.wreq.abort() // trigger keep } ''' @@ -938,7 +943,7 @@ %poll ?: ?=([~ %js] p.pok) :: XX treat non-json cases? =+ polling-url=['/' (apex:earn %| pok(u.p %json) quy)] - [%& %js (add-json (joba %poll (jape polling-url)) poll:js)] + [%& %js (add-json (joba %wurl (jape polling-url)) poll:js)] |- =. done (new-dependency i.p.hem %& hen) ?~ t.p.hem [%| done]