diff --git a/.eslintrc.json b/.eslintrc.json
index c6f059affd..06a2d36d9f 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -11,7 +11,14 @@
"no-mixed-spaces-and-tabs": "warn",
// "no-unused-vars": "warn",
// "no-use-before-define": "error",
- "no-undef": "off",
+ "prefer-const": [
+ "warn",
+ {
+ "destructuring": "any",
+ "ignoreReadBeforeAssign": true
+ }
+ ],
+ "no-undef": "warn",
"no-unused-vars": "off",
"indent": ["warn", 4, { "SwitchCase": 1 }],
"quotes": ["warn", "double", { "avoidEscape": true }],
diff --git a/documentation/notecounter2_block.svg b/documentation/notecounter2_block.svg
new file mode 100644
index 0000000000..061dff3d0d
--- /dev/null
+++ b/documentation/notecounter2_block.svg
@@ -0,0 +1,68 @@
+
+
diff --git a/documentation/oscilloscope_block.svg b/documentation/oscilloscope_block.svg
new file mode 100644
index 0000000000..cb49c29b91
--- /dev/null
+++ b/documentation/oscilloscope_block.svg
@@ -0,0 +1,86 @@
+
+
diff --git a/js/activity.js b/js/activity.js
index 24699c2e12..ef5ef912b9 100644
--- a/js/activity.js
+++ b/js/activity.js
@@ -45,15 +45,15 @@ function Activity() {
let bassBitmap = null;
let ERRORARTWORK = [
- 'emptybox',
- 'emptyheap',
- 'negroot',
- 'noinput',
- 'zerodivide',
- 'notanumber',
- 'nostack',
- 'notastring',
- 'nomicrophone'
+ "emptybox",
+ "emptyheap",
+ "negroot",
+ "noinput",
+ "zerodivide",
+ "notanumber",
+ "nostack",
+ "notastring",
+ "nomicrophone"
];
const that = this;
@@ -80,7 +80,7 @@ function Activity() {
if (_THIS_IS_TURTLE_BLOCKS_) {
function facebookInit() {
window.fbAsyncInit = function () {
- FB.init({ appId: '1496189893985945', xfbml: true, version: 'v2.1' });
+ FB.init({ appId: "1496189893985945", xfbml: true, version: "v2.1" });
// ADD ADDITIONAL FACEBOOK CODE HERE
};
@@ -95,9 +95,9 @@ function Activity() {
js = d.createElement(s);
js.id = id;
- js.src = 'https://connect.facebook.net/en_US/sdk.js';
+ js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
- })(document, 'script', 'facebook-jssdk');
+ })(document, "script", "facebook-jssdk");
} catch (e) {}
}
@@ -107,27 +107,27 @@ function Activity() {
try {
if (localStorage.beginnerMode === undefined) {
firstTimeUser = true;
- console.debug('FIRST TIME USER');
+ console.debug("FIRST TIME USER");
} else if (localStorage.beginnerMode !== null) {
beginnerMode = localStorage.beginnerMode;
console.debug(
- 'READING BEGINNERMODE FROM LOCAL STORAGE: ' +
+ "READING BEGINNERMODE FROM LOCAL STORAGE: " +
beginnerMode +
- ' ' +
+ " " +
typeof beginnerMode
);
- if (typeof beginnerMode === 'string') {
- if (beginnerMode === 'false') {
+ if (typeof beginnerMode === "string") {
+ if (beginnerMode === "false") {
beginnerMode = false;
}
}
}
- console.debug('BEGINNERMODE is ' + beginnerMode);
+ console.debug("BEGINNERMODE is " + beginnerMode);
} catch (e) {
console.debug(e);
- console.debug('ERROR READING BEGINNER MODE');
- console.debug('BEGINNERMODE is ' + beginnerMode);
+ console.debug("ERROR READING BEGINNER MODE");
+ console.debug("BEGINNERMODE is " + beginnerMode);
}
} else {
// Turtle Blocks
@@ -135,21 +135,21 @@ function Activity() {
}
if (beginnerMode) {
- console.debug('BEGINNER MODE');
+ console.debug("BEGINNER MODE");
} else {
- console.debug('ADVANCED MODE');
+ console.debug("ADVANCED MODE");
}
try {
- console.debug('stored preference: ' + localStorage.languagePreference);
- console.debug('browser preference: ' + navigator.language);
+ console.debug("stored preference: " + localStorage.languagePreference);
+ console.debug("browser preference: " + navigator.language);
if (localStorage.languagePreference !== undefined) {
try {
console.log(localStorage.languagePreference);
lang = localStorage.languagePreference;
document.webL10n.setLanguage(lang);
- console.log('SUCCESS');
+ console.log("SUCCESS");
} catch (e) {
console.debug(e);
}
@@ -157,139 +157,138 @@ function Activity() {
// document.webL10n.getLanguage();
lang = navigator.language;
console.log(lang);
- if (lang.indexOf('-') !== -1) {
- lang = lang.slice(0, lang.indexOf('-'));
+ if (lang.indexOf("-") !== -1) {
+ lang = lang.slice(0, lang.indexOf("-"));
document.webL10n.setLanguage(lang);
}
- console.log('ELSE');
+ console.log("ELSE");
}
} catch (e) {
console.debug(e);
}
MYDEFINES = [
- 'activity/sugarizer-compatibility',
- 'utils/platformstyle',
- 'easeljs.min',
- 'tweenjs.min',
- 'preloadjs.min',
- 'howler',
- 'p5.min',
- 'p5.sound.min',
- 'p5.dom.min',
+ "activity/sugarizer-compatibility",
+ "utils/platformstyle",
+ "easeljs.min",
+ "tweenjs.min",
+ "preloadjs.min",
+ "howler",
+ "p5.min",
+ "p5.sound.min",
+ "p5.dom.min",
// 'mespeak',
- 'Chart',
- 'utils/utils',
- 'activity/artwork',
- 'widgets/status',
- 'widgets/help',
- 'utils/munsell',
- 'activity/toolbar',
- 'activity/trash',
- 'activity/boundary',
- 'activity/palette',
- 'activity/protoblocks',
- 'activity/blocks',
- 'activity/block',
- 'activity/turtledefs',
- 'activity/notation',
- 'activity/logo',
- 'activity/turtle',
- 'activity/turtles',
- 'activity/turtle-singer',
- 'activity/turtle-painter',
- 'activity/languagebox',
- 'activity/basicblocks',
- 'activity/blockfactory',
- 'activity/piemenus',
- 'activity/rubrics',
- 'activity/macros',
- 'activity/SaveInterface',
- 'utils/musicutils',
- 'utils/synthutils',
- 'utils/mathutils',
- 'activity/pastebox',
- 'prefixfree.min'
+ "Chart",
+ "utils/utils",
+ "activity/artwork",
+ "widgets/status",
+ "widgets/help",
+ "utils/munsell",
+ "activity/toolbar",
+ "activity/trash",
+ "activity/boundary",
+ "activity/palette",
+ "activity/protoblocks",
+ "activity/blocks",
+ "activity/block",
+ "activity/turtledefs",
+ "activity/notation",
+ "activity/logo",
+ "activity/turtle",
+ "activity/turtles",
+ "activity/turtle-singer",
+ "activity/turtle-painter",
+ "activity/languagebox",
+ "activity/basicblocks",
+ "activity/blockfactory",
+ "activity/piemenus",
+ "activity/rubrics",
+ "activity/macros",
+ "activity/SaveInterface",
+ "utils/musicutils",
+ "utils/synthutils",
+ "utils/mathutils",
+ "activity/pastebox",
+ "prefixfree.min"
];
if (_THIS_IS_MUSIC_BLOCKS_) {
let MUSICBLOCKS_EXTRAS = [
- 'Tone',
- 'activity/js-export/samples/sample',
- 'activity/js-export/export',
- 'activity/js-export/interface',
- 'activity/js-export/constraints',
- 'activity/js-export/ASTutils',
- 'activity/js-export/generate',
- 'activity/js-export/API/GraphicsBlocksAPI',
- 'activity/js-export/API/PenBlocksAPI',
- 'activity/js-export/API/RhythmBlocksAPI',
- 'activity/js-export/API/MeterBlocksAPI',
- 'activity/js-export/API/PitchBlocksAPI',
- 'activity/js-export/API/IntervalsBlocksAPI',
- 'activity/js-export/API/ToneBlocksAPI',
- 'activity/js-export/API/OrnamentBlocksAPI',
- 'activity/js-export/API/VolumeBlocksAPI',
- 'activity/js-export/API/DrumBlocksAPI',
- 'activity/js-export/API/DictBlocksAPI',
- 'widgets/widgetWindows',
- 'widgets/jseditor',
- 'widgets/modewidget',
- 'widgets/meterwidget',
- 'widgets/phrasemaker',
- 'widgets/pitchdrummatrix',
- 'widgets/rhythmruler',
- 'widgets/pitchstaircase',
- 'widgets/temperament',
- 'widgets/tempo',
- 'widgets/pitchslider',
- 'widgets/musickeyboard',
- 'widgets/timbre',
- 'widgets/oscilloscope',
- 'widgets/statistics',
- 'activity/lilypond',
- 'activity/abc',
- 'activity/mxml',
- 'activity/turtleactions/RhythmActions',
- 'activity/turtleactions/MeterActions',
- 'activity/turtleactions/PitchActions',
- 'activity/turtleactions/IntervalsActions',
- 'activity/turtleactions/ToneActions',
- 'activity/turtleactions/OrnamentActions',
- 'activity/turtleactions/VolumeActions',
- 'activity/turtleactions/DrumActions',
- 'activity/turtleactions/DictActions',
- 'activity/blocks/RhythmBlocks',
- 'activity/blocks/MeterBlocks',
- 'activity/blocks/PitchBlocks',
- 'activity/blocks/IntervalsBlocks',
- 'activity/blocks/ToneBlocks',
- 'activity/blocks/OrnamentBlocks',
- 'activity/blocks/VolumeBlocks',
- 'activity/blocks/DrumBlocks',
- 'activity/blocks/WidgetBlocks',
- 'activity/blocks/RhythmBlockPaletteBlocks',
- 'activity/blocks/ActionBlocks',
- 'activity/blocks/FlowBlocks',
- 'activity/blocks/NumberBlocks',
- 'activity/blocks/BoxesBlocks',
- 'activity/blocks/BooleanBlocks',
- 'activity/blocks/HeapBlocks',
- 'activity/blocks/DictBlocks',
- 'activity/blocks/ExtrasBlocks',
- 'activity/blocks/ProgramBlocks',
- 'activity/blocks/GraphicsBlocks',
- 'activity/blocks/PenBlocks',
- 'activity/blocks/MediaBlocks',
- 'activity/blocks/SensorsBlocks',
- 'activity/blocks/EnsembleBlocks'
+ "Tone",
+ "activity/js-export/samples/sample",
+ "activity/js-export/export",
+ "activity/js-export/interface",
+ "activity/js-export/constraints",
+ "activity/js-export/ASTutils",
+ "activity/js-export/generate",
+ "activity/js-export/API/GraphicsBlocksAPI",
+ "activity/js-export/API/PenBlocksAPI",
+ "activity/js-export/API/RhythmBlocksAPI",
+ "activity/js-export/API/MeterBlocksAPI",
+ "activity/js-export/API/PitchBlocksAPI",
+ "activity/js-export/API/IntervalsBlocksAPI",
+ "activity/js-export/API/ToneBlocksAPI",
+ "activity/js-export/API/OrnamentBlocksAPI",
+ "activity/js-export/API/VolumeBlocksAPI",
+ "activity/js-export/API/DrumBlocksAPI",
+ "activity/js-export/API/DictBlocksAPI",
+ "widgets/widgetWindows",
+ "widgets/jseditor",
+ "widgets/modewidget",
+ "widgets/meterwidget",
+ "widgets/phrasemaker",
+ "widgets/pitchdrummatrix",
+ "widgets/rhythmruler",
+ "widgets/pitchstaircase",
+ "widgets/temperament",
+ "widgets/tempo",
+ "widgets/pitchslider",
+ "widgets/musickeyboard",
+ "widgets/timbre",
+ "widgets/oscilloscope",
+ "widgets/statistics",
+ "activity/lilypond",
+ "activity/abc",
+ "activity/mxml",
+ "activity/turtleactions/RhythmActions",
+ "activity/turtleactions/MeterActions",
+ "activity/turtleactions/PitchActions",
+ "activity/turtleactions/IntervalsActions",
+ "activity/turtleactions/ToneActions",
+ "activity/turtleactions/OrnamentActions",
+ "activity/turtleactions/VolumeActions",
+ "activity/turtleactions/DrumActions",
+ "activity/turtleactions/DictActions",
+ "activity/blocks/RhythmBlocks",
+ "activity/blocks/MeterBlocks",
+ "activity/blocks/PitchBlocks",
+ "activity/blocks/IntervalsBlocks",
+ "activity/blocks/ToneBlocks",
+ "activity/blocks/OrnamentBlocks",
+ "activity/blocks/VolumeBlocks",
+ "activity/blocks/DrumBlocks",
+ "activity/blocks/WidgetBlocks",
+ "activity/blocks/RhythmBlockPaletteBlocks",
+ "activity/blocks/ActionBlocks",
+ "activity/blocks/FlowBlocks",
+ "activity/blocks/NumberBlocks",
+ "activity/blocks/BoxesBlocks",
+ "activity/blocks/BooleanBlocks",
+ "activity/blocks/HeapBlocks",
+ "activity/blocks/DictBlocks",
+ "activity/blocks/ExtrasBlocks",
+ "activity/blocks/ProgramBlocks",
+ "activity/blocks/GraphicsBlocks",
+ "activity/blocks/PenBlocks",
+ "activity/blocks/MediaBlocks",
+ "activity/blocks/SensorsBlocks",
+ "activity/blocks/EnsembleBlocks"
];
MYDEFINES = MYDEFINES.concat(MUSICBLOCKS_EXTRAS);
}
- /*
- * Initialises major variables and renders default stack
- *
+ /**
+ * Initialises major variables and renders default stack.
*/
this.setupDependencies = function () {
// blocks = new Blocks(this);
@@ -318,15 +317,15 @@ function Activity() {
document.title = TITLESTRING;
- canvas = docById('myCanvas');
+ canvas = docById("myCanvas");
// Set up a file chooser for the doOpen function.
- fileChooser = docById('myOpenFile');
+ fileChooser = docById("myOpenFile");
// Set up a file chooser for the doOpenPlugin function.
- pluginChooser = docById('myOpenPlugin');
+ pluginChooser = docById("myOpenPlugin");
// The file chooser for all files.
- allFilesChooser = docById('myOpenAll');
- auxToolbar = docById('aux-toolbar');
+ allFilesChooser = docById("myOpenAll");
+ auxToolbar = docById("aux-toolbar");
// Are we running off of a server?
server = true;
@@ -359,22 +358,22 @@ function Activity() {
hideBlocksContainer = null;
collapseBlocksContainer = null;
- searchWidget = docById('search');
- searchWidget.style.visibility = 'hidden';
- searchWidget.placeholder = _('search for blocks');
+ searchWidget = docById("search");
+ searchWidget.style.visibility = "hidden";
+ searchWidget.placeholder = _("search for blocks");
- progressBar = docById('myProgress');
- progressBar.style.visibility = 'hidden';
+ progressBar = docById("myProgress");
+ progressBar.style.visibility = "hidden";
- new createjs.DOMElement(docById('paste'));
- paste = docById('paste');
- paste.style.visibility = 'hidden';
+ new createjs.DOMElement(docById("paste"));
+ paste = docById("paste");
+ paste.style.visibility = "hidden";
closeContextWheel = function () {
// docById('contextWheelDiv').style.display = 'none';
};
- toolbarHeight = document.getElementById('toolbars').offsetHeight;
+ toolbarHeight = document.getElementById("toolbars").offsetHeight;
};
/*
@@ -383,7 +382,7 @@ function Activity() {
*/
this.doContextMenus = function () {
document.addEventListener(
- 'contextmenu',
+ "contextmenu",
function (event) {
event.preventDefault();
event.stopPropagation();
@@ -464,9 +463,8 @@ function Activity() {
pluginsImages = {};
};
- /*
- * Recenters blocks by finding their position on the screen
- * and moving them accordingly
+ /**
+ * Recenters blocks by finding their position on the screen and moving them accordingly.
*/
_findBlocks = function () {
// _showHideAuxMenu(false);
@@ -481,7 +479,7 @@ function Activity() {
blocksContainer.x = 0;
blocksContainer.y = 0;
- if (auxToolbar.style.display === 'block') {
+ if (auxToolbar.style.display === "block") {
toppos = 90 + toolbarHeight;
} else {
toppos = 90;
@@ -496,7 +494,7 @@ function Activity() {
for (let blk in blocks.blockList) {
if (!blocks.blockList[blk].trash) {
let myBlock = blocks.blockList[blk];
- if (myBlock.name !== 'start') {
+ if (myBlock.name !== "start") {
continue;
}
@@ -533,7 +531,7 @@ function Activity() {
for (let blk in blocks.blockList) {
if (!blocks.blockList[blk].trash) {
let myBlock = blocks.blockList[blk];
- if (myBlock.name === 'start') {
+ if (myBlock.name === "start") {
continue;
}
@@ -571,7 +569,7 @@ function Activity() {
// Return mice to the center of the screen.
for (let turtle = 0; turtle < turtles.turtleList.length; turtle++) {
- console.debug('bringing turtle ' + turtle + 'home');
+ console.debug("bringing turtle " + turtle + "home");
let savedPenState = turtles.turtleList[turtle].painter.penState;
turtles.turtleList[turtle].painter.penState = false;
turtles.turtleList[turtle].painter.doSetXY(0, 0);
@@ -580,7 +578,7 @@ function Activity() {
}
};
- /*
+ /**
* @param zero {hides container}
* @param one {shows container}
*/
@@ -604,7 +602,7 @@ function Activity() {
if (message.length < 4) {
// If there is nothing specified, just
// load the block.
- console.debug('CLICK: ' + name);
+ console.debug("CLICK: " + name);
let obj = blocks.palettes.getProtoNameAndPalette(name);
let protoblk = obj[0];
let paletteName = obj[1];
@@ -620,22 +618,22 @@ function Activity() {
}
);
}
- } else if (typeof message[3] === 'string') {
+ } else if (typeof message[3] === "string") {
// If it is a string, load the macro
// assocuated with this block
let blocksToLoad = getMacroExpansion(message[3], 0, 0);
- console.debug('CLICK: ' + blocksToLoad);
+ console.debug("CLICK: " + blocksToLoad);
blocks.loadNewBlocks(blocksToLoad);
} else {
// Load the blocks.
let blocksToLoad = message[3];
- console.debug('CLICK: ' + blocksToLoad);
+ console.debug("CLICK: " + blocksToLoad);
blocks.loadNewBlocks(blocksToLoad);
}
setTimeout(function () {
// save.saveBlockArtwork(message[3]);
- save.saveBlockArtwork(name + '_block.svg');
+ save.saveBlockArtwork(name + "_block.svg");
}, 500);
}, 500);
}, delay + 1000);
@@ -655,7 +653,7 @@ function Activity() {
}
for (let name in blockHelpList) {
- console.debug(name + ' ' + blockHelpList[name]);
+ console.debug(name + " " + blockHelpList[name]);
__saveHelpBlock(blockHelpList[name], i * 2000);
i += 1;
}
@@ -663,13 +661,13 @@ function Activity() {
sendAllToTrash(true, true);
};
- /*
- * @return {SVG} returns SVG of blocks
+ /**
+ * @returns {SVG} returns SVG of blocks
*/
_printBlockSVG = function () {
blocks.activeBlock = null;
let startCounter = 0;
- let svg = '';
+ let svg = "";
let xMax = 0;
let yMax = 0;
let parts;
@@ -687,66 +685,66 @@ function Activity() {
}
if (blocks.blockList[i].collapsed) {
- parts = blocks.blockCollapseArt[i].split('><');
+ parts = blocks.blockCollapseArt[i].split("><");
} else {
- parts = blocks.blockArt[i].split('><');
+ parts = blocks.blockArt[i].split("><");
}
if (blocks.blockList[i].isCollapsible()) {
- svg += '';
+ svg += "";
}
svg +=
'';
if (SPECIALINPUTS.indexOf(blocks.blockList[i].name) !== -1) {
for (let p = 1; p < parts.length; p++) {
// FIXME: This is fragile.
if (p === 1) {
- svg += '<' + parts[p] + '><';
+ svg += "<" + parts[p] + "><";
} else if (p === 2) {
// skip filter
} else if (p === 3) {
- svg += parts[p].replace('filter:url(#dropshadow);', '') + '><';
+ svg += parts[p].replace("filter:url(#dropshadow);", "") + "><";
} else if (p === 5) {
// Add block value to SVG between tspans
- if (typeof blocks.blockList[i].value === 'string') {
+ if (typeof blocks.blockList[i].value === "string") {
console.debug(_(blocks.blockList[i].value));
- svg += parts[p] + '>' + _(blocks.blockList[i].value) + '<';
+ svg += parts[p] + ">" + _(blocks.blockList[i].value) + "<";
} else {
- svg += parts[p] + '>' + blocks.blockList[i].value + '<';
+ svg += parts[p] + ">" + blocks.blockList[i].value + "<";
}
} else if (p === parts.length - 2) {
- svg += parts[p] + '>';
+ svg += parts[p] + ">";
} else if (p === parts.length - 1) {
// skip final
} else {
- svg += parts[p] + '><';
+ svg += parts[p] + "><";
}
}
} else {
for (let p = 1; p < parts.length; p++) {
// FIXME: This is fragile.
if (p === 1) {
- svg += '<' + parts[p] + '><';
+ svg += "<" + parts[p] + "><";
} else if (p === 2) {
// skip filter
} else if (p === 3) {
- svg += parts[p].replace('filter:url(#dropshadow);', '') + '><';
+ svg += parts[p].replace("filter:url(#dropshadow);", "") + "><";
} else if (p === parts.length - 2) {
- svg += parts[p] + '>';
+ svg += parts[p] + ">";
} else if (p === parts.length - 1) {
// skip final
} else {
- svg += parts[p] + '><';
+ svg += parts[p] + "><";
}
}
}
- svg += '';
+ svg += "";
if (blocks.blockList[i].isCollapsible()) {
let y;
@@ -759,30 +757,30 @@ function Activity() {
svg +=
'';
if (blocks.blockList[i].collapsed) {
- parts = EXPANDBUTTON.split('><');
+ parts = EXPANDBUTTON.split("><");
} else {
- parts = COLLAPSEBUTTON.split('><');
+ parts = COLLAPSEBUTTON.split("><");
}
for (let p = 2; p < parts.length - 1; p++) {
- svg += '<' + parts[p] + '>';
+ svg += "<" + parts[p] + ">";
}
- svg += '';
+ svg += "";
}
- if (blocks.blockList[i].name === 'start') {
+ if (blocks.blockList[i].name === "start") {
let x = blocks.blockList[i].container.x + 110;
let y = blocks.blockList[i].container.y + 12;
- svg += '';
+ svg += '';
parts = TURTLESVG.replace(/fill_color/g, FILLCOLORS[startCounter])
.replace(/stroke_color/g, STROKECOLORS[startCounter])
- .split('><');
+ .split("><");
startCounter += 1;
if (startCounter > 9) {
@@ -790,18 +788,18 @@ function Activity() {
}
for (let p = 2; p < parts.length - 1; p++) {
- svg += '<' + parts[p] + '>';
+ svg += "<" + parts[p] + ">";
}
- svg += '';
+ svg += "";
}
if (blocks.blockList[i].isCollapsible()) {
- svg += '';
+ svg += "";
}
}
- svg += '';
+ svg += "";
return (
'