cryptpad/www/common/sframe-boot2.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-08-07 14:27:57 +00:00
// This is stage 1, it can be changed but you must bump the version of the project.
// Note: This must only be loaded from inside of a sandbox-iframe.
define([
2017-08-09 12:45:39 +00:00
'/common/requireconfig.js',
'/common/sframe-channel.js'
], function (RequireConfig, SFrameChannel) {
2017-08-07 14:27:57 +00:00
require.config(RequireConfig);
console.log('boot2');
// most of CryptPad breaks if you don't support isArray
if (!Array.isArray) {
Array.isArray = function(arg) { // CRYPTPAD_SHIM
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
var mkFakeStore = function () {
var fakeStorage = {
getItem: function (k) { return fakeStorage[k]; },
setItem: function (k, v) { fakeStorage[k] = v; return v; }
};
return fakeStorage;
};
window.__defineGetter__('localStorage', function () { return mkFakeStore(); });
window.__defineGetter__('sessionStorage', function () { return mkFakeStore(); });
2017-08-09 12:45:39 +00:00
SFrameChannel.init(window.top, function () { });
2017-08-07 14:27:57 +00:00
require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]);
});