2021-11-08 11:53:10 -05:00
|
|
|
import 'regenerator-runtime/runtime'; // Needed for async/await
|
2024-03-20 18:12:54 -04:00
|
|
|
import jar from './lib/jar';
|
2015-10-15 23:05:57 -04:00
|
|
|
|
2015-10-21 20:49:31 -04:00
|
|
|
/**
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
* L10N
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
2023-01-06 15:55:16 -05:00
|
|
|
(() => {
|
2018-01-30 11:53:12 -05:00
|
|
|
/*
|
2015-10-15 23:05:57 -04:00
|
|
|
* Bind locale code from cookie if available. Uses navigator language API as a fallback.
|
|
|
|
*
|
|
|
|
* @return {string}
|
|
|
|
*/
|
2018-01-30 11:53:12 -05:00
|
|
|
const updateLocale = () => {
|
|
|
|
let obj = jar.get('scratchlanguage');
|
2015-10-15 23:05:57 -04:00
|
|
|
if (typeof obj === 'undefined') {
|
|
|
|
obj = window.navigator.userLanguage || window.navigator.language;
|
2018-01-30 11:53:12 -05:00
|
|
|
if (['pt', 'pt-pt', 'PT', 'PT-PT'].indexOf(obj) !== -1) {
|
2016-01-04 14:18:47 -05:00
|
|
|
obj = 'pt-br'; // default Portuguese users to Brazilian Portuguese due to our user base. Added in 2.2.5.
|
|
|
|
}
|
2020-01-29 16:11:58 -05:00
|
|
|
} else {
|
|
|
|
// delete the old cookie (just hostname) by setting it to null and expiring in the past
|
|
|
|
/* eslint-disable max-len */
|
2020-01-30 09:43:51 -05:00
|
|
|
document.cookie = `scratchlanguage=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
|
2020-01-29 16:11:58 -05:00
|
|
|
/* eslint-enable max-len */
|
|
|
|
// create the new cookie
|
|
|
|
let opts = {};
|
|
|
|
if (window.location.hostname !== 'localhost') {
|
|
|
|
opts = {domain: `.${window.location.hostname}`};
|
|
|
|
}
|
|
|
|
jar.set('scratchlanguage', obj, opts);
|
2015-10-15 23:05:57 -04:00
|
|
|
}
|
|
|
|
return obj;
|
2018-01-30 11:53:12 -05:00
|
|
|
};
|
2015-10-15 23:05:57 -04:00
|
|
|
|
2016-01-06 14:09:32 -05:00
|
|
|
window._locale = updateLocale();
|
2018-08-22 13:05:49 -04:00
|
|
|
document.documentElement.lang = window._locale;
|
2015-10-15 23:05:57 -04:00
|
|
|
})();
|
2018-06-29 09:23:55 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
* Console warning
|
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
(() => {
|
|
|
|
window.onload = function () {
|
2018-06-29 09:57:46 -04:00
|
|
|
/* eslint-disable no-console */
|
2018-06-29 09:23:55 -04:00
|
|
|
console.log('%cStop!', 'color: #F00; font-size: 30px; -webkit-text-stroke: 1px black; font-weight:bold');
|
|
|
|
console.log(
|
|
|
|
'This is part of your browser intended for developers. ' +
|
|
|
|
'If someone told you to copy-and-paste something here, ' +
|
|
|
|
'don\'t do it! It could allow them to take over your ' +
|
|
|
|
'Scratch account, delete all of your projects, or do many ' +
|
|
|
|
'other harmful things. If you don\'t understand what exactly ' +
|
|
|
|
'you are doing here, you should close this window without doing ' +
|
|
|
|
'anything.'
|
|
|
|
);
|
2018-06-29 09:57:46 -04:00
|
|
|
/* eslint-enable no-console */
|
2018-06-29 09:23:55 -04:00
|
|
|
};
|
|
|
|
})();
|