Skip to content

Commit cbbdefc

Browse files
committed
Fixed smaller code issues for perparing next release.
1 parent 4e45e83 commit cbbdefc

File tree

12 files changed

+58
-654
lines changed

12 files changed

+58
-654
lines changed

package-lock.json

Lines changed: 0 additions & 611 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@
8080
"depswriter": "python third_party/closure-library/closure/bin/build/depswriter.py --root_with_prefix=\"src/ ../../../../src/\"",
8181
"documentation": "jsdoc src -r -c documentation.json -d docs",
8282
"launch": "echo Lauching app. Please wait ... && npm run launch:linux --silent || npm run launch:mac --silent || npm run launch:win-experimental --silent",
83-
"launch:linux": "google-chrome --load-and-launch:app=$PWD/dist/chrome_os --enable-logging --v=1 --no-first-run",
83+
"launch:linux": "google-chrome --load-and-launch-app=$PWD/dist/chrome_os --enable-logging --v=1 --no-first-run",
8484
"launch:mac": "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\" --load-and-launch-app=$PWD/dist/chrome_os --enable-logging --v=1 --no-first-run",
8585
"launch:nw": "nw dist/nw_app",
8686
"launch:web": "http-server dist/web_app",
87-
"launch:win": "echo && \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --profile-directory=Default --app-id=becloognjehhioodmnimnehjcibkloed --enable-logging --v=1 --no-first-run",
88-
"launch:win-beta": "echo && \"C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe\" --profile-directory=Default --app-id=becloognjehhioodmnimnehjcibkloed --enable-logging --v=1 --no-first-run --enable-experimental-web-platform-features",
89-
"launch:win-experimental": "echo && \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --profile-directory=Default --app-id=becloognjehhioodmnimnehjcibkloed --enable-logging --v=1 --no-first-run --enable-experimental-web-platform-features",
87+
"launch:win": "echo && \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --profile-directory=Default --load-and-launch-app=%CD%\\dist\\chrome_os --enable-logging --v=1 --no-first-run",
88+
"launch:win-beta": "echo && \"C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe\" --profile-directory=Default --load-and-launch-app=%CD%\\dist\\chrome_os --enable-logging --v=1 --no-first-run --enable-experimental-web-platform-features",
89+
"launch:win-experimental": "echo && \"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --profile-directory=Default --load-and-launch-app=%CD%\\dist\\chrome_os --enable-logging --v=1 --no-first-run --enable-experimental-web-platform-features",
9090
"lint": "npm run lint-javascript && npm run lint-markdown",
9191
"lint-javascript": "eslint .",
9292
"lint-markdown": "markdownlint doc/ training/ *.md src/**/*.md",

