mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-28 18:15:37 -05:00
Adding module about page and include roots
Localization, MediaLib, and Settings loads need an adjustable path for now because inapp/ pages are in a subdirectory.
This commit is contained in:
parent
b102d7a100
commit
def37de218
4 changed files with 50 additions and 44 deletions
File diff suppressed because one or more lines are too long
|
@ -121,8 +121,8 @@ function editorCreateScratchJr () {
|
|||
}
|
||||
}
|
||||
|
||||
function loadSettings (whenDone) {
|
||||
IO.requestFromServer('./settings.json', (result) => {
|
||||
function loadSettings (settingsRoot, whenDone) {
|
||||
IO.requestFromServer(settingsRoot + 'settings.json', (result) => {
|
||||
window.Settings = JSON.parse(result);
|
||||
whenDone();
|
||||
});
|
||||
|
@ -159,14 +159,19 @@ function gettingStartedCloseMe () {
|
|||
|
||||
// App-wide entry-point
|
||||
window.onload = () => {
|
||||
// Load settings from JSON
|
||||
loadSettings(() => {
|
||||
// Load locale strings from JSON
|
||||
Localization.includeLocales(() => {
|
||||
// Load Media Lib from JSON
|
||||
MediaLib.loadMediaLib(() => {
|
||||
// Continue to load the page
|
||||
let page = window.scratchJrPage;
|
||||
let root = './';
|
||||
if (page == 'inappAbout') {
|
||||
root = '../';
|
||||
}
|
||||
// Load settings from JSON
|
||||
loadSettings(root, () => {
|
||||
// Load locale strings from JSON
|
||||
Localization.includeLocales(root, () => {
|
||||
// Load Media Lib from JSON
|
||||
MediaLib.loadMediaLib(root, () => {
|
||||
// Continue to load the page
|
||||
|
||||
if (page == 'index') {
|
||||
preprocessAndLoadCss('css', 'css/font.css');
|
||||
preprocessAndLoadCss('css', 'css/base.css');
|
||||
|
@ -199,6 +204,21 @@ window.onload = () => {
|
|||
gn('closeHelp').onclick = gettingStartedCloseMe;
|
||||
gn('closeHelp').ontouchstart = gettingStartedCloseMe;
|
||||
iOS.waitForInterface(gettingStartedVideo);
|
||||
} else if (page == 'inappAbout') {
|
||||
preprocessAndLoadCss('style', 'style/about.css');
|
||||
gn('aboutScratchjrTitle').textContent = Localization.localize('ABOUT_SCRATCHJR');
|
||||
gn('aboutWhatIs').textContent = Localization.localize('ABOUT_WHAT_IS');
|
||||
gn('aboutDescription').innerHTML = Localization.localize('ABOUT_DESCRIPTION') + '<br/><br/>' +
|
||||
Localization.localize('ABOUT_INSPIRED_BY');
|
||||
gn('aboutWhyCreate').textContent = Localization.localize('ABOUT_WHY_CREATE');
|
||||
gn('aboutWhyCreateDescription').innerHTML = Localization.localize('ABOUT_WHY_CREATE_DESCRIPTION');
|
||||
gn('aboutWhoCreated').textContent = Localization.localize('ABOUT_WHO_CREATED');
|
||||
gn('aboutWhoCreatedDescription').innerHTML = (
|
||||
Localization.localize('ABOUT_WHO_CREATED_DESCRIPTION'));
|
||||
gn('aboutWhoSupported').textContent = Localization.localize('ABOUT_WHO_SUPPORTED');
|
||||
gn('aboutWhoSupportedDescription').innerHTML = (
|
||||
Localization.localize('ABOUT_WHO_SUPPORTED_DESCRIPTION')
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,8 +33,8 @@ export default class MediaLib {
|
|||
return keys;
|
||||
}
|
||||
|
||||
static loadMediaLib (whenDone) {
|
||||
IO.requestFromServer('./media.json', (result) => {
|
||||
static loadMediaLib (root, whenDone) {
|
||||
IO.requestFromServer(root + 'media.json', (result) => {
|
||||
let parsedResult = JSON.parse(result);
|
||||
path = parsedResult.path;
|
||||
samples = parsedResult.samples;
|
||||
|
|
|
@ -11,7 +11,6 @@ require('intl-messageformat/dist/locale-data/en');
|
|||
require('intl-messageformat/dist/locale-data/es');
|
||||
|
||||
let currentLocale;
|
||||
let root = '';
|
||||
let localizationMessages = {};
|
||||
|
||||
// Configuration
|
||||
|
@ -54,7 +53,7 @@ export default class Localization {
|
|||
|
||||
// Include locale support files and load the messages
|
||||
// Call this when the app is initialized
|
||||
static includeLocales (whenDone) {
|
||||
static includeLocales (localizationRoot, whenDone) {
|
||||
var localizationCookie = Cookie.get('localization');
|
||||
|
||||
if (localizationCookie === null) {
|
||||
|
@ -65,7 +64,7 @@ export default class Localization {
|
|||
var topLevel = currentLocale.split('-')[0];
|
||||
|
||||
// Get messages
|
||||
IO.requestFromServer(root + 'localizations/' + topLevel + '.json', (result) => {
|
||||
IO.requestFromServer(localizationRoot + 'localizations/' + topLevel + '.json', (result) => {
|
||||
localizationMessages = JSON.parse(result);
|
||||
whenDone();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue