2023-10-20 14:35:26 +00:00
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
//
// SPDX-License-Identifier: AGPL-3.0-or-later
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.
2017-12-20 17:36:53 +00:00
define ( [
'/common/requireconfig.js' ,
2021-11-22 11:05:35 +00:00
//'/common/test.js'
] , function ( RequireConfig /*, Test */ ) {
2017-08-22 13:50:10 +00:00
require . config ( RequireConfig ( ) ) ;
2017-08-09 15:37:55 +00:00
2017-08-07 14:27:57 +00: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]' ;
} ;
}
2023-07-19 11:04:23 +00:00
var ls = { } ;
try { ls = window . localStorage ; } catch ( e ) { console . warn ( e ) ; }
2023-07-18 15:31:36 +00:00
window . CryptPad _flushCacheInner = function ( ) {
Object . keys ( ls ) . forEach ( function ( k ) {
if ( k . indexOf ( 'CRYPTPAD_CACHE|' ) !== 0 && k . indexOf ( 'LESS_CACHE' ) !== 0 ) { return ; }
delete ls [ k ] ;
} ) ;
} ;
2017-08-07 14:27:57 +00:00
var mkFakeStore = function ( ) {
var fakeStorage = {
getItem : function ( k ) { return fakeStorage [ k ] ; } ,
2017-10-27 08:37:44 +00:00
setItem : function ( k , v ) { fakeStorage [ k ] = v ; return v ; } ,
removeItem : function ( k ) { delete fakeStorage [ k ] ; }
2017-08-07 14:27:57 +00:00
} ;
return fakeStorage ;
} ;
window . _ _defineGetter _ _ ( 'localStorage' , function ( ) { return mkFakeStore ( ) ; } ) ;
window . _ _defineGetter _ _ ( 'sessionStorage' , function ( ) { return mkFakeStore ( ) ; } ) ;
2017-09-14 08:23:05 +00:00
window . CRYPTPAD _INSIDE = true ;
2017-12-20 17:36:53 +00:00
// This test is for keeping the testing infrastructure operating
// until all tests have been registered.
// This test is completed in common-interface.js
2021-11-22 11:05:35 +00:00
//Test(function (t) { Test.__ASYNC_BLOCKER__ = t; });
2017-12-20 17:36:53 +00:00
2018-01-24 15:16:46 +00:00
window . onerror = function ( e ) {
if ( /requirejs\.org/ . test ( e ) ) {
console . log ( ) ;
2023-01-07 12:27:20 +00:00
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 `npm install` to get the latest code, then modify their cache version.\nBest of luck,\nThe CryptPad Developers" ) ;
2018-01-24 15:16:46 +00:00
return void console . log ( ) ;
}
2020-10-09 14:10:39 +00:00
if ( window . CryptPad _loadingError ) {
2020-11-04 04:58:52 +00:00
return void window . CryptPad _loadingError ( e ) ;
2020-10-09 14:10:39 +00:00
}
2018-01-24 15:16:46 +00:00
throw e ;
} ;
2017-08-07 14:27:57 +00:00
require ( [ document . querySelector ( 'script[data-bootload]' ) . getAttribute ( 'data-bootload' ) ] ) ;
} ) ;