src/file_format/file_format.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,16 @@ cwc.fileFormat.File.prototype.getFrameworks = function() {
297297
/**
298298
* @param {string} name
299299
* @param {string=} namespace
300+
* @param {boolean=} quiet
300301
* @return {!string|Array}
301302
*/
302303
cwc.fileFormat.File.prototype.getMetadata = function(
303-
name, namespace = this.metedataNamespace_) {
304+
name, namespace = this.metedataNamespace_, quiet = false) {
304305
if (!(namespace in this.metadata_) ||
305306
(name && !(name in this.metadata_[namespace]))) {
306-
this.log_.warn('Unknown meta data', namespace + (name ? '.' + name : ''));
307+
if (!quiet) {
308+
this.log_.warn('Unknown meta data', namespace + (name ? '.' + name : ''));
309+
}
307310
return '';
308311
}
309312
if (name) {
@@ -409,18 +412,12 @@ cwc.fileFormat.File.prototype.getTitle = function() {
409412
* @return {Object}
410413
*/
411414
cwc.fileFormat.File.prototype.getTour = function(language = 'eng') {
412-
let tour = this.getMetadata('', '__tour__');
413-
let userLanguage = language;
414-
if (tour) {
415-
if (!tour[userLanguage]) {
416-
this.log_.warn('Tour is not available in user\'s language', language);
417-
userLanguage = 'eng';
418-
}
419-
if (tour[userLanguage]) {
420-
return tour[userLanguage];
421-
}
415+
let tour = this.getMetadata(language, '__tour__', true);
416+
if (!tour && this.getMetadata(null, '__tour__', true)) {
417+
this.log_.warn('Tour is not available in user\'s language', language);
418+
return this.getMetadata('eng', '__tour__', true);
422419
}
423-
return null;
420+
return tour;
424421
};
425422

426423

@@ -429,18 +426,12 @@ cwc.fileFormat.File.prototype.getTour = function(language = 'eng') {
429426
* @return {Object}
430427
*/
431428
cwc.fileFormat.File.prototype.getTutorial = function(language = 'eng') {
432-
let tutorial = this.getMetadata('', '__tutorial__');
433-
let userLanguage = language;
434-
if (tutorial) {
435-
if (!tutorial[userLanguage]) {
436-
this.log_.warn('Tutorial is not available in user\'s language', language);
437-
userLanguage = 'eng';
438-
}
439-
if (tutorial[userLanguage]) {
440-
return tutorial[userLanguage];
441-
}
429+
let tutorial = this.getMetadata(language, '__tutorial__', true);
430+
if (!tutorial && this.getMetadata(null, '__tutorial__', true)) {
431+
this.log_.warn('Tutorial is not available in user\'s language', language);
432+
return this.getMetadata('eng', '__tutorial__', true);
442433
}
443-
return null;
434+
return tutorial;
444435
};
445436

446437

src/file_handler/file_loader.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,24 @@ cwc.fileHandler.FileLoader.prototype.loadCWCFile = async function(data,
242242

243243
// Handle tour data
244244
let tourInstance = this.helper.getInstance('tour');
245-
if (tourInstance) {
246-
tourInstance.setTour(file.getTour(userLanguage));
245+
let tourAvailable = file.getTour(userLanguage);
246+
if (tourInstance && tourAvailable) {
247+
tourInstance.setTour(tourAvailable);
247248
}
248249

249250
// Handle tutorial data
250251
let tutorialInstance = this.helper.getInstance('tutorial');
251-
if (tutorialInstance) {
252+
let tutorialAvailable = file.getTutorial(userLanguage);
253+
if (tutorialInstance && tutorialAvailable) {
252254
tutorialInstance.setTutorial(file.getTutorial(userLanguage));
253255
}
254256

255257
// Handle sidebar icons
256258
let sidebarInstance = this.helper.getInstance('sidebar');
257259
if (sidebarInstance) {
258260
sidebarInstance.enableDescription(file.getDescription());
259-
sidebarInstance.enableTour(file.getTour(userLanguage));
261+
sidebarInstance.enableTour(tourAvailable);
262+
sidebarInstance.enableTutorial(tutorialAvailable);
260263
sidebarInstance.showLibrary(true);
261264
sidebarInstance.showMedia(false);
262265
}

src/frameworks/sphero/sphero2/sphero2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cwc.framework.sphero.Sphero2 = function() {
4747
},
4848
};
4949

50-
/** @private {} */
50+
/** @private {Object} */
5151
this.events_ = {
5252
collision: function() {},
5353
position: function() {},

src/frameworks/sphero/sprk_plus/sprk_plus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cwc.framework.sphero.SprkPlus = function() {
4747
},
4848
};
4949

50-
/** @private {} */
50+
/** @private {Object} */
5151
this.events_ = {
5252
collision: function() {},
5353
position: function() {},

src/mode/sphero/sprk_plus/simulation/command.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ cwc.mode.sphero.sprkPlus.SimulationCommand = function(turtle) {
4848
*/
4949
cwc.mode.sphero.sprkPlus.SimulationCommand.prototype['__handshake__'] =
5050
function() {
51+
this.angle_ = 0;
52+
this.heading_ = 0;
5153
this.turtle.action('scale', this.scale_);
5254
this.turtle.action('speed', this.speed_);
5355
this.turtle.reset();
@@ -72,7 +74,7 @@ cwc.mode.sphero.sprkPlus.SimulationCommand.prototype['roll'] = function(data) {
7274
}
7375
this.angle_ = heading;
7476
this.turtle.action('rt', angle);
75-
this.turtle.action('fd', speed);
77+
this.turtle.action('fd', speed * 0.75);
7678
};
7779

7880

src/ui/blockly/blockly.gss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@
1717
#{$prefix}blockly-code {
1818
position: relative;
1919
}
20+
21+
#{$prefix}blockly-toolbar .mdl-navigation {
22+
height: auto;
23+
}
24+
25+
#{$prefix}blockly-toolbar .mdl-navigation__link {
26+
line-height: inherit;
27+
}

src/ui/editor/editor.gss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@
7373
#{$prefix}editor-code-custom {
7474
box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
7575
}
76+
77+
#{$prefix}editor-toolbar .mdl-navigation {
78+
height: auto;
79+
}
80+
81+
#{$prefix}editor-toolbar .mdl-navigation__link {
82+
line-height: inherit;
83+
}

src/ui/sidebar/sidebar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ cwc.ui.Sidebar.prototype.enableTour = function(enabled) {
240240
this.enableButton('tour', enabled);
241241
};
242242

243+
243244
/**
244245
* @param {boolean} enabled
245246
*/

0 commit comments

Comments
 (0)