diff --git a/www/common/LessLoader.js b/www/common/LessLoader.js index b25db9418..61cacfbeb 100644 --- a/www/common/LessLoader.js +++ b/www/common/LessLoader.js @@ -10,7 +10,13 @@ define([ var module = { exports: {} }; var key = Config.requireConf.urlArgs; - var localStorage = window.localStorage || {}; + var localStorage; + try { + localStorage = window.localStorage || {}; + } catch (e) { + console.error(e); + localStorage = {}; + } var fixURL = function (url) { var mark = (url.indexOf('?') !== -1) ? '&' : '?'; diff --git a/www/common/sframe-boot.js b/www/common/sframe-boot.js index 6ed56cfea..2ff9762b6 100644 --- a/www/common/sframe-boot.js +++ b/www/common/sframe-boot.js @@ -1,30 +1,40 @@ // Stage 0, this gets cached which means we can't change it. boot2-sframe.js is changable. // Note that this file is meant to be executed only inside of a sandbox iframe. ;(function () { -var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); -req.cfg = req.cfg || {}; -if (req.pfx) { - req.cfg.onNodeCreated = function (node /*, config, module, path*/) { - node.setAttribute('src', req.pfx + node.getAttribute('src')); +var afterLoaded = function (req) { + req.cfg = req.cfg || {}; + if (req.pfx) { + req.cfg.onNodeCreated = function (node /*, config, module, path*/) { + node.setAttribute('src', req.pfx + node.getAttribute('src')); + }; + } + require.config(req.cfg); + var txid = Math.random().toString(16).replace('0.', ''); + var intr; + var ready = function () { + intr = setInterval(function () { + if (typeof(txid) !== 'string') { return; } + window.parent.postMessage(JSON.stringify({ q: 'READY', txid: txid }), '*'); + }, 1); }; -} -require.config(req.cfg); -var txid = Math.random().toString(16).replace('0.', ''); -var intr; -var ready = function () { - intr = setInterval(function () { - if (typeof(txid) !== 'string') { return; } - window.parent.postMessage(JSON.stringify({ q: 'READY', txid: txid }), '*'); - }, 1); -}; -if (req.req) { require(req.req, ready); } else { ready(); } -var onReply = function (msg) { - var data = JSON.parse(msg.data); - if (data.txid !== txid) { return; } - clearInterval(intr); - txid = {}; - window.removeEventListener('message', onReply); - require(['/common/sframe-boot2.js'], function () { }); + if (req.req) { require(req.req, ready); } else { ready(); } + var onReply = function (msg) { + var data = JSON.parse(msg.data); + if (data.txid !== txid) { return; } + clearInterval(intr); + txid = {}; + window.removeEventListener('message', onReply); + require(['/common/sframe-boot2.js'], function () { }); + }; + window.addEventListener('message', onReply); }; -window.addEventListener('message', onReply); -}()); \ No newline at end of file + +var intr = setInterval(function () { + try { + var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); + clearInterval(intr); + afterLoaded(req); + } catch (e) { console.error(e); } +}, 100); + +}()); diff --git a/www/pad/inner.html b/www/pad/inner.html index b9d3645a5..aa487deac 100644 --- a/www/pad/inner.html +++ b/www/pad/inner.html @@ -2,7 +2,7 @@ - +