2017-03-01 17:23:34 +01:00
// This is stage 1, it can be changed but you must bump the version of the project.
2017-08-07 16:27:57 +02:00
define ([
'/common/requireconfig.js'
], function ( RequireConfig ) {
2017-08-22 15:50:10 +02:00
require . config ( RequireConfig ());
2017-05-15 10:26:52 +02: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]' ;
};
}
2017-08-29 11:49:10 +02:00
// file encryption/decryption won't work if you don't have Array.fill
if ( typeof ( Array . prototype . fill ) !== 'function' ) {
Array . prototype . fill = function ( x ) { // CRYPTPAD_SHIM
var i = 0 ;
var l = this . length ;
for (; i < l ; i ++ ) { this [ i ] = x ; }
return this ;
};
}
2018-01-16 18:03:55 +01:00
// RPC breaks if you don't support Number.MAX_SAFE_INTEGER
if ( Number && ! Number . MAX_SAFE_INTEGER ) {
Number . MAX_SAFE_INTEGER = 9007199254740991 ;
}
2017-06-13 11:57:21 +02:00
var failStore = function () {
2017-06-13 12:24:32 +02:00
console . error ( new Error ( 'wut' ));
2017-06-13 11:57:21 +02:00
require ([ 'jquery' ], function ( $ ) {
2017-06-13 11:33:25 +02:00
$ . ajax ({
type : 'HEAD' ,
url : '/common/feedback.html?NO_LOCALSTORAGE=' + ( + new Date ()),
});
});
window . alert ( "CryptPad needs localStorage to work, try a different browser" );
2017-06-13 11:57:21 +02:00
};
2018-01-24 16:16:46 +01: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-06-13 11:57:21 +02:00
try {
var test_key = 'localStorage_test' ;
var testval = Math . random (). toString ();
localStorage . setItem ( test_key , testval );
2017-06-13 12:24:32 +02:00
if ( localStorage . getItem ( test_key ) !== testval ) {
2017-06-13 12:02:36 +02:00
failStore ();
2017-06-13 11:57:21 +02:00
}
2017-06-13 12:02:36 +02:00
} catch ( e ) { console . error ( e ); failStore (); }
2017-06-13 11:33:25 +02:00
2017-03-01 17:23:34 +01:00
require ([ document . querySelector ( 'script[data-bootload]' ). getAttribute ( 'data-bootload' )]);
});