Comparing version
@@ -25,4 +25,8 @@ /** Big ups to https://github.com/olark/lightningjs for | ||
booter.loadScript = function(url, globalExports) { | ||
var frame | ||
// Params: | ||
// - url: full or relative URL of script to load inside iframe | ||
// - globalExports: which globals to pull out of the iframe | ||
// - silent: return exported globals, but don't attach to parent window | ||
booter.loadScript = function(url, globalExports, silent) { | ||
var frame, pending={} | ||
@@ -95,9 +99,13 @@ if (! isArray(globalExports)) globalExports = [globalExports]; | ||
function exportGlobals() { | ||
var globs = [] | ||
for (var i=0, len=globalExports.length; i<len; i++) { | ||
var x = globalExports[i] | ||
window[x] = frame[CWIN][x] | ||
var key=globalExports[i], value=frame[CWIN][key] | ||
globs.push(value) | ||
silent || (window[key] = value) | ||
} | ||
pending.onReady && pending.onReady.apply(null, globs) | ||
} | ||
loadScriptInsideFrame() | ||
return pending | ||
} | ||
@@ -104,0 +112,0 @@ |
{ | ||
"name": "booter", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Browser-side script loader", | ||
@@ -5,0 +5,0 @@ "main": "booter.js", |
booter | ||
====== | ||
A tiny browser-side script loader designed to load scripts for embedded widgets | ||
A tiny browser-side script loader designed to load scripts for embedded | ||
widgets that safely loads scripts inside an iframe and exposes globals | ||
you select to the outer page. | ||
@@ -6,0 +8,0 @@ ## Usage options: |
Sorry, the diff of this file is not supported yet
6660
12.35%8
14.29%105
12.9%28
7.69%