2017-08-07 22:27:57 +08: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.
2017-12-21 01:36:53 +08:00
define ( [
'/common/requireconfig.js' ,
'/common/test.js'
] , function ( RequireConfig , Test ) {
2017-08-22 21:50:10 +08:00
require . config ( RequireConfig ( ) ) ;
2017-08-09 23:37:55 +08:00
2017-08-07 22:27:57 +08:00
// 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]' ;
} ;
}
2018-01-04 00:14:35 +08:00
// RPC breaks if you don't support Number.MAX_SAFE_INTEGER
if ( Number && ! Number . MAX _SAFE _INTEGER ) {
Number . MAX _SAFE _INTEGER = 9007199254740991 ;
}
2017-08-07 22:27:57 +08:00
var mkFakeStore = function ( ) {
var fakeStorage = {
getItem : function ( k ) { return fakeStorage [ k ] ; } ,
2017-10-27 16:37:44 +08:00
setItem : function ( k , v ) { fakeStorage [ k ] = v ; return v ; } ,
removeItem : function ( k ) { delete fakeStorage [ k ] ; }
2017-08-07 22:27:57 +08:00
} ;
return fakeStorage ;
} ;
window . _ _defineGetter _ _ ( 'localStorage' , function ( ) { return mkFakeStore ( ) ; } ) ;
window . _ _defineGetter _ _ ( 'sessionStorage' , function ( ) { return mkFakeStore ( ) ; } ) ;
2017-09-14 16:23:05 +08:00
window . CRYPTPAD _INSIDE = true ;
2017-12-21 01:36:53 +08:00
// This test is for keeping the testing infrastructure operating
// until all tests have been registered.
// This test is completed in common-interface.js
Test ( function ( t ) { Test . _ _ASYNC _BLOCKER _ _ = t ; } ) ;
2018-01-24 23:16:46 +08:00
window . onerror = function ( e ) {
if ( /requirejs\.org/ . test ( e ) ) {
console . log ( ) ;
console . error ( "Require.js threw a Script Error. This probably means you're missing a dependency for CryptPad.\nIt is recommended that the admin of this server runs `bower install && bower update` to get the latest code, then modify their cache version.\nBest of luck,\nThe CryptPad Developers" ) ;
return void console . log ( ) ;
}
throw e ;
} ;
2017-08-07 22:27:57 +08:00
require ( [ document . querySelector ( 'script[data-bootload]' ) . getAttribute ( 'data-bootload' ) ] ) ;
} ) ;