mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-02-26 22:45:13 -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) {
|
function loadSettings (settingsRoot, whenDone) {
|
||||||
IO.requestFromServer('./settings.json', (result) => {
|
IO.requestFromServer(settingsRoot + 'settings.json', (result) => {
|
||||||
window.Settings = JSON.parse(result);
|
window.Settings = JSON.parse(result);
|
||||||
whenDone();
|
whenDone();
|
||||||
});
|
});
|
||||||
|
@ -159,14 +159,19 @@ function gettingStartedCloseMe () {
|
||||||
|
|
||||||
// App-wide entry-point
|
// App-wide entry-point
|
||||||
window.onload = () => {
|
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 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') {
|
if (page == 'index') {
|
||||||
preprocessAndLoadCss('css', 'css/font.css');
|
preprocessAndLoadCss('css', 'css/font.css');
|
||||||
preprocessAndLoadCss('css', 'css/base.css');
|
preprocessAndLoadCss('css', 'css/base.css');
|
||||||
|
@ -199,6 +204,21 @@ window.onload = () => {
|
||||||
gn('closeHelp').onclick = gettingStartedCloseMe;
|
gn('closeHelp').onclick = gettingStartedCloseMe;
|
||||||
gn('closeHelp').ontouchstart = gettingStartedCloseMe;
|
gn('closeHelp').ontouchstart = gettingStartedCloseMe;
|
||||||
iOS.waitForInterface(gettingStartedVideo);
|
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;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadMediaLib (whenDone) {
|
static loadMediaLib (root, whenDone) {
|
||||||
IO.requestFromServer('./media.json', (result) => {
|
IO.requestFromServer(root + 'media.json', (result) => {
|
||||||
let parsedResult = JSON.parse(result);
|
let parsedResult = JSON.parse(result);
|
||||||
path = parsedResult.path;
|
path = parsedResult.path;
|
||||||
samples = parsedResult.samples;
|
samples = parsedResult.samples;
|
||||||
|
|
|
@ -11,7 +11,6 @@ require('intl-messageformat/dist/locale-data/en');
|
||||||
require('intl-messageformat/dist/locale-data/es');
|
require('intl-messageformat/dist/locale-data/es');
|
||||||
|
|
||||||
let currentLocale;
|
let currentLocale;
|
||||||
let root = '';
|
|
||||||
let localizationMessages = {};
|
let localizationMessages = {};
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
|
@ -54,7 +53,7 @@ export default class Localization {
|
||||||
|
|
||||||
// Include locale support files and load the messages
|
// Include locale support files and load the messages
|
||||||
// Call this when the app is initialized
|
// Call this when the app is initialized
|
||||||
static includeLocales (whenDone) {
|
static includeLocales (localizationRoot, whenDone) {
|
||||||
var localizationCookie = Cookie.get('localization');
|
var localizationCookie = Cookie.get('localization');
|
||||||
|
|
||||||
if (localizationCookie === null) {
|
if (localizationCookie === null) {
|
||||||
|
@ -65,7 +64,7 @@ export default class Localization {
|
||||||
var topLevel = currentLocale.split('-')[0];
|
var topLevel = currentLocale.split('-')[0];
|
||||||
|
|
||||||
// Get messages
|
// Get messages
|
||||||
IO.requestFromServer(root + 'localizations/' + topLevel + '.json', (result) => {
|
IO.requestFromServer(localizationRoot + 'localizations/' + topLevel + '.json', (result) => {
|
||||||
localizationMessages = JSON.parse(result);
|
localizationMessages = JSON.parse(result);
|
||||||
whenDone();
|
whenDone();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue