Merge remote-tracking branch 'ohaitch/urb-defer-init'

Conflicts:
	ren/tree/head.hoon
	web/tree/~.main_urb.js

Add urb.init to pull /~/auth.json
Tree was already at a newer version on master head
This commit is contained in:
Raymond Pasco 2016-06-10 18:06:42 -04:00
commit a6e1b087f0

View File

@ -1,6 +1,23 @@
window.urb = window.urb || {}
window.urb.appl = window.urb.appl || null
window.urb.init = function(onload){ // XX proper class?
onload = onload || function(){}
var $init = this.init
if($init.loaded) return onload()
if($init.loading) return $init.loading.push(onload)
$init.loading = [onload]
var s = document.createElement('script')
s.src = "/~/at/~/auth.js" // XX nop.js? auth.json?
s.onload = function(){
$init.loading.map(function(f){f()})
delete $init.loading
$init.loaded = true
}
document.body.appendChild(s)
}
window.urb.init.loaded = window.urb.oryx
window.urb.req = function(method,url,params,json,cb) {
var xhr = new XMLHttpRequest()
method = method.toUpperCase()