mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-25 00:28:20 -05:00
Merge entry-points and bundles for editor, home, index
This commit is contained in:
parent
3e0a600953
commit
2f2d36dd86
8 changed files with 181 additions and 208 deletions
|
@ -8,9 +8,10 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Junior</title>
|
<title>Junior</title>
|
||||||
|
|
||||||
<script type="text/javascript" src="./Settings.js"></script>
|
<script>
|
||||||
<script type="text/javascript" src="./MediaLib.js"></script>
|
window.scratchJrPage = 'editor';
|
||||||
<script type="text/javascript" src="jssource/build/bundles/editor.bundle.js"></script>
|
</script>
|
||||||
|
<script type="text/javascript" src="jssource/build/bundles/app.bundle.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body style="background: white;">
|
<body style="background: white;">
|
||||||
<div class="frame" id="frame"></div>
|
<div class="frame" id="frame"></div>
|
||||||
|
|
|
@ -8,52 +8,11 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Scratch Jr</title>
|
<title>Scratch Jr</title>
|
||||||
|
|
||||||
<script type="text/javascript" src="./Settings.js"></script>
|
|
||||||
<script type="text/javascript" src="./MediaLib.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/build/bundles/home.bundle.js"></script>
|
|
||||||
<!--
|
|
||||||
<script type="text/javascript" src="./Settings.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/utils/Cookie.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/utils/lib.js"></script>
|
|
||||||
-->
|
|
||||||
<!-- Localization includes --><!--
|
|
||||||
<script type="text/javascript" src="jssource/external/Intl/Intl.min.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/external/intl-messageformat/intl-messageformat.min.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/utils/Localization.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
Localization.includeLocales();
|
window.scratchJrPage = 'home';
|
||||||
</script>-->
|
|
||||||
<!-- End localization includes -->
|
|
||||||
<!--
|
|
||||||
<script type="text/javascript">
|
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/javascript" src="jssource/build/bundles/app.bundle.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="jssource/lobby/Lobby.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/lobby/Home.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/lobby/Samples.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="jssource/utils/Events.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/utils/SVG2Canvas.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/utils/ScratchAudio.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/utils/Sound.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="jssource/external/jszip.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/editor/ui/Project.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="jssource/utils/DrawPath.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/editor/ui/Alert.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/iPad/iOS.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/iPad/IO.js"></script>
|
|
||||||
<script type="text/javascript" src="./MediaLib.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/geom/Vector.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/geom/Matrix.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/geom/Rectangle.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="jssource/painteditor/SVGImage.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/painteditor/Transform.js"></script>
|
|
||||||
<script type="text/javascript" src="jssource/painteditor/SVGTools.js"></script>
|
|
||||||
|
|
||||||
-->
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="frame" id="frame">
|
<div class="frame" id="frame">
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>ScratchJr Intro</title>
|
<title>ScratchJr Intro</title>
|
||||||
<script type="text/javascript" src="./Settings.js"></script>
|
<script>
|
||||||
<script type="text/javascript" src="./MediaLib.js"></script>
|
window.scratchJrPage = 'index';
|
||||||
<script type="text/javascript" src="jssource/build/bundles/index.bundle.js"></script>
|
</script>
|
||||||
|
<script type="text/javascript" src="jssource/build/bundles/app.bundle.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body style="margin:0px; background: black;">
|
<body style="margin:0px; background: black;">
|
||||||
<div class="frame" id="frame">
|
<div class="frame" id="frame">
|
||||||
|
|
170
src/entry/app.js
Normal file
170
src/entry/app.js
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
import {isAndroid, isiOS, gn, getUrlVars, preprocessAndLoadCss} from '../utils/lib';
|
||||||
|
import Localization from '../utils/Localization';
|
||||||
|
import iOS from '../iPad/iOS';
|
||||||
|
import IO from '../iPad/IO';
|
||||||
|
import MediaLib from '../iPad/MediaLib';
|
||||||
|
import ScratchJr from '../editor/ScratchJr';
|
||||||
|
import ScratchAudio from '../utils/ScratchAudio';
|
||||||
|
import Lobby from '../lobby/Lobby.js';
|
||||||
|
import Record from '../editor/ui/Record';
|
||||||
|
import Camera from '../painteditor/Camera';
|
||||||
|
|
||||||
|
// Entry-points for each page
|
||||||
|
// Previously index.html
|
||||||
|
function indexStartup () {
|
||||||
|
ScratchAudio.init();
|
||||||
|
var urlvars = getUrlVars();
|
||||||
|
if (urlvars.back) {
|
||||||
|
indexLoadOptions();
|
||||||
|
} else {
|
||||||
|
indexFirstTime();
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
gn('rays').className = 'rays spinme';
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexFirstTime () {
|
||||||
|
gn('authors').className = 'credits show';
|
||||||
|
gn('authorsText').className = 'creditsText show';
|
||||||
|
gn('purpleguy').className = 'purple show';
|
||||||
|
gn('blueguy').className = 'blue show';
|
||||||
|
gn('redguy').className = 'red show';
|
||||||
|
iOS.askpermission(); // ask for sound recording
|
||||||
|
setTimeout(function () {
|
||||||
|
iOS.hidesplash(doit);
|
||||||
|
}, 500);
|
||||||
|
function doit () {
|
||||||
|
ScratchAudio.sndFX('tap.wav');
|
||||||
|
window.ontouchend = function () {
|
||||||
|
indexLoadOptions();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
indexLoadOptions();
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexLoadOptions () {
|
||||||
|
gn('authors').className = 'credits hide';
|
||||||
|
gn('authorsText').className = 'creditsText hide';
|
||||||
|
gn('purpleguy').className = 'purple hide';
|
||||||
|
gn('blueguy').className = 'blue hide';
|
||||||
|
gn('redguy').className = 'red hide';
|
||||||
|
gn('gettings').className = 'gettings show';
|
||||||
|
gn('startcode').className = 'startcode show';
|
||||||
|
document.ontouchmove = function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
};
|
||||||
|
if (isAndroid) {
|
||||||
|
AndroidInterface.notifySplashDone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexGohome () {
|
||||||
|
// On iOS, sounds are loaded async, but the code as written expects to play tap.wav when we enter home.html
|
||||||
|
// (but since it isn't loaded yet, no sound is played).
|
||||||
|
// On Android, sync sounds means both calls to tap.wav result in a sound play.
|
||||||
|
// XXX: we should re-write the lobby loading to wait for the sounds to load, and not play a sound here.
|
||||||
|
if (isiOS) {
|
||||||
|
ScratchAudio.sndFX('tap.wav');
|
||||||
|
}
|
||||||
|
iOS.setfile('homescroll.sjr', 0, function () {
|
||||||
|
doNext();
|
||||||
|
});
|
||||||
|
function doNext () {
|
||||||
|
window.location.href = 'home.html';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexGettingstarted () {
|
||||||
|
ScratchAudio.sndFX('tap.wav');
|
||||||
|
window.location.href = 'gettingstarted.html?place=home';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Previously home.html
|
||||||
|
|
||||||
|
function homeStartup () {
|
||||||
|
homeStrings();
|
||||||
|
iOS.getsettings(doNext);
|
||||||
|
function doNext (str) {
|
||||||
|
var list = str.split(',');
|
||||||
|
iOS.path = list[1] == '0' ? list[0] + '/' : undefined;
|
||||||
|
Lobby.appinit(window.Settings.scratchJrVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function homeGoBack () {
|
||||||
|
window.location.href = 'index.html?back=yes';
|
||||||
|
}
|
||||||
|
|
||||||
|
function homeStrings () {
|
||||||
|
gn('abouttab-text').textContent = Localization.localize('ABOUT_SCRATCHJR');
|
||||||
|
gn('interfacetab-text').textContent = Localization.localize('INTERFACE_GUIDE');
|
||||||
|
gn('painttab-text').textContent = Localization.localize('PAINT_EDITOR_GUIDE');
|
||||||
|
gn('blockstab-text').textContent = Localization.localize('BLOCKS_GUIDE');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Previously editor.html
|
||||||
|
function editorCreateScratchJr () {
|
||||||
|
iOS.getsettings(doNext);
|
||||||
|
function doNext (str) {
|
||||||
|
var list = str.split(',');
|
||||||
|
iOS.path = list[1] == '0' ? list[0] + '/' : undefined;
|
||||||
|
if (list.length > 2) {
|
||||||
|
Record.available = list[2] == 'YES' ? true : false;
|
||||||
|
}
|
||||||
|
if (list.length > 3) {
|
||||||
|
Camera.available = list[3] == 'YES' ? true : false;
|
||||||
|
}
|
||||||
|
ScratchJr.appinit(window.Settings.scratchJrVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadSettings (whenDone) {
|
||||||
|
IO.requestFromServer('./settings.json', (result) => {
|
||||||
|
window.Settings = JSON.parse(result);
|
||||||
|
whenDone();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
if (page == 'index') {
|
||||||
|
preprocessAndLoadCss('css', 'css/font.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/base.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/start.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/thumbs.css');
|
||||||
|
gn('gettings').ontouchend = indexGettingstarted;
|
||||||
|
gn('startcode').ontouchend = indexGohome;
|
||||||
|
iOS.waitForInterface(indexStartup);
|
||||||
|
} else if (page == 'home') {
|
||||||
|
preprocessAndLoadCss('css', 'css/font.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/base.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/lobby.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/thumbs.css');
|
||||||
|
gn('logotab').ontouchend = homeGoBack;
|
||||||
|
iOS.waitForInterface(homeStartup);
|
||||||
|
} else if (page == 'editor') {
|
||||||
|
preprocessAndLoadCss('css', 'css/font.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/base.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/editor.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/editorleftpanel.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/editorstage.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/editormodal.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/librarymodal.css');
|
||||||
|
preprocessAndLoadCss('css', 'css/paintlook.css');
|
||||||
|
iOS.waitForInterface(editorCreateScratchJr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,34 +0,0 @@
|
||||||
import ScratchJr from '../editor/ScratchJr';
|
|
||||||
import iOS from '../iPad/iOS';
|
|
||||||
import Localization from '../utils/Localization';
|
|
||||||
import Record from '../editor/ui/Record';
|
|
||||||
import Camera from '../painteditor/Camera';
|
|
||||||
import {preprocessAndLoadCss} from '../utils/lib';
|
|
||||||
|
|
||||||
function createScratchJr () {
|
|
||||||
iOS.getsettings(doNext);
|
|
||||||
function doNext (str) {
|
|
||||||
var list = str.split(',');
|
|
||||||
iOS.path = list[1] == '0' ? list[0] + '/' : undefined;
|
|
||||||
if (list.length > 2) {
|
|
||||||
Record.available = list[2] == 'YES' ? true : false;
|
|
||||||
}
|
|
||||||
if (list.length > 3) {
|
|
||||||
Camera.available = list[3] == 'YES' ? true : false;
|
|
||||||
}
|
|
||||||
ScratchJr.appinit(Settings.scratchJrVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload = () => {
|
|
||||||
preprocessAndLoadCss('css', 'css/font.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/base.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/editor.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/editorleftpanel.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/editorstage.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/editormodal.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/librarymodal.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/paintlook.css');
|
|
||||||
Localization.includeLocales();
|
|
||||||
iOS.waitForInterface(createScratchJr);
|
|
||||||
};
|
|
|
@ -1,35 +0,0 @@
|
||||||
import {gn, preprocessAndLoadCss} from '../utils/lib';
|
|
||||||
import iOS from '../iPad/iOS';
|
|
||||||
import Localization from '../utils/Localization';
|
|
||||||
import Lobby from '../lobby/Lobby.js';
|
|
||||||
|
|
||||||
function startup () {
|
|
||||||
homeStrings();
|
|
||||||
iOS.getsettings(doNext);
|
|
||||||
function doNext (str) {
|
|
||||||
var list = str.split(',');
|
|
||||||
iOS.path = list[1] == '0' ? list[0] + '/' : undefined;
|
|
||||||
Lobby.appinit(Settings.scratchJrVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function goBack () {
|
|
||||||
window.location.href = 'index.html?back=yes';
|
|
||||||
}
|
|
||||||
|
|
||||||
function homeStrings () {
|
|
||||||
gn('abouttab-text').textContent = Localization.localize('ABOUT_SCRATCHJR');
|
|
||||||
gn('interfacetab-text').textContent = Localization.localize('INTERFACE_GUIDE');
|
|
||||||
gn('painttab-text').textContent = Localization.localize('PAINT_EDITOR_GUIDE');
|
|
||||||
gn('blockstab-text').textContent = Localization.localize('BLOCKS_GUIDE');
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload = () => {
|
|
||||||
Localization.includeLocales();
|
|
||||||
preprocessAndLoadCss('css', 'css/font.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/base.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/lobby.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/thumbs.css');
|
|
||||||
gn('logotab').ontouchend = goBack;
|
|
||||||
iOS.waitForInterface(startup);
|
|
||||||
};
|
|
|
@ -1,87 +0,0 @@
|
||||||
import {isAndroid, isiOS, gn, getUrlVars, preprocessAndLoadCss} from '../utils/lib';
|
|
||||||
import Localization from '../utils/Localization';
|
|
||||||
import iOS from '../iPad/iOS';
|
|
||||||
import ScratchAudio from '../utils/ScratchAudio';
|
|
||||||
|
|
||||||
function startup () {
|
|
||||||
ScratchAudio.init();
|
|
||||||
var urlvars = getUrlVars();
|
|
||||||
if (urlvars.back) {
|
|
||||||
loadOptions();
|
|
||||||
} else {
|
|
||||||
firstTime();
|
|
||||||
}
|
|
||||||
setTimeout(function () {
|
|
||||||
gn('rays').className = 'rays spinme';
|
|
||||||
}, 250);
|
|
||||||
}
|
|
||||||
|
|
||||||
function firstTime () {
|
|
||||||
gn('authors').className = 'credits show';
|
|
||||||
gn('authorsText').className = 'creditsText show';
|
|
||||||
gn('purpleguy').className = 'purple show';
|
|
||||||
gn('blueguy').className = 'blue show';
|
|
||||||
gn('redguy').className = 'red show';
|
|
||||||
iOS.askpermission(); // ask for sound recording
|
|
||||||
setTimeout(function () {
|
|
||||||
iOS.hidesplash(doit);
|
|
||||||
}, 500);
|
|
||||||
function doit () {
|
|
||||||
ScratchAudio.sndFX('tap.wav');
|
|
||||||
window.ontouchend = function () {
|
|
||||||
loadOptions();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
setTimeout(function () {
|
|
||||||
loadOptions();
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadOptions () {
|
|
||||||
gn('authors').className = 'credits hide';
|
|
||||||
gn('authorsText').className = 'creditsText hide';
|
|
||||||
gn('purpleguy').className = 'purple hide';
|
|
||||||
gn('blueguy').className = 'blue hide';
|
|
||||||
gn('redguy').className = 'red hide';
|
|
||||||
gn('gettings').className = 'gettings show';
|
|
||||||
gn('startcode').className = 'startcode show';
|
|
||||||
document.ontouchmove = function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
};
|
|
||||||
if (isAndroid) {
|
|
||||||
AndroidInterface.notifySplashDone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function gohome () {
|
|
||||||
// On iOS, sounds are loaded async, but the code as written expects to play tap.wav when we enter home.html
|
|
||||||
// (but since it isn't loaded yet, no sound is played).
|
|
||||||
// On Android, sync sounds means both calls to tap.wav result in a sound play.
|
|
||||||
// XXX: we should re-write the lobby loading to wait for the sounds to load, and not play a sound here.
|
|
||||||
if (isiOS) {
|
|
||||||
ScratchAudio.sndFX('tap.wav');
|
|
||||||
}
|
|
||||||
iOS.setfile('homescroll.sjr', 0, function () {
|
|
||||||
doNext();
|
|
||||||
});
|
|
||||||
function doNext () {
|
|
||||||
window.location.href = 'home.html';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function gettingstarted () {
|
|
||||||
ScratchAudio.sndFX('tap.wav');
|
|
||||||
window.location.href = 'gettingstarted.html?place=home';
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload = () => {
|
|
||||||
Localization.includeLocales();
|
|
||||||
preprocessAndLoadCss('css', 'css/font.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/base.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/start.css');
|
|
||||||
preprocessAndLoadCss('css', 'css/thumbs.css');
|
|
||||||
gn('gettings').ontouchend = gettingstarted;
|
|
||||||
gn('startcode').ontouchend = gohome;
|
|
||||||
|
|
||||||
iOS.waitForInterface(startup);
|
|
||||||
};
|
|
|
@ -1,9 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
entry: {
|
entry: {
|
||||||
index: './src/entry/index.js',
|
app: './src/entry/app.js'
|
||||||
editor: './src/entry/editor.js',
|
|
||||||
home: './src/entry/home.js'
|
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: './src/build/bundles',
|
path: './src/build/bundles',
|
||||||
|
|
Loading…
Reference in a new issue