diff --git a/game/static/game/js/game.js b/game/static/game/js/game.js
index 3d0d13ac4..f376fddf9 100644
--- a/game/static/game/js/game.js
+++ b/game/static/game/js/game.js
@@ -10,133 +10,135 @@ ocargo.Game = function () {
}
ocargo.Game.prototype.setup = function () {
- if(new Date().getMonth() === 11) {
- $("#paper").css('background-color', '#eef7ff')
- }
-
- if (NIGHT_MODE_FEATURE_ENABLED) {
- if (NIGHT_MODE) {
- $('#paper').css('background-color', 'black')
+ loadLanguage("/static/game/js/blockly/msg/js/", navigator.language.toLowerCase(), function() {
+ if(new Date().getMonth() === 11) {
+ $("#paper").css('background-color', '#eef7ff')
}
- if (!ANONYMOUS) {
- $('#nightmode_tab').show()
+ if (NIGHT_MODE_FEATURE_ENABLED) {
+ if (NIGHT_MODE) {
+ $('#paper').css('background-color', 'black')
+ }
+
+ if (!ANONYMOUS) {
+ $('#nightmode_tab').show()
+ }
}
- }
-// Function being called when there is a change in game level.
-ocargo.Game.prototype.onLevelChange = function() {
- const currentLevelId = LEVEL_ID;
- localStorage.setItem('currentEpisode', EPISODE);
-}
+ // Function being called when there is a change in game level.
+ ocargo.Game.prototype.onLevelChange = function() {
+ const currentLevelId = LEVEL_ID;
+ localStorage.setItem('currentEpisode', EPISODE);
+ }
- restoreCmsLogin()
- initCustomBlocks()
- ocargo.solutionLoaded = false
- ocargo.blocklyControl = new ocargo.BlocklyControl()
- ocargo.pythonControl = new ocargo.PythonControl()
- ocargo.blocklyCompiler = new ocargo.BlocklyCompiler()
- ocargo.model = new ocargo.Model(
- PATH,
- ORIGIN,
- DESTINATIONS,
- TRAFFIC_LIGHTS,
- COWS,
- MAX_FUEL
- )
- this.drawing = new ocargo.Drawing(ocargo.model.startingPosition())
- this.drawing.preloadRoadTiles()
- ocargo.animation = new ocargo.Animation(ocargo.model, DECOR, this.drawing)
- this.saving = new ocargo.Saving()
- this.sharing = new ocargo.Sharing(
- () => parseInt(LEVEL_ID),
- () => true
- )
+ restoreCmsLogin()
+ initCustomBlocks()
+ ocargo.solutionLoaded = false
+ ocargo.blocklyControl = new ocargo.BlocklyControl()
+ ocargo.pythonControl = new ocargo.PythonControl()
+ ocargo.blocklyCompiler = new ocargo.BlocklyCompiler()
+ ocargo.model = new ocargo.Model(
+ PATH,
+ ORIGIN,
+ DESTINATIONS,
+ TRAFFIC_LIGHTS,
+ COWS,
+ MAX_FUEL
+ )
+ this.drawing = new ocargo.Drawing(ocargo.model.startingPosition())
+ this.drawing.preloadRoadTiles()
+ ocargo.animation = new ocargo.Animation(ocargo.model, DECOR, this.drawing)
+ this.saving = new ocargo.Saving()
+ this.sharing = new ocargo.Sharing(
+ () => parseInt(LEVEL_ID),
+ () => true
+ )
- // Setup the blockly workspace
- ocargo.blocklyControl.reset()
- ocargo.blocklyControl.loadPreviousAttempt()
- ocargo.pythonControl.loadPreviousAttempt()
+ // Setup the blockly workspace
+ ocargo.blocklyControl.reset()
+ ocargo.blocklyControl.loadPreviousAttempt()
+ ocargo.pythonControl.loadPreviousAttempt()
- // Setup the ui
- this._setupConsoleSliderListeners()
- this._setupPythonViewSliderListeners()
- this._setupConsoleLogViewSliderListeners()
- this._setupDirectDriveListeners()
- this._setupFuelGauge(ocargo.model.map.nodes, BLOCKS)
- this._setupTabs()
+ // Setup the ui
+ this._setupConsoleSliderListeners()
+ this._setupPythonViewSliderListeners()
+ this._setupConsoleLogViewSliderListeners()
+ this._setupDirectDriveListeners()
+ this._setupFuelGauge(ocargo.model.map.nodes, BLOCKS)
+ this._setupTabs()
- this.onStopControls()
+ this.onStopControls()
- // default controller
- if (BLOCKLY_ENABLED) {
- ocargo.controller = ocargo.blocklyControl
- } else {
- ocargo.controller = ocargo.pythonControl
- }
+ // default controller
+ if (BLOCKLY_ENABLED) {
+ ocargo.controller = ocargo.blocklyControl
+ } else {
+ ocargo.controller = ocargo.pythonControl
+ }
- // Setup blockly to python
- Blockly.Python.init(Blockly.getMainWorkspace())
- window.addEventListener(
- 'unload',
- function (event) {
- ocargo.pythonControl.teardown()
- ocargo.blocklyControl.teardown()
- }.bind(this)
- )
+ // Setup blockly to python
+ Blockly.Python.init(Blockly.getMainWorkspace())
+ window.addEventListener(
+ 'unload',
+ function (event) {
+ ocargo.pythonControl.teardown()
+ ocargo.blocklyControl.teardown()
+ }.bind(this)
+ )
- var loggedOutWarning = ''
- // Check if logged on
- if (USER_STATUS == 'UNTRACKED') {
- loggedOutWarning =
- '
'
- }
- // Start the popup
- var title = gettext('Try solving this one...')
- if (LEVEL_ID) {
- var titlePrefix = ''
- if (NIGHT_MODE) {
- titlePrefix = gettext('Night Level %(level_name)s')
- } else if (DEFAULT_LEVEL) {
- titlePrefix = gettext('Level %(level_name)s')
+ var loggedOutWarning = ''
+ // Check if logged on
+ if (USER_STATUS == 'UNTRACKED') {
+ loggedOutWarning =
+ '
'
}
- if (titlePrefix) {
- title = interpolate(titlePrefix, { level_name: LEVEL_NAME }, true)
- } else {
- title = LEVEL_NAME
+ // Start the popup
+ var title = gettext('Try solving this one...')
+ if (LEVEL_ID) {
+ var titlePrefix = ''
+ if (NIGHT_MODE) {
+ titlePrefix = gettext('Night Level %(level_name)s')
+ } else if (DEFAULT_LEVEL) {
+ titlePrefix = gettext('Level %(level_name)s')
+ }
+ if (titlePrefix) {
+ title = interpolate(titlePrefix, { level_name: LEVEL_NAME }, true)
+ } else {
+ title = LEVEL_NAME
+ }
}
- }
- var message
- if (NIGHT_MODE) {
- message =
- '
' +
- gettext(
- 'In Night Mode you can only see a very short distance. ' +
- "We've given you more blocks to help you find your way!"
- )
- } else {
- message = loggedOutWarning
- }
+ var message
+ if (NIGHT_MODE) {
+ message =
+ '
' +
+ gettext(
+ 'In Night Mode you can only see a very short distance. ' +
+ "We've given you more blocks to help you find your way!"
+ )
+ } else {
+ message = loggedOutWarning
+ }
- this.drawing.enablePanning()
+ this.drawing.enablePanning()
- const showMascot = BLOCKLY_ENABLED && !PYTHON_VIEW_ENABLED && LEVEL_NAME <= 80; // show mascot on Blockly-only levels that are not above 80
+ const showMascot = BLOCKLY_ENABLED && !PYTHON_VIEW_ENABLED && LEVEL_NAME <= 80; // show mascot on Blockly-only levels that are not above 80
- ocargo.Drawing.startPopup(
- title,
- LESSON,
- message,
- showMascot,
- [
- ocargo.button.dismissButtonHtml("prev_button", gettext("Previous level")),
- ocargo.button.dismissButtonHtml('play_button', gettext('Play')),
- ocargo.button.dismissButtonHtml("next_button", gettext("Next level"))
- ]
- )
+ ocargo.Drawing.startPopup(
+ title,
+ LESSON,
+ message,
+ showMascot,
+ [
+ ocargo.button.dismissButtonHtml("prev_button", gettext("Previous level")),
+ ocargo.button.dismissButtonHtml('play_button', gettext('Play')),
+ ocargo.button.dismissButtonHtml("next_button", gettext("Next level"))
+ ]
+ )
+ });
}
// Script used to save and check for episode upon loading of the webpage
diff --git a/game/templates/game/game.html b/game/templates/game/game.html
index 9415a9833..0ae613841 100644
--- a/game/templates/game/game.html
+++ b/game/templates/game/game.html
@@ -88,7 +88,6 @@
-