From 3cce2b0b4502174b0f97298fa2eb35da8f374c44 Mon Sep 17 00:00:00 2001 From: Shubham Jain Date: Fri, 11 Dec 2020 18:11:10 +0530 Subject: [PATCH 01/11] drumlabels error fix --- js/block.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/block.js b/js/block.js index c2922db2df..457479a57f 100644 --- a/js/block.js +++ b/js/block.js @@ -3132,7 +3132,7 @@ class Block { } } - piemenuVoices(this, DrumLabels, drumValues, categories, selectedDrum); + piemenuVoices(this, drumLabels, drumValues, categories, selectedDrum); } else if (this.name === "effectsname") { if (this.value != null) { selectedDrum = this.value; From a9c2564cf93ee8fa5c7ce009f1e34f8fa51e5df8 Mon Sep 17 00:00:00 2001 From: Shubham Jain Date: Fri, 11 Dec 2020 20:48:18 +0530 Subject: [PATCH 02/11] Add JSDoc style comments * jsdoc style to activity.js * jsdoc style to block.js * jsdoc style to blocks.js * jsdoc style to logo.js * jsdoc style to logo.js * Cleanup Co-authored-by: Shubham Jain Co-authored-by: Anindya Kundu --- js/activity.js | 1616 ++++++++++++++++++++++++------------------------ js/block.js | 207 +++---- js/blocks.js | 514 +++++++-------- 3 files changed, 1160 insertions(+), 1177 deletions(-) diff --git a/js/activity.js b/js/activity.js index 7535b18897..0b6b1ed3ec 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()) { if (INLINECOLLAPSIBLES.indexOf(blocks.blockList[i].name) !== -1) { @@ -758,30 +756,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) { @@ -789,18 +787,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 ( '"; - const MSGSuffix = ''; + const MSGSuffix = ""; - if (mode === null || mode === undefined || mode === 'true') { + if (mode === null || mode === undefined || mode === "true") { textMsg( - _(MSGPrefix + _('Refresh your browser to change to advanced mode.') + MSGSuffix) + _(MSGPrefix + _("Refresh your browser to change to advanced mode.") + MSGSuffix) ); - localStorage.setItem('beginnerMode', false); + localStorage.setItem("beginnerMode", false); } else { textMsg( - _(MSGPrefix + _('Refresh your browser to change to beginner mode.') + MSGSuffix) + _(MSGPrefix + _("Refresh your browser to change to beginner mode.") + MSGSuffix) ); - localStorage.setItem('beginnerMode', true); + localStorage.setItem("beginnerMode", true); } refreshCanvas(); }; chooseKeyMenu = () => { - docById('chooseKeyDiv').style.display = 'block'; - docById('moveable').style.display = 'block'; + docById("chooseKeyDiv").style.display = "block"; + docById("moveable").style.display = "block"; - let keyNameWheel = new wheelnav('chooseKeyDiv', null, 1200, 1200); - let keyNameWheel2 = new wheelnav('keyNameWheel2', keyNameWheel.raphael); - let keys = ['C', 'G', 'D', 'A', 'E', 'B/C♭', 'F♯/G♭', 'C♯/D♭', 'G♯/A♭', 'D♯/E♭', 'B♭', 'F']; + let keyNameWheel = new wheelnav("chooseKeyDiv", null, 1200, 1200); + let keyNameWheel2 = new wheelnav("keyNameWheel2", keyNameWheel.raphael); + let keys = ["C", "G", "D", "A", "E", "B/C♭", "F♯/G♭", "C♯/D♭", "G♯/A♭", "D♯/E♭", "B♭", "F"]; wheelnav.cssMode = true; @@ -1146,12 +1141,12 @@ function Activity() { for (let i = 0; i < keys.length; i++) { if (keys[i].length > 2) { - let obj = keys[i].split('/'); + let obj = keys[i].split("/"); keys2.push(obj[0]); keys2.push(obj[1]); } else { - keys2.push(''); - keys2.push(''); + keys2.push(""); + keys2.push(""); } } @@ -1159,8 +1154,8 @@ function Activity() { keyNameWheel2.animatetime = 0; keyNameWheel2.createWheel(keys2); - let modenameWheel = new wheelnav('modenameWheel', keyNameWheel.raphael); - modes = ['major', 'dorian', 'phrygian', 'lydian', 'mixolydian', 'minor', 'locrian']; + let modenameWheel = new wheelnav("modenameWheel", keyNameWheel.raphael); + modes = ["major", "dorian", "phrygian", "lydian", "mixolydian", "minor", "locrian"]; modenameWheel.slicePathFunction = slicePath().DonutSlice; modenameWheel.slicePathCustom = slicePath().DonutSliceCustomization(); modenameWheel.slicePathCustom.minRadiusPercent = 0.2; @@ -1173,7 +1168,7 @@ function Activity() { modenameWheel.createWheel(modes); - let exitWheel = new wheelnav('exitWheel', keyNameWheel.raphael); + let exitWheel = new wheelnav("exitWheel", keyNameWheel.raphael); exitWheel.slicePathFunction = slicePath().DonutSlice; exitWheel.slicePathCustom = slicePath().DonutSliceCustomization(); exitWheel.slicePathCustom.minRadiusPercent = 0.0; @@ -1184,23 +1179,23 @@ function Activity() { exitWheel.clickModeRotate = false; exitWheel.colors = platformColor.exitWheelcolors; exitWheel.animatetime = 0; - exitWheel.createWheel(['×', ' ']); + exitWheel.createWheel(["×", " "]); let x = event.clientX; let y = event.clientY; - docById('chooseKeyDiv').style.left = x - 175 + 'px'; - docById('chooseKeyDiv').style.top = y + 50 + 'px'; - docById('moveable').style.left = x - 110 + 'px'; - docById('moveable').style.top = y + 400 + 'px'; + docById("chooseKeyDiv").style.left = x - 175 + "px"; + docById("chooseKeyDiv").style.top = y + 50 + "px"; + docById("moveable").style.left = x - 110 + "px"; + docById("moveable").style.top = y + 400 + "px"; let __exitMenu = () => { - docById('chooseKeyDiv').style.display = 'none'; - docById('moveable').style.display = 'none'; - let ele = document.getElementsByName('moveable'); + docById("chooseKeyDiv").style.display = "none"; + docById("moveable").style.display = "none"; + let ele = document.getElementsByName("moveable"); for (let i = 0; i < ele.length; i++) { if (ele[i].checked) { - KeySignatureEnv[2] = ele[i].value == 'true' ? true : false; + KeySignatureEnv[2] = ele[i].value == "true" ? true : false; } } keyNameWheel.removeWheel(); @@ -1213,8 +1208,8 @@ function Activity() { exitWheel.navItems[0].navigateFunction = __exitMenu; let __playNote = (note) => { - let obj = getNote(note, 4, null, note + ' ' + KeySignatureEnv[1], false, null, null); - obj[0] = obj[0].replace(SHARP, '#').replace(FLAT, 'b'); + let obj = getNote(note, 4, null, note + " " + KeySignatureEnv[1], false, null, null); + obj[0] = obj[0].replace(SHARP, "#").replace(FLAT, "b"); let tur = blocks.logo.turtles.ithTurtle(0); if ( @@ -1247,7 +1242,7 @@ function Activity() { __playNote(KeySignatureEnv[0]); } else { let selection = keyNameWheel.navItems[keyNameWheel.selectedNavItemIndex].title; - selection = selection.split('/'); + selection = selection.split("/"); __playNote(selection[0]); } }; @@ -1256,7 +1251,7 @@ function Activity() { let __selectionChangedKey = () => { let selection = keyNameWheel.navItems[keyNameWheel.selectedNavItemIndex].title; keyNameWheel2.navigateWheel(2 * keyNameWheel.selectedNavItemIndex); - if (selection === '') { + if (selection === "") { keyNameWheel.navigateWheel( (keyNameWheel.selectedNavItemIndex + 1) % keyNameWheel.navItems.length ); @@ -1271,7 +1266,7 @@ function Activity() { let __selectionChangedMode = () => { let selection = modenameWheel.navItems[modenameWheel.selectedNavItemIndex].title; - if (selection === '') { + if (selection === "") { modenameWheel.navigateWheel( (modenameWheel.selectedNavItemIndex + 1) % modenameWheel.navItems.length ); @@ -1297,12 +1292,12 @@ function Activity() { }; } if (localStorage.KeySignatureEnv !== undefined) { - let ks = localStorage.KeySignatureEnv.split(','); + let ks = localStorage.KeySignatureEnv.split(","); KeySignatureEnv[0] = ks[0]; KeySignatureEnv[1] = ks[1]; - KeySignatureEnv[2] = ks[2] == 'true' ? true : false; + KeySignatureEnv[2] = ks[2] == "true" ? true : false; } else { - KeySignatureEnv = ['C', 'major', false]; + KeySignatureEnv = ["C", "major", false]; } let i = keys.indexOf(KeySignatureEnv[0]); if (i == -1) { @@ -1356,14 +1351,14 @@ function Activity() { function setScroller() { blocks.activeBlock = null; scrollBlockContainer = !scrollBlockContainer; - let enableHorizScrollIcon = docById('enableHorizScrollIcon'); - let disableHorizScrollIcon = docById('disableHorizScrollIcon'); + let enableHorizScrollIcon = docById("enableHorizScrollIcon"); + let disableHorizScrollIcon = docById("disableHorizScrollIcon"); if (scrollBlockContainer && !beginnerMode) { - enableHorizScrollIcon.style.display = 'none'; - disableHorizScrollIcon.style.display = 'block'; + enableHorizScrollIcon.style.display = "none"; + disableHorizScrollIcon.style.display = "block"; } else { - enableHorizScrollIcon.style.display = 'block'; - disableHorizScrollIcon.style.display = 'none'; + enableHorizScrollIcon.style.display = "block"; + disableHorizScrollIcon.style.display = "none"; } } @@ -1371,26 +1366,26 @@ function Activity() { doLoadAnimation = function () { let messages = { load_messages: [ - _('Catching mice'), - _('Cleaning the instruments'), - _('Testing key pieces'), - _('Sight-reading'), - _('Combining math and music'), - _('Generating more blocks'), - _('Do Re Mi Fa Sol La Ti Do'), - _('Tuning string instruments'), - _('Pressing random keys') + _("Catching mice"), + _("Cleaning the instruments"), + _("Testing key pieces"), + _("Sight-reading"), + _("Combining math and music"), + _("Generating more blocks"), + _("Do Re Mi Fa Sol La Ti Do"), + _("Tuning string instruments"), + _("Pressing random keys") ] }; - document.getElementById('load-container').style.display = 'block'; + document.getElementById("load-container").style.display = "block"; let counter = 0; setInterval(changeText, 2000); function changeText() { let randomLoadMessage = messages.load_messages[Math.floor(Math.random() * messages.load_messages.length)]; - document.getElementById('messageText').innerHTML = randomLoadMessage + '...'; + document.getElementById("messageText").innerHTML = randomLoadMessage + "..."; counter++; if (counter >= messages.load_messages.length) { counter = 0; @@ -1398,13 +1393,13 @@ function Activity() { } }; - /* + /** + * Checks if the canvas is blank. * @param canvas {compares existing canvas with a new blank canvas} - * @return {boolean} {if canvas is blank } - * Checks if the canvas is blank + * @returns {boolean} {if canvas is blank } */ function _isCanvasBlank(canvas) { - let blank = document.createElement('canvas'); + let blank = document.createElement("canvas"); blank.width = canvas.width; blank.height = canvas.height; return canvas.toDataURL() === blank.toDataURL(); @@ -1482,10 +1477,10 @@ function Activity() { palettes.paletteObject.promptPaletteDelete(); } else { // look to see if My Blocks palette is visible - if (palettes.buttons['myblocks'].visible) { - console.debug(palettes.dict['myblocks'].visible); - if (palettes.dict['myblocks'].visible) { - palettes.dict['myblocks'].promptMacrosDelete(); + if (palettes.buttons["myblocks"].visible) { + console.debug(palettes.dict["myblocks"].visible); + if (palettes.dict["myblocks"].visible) { + palettes.dict["myblocks"].promptMacrosDelete(); } } } @@ -1495,7 +1490,7 @@ function Activity() { * Hides all grids (Cartesian/polar/treble/et al.) */ hideGrids = function () { - turtles.setGridLabel(_('show Cartesian')); + turtles.setGridLabel(_("show Cartesian")); _hideCartesian(); _hidePolar(); if (_THIS_IS_MUSIC_BLOCKS_) { @@ -1517,57 +1512,57 @@ function Activity() { _hideCartesian(); if (_THIS_IS_MUSIC_BLOCKS_) { //.TRANS: show treble clef - turtles.setGridLabel(_('show treble')); + turtles.setGridLabel(_("show treble")); } else { //.TRANS: hide Polar coordinate overlay grid - turtles.setGridLabel(_('hide Polar')); + turtles.setGridLabel(_("hide Polar")); } } else if (!cartesianBitmap.visible && polarBitmap.visible) { _hidePolar(); if (_THIS_IS_MUSIC_BLOCKS_) { this._showTreble(); //.TRANS: show bass clef - turtles.setGridLabel(_('show bass')); + turtles.setGridLabel(_("show bass")); } else { //.TRANS: show Cartesian coordinate overlay grid - turtles.setGridLabel(_('show Cartesian')); + turtles.setGridLabel(_("show Cartesian")); } } else if (trebleBitmap.visible) { _hideTreble(); this._showGrand(); //.TRANS: show mezzo-soprano staff - turtles.setGridLabel(_('show mezzo-soprano')); + turtles.setGridLabel(_("show mezzo-soprano")); } else if (grandBitmap.visible) { _hideGrand(); this._showSoprano(); //.TRANS: show alto clef - turtles.setGridLabel(_('show alto')); + turtles.setGridLabel(_("show alto")); } else if (sopranoBitmap.visible) { _hideSoprano(); this._showAlto(); //.TRANS: show tenor clef - turtles.setGridLabel(_('show tenor')); + turtles.setGridLabel(_("show tenor")); } else if (altoBitmap.visible) { _hideAlto(); this._showTenor(); //.TRANS: show bass clef - turtles.setGridLabel(_('show bass')); + turtles.setGridLabel(_("show bass")); } else if (tenorBitmap.visible) { _hideTenor(); this._showBass(); //.TRANS: hide bass clef - turtles.setGridLabel(_('hide bass')); + turtles.setGridLabel(_("hide bass")); } else if (bassBitmap.visible) { _hideBass(); - turtles.setGridLabel(_('show Cartesian')); + turtles.setGridLabel(_("show Cartesian")); } else if (!cartesianBitmap.visible && !polarBitmap.visible) { this._showCartesian(); //.TRANS: show Polar coordinate overlay grid - turtles.setGridLabel(_('show Polar')); + turtles.setGridLabel(_("show Polar")); } else if (cartesianBitmap.visible && !polarBitmap.visible) { this._showPolar(); //.TRANS: hide Cartesian coordinate overlay grid - turtles.setGridLabel(_('hide Cartesian')); + turtles.setGridLabel(_("hide Cartesian")); } update = true; @@ -1585,11 +1580,11 @@ function Activity() { }; let closeAnyOpenMenusAndLabels = function () { - if (docById('wheelDiv') != null) docById('wheelDiv').style.display = 'none'; - if (docById('contextWheelDiv') != null) - docById('contextWheelDiv').style.display = 'none'; - if (docById('textLabel') != null) docById('textLabel').style.display = 'none'; - if (docById('numberLabel') != null) docById('numberLabel').style.display = 'none'; + if (docById("wheelDiv") != null) docById("wheelDiv").style.display = "none"; + if (docById("contextWheelDiv") != null) + docById("contextWheelDiv").style.display = "none"; + if (docById("textLabel") != null) docById("textLabel").style.display = "none"; + if (docById("numberLabel") != null) docById("numberLabel").style.display = "none"; }; let normalizeWheel = (event) => { @@ -1602,13 +1597,13 @@ function Activity() { pX = 0, pY = 0; // pixelX, pixelY - if ('detail' in event) sY = event.detail; - if ('wheelDelta' in event) sY = -event.wheelDelta / 120; - if ('wheelDeltaY' in event) sY = -event.wheelDeltaY / 120; - if ('wheelDeltaX' in event) sX = -event.wheelDeltaX / 120; + if ("detail" in event) sY = event.detail; + if ("wheelDelta" in event) sY = -event.wheelDelta / 120; + if ("wheelDeltaY" in event) sY = -event.wheelDeltaY / 120; + if ("wheelDeltaX" in event) sX = -event.wheelDeltaX / 120; // side scrolling on FF with DOMMouseScroll - if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) { + if ("axis" in event && event.axis === event.HORIZONTAL_AXIS) { sX = sY; sY = 0; } @@ -1616,8 +1611,8 @@ function Activity() { pX = sX * PIXEL_STEP; pY = sY * PIXEL_STEP; - if ('deltaY' in event) pY = event.deltaY; - if ('deltaX' in event) pX = event.deltaX; + if ("deltaY" in event) pY = event.deltaY; + if ("deltaX" in event) pX = event.deltaX; if ((pX || pY) && event.deltaMode) { if (event.deltaMode == 1) { @@ -1658,7 +1653,7 @@ function Activity() { refreshCanvas(); }; - docById('myCanvas').addEventListener('wheel', __wheelHandler, false); + docById("myCanvas").addEventListener("wheel", __wheelHandler, false); let __stageMouseUpHandler = function (event) { stageMouseDown = false; @@ -1670,16 +1665,16 @@ function Activity() { } }; - stage.on('stagemousemove', function (event) { + stage.on("stagemousemove", function (event) { stageX = event.stageX; stageY = event.stageY; }); - stage.on('stagemousedown', function (event) { + stage.on("stagemousedown", function (event) { stageMouseDown = true; if ((stage.getObjectUnderPoint() !== null) | turtles.running()) { - stage.removeAllEventListeners('stagemouseup'); - stage.on('stagemouseup', __stageMouseUpHandler); + stage.removeAllEventListeners("stagemouseup"); + stage.on("stagemouseup", __stageMouseUpHandler); return; } @@ -1692,8 +1687,8 @@ function Activity() { hideDOMLabel(); - stage.removeAllEventListeners('stagemousemove'); - stage.on('stagemousemove', function (event) { + stage.removeAllEventListeners("stagemousemove"); + stage.on("stagemousemove", function (event) { stageX = event.stageX; stageY = event.stageY; @@ -1721,8 +1716,8 @@ function Activity() { refreshCanvas(); }); - stage.removeAllEventListeners('stagemouseup'); - stage.on('stagemouseup', __stageMouseUpHandler); + stage.removeAllEventListeners("stagemouseup"); + stage.on("stagemouseup", __stageMouseUpHandler); }); }; @@ -1770,9 +1765,9 @@ function Activity() { // cameraID = id; // }; - /* + /** + * Renders grid. * @param imagePath {path of grid to be rendered} - * Renders grid */ _createGrid = function (imagePath) { let img = new Image(); @@ -1793,12 +1788,12 @@ function Activity() { return bitmap; }; - /* + /** * @param fillColor {inner color of message} * @param strokeColor {border of message} * @param callback {callback function assigned to particular message} * @param y {position on canvas} - * @return {description} + * @returns {description} */ _createMsgContainer = function (fillColor, strokeColor, callback, y) { let container = new createjs.Container(); @@ -1808,18 +1803,18 @@ function Activity() { container.visible = false; let img = new Image(); - let svgData = MSGBLOCK.replace('fill_color', fillColor).replace( - 'stroke_color', + let svgData = MSGBLOCK.replace("fill_color", fillColor).replace( + "stroke_color", strokeColor ); img.onload = function () { let msgBlock = new createjs.Bitmap(img); container.addChild(msgBlock); - let text = new createjs.Text('your message here', '20px Arial', '#000000'); + let text = new createjs.Text("your message here", "20px Arial", "#000000"); container.addChild(text); - text.textAlign = 'center'; - text.textBaseline = 'alphabetic'; + text.textAlign = "center"; + text.textBaseline = "alphabetic"; text.x = 500; text.y = 30; @@ -1827,12 +1822,12 @@ function Activity() { container.cache(bounds.x, bounds.y, bounds.width, bounds.height); let hitArea = new createjs.Shape(); - hitArea.graphics.beginFill('#FFF').drawRect(0, 0, 1000, 42); + hitArea.graphics.beginFill("#FFF").drawRect(0, 0, 1000, 42); hitArea.x = 0; hitArea.y = 0; container.hitArea = hitArea; - container.on('click', function (event) { + container.on("click", function (event) { container.visible = false; // On the possibility that there was an error // arrow associated with this container @@ -1847,7 +1842,7 @@ function Activity() { blocks.setMsgText(text); }; - img.src = 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(svgData))); + img.src = "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(svgData))); }; /* @@ -1860,9 +1855,9 @@ function Activity() { } }; - /* + /** + * Renders error message with appropriate artwork. * @param name {specifies svg to be rendered} - * renders error message with appropriate artwork */ _makeErrorArtwork = function (name) { let container = new createjs.Container(); @@ -1877,7 +1872,7 @@ function Activity() { img.onload = function () { let artwork = new createjs.Bitmap(img); container.addChild(artwork); - let text = new createjs.Text('', '20px Sans', '#000000'); + let text = new createjs.Text("", "20px Sans", "#000000"); container.addChild(text); text.x = 70; text.y = 10; @@ -1886,12 +1881,12 @@ function Activity() { container.cache(bounds.x, bounds.y, bounds.width, bounds.height); let hitArea = new createjs.Shape(); - hitArea.graphics.beginFill('#FFF').drawRect(0, 0, bounds.width, bounds.height); + hitArea.graphics.beginFill("#FFF").drawRect(0, 0, bounds.width, bounds.height); hitArea.x = 0; hitArea.y = 0; container.hitArea = hitArea; - container.on('click', function (event) { + container.on("click", function (event) { container.visible = false; // On the possibility that there was an error // arrow associated with this container @@ -1902,7 +1897,7 @@ function Activity() { }); }; - img.src = 'images/' + name + '.svg'; + img.src = "images/" + name + ".svg"; }; /* @@ -1917,9 +1912,9 @@ function Activity() { for (i in blocks.protoBlockDict) { let block = blocks.protoBlockDict[i]; - let blockLabel = block.staticLabels.join(' '); + let blockLabel = block.staticLabels.join(" "); let artwork = block.palette.model.makeBlockInfo(0, block, block.name, block.name)[ - 'artwork64' + "artwork64" ]; if (blockLabel || block.extraSearchTerms !== undefined) { if (block.deprecated) { @@ -1953,13 +1948,13 @@ function Activity() { */ hideSearchWidget = function () { // Hide the jQuery search results widget - let obj = docByClass('ui-menu'); + let obj = docByClass("ui-menu"); if (obj.length > 0) { - obj[0].style.visibility = 'hidden'; + obj[0].style.visibility = "hidden"; } - searchWidget.style.visibility = 'hidden'; - searchWidget.idInput_custom = ''; + searchWidget.style.visibility = "hidden"; + searchWidget.idInput_custom = ""; }; /* @@ -1968,39 +1963,39 @@ function Activity() { showSearchWidget = function () { //bring to top; searchWidget.style.zIndex = 1; - if (searchWidget.style.visibility === 'visible') { + if (searchWidget.style.visibility === "visible") { hideSearchWidget(); } else { - let obj = docByClass('ui-menu'); + let obj = docByClass("ui-menu"); if (obj.length > 0) { - obj[0].style.visibility = 'visible'; + obj[0].style.visibility = "visible"; } searchWidget.value = null; //docById("searchResults").style.visibility = "visible"; - searchWidget.style.visibility = 'visible'; - searchWidget.style.left = palettes.getSearchPos()[0] * turtleBlocksScale + 'px'; - searchWidget.style.top = palettes.getSearchPos()[1] * turtleBlocksScale + 'px'; + searchWidget.style.visibility = "visible"; + searchWidget.style.left = palettes.getSearchPos()[0] * turtleBlocksScale + "px"; + searchWidget.style.top = palettes.getSearchPos()[1] * turtleBlocksScale + "px"; searchBlockPosition = [100, 100]; prepSearchWidget(); let closeListener = (e) => { if ( - docById('search').style.visibility == 'visible' && - (e.target === docById('search') || docById('search').contains(e.target)) + docById("search").style.visibility == "visible" && + (e.target === docById("search") || docById("search").contains(e.target)) ) { //do nothing when clicked in the input field } else if ( - docById('ui-id-1').style.display == 'block' && - (e.target === docById('ui-id-1') || docById('ui-id-1').contains(e.target)) + docById("ui-id-1").style.display == "block" && + (e.target === docById("ui-id-1") || docById("ui-id-1").contains(e.target)) ) { //do nothing when clicked on the menu } else { hideSearchWidget(); - document.removeEventListener('mousedown', closeListener); + document.removeEventListener("mousedown", closeListener); } }; - document.addEventListener('mousedown', closeListener); + document.addEventListener("mousedown", closeListener); // Give the browser time to update before selecting // focus. @@ -2017,7 +2012,7 @@ function Activity() { doSearch = function () { let $j = jQuery.noConflict(); - $j('#search').autocomplete({ + $j("#search").autocomplete({ source: searchSuggestions, select: function (event, ui) { event.preventDefault(); @@ -2032,19 +2027,19 @@ function Activity() { } }); - $j('#search').autocomplete('widget').addClass('scrollSearch'); + $j("#search").autocomplete("widget").addClass("scrollSearch"); - $j('#search').autocomplete('instance')._renderItem = function (ul, item) { - return $j('
  • ') - .data('item.autocomplete', item) + $j("#search").autocomplete("instance")._renderItem = function (ul, item) { + return $j("
  • ") + .data("item.autocomplete", item) .append( '' + - '' + - ' ' + + "" + + " " + item.label + - '' + "" ) .appendTo(ul); }; @@ -2074,12 +2069,12 @@ function Activity() { searchBlockPosition[0] += STANDARDBLOCKHEIGHT; searchBlockPosition[1] += STANDARDBLOCKHEIGHT; } else if (deprecatedBlockNames.indexOf(searchInput) > -1) { - blocks.errorMsg(_('This block is deprecated.')); + blocks.errorMsg(_("This block is deprecated.")); } else { - blocks.errorMsg(_('Block cannot be found.')); + blocks.errorMsg(_("Block cannot be found.")); } - searchWidget.value = ''; + searchWidget.value = ""; update = true; }; @@ -2088,12 +2083,12 @@ function Activity() { */ __makeNewNote = function (octave, solf) { let newNote = [ - [0, 'newnote', 300 - blocksContainer.x, 300 - blocksContainer.y, [null, 1, 4, 8]], - [1, 'divide', 0, 0, [0, 2, 3]], + [0, "newnote", 300 - blocksContainer.x, 300 - blocksContainer.y, [null, 1, 4, 8]], + [1, "divide", 0, 0, [0, 2, 3]], [ 2, [ - 'number', + "number", { value: 1 } @@ -2105,7 +2100,7 @@ function Activity() { [ 3, [ - 'number', + "number", { value: 4 } @@ -2114,12 +2109,12 @@ function Activity() { 0, [1] ], - [4, 'vspace', 0, 0, [0, 5]], - [5, 'pitch', 0, 0, [4, 6, 7, null]], + [4, "vspace", 0, 0, [0, 5]], + [5, "pitch", 0, 0, [4, 6, 7, null]], [ 6, [ - 'solfege', + "solfege", { value: solf } @@ -2131,7 +2126,7 @@ function Activity() { [ 7, [ - 'number', + "number", { value: octave } @@ -2140,7 +2135,7 @@ function Activity() { 0, [5] ], - [8, 'hidden', 0, 0, [0, null]] + [8, "hidden", 0, 0, [0, null]] ]; blocks.loadNewBlocks(newNote); @@ -2149,10 +2144,10 @@ function Activity() { // (if it is a hidden block at the end of a new note // block). let bottom = blocks.findBottomBlock(blocks.activeBlock); - console.debug(blocks.activeBlock + ' ' + bottom); + console.debug(blocks.activeBlock + " " + bottom); if ( - blocks.blockList[bottom].name === 'hidden' && - blocks.blockList[blocks.blockList[bottom].connections[0]].name === 'newnote' + blocks.blockList[bottom].name === "hidden" && + blocks.blockList[blocks.blockList[bottom].connections[0]].name === "newnote" ) { // The note block macro creates nine blocks. let newlyCreatedBlock = blocks.blockList.length - 9; @@ -2182,7 +2177,7 @@ function Activity() { let keyboardEnableFlag; function __keyPressed(event) { - if (window.widgetWindows.isOpen('JavaScript Editor') === true) return; + if (window.widgetWindows.isOpen("JavaScript Editor") === true) return; let that = this; let disableKeys; @@ -2190,41 +2185,41 @@ function Activity() { if (!keyboardEnableFlag) { return; } - if (docById('labelDiv').classList.contains('hasKeyboard')) { + if (docById("labelDiv").classList.contains("hasKeyboard")) { return; } if (_THIS_IS_MUSIC_BLOCKS_ && keyboardEnableFlag) { if ( - docById('BPMInput') !== null && - docById('BPMInput').classList.contains('hasKeyboard') + docById("BPMInput") !== null && + docById("BPMInput").classList.contains("hasKeyboard") ) { return; } if ( - docById('musicratio1') !== null && - docById('musicratio1').classList.contains('hasKeyboard') + docById("musicratio1") !== null && + docById("musicratio1").classList.contains("hasKeyboard") ) { return; } if ( - docById('musicratio2') !== null && - docById('musicratio2').classList.contains('hasKeyboard') + docById("musicratio2") !== null && + docById("musicratio2").classList.contains("hasKeyboard") ) { return; } if ( - docById('dissectNumber') !== null && - docById('dissectNumber').classList.contains('hasKeyboard') + docById("dissectNumber") !== null && + docById("dissectNumber").classList.contains("hasKeyboard") ) { return; } if ( - docById('timbreName') !== null && - docById('timbreName').classList.contains('hasKeyboard') + docById("timbreName") !== null && + docById("timbreName").classList.contains("hasKeyboard") ) { return; } @@ -2268,23 +2263,23 @@ function Activity() { if (_THIS_IS_MUSIC_BLOCKS_) { disableKeys = - docById('lilypondModal').style.display === 'block' || - searchWidget.style.visibility === 'visible' || - docById('planet-iframe').style.display === '' || - docById('paste').style.visibility === 'visible' || - docById('wheelDiv').style.display === '' || + docById("lilypondModal").style.display === "block" || + searchWidget.style.visibility === "visible" || + docById("planet-iframe").style.display === "" || + docById("paste").style.visibility === "visible" || + docById("wheelDiv").style.display === "" || logo.turtles.running(); } else { disableKeys = - searchWidget.style.visibility === 'visible' || - docById('paste').style.visibility === 'visible' || + searchWidget.style.visibility === "visible" || + docById("paste").style.visibility === "visible" || logo.turtles.running(); } - let widgetTitle = document.getElementsByClassName('wftTitle'); + let widgetTitle = document.getElementsByClassName("wftTitle"); let inTempoWidget = false; for (let i = 0; i < widgetTitle.length; i++) { - if (widgetTitle[i].innerHTML === 'tempo') { + if (widgetTitle[i].innerHTML === "tempo") { inTempoWidget = true; break; } @@ -2293,123 +2288,123 @@ function Activity() { if (event.altKey && !disableKeys) { switch (event.keyCode) { case 66: // 'B' - textMsg('Alt-B ' + _('Saving block artwork')); + textMsg("Alt-B " + _("Saving block artwork")); save.saveBlockArtwork(); break; case 67: // 'C' - textMsg('Alt-C ' + _('Copy')); + textMsg("Alt-C " + _("Copy")); blocks.prepareStackForCopy(); break; case 68: // 'D' - palettes.dict['myblocks'].promptMacrosDelete(); + palettes.dict["myblocks"].promptMacrosDelete(); break; case 69: // 'E' - textMsg('Alt-E ' + _('Erase')); + textMsg("Alt-E " + _("Erase")); _allClear(false); break; case 82: // 'R' - textMsg('Alt-R ' + _('Play')); + textMsg("Alt-R " + _("Play")); that._doFastButton(); break; case 83: // 'S' - textMsg('Alt-S ' + _('Stop')); + textMsg("Alt-S " + _("Stop")); logo.doStopTurtles(); break; case 86: // 'V' - textMsg('Alt-V ' + _('Paste')); + textMsg("Alt-V " + _("Paste")); blocks.pasteStack(); break; case 72: // 'H' save block help - textMsg('Alt-H ' + _('Save block help')); + textMsg("Alt-H " + _("Save block help")); _saveHelpBlocks(); break; } } else if (event.ctrlKey) { switch (event.keyCode) { case V: - textMsg('Ctl-V ' + _('Paste')); + textMsg("Ctl-V " + _("Paste")); pasteBox.createBox(turtleBlocksScale, 200, 200); pasteBox.show(); - docById('paste').style.left = - (pasteBox.getPos()[0] + 10) * turtleBlocksScale + 'px'; - docById('paste').style.top = - (pasteBox.getPos()[1] + 10) * turtleBlocksScale + 'px'; - docById('paste').focus(); - docById('paste').style.visibility = 'visible'; + docById("paste").style.left = + (pasteBox.getPos()[0] + 10) * turtleBlocksScale + "px"; + docById("paste").style.top = + (pasteBox.getPos()[1] + 10) * turtleBlocksScale + "px"; + docById("paste").focus(); + docById("paste").style.visibility = "visible"; update = true; break; } } else if (event.shiftKey && !disableKeys) { - let solfnotes_ = _('ti la sol fa mi re do').split(' '); + let solfnotes_ = _("ti la sol fa mi re do").split(" "); switch (event.keyCode) { case KEYCODE_D: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('D ' + solfnotes_[6]); - __makeNewNote(5, 'do'); + textMsg("D " + solfnotes_[6]); + __makeNewNote(5, "do"); } break; case KEYCODE_R: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('R ' + solfnotes_[5]); - __makeNewNote(5, 're'); + textMsg("R " + solfnotes_[5]); + __makeNewNote(5, "re"); } break; case KEYCODE_M: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('M ' + solfnotes_[4]); - __makeNewNote(5, 'mi'); + textMsg("M " + solfnotes_[4]); + __makeNewNote(5, "mi"); } break; case KEYCODE_F: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('F ' + solfnotes_[3]); - __makeNewNote(5, 'fa'); + textMsg("F " + solfnotes_[3]); + __makeNewNote(5, "fa"); } break; case KEYCODE_S: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('S ' + solfnotes_[2]); - __makeNewNote(5, 'sol'); + textMsg("S " + solfnotes_[2]); + __makeNewNote(5, "sol"); } break; case KEYCODE_L: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('L ' + solfnotes_[1]); - __makeNewNote(5, 'la'); + textMsg("L " + solfnotes_[1]); + __makeNewNote(5, "la"); } break; case KEYCODE_T: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('T ' + solfnotes_[0]); - __makeNewNote(5, 'ti'); + textMsg("T " + solfnotes_[0]); + __makeNewNote(5, "ti"); } break; } } else { - if (docById('paste').style.visibility === 'visible' && event.keyCode === RETURN) { - if (docById('paste').value.length > 0) { + if (docById("paste").style.visibility === "visible" && event.keyCode === RETURN) { + if (docById("paste").value.length > 0) { pasted(); } } else if (!disableKeys) { - let solfnotes_ = _('ti la sol fa mi re do').split(' '); + let solfnotes_ = _("ti la sol fa mi re do").split(" "); switch (event.keyCode) { case END: - textMsg('END ' + _('Jumping to the bottom of the page.')); + textMsg("END " + _("Jumping to the bottom of the page.")); blocksContainer.y = -blocks.bottomMostBlock() + logo.canvas.height / 2; stage.update(); break; case PAGE_UP: - textMsg('PAGE_UP ' + _('Scrolling up.')); + textMsg("PAGE_UP " + _("Scrolling up.")); blocksContainer.y += logo.canvas.height / 2; stage.update(); break; case PAGE_DOWN: - textMsg('PAGE_DOWN ' + _('Scrolling down.')); + textMsg("PAGE_DOWN " + _("Scrolling down.")); blocksContainer.y -= logo.canvas.height / 2; stage.update(); break; case DEL: - textMsg('DEL ' + _('Extracting block')); + textMsg("DEL " + _("Extracting block")); blocks.extract(); break; case KEYCODE_UP: @@ -2417,7 +2412,7 @@ function Activity() { logo.tempo.speedUp(0); } else { if (blocks.activeBlock != null) { - textMsg('UP ARROW ' + _('Moving block up.')); + textMsg("UP ARROW " + _("Moving block up.")); blocks.moveStackRelative( blocks.activeBlock, 0, @@ -2438,7 +2433,7 @@ function Activity() { logo.tempo.slowDown(0); } else { if (blocks.activeBlock != null) { - textMsg('DOWN ARROW ' + _('Moving block down.')); + textMsg("DOWN ARROW " + _("Moving block down.")); blocks.moveStackRelative( blocks.activeBlock, 0, @@ -2457,7 +2452,7 @@ function Activity() { case KEYCODE_LEFT: if (!inTempoWidget) { if (blocks.activeBlock != null) { - textMsg('LEFT ARROW ' + _('Moving block left.')); + textMsg("LEFT ARROW " + _("Moving block left.")); blocks.moveStackRelative( blocks.activeBlock, -STANDARDBLOCKHEIGHT / 2, @@ -2474,7 +2469,7 @@ function Activity() { case KEYCODE_RIGHT: if (!inTempoWidget) { if (blocks.activeBlock != null) { - textMsg('RIGHT ARROW ' + _('Moving block right.')); + textMsg("RIGHT ARROW " + _("Moving block right.")); blocks.moveStackRelative( blocks.activeBlock, STANDARDBLOCKHEIGHT / 2, @@ -2489,9 +2484,9 @@ function Activity() { } break; case HOME: - textMsg('HOME ' + _('Jump to home position.')); + textMsg("HOME " + _("Jump to home position.")); if (palettes.mouseOver) { - let dy = Math.max(55 - palettes.buttons['rhythm'].y, 0); + let dy = Math.max(55 - palettes.buttons["rhythm"].y, 0); palettes.menuScrollEvent(1, dy); palettes.hidePaletteIconCircles(); } else if (palettes.activePalette != null) { @@ -2515,16 +2510,16 @@ function Activity() { } break; case ESC: - if (searchWidget.style.visibility === 'visible') { - textMsg('ESC ' + _('Hide blocks')); - searchWidget.style.visibility = 'hidden'; + if (searchWidget.style.visibility === "visible") { + textMsg("ESC " + _("Hide blocks")); + searchWidget.style.visibility = "hidden"; } else { // toggle full screen // _toggleToolbar(); } break; case RETURN: - textMsg('Return ' + _('Play')); + textMsg("Return " + _("Play")); if (inTempoWidget) { if (logo.tempo.isMoving) { logo.tempo.pause(); @@ -2540,44 +2535,44 @@ function Activity() { break; case KEYCODE_D: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('d ' + solfnotes_[6]); - __makeNewNote(4, 'do'); + textMsg("d " + solfnotes_[6]); + __makeNewNote(4, "do"); } break; case KEYCODE_R: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('r ' + solfnotes_[5]); - __makeNewNote(4, 're'); + textMsg("r " + solfnotes_[5]); + __makeNewNote(4, "re"); } break; case KEYCODE_M: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('m ' + solfnotes_[4]); - __makeNewNote(4, 'mi'); + textMsg("m " + solfnotes_[4]); + __makeNewNote(4, "mi"); } break; case KEYCODE_F: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('f ' + solfnotes_[3]); - __makeNewNote(4, 'fa'); + textMsg("f " + solfnotes_[3]); + __makeNewNote(4, "fa"); } break; case KEYCODE_S: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('s ' + solfnotes_[2]); - __makeNewNote(4, 'sol'); + textMsg("s " + solfnotes_[2]); + __makeNewNote(4, "sol"); } break; case KEYCODE_L: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('l ' + solfnotes_[1]); - __makeNewNote(4, 'la'); + textMsg("l " + solfnotes_[1]); + __makeNewNote(4, "la"); } break; case KEYCODE_T: if (_THIS_IS_MUSIC_BLOCKS_) { - textMsg('t ' + solfnotes_[0]); - __makeNewNote(4, 'ti'); + textMsg("t " + solfnotes_[0]); + __makeNewNote(4, "ti"); } break; default: @@ -2591,8 +2586,8 @@ function Activity() { } } - /* - * @return currentKeyCode + /** + * @returns currentKeyCode */ this.getCurrentKeyCode = function () { return currentKeyCode; @@ -2602,7 +2597,7 @@ function Activity() { * Sets current key code to 0 */ this.clearCurrentKeyCode = function () { - currentKey = ''; + currentKey = ""; currentKeyCode = 0; }; @@ -2613,26 +2608,26 @@ function Activity() { */ function _onResize(force) { if (!force) { - console.debug('Saving locally due to resize event'); + console.debug("Saving locally due to resize event"); saveLocally(); } let $j = jQuery.noConflict(); console.debug( - 'document.body.clientWidth and clientHeight: ' + + "document.body.clientWidth and clientHeight: " + document.body.clientWidth + - ' ' + + " " + document.body.clientHeight ); - console.debug('stored values: ' + this._clientWidth + ' ' + this._clientHeight); + console.debug("stored values: " + this._clientWidth + " " + this._clientHeight); console.debug( - 'window inner/outer width/height: ' + + "window inner/outer width/height: " + window.innerWidth + - ', ' + + ", " + window.innerHeight + - ' ' + + " " + window.outerWidth + - ', ' + + ", " + window.outerHeight ); let w = 0, @@ -2659,7 +2654,7 @@ function Activity() { this._outerWidth = window.outerWidth; this._outerHeight = window.outerHeight; - if (docById('labelDiv').classList.contains('hasKeyboard')) { + if (docById("labelDiv").classList.contains("hasKeyboard")) { return; } @@ -2731,7 +2726,7 @@ function Activity() { turtles.turtleList[turtle].painter.doClear(false, false, true); } - let artcanvas = docById('overlayCanvas'); + let artcanvas = docById("overlayCanvas"); // Workaround for #795.5 if (mobileSize) { artcanvas.width = w * 2; @@ -2765,7 +2760,7 @@ function Activity() { let dy = -cellSize * 3; // Reposition if (blocks.trashStacks.length === 0) { - console.debug('Trash is empty--nothing to do'); + console.debug("Trash is empty--nothing to do"); return; } @@ -2784,13 +2779,13 @@ function Activity() { blocks.raiseStackToTop(thisBlock); if ( - blocks.blockList[thisBlock].name === 'start' || - blocks.blockList[thisBlock].name === 'drum' + blocks.blockList[thisBlock].name === "start" || + blocks.blockList[thisBlock].name === "drum" ) { let turtle = blocks.blockList[thisBlock].value; turtles.turtleList[turtle].inTrash = false; turtles.turtleList[turtle].container.visible = true; - } else if (blocks.blockList[thisBlock].name === 'action') { + } else if (blocks.blockList[thisBlock].name === "action") { // We need to add a palette entry for this action. // But first we need to ensure we have a unqiue name, // as the name could have been taken in the interim. @@ -2806,9 +2801,9 @@ function Activity() { if (uniqueName !== actionArg) { console.debug( - 'renaming action when restoring from trash. old name: ' + + "renaming action when restoring from trash. old name: " + oldName + - ' unique name: ' + + " unique name: " + uniqueName ); @@ -2816,7 +2811,7 @@ function Activity() { let label = actionArg.value.toString(); if (label.length > 8) { - label = label.substr(0, 7) + '...'; + label = label.substr(0, 7) + "..."; } actionArg.text.text = label; @@ -2831,18 +2826,18 @@ function Activity() { for (let b = 0; b < blocks.dragGroup.length; b++) { let me = blocks.blockList[blocks.dragGroup[b]]; if ( - ['nameddo', 'nameddoArg', 'namedcalc', 'namedcalcArg'].indexOf( + ["nameddo", "nameddoArg", "namedcalc", "namedcalcArg"].indexOf( me.name ) !== -1 && me.privateData === oldName ) { - console.debug('reassigning nameddo to ' + uniqueName); + console.debug("reassigning nameddo to " + uniqueName); me.privateData = uniqueName; me.value = uniqueName; label = me.value.toString(); if (label.length > 8) { - label = label.substr(0, 7) + '...'; + label = label.substr(0, 7) + "..."; } me.text.text = label; me.overrideName = label; @@ -2853,9 +2848,9 @@ function Activity() { } let actionName = actionArg.value; - if (actionName !== _('action')) { + if (actionName !== _("action")) { // blocks.checkPaletteEntries('action'); - console.debug('FIXME: Check for unique action name here'); + console.debug("FIXME: Check for unique action name here"); } } } @@ -2884,12 +2879,10 @@ function Activity() { } }; - /* + /** + * Hide the palettes before update, then deletes everything/sends all to trash. * @param {boolean} addStartBlock {if true adds a new start block to new project instance} * @param {boolean} doNotSave {if true discards any changes to project} - * - * Hide the palettes before update. - * Then deletes everything/sends all to trash */ sendAllToTrash = function (addStartBlock, doNotSave) { // Return to home position after loading new blocks. @@ -2912,15 +2905,15 @@ function Activity() { blocks.trashStacks.push(blk); } - if (blocks.blockList[blk].name === 'start' || blocks.blockList[blk].name === 'drum') { - console.debug('start blk ' + blk + ' value is ' + blocks.blockList[blk].value); + if (blocks.blockList[blk].name === "start" || blocks.blockList[blk].name === "drum") { + console.debug("start blk " + blk + " value is " + blocks.blockList[blk].value); let turtle = blocks.blockList[blk].value; if (!blocks.blockList[blk].trash && turtle != null) { - console.debug('sending turtle ' + turtle + ' to trash'); + console.debug("sending turtle " + turtle + " to trash"); turtles.turtleList[turtle].inTrash = true; turtles.turtleList[turtle].container.visible = false; } - } else if (blocks.blockList[blk].name === 'action') { + } else if (blocks.blockList[blk].name === "action") { if (!blocks.blockList[blk].trash) { blocks.deleteActionBlock(blocks.blockList[blk]); actionBlockCounter += 1; @@ -2933,7 +2926,7 @@ function Activity() { } if (addStartBlock) { - console.debug('ADDING START BLOCK'); + console.debug("ADDING START BLOCK"); blocks.loadNewBlocks(DATAOBJS); _allClear(false); } else if (!doNotSave) { @@ -2944,7 +2937,7 @@ function Activity() { // Wait for palette to clear (#891) // We really need to signal when each palette item is deleted setTimeout(function () { - stage.dispatchEvent('trashsignal'); + stage.dispatchEvent("trashsignal"); }, 100 * actionBlockCounter); // 1000 update = true; @@ -3060,13 +3053,13 @@ function Activity() { * Opens samples on planet after closing all sub menus */ _doOpenSamples = function () { - if (docById('palette').style.display != 'none') docById('palette').style.display = 'none'; + if (docById("palette").style.display != "none") docById("palette").style.display = "none"; toolbar.closeAuxToolbar(_showHideAuxMenu); planet.openPlanet(); - if (docById('buttoncontainerBOTTOM').style.display != 'none') - docById('buttoncontainerBOTTOM').style.display = 'none'; - if (docById('buttoncontainerTOP').style.display != 'none') - docById('buttoncontainerTOP').style.display = 'none'; + if (docById("buttoncontainerBOTTOM").style.display != "none") + docById("buttoncontainerBOTTOM").style.display = "none"; + if (docById("buttoncontainerTOP").style.display != "none") + docById("buttoncontainerTOP").style.display = "none"; }; /* @@ -3077,7 +3070,7 @@ function Activity() { this.doSave = function () { toolbar.closeAuxToolbar(_showHideAuxMenu); if (beginnerMode) { - save.saveHTML(_('My Project')); + save.saveHTML(_("My Project")); } }; @@ -3104,55 +3097,54 @@ function Activity() { } if (merge) { - console.debug('MERGE LOAD'); + console.debug("MERGE LOAD"); merging = true; } else { - console.debug('LOAD NEW'); + console.debug("LOAD NEW"); merging = false; } - console.debug('Loading .tb file'); - document.querySelector('#myOpenFile').focus(); - document.querySelector('#myOpenFile').click(); + console.debug("Loading .tb file"); + document.querySelector("#myOpenFile").focus(); + document.querySelector("#myOpenFile").click(); window.scroll(0, 0); that.doHardStopButton(); - console.debug('Calling all clear from doLoad'); + console.debug("Calling all clear from doLoad"); _allClear(true); }; window.prepareExport = prepareExport; - /* + /** + * Runs music blocks project. * @param env {specifies environment} - * Runs music blocks project */ this.runProject = function (env) { - console.debug('Running Project from Event'); - document.removeEventListener('finishedLoading', this.runProject); + console.debug("Running Project from Event"); + document.removeEventListener("finishedLoading", this.runProject); setTimeout(function () { - console.debug('Run'); + console.debug("Run"); _changeBlockVisibility(); that._doFastButton(env); }, 5000); }; - /* + /** + * Loads MB project from Planet. * @param projectID {Planet project ID} * @param flags {parameteres} * @param env {specifies environment} - * - * Loads MB project from Planet */ this.loadProject = function (projectID, flags, env) { - console.debug('LOAD PROJECT'); + console.debug("LOAD PROJECT"); if (planet === undefined) { - console.debug('CANNOT ACCESS PLANET'); + console.debug("CANNOT ACCESS PLANET"); return; } //set default value of run flags = - typeof flags !== 'undefined' + typeof flags !== "undefined" ? flags : { run: false, @@ -3160,11 +3152,11 @@ function Activity() { collapse: false }; loading = true; - document.body.style.cursor = 'wait'; + document.body.style.cursor = "wait"; doLoadAnimation(); // palettes.updatePalettes(); - console.debug('LOADING' + planet.getCurrentProjectName()); + console.debug("LOADING" + planet.getCurrentProjectName()); textMsg(planet.getCurrentProjectName()); setTimeout(function () { try { @@ -3173,7 +3165,7 @@ function Activity() { }); } catch (e) { console.debug(e); - console.debug('that._loadStart on error'); + console.debug("that._loadStart on error"); that.loadStartWrapper(that._loadStart); } @@ -3181,7 +3173,7 @@ function Activity() { // Restore default cursor loading = false; - document.body.style.cursor = 'default'; + document.body.style.cursor = "default"; update = true; }, 2500); @@ -3200,7 +3192,7 @@ function Activity() { turtles.turtleList[turtle].painter.doClear(true, true, false); } - textMsg(_('Click the run button to run the project.')); + textMsg(_("Click the run button to run the project.")); // that.runProject(env); if (show) { @@ -3214,23 +3206,21 @@ function Activity() { _changeBlockVisibility(); } - document.removeEventListener('finishedLoading', __functionload); + document.removeEventListener("finishedLoading", __functionload); firstRun = false; }, 1000); }; if (document.addEventListener) { - document.addEventListener('finishedLoading', __functionload, false); + document.addEventListener("finishedLoading", __functionload, false); } else { - document.attachEvent('finishedLoading', __functionload); + document.attachEvent("finishedLoading", __functionload); } }; - /* - * Calculate time such that no matter how long it takes to - * load the program, the loading animation will cycle at least - * once. - * + /** + * Calculate time such that no matter how long it takes to load the program, the loading + * animation will cycle at least once. * @param loadProject all params are from load project function */ this.loadStartWrapper = async function (func, arg1, arg2, arg3) { @@ -3248,10 +3238,10 @@ function Activity() { * Shows contents of MB after loading screen. */ this.showContents = function () { - docById('loading-image-container').style.display = 'none'; - docById('palette').style.display = 'block'; + docById("loading-image-container").style.display = "none"; + docById("palette").style.display = "block"; // docById('canvas').style.display = 'none'; - docById('hideContents').style.display = 'block'; + docById("hideContents").style.display = "block"; /* // Warn the user -- chrome only -- if the browser level is @@ -3261,12 +3251,12 @@ function Activity() { console.debug('zoom level is not 100%: ' + window.innerWidth + ' !== ' + window.outerWidth); } */ - docById('buttoncontainerBOTTOM').style.display = 'block'; - docById('buttoncontainerTOP').style.display = 'block'; + docById("buttoncontainerBOTTOM").style.display = "block"; + docById("buttoncontainerTOP").style.display = "block"; }; this._loadStart = async function () { - console.debug('LOAD START'); + console.debug("LOAD START"); // Set the flag to zero to disable keyboard keyboardEnableFlag = 0; @@ -3274,7 +3264,7 @@ function Activity() { // where to put this? // palettes.updatePalettes(); justLoadStart = function () { - console.debug('Loading start'); + console.debug("Loading start"); blocks.loadNewBlocks(DATAOBJS); }; @@ -3285,14 +3275,14 @@ function Activity() { sessionData = await planet.openCurrentProject(); } else { let currentProject = storage.currentProject; - sessionData = storage['SESSION' + currentProject]; + sessionData = storage["SESSION" + currentProject]; } let __afterLoad = function () { if (!turtles.running()) { setTimeout(function () { stage.update(event); - console.debug('reset turtles after load: ' + turtles.turtleList.length); + console.debug("reset turtles after load: " + turtles.turtleList.length); for (let turtle = 0; turtle < turtles.turtleList.length; turtle++) { logo.turtleHeaps[turtle] = []; @@ -3302,16 +3292,16 @@ function Activity() { turtles.turtleList[turtle].painter.doClear(true, true, false); } const imgUrl = - 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+IDxzdmcgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIiB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgaWQ9InN2ZzExMjEiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDM0LjEzMTI0OSAxNC41NTIwODkiIGhlaWdodD0iNTUuMDAwMDE5IiB3aWR0aD0iMTI5Ij4gPGRlZnMgaWQ9ImRlZnMxMTE1Ij4gPGNsaXBQYXRoIGlkPSJjbGlwUGF0aDQzMzciIGNsaXBQYXRoVW5pdHM9InVzZXJTcGFjZU9uVXNlIj4gPHJlY3QgeT0iNTUyIiB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MjM2OTQiIHN0eWxlPSJmaWxsOm5vbmU7ZmlsbC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlOiM1MDUwNTA7c3Ryb2tlLXdpZHRoOjAuMTA0NjA5OTtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MSIgLz4gPHRleHQgaWQ9InRleHQ0MjQ1IiB5PSIyLjA1MTI3MTQiIHg9IjExLjU1NzI5OSIgc3R5bGU9ImZvbnQtc3R5bGU6bm9ybWFsO2ZvbnQtd2VpZ2h0Om5vcm1hbDtmb250LXNpemU6MC4xMjU1MzE4OHB4O2xpbmUtaGVpZ2h0OjAlO2ZvbnQtZmFtaWx5OnNhbnMtc2VyaWY7bGV0dGVyLXNwYWNpbmc6MHB4O3dvcmQtc3BhY2luZzowcHg7ZmlsbDojMDAwMDAwO2ZpbGwtb3BhY2l0eToxO3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDowLjAxMDQ2MDk5cHg7c3Ryb2tlLWxpbmVjYXA6YnV0dDtzdHJva2UtbGluZWpvaW46bWl0ZXI7c3Ryb2tlLW9wYWNpdHk6MSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHRzcGFuIHN0eWxlPSJmb250LXNpemU6MC40MTg0Mzk2cHg7bGluZS1oZWlnaHQ6MS4yNTtzdHJva2Utd2lkdGg6MC4wMTA0NjA5OXB4IiB5PSIyLjA1MTI3MTQiIHg9IjExLjU1NzI5OSIgaWQ9InRzcGFuNDI0NyI+wqA8L3RzcGFuPjwvdGV4dD4gPC9nPiA8L3N2Zz4="; console.log( - '%cMusic Blocks', - 'font-size: 24px; font-weight: bold; font-family: sans-serif; padding:20px 0 0 110px; background: url(' + + "%cMusic Blocks", + "font-size: 24px; font-weight: bold; font-family: sans-serif; padding:20px 0 0 110px; background: url(" + imgUrl + - ') no-repeat;' + ") no-repeat;" ); console.log( - '%cMusic Blocks is a collection of tools for exploring fundamental musical concepts in a fun way.', - 'font-size: 16px; font-family: sans-serif; font-weight: bold;' + "%cMusic Blocks is a collection of tools for exploring fundamental musical concepts in a fun way.", + "font-size: 16px; font-family: sans-serif; font-weight: bold;" ); // Set flag to 1 to enable keyboard after MB finishes loading @@ -3319,22 +3309,22 @@ function Activity() { }, 1000); } - document.removeEventListener('finishedLoading', __afterLoad); + document.removeEventListener("finishedLoading", __afterLoad); }; // After we have finished loading the project, clear all // to ensure a clean start. if (document.addEventListener) { - document.addEventListener('finishedLoading', __afterLoad); + document.addEventListener("finishedLoading", __afterLoad); } else { - document.attachEvent('finishedLoading', __afterLoad); + document.attachEvent("finishedLoading", __afterLoad); } if (sessionData) { doLoadAnimation(); try { - if (sessionData === 'undefined' || sessionData === '[]') { - console.debug('empty session found: loading start'); + if (sessionData === "undefined" || sessionData === "[]") { + console.debug("empty session found: loading start"); justLoadStart(); } else { window.loadedSession = sessionData; @@ -3362,11 +3352,11 @@ function Activity() { */ hideMsgs = function () { errorMsgText.parent.visible = false; - errorText.classList.remove('show'); + errorText.classList.remove("show"); hideArrows(); msgText.parent.visible = false; - printText.classList.remove('show'); + printText.classList.remove("show"); for (let i in errorArtwork) { errorArtwork[i].visible = false; } @@ -3393,15 +3383,15 @@ function Activity() { } // Show and populate printText div - let printText = document.getElementById('printText'); + let printText = document.getElementById("printText"); - printText.classList.add('show'); + printText.classList.add("show"); - let printTextContent = document.getElementById('printTextContent'); + let printTextContent = document.getElementById("printTextContent"); printTextContent.innerHTML = msg; msgTimeoutID = setTimeout(function () { - printText.classList.remove('show'); + printText.classList.remove("show"); msgTimeoutID = null; }, _MSGTIMEOUT_); }; @@ -3437,7 +3427,7 @@ function Activity() { errorMsgArrow.addChild(line); line.graphics .setStrokeStyle(4) - .beginStroke('#ff0031') + .beginStroke("#ff0031") .moveTo(fromX, fromY) .lineTo(toX, toY); stage.setChildIndex(errorMsgArrow, stage.children.length - 1); @@ -3447,7 +3437,7 @@ function Activity() { errorMsgArrow.addChild(head); head.graphics .setStrokeStyle(4) - .beginStroke('#ff0031') + .beginStroke("#ff0031") .moveTo(-10, 18) .lineTo(0, 0) .lineTo(10, 18); @@ -3458,58 +3448,58 @@ function Activity() { switch (msg) { case NOMICERRORMSG: - errorArtwork['nomicrophone'].visible = true; - stage.setChildIndex(errorArtwork['nomicrophone'], stage.children.length - 1); + errorArtwork["nomicrophone"].visible = true; + stage.setChildIndex(errorArtwork["nomicrophone"], stage.children.length - 1); break; case NOSTRINGERRORMSG: - errorArtwork['notastring'].visible = true; - stage.setChildIndex(errorArtwork['notastring'], stage.children.length - 1); + errorArtwork["notastring"].visible = true; + stage.setChildIndex(errorArtwork["notastring"], stage.children.length - 1); break; case EMPTYHEAPERRORMSG: - errorArtwork['emptyheap'].visible = true; - stage.setChildIndex(errorArtwork['emptyheap'], stage.children.length - 1); + errorArtwork["emptyheap"].visible = true; + stage.setChildIndex(errorArtwork["emptyheap"], stage.children.length - 1); break; case NOSQRTERRORMSG: - errorArtwork['negroot'].visible = true; - stage.setChildIndex(errorArtwork['negroot'], stage.children.length - 1); + errorArtwork["negroot"].visible = true; + stage.setChildIndex(errorArtwork["negroot"], stage.children.length - 1); break; case NOACTIONERRORMSG: if (text == null) { - text = 'foo'; + text = "foo"; } - errorArtwork['nostack'].children[1].text = text; - errorArtwork['nostack'].visible = true; - errorArtwork['nostack'].updateCache(); - stage.setChildIndex(errorArtwork['nostack'], stage.children.length - 1); + errorArtwork["nostack"].children[1].text = text; + errorArtwork["nostack"].visible = true; + errorArtwork["nostack"].updateCache(); + stage.setChildIndex(errorArtwork["nostack"], stage.children.length - 1); break; case NOBOXERRORMSG: if (text == null) { - text = 'foo'; + text = "foo"; } - errorArtwork['emptybox'].children[1].text = text; - errorArtwork['emptybox'].visible = true; - errorArtwork['emptybox'].updateCache(); - stage.setChildIndex(errorArtwork['emptybox'], stage.children.length - 1); + errorArtwork["emptybox"].children[1].text = text; + errorArtwork["emptybox"].visible = true; + errorArtwork["emptybox"].updateCache(); + stage.setChildIndex(errorArtwork["emptybox"], stage.children.length - 1); break; case ZERODIVIDEERRORMSG: - errorArtwork['zerodivide'].visible = true; - stage.setChildIndex(errorArtwork['zerodivide'], stage.children.length - 1); + errorArtwork["zerodivide"].visible = true; + stage.setChildIndex(errorArtwork["zerodivide"], stage.children.length - 1); break; case NANERRORMSG: - errorArtwork['notanumber'].visible = true; - stage.setChildIndex(errorArtwork['notanumber'], stage.children.length - 1); + errorArtwork["notanumber"].visible = true; + stage.setChildIndex(errorArtwork["notanumber"], stage.children.length - 1); break; case NOINPUTERRORMSG: - errorArtwork['noinput'].visible = true; - stage.setChildIndex(errorArtwork['noinput'], stage.children.length - 1); + errorArtwork["noinput"].visible = true; + stage.setChildIndex(errorArtwork["noinput"], stage.children.length - 1); break; default: // Show and populate errorText div - let errorText = document.getElementById('errorText'); - errorText.classList.add('show'); - let errorTextContent = document.getElementById('errorTextContent'); + let errorText = document.getElementById("errorText"); + errorText.classList.add("show"); + let errorTextContent = document.getElementById("errorTextContent"); errorTextContent.innerHTML = msg; break; } @@ -3706,13 +3696,13 @@ function Activity() { if ( myBlock.isValueBlock() || - myBlock.name === 'loadFile' || - myBlock.name === 'boolean' + myBlock.name === "loadFile" || + myBlock.name === "boolean" ) { // FIX ME: scale image if it exceeds a maximum size. switch (myBlock.name) { - case 'namedbox': - case 'namedarg': + case "namedbox": + case "namedarg": args = { value: myBlock.privateData }; @@ -3724,8 +3714,8 @@ function Activity() { } } else { switch (myBlock.name) { - case 'start': - case 'drum': + case "start": + case "drum": // Find the turtle associated with this block. let turtle = turtles.turtleList[myBlock.value]; if (turtle == null) { @@ -3755,7 +3745,7 @@ function Activity() { }; } break; - case 'temperament1': + case "temperament1": if (blocks.customTemperamentDefined) { // If temperament block is present custom = {}; @@ -3769,43 +3759,43 @@ function Activity() { }; } break; - case 'interval': - case 'newnote': - case 'action': - case 'matrix': - case 'pitchdrummatrix': - case 'rhythmruler': - case 'timbre': - case 'pitchstaircase': - case 'tempo': - case 'pitchslider': - case 'musickeyboard': - case 'modewidget': - case 'meterwidget': - case 'status': + case "interval": + case "newnote": + case "action": + case "matrix": + case "pitchdrummatrix": + case "rhythmruler": + case "timbre": + case "pitchstaircase": + case "tempo": + case "pitchslider": + case "musickeyboard": + case "modewidget": + case "meterwidget": + case "status": args = { collapsed: myBlock.collapsed }; break; - case 'storein2': - case 'nameddo': - case 'nameddoArg': - case 'namedcalc': - case 'namedcalcArg': - case 'outputtools': + case "storein2": + case "nameddo": + case "nameddoArg": + case "namedcalc": + case "namedcalcArg": + case "outputtools": args = { value: myBlock.privateData }; break; - case 'nopValueBlock': - case 'nopZeroArgBlock': - case 'nopOneArgBlock': - case 'nopTwoArgBlock': - case 'nopThreeArgBlock': + case "nopValueBlock": + case "nopZeroArgBlock": + case "nopOneArgBlock": + case "nopTwoArgBlock": + case "nopThreeArgBlock": // restore original block name myBlock.name = myBlock.privateData; break; - case 'matrixData': + case "matrixData": // deprecated args = { notes: window.savedMatricesNotes, @@ -3911,10 +3901,10 @@ function Activity() { */ _setupPaletteMenu = function (turtleBlocksScale) { let removed = false; - if (docById('buttoncontainerBOTTOM')) { + if (docById("buttoncontainerBOTTOM")) { removed = true; - docById('buttoncontainerBOTTOM').parentNode.removeChild( - docById('buttoncontainerBOTTOM') + docById("buttoncontainerBOTTOM").parentNode.removeChild( + docById("buttoncontainerBOTTOM") ); } let btnSize = cellSize; @@ -3923,14 +3913,14 @@ function Activity() { let y = this._innerHeight - 57.5; let dx = btnSize; - let ButtonHolder = document.createElement('div'); - ButtonHolder.setAttribute('id', 'buttoncontainerBOTTOM'); - if (!removed) ButtonHolder.style.display = 'none'; // if firsttime: make visible later. + let ButtonHolder = document.createElement("div"); + ButtonHolder.setAttribute("id", "buttoncontainerBOTTOM"); + if (!removed) ButtonHolder.style.display = "none"; // if firsttime: make visible later. document.body.appendChild(ButtonHolder); homeButtonContainer = _makeButton( GOHOMEFADEDBUTTON, - _('Home') + ' [' + _('Home').toUpperCase() + ']', + _("Home") + " [" + _("Home").toUpperCase() + "]", x, y, btnSize, @@ -3942,14 +3932,14 @@ function Activity() { x += dx; - hideBlocksContainer = _makeButton(SHOWBLOCKSBUTTON, _('Show/hide block'), x, y, btnSize, 0); + hideBlocksContainer = _makeButton(SHOWBLOCKSBUTTON, _("Show/hide block"), x, y, btnSize, 0); that._loadButtonDragHandler(hideBlocksContainer, x, y, _changeBlockVisibility); x += dx; collapseBlocksContainer = _makeButton( COLLAPSEBLOCKSBUTTON, - _('Expand/collapse blocks'), + _("Expand/collapse blocks"), x, y, btnSize, @@ -3959,12 +3949,12 @@ function Activity() { x += dx; - smallerContainer = _makeButton(SMALLERBUTTON, _('Decrease block size'), x, y, btnSize, 0); + smallerContainer = _makeButton(SMALLERBUTTON, _("Decrease block size"), x, y, btnSize, 0); that._loadButtonDragHandler(smallerContainer, x, y, doSmallerBlocks); x += dx; - largerContainer = _makeButton(BIGGERBUTTON, _('Increase block size'), x, y, btnSize, 0); + largerContainer = _makeButton(BIGGERBUTTON, _("Increase block size"), x, y, btnSize, 0); that._loadButtonDragHandler(largerContainer, x, y, doLargerBlocks); }; @@ -4093,56 +4083,55 @@ function Activity() { * Makes non-toolbar buttons, e.g., the palette menu buttons */ _makeButton = function (name, label, x, y) { - let container = document.createElement('div'); - container.setAttribute('id', '' + label); + let container = document.createElement("div"); + container.setAttribute("id", "" + label); - container.setAttribute('class', 'tooltipped'); - container.setAttribute('data-tooltip', label); - container.setAttribute('data-position', 'top'); - jQuery.noConflict()('.tooltipped').tooltip({ + container.setAttribute("class", "tooltipped"); + container.setAttribute("data-tooltip", label); + container.setAttribute("data-position", "top"); + jQuery.noConflict()(".tooltipped").tooltip({ html: true, delay: 100 }); container.onmouseover = (event) => { if (!loading) { - document.body.style.cursor = 'pointer'; + document.body.style.cursor = "pointer"; } }; container.onmouseout = (event) => { if (!loading) { - document.body.style.cursor = 'default'; + document.body.style.cursor = "default"; } }; let img = new Image(); - img.src = 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(name))); + img.src = "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(name))); container.appendChild(img); container.setAttribute( - 'style', - 'position: absolute; right:' + + "style", + "position: absolute; right:" + (document.body.clientWidth - x) + - 'px; top: ' + + "px; top: " + y + - 'px;' + "px;" ); - docById('buttoncontainerBOTTOM').appendChild(container); + docById("buttoncontainerBOTTOM").appendChild(container); return container; }; - /* + /** + * Handles button dragging, long hovering and prevents multiple button presses. * @param container longAction * @param ox extraLongAction, * @param oy longImg, * @param hoverAction extraLongImg - * - * Handles button dragging, long hovering and prevents multiple button presses */ this._loadButtonDragHandler = function (container, ox, oy, action, actionClick, arg) { container.onmousedown = function (event) { if (!loading) { - document.body.style.cursor = 'default'; + document.body.style.cursor = "default"; } action(); if (actionClick) actionClick(arg); @@ -4153,17 +4142,17 @@ function Activity() { * Handles pasted strings into input fields */ pasted = function () { - let rawData = docById('paste').value; - let obj = ''; - if (rawData == null || rawData === '') { + let rawData = docById("paste").value; + let obj = ""; + if (rawData == null || rawData === "") { return; } - let cleanData = rawData.replace('\n', ' '); + let cleanData = rawData.replace("\n", " "); try { obj = JSON.parse(cleanData); } catch (e) { - errorMsg(_('Could not parse JSON input.')); + errorMsg(_("Could not parse JSON input.")); return; } @@ -4177,13 +4166,10 @@ function Activity() { pasteBox.hide(); }; - /* - * + /** + * Handles changes in y coordinates of elements when aux toolbar is opened. + * Repositions elements on screen by a certain amount (dy). * @param dy how much of a change in y - * - * Handles changes in y coordinates of elements when - * aux toolbar is opened. - * Repositions elements on screen by a certain amount (dy) */ deltaY = function (dy) { toolbarHeight += dy; @@ -4259,9 +4245,9 @@ function Activity() { */ this.init = async function () { console.debug( - 'document.body.clientWidth and clientHeight: ' + + "document.body.clientWidth and clientHeight: " + document.body.clientWidth + - ' ' + + " " + document.body.clientHeight ); this._clientWidth = document.body.clientWidth; @@ -4273,13 +4259,13 @@ function Activity() { this._outerHeight = window.outerHeight; console.debug( - 'window inner/outer width/height: ' + + "window inner/outer width/height: " + this._innerWidth + - ', ' + + ", " + this._innerHeight + - ' ' + + " " + this._outerWidth + - ', ' + + ", " + this._outerHeight ); @@ -4290,7 +4276,7 @@ function Activity() { storage = localStorage; } - docById('loader').className = 'loader'; + docById("loader").className = "loader"; /* * run browser check before implementing onblur --> stop MB functionality @@ -4314,20 +4300,20 @@ function Activity() { // createjs.Ticker.addEventListener('tick', that.__tick); let mouseEvents = 0; - document.addEventListener('mousemove', function () { + document.addEventListener("mousemove", function () { mouseEvents++; if (mouseEvents % 4 === 0) { that.__tick(); } }); - document.addEventListener('click', function () { + document.addEventListener("click", function () { that.__tick(); }); _createMsgContainer( - '#ffffff', - '#7a7a7a', + "#ffffff", + "#7a7a7a", function (text) { msgText = text; }, @@ -4335,8 +4321,8 @@ function Activity() { ); _createMsgContainer( - '#ffcbc4', - '#ff0031', + "#ffcbc4", + "#ff0031", function (text) { errorMsgText = text; }, @@ -4446,10 +4432,10 @@ function Activity() { widgetWindows.hideAllWindows(); logo.doStopTurtles(); - docById('helpElem').style.visibility = 'hidden'; - document.querySelector('.canvasHolder').classList.add('hide'); - document.querySelector('#canvas').style.display = 'none'; - document.querySelector('#theme-color').content = '#8bc34a'; + docById("helpElem").style.visibility = "hidden"; + document.querySelector(".canvasHolder").classList.add("hide"); + document.querySelector("#canvas").style.display = "none"; + document.querySelector("#theme-color").content = "#8bc34a"; setTimeout(function () { // Time to release the mouse stage.enableDOMEvents(false); @@ -4459,37 +4445,37 @@ function Activity() { this.showMusicBlocks = function () { document.title = planet.getCurrentProjectName(); - document.getElementById('toolbars').style.display = 'block'; - document.getElementById('palette').style.display = 'block'; + document.getElementById("toolbars").style.display = "block"; + document.getElementById("palette").style.display = "block"; prepSearchWidget(); widgetWindows.showWindows(); - document.querySelector('.canvasHolder').classList.remove('hide'); - document.querySelector('#canvas').style.display = ''; - document.querySelector('#theme-color').content = platformColor.header; + document.querySelector(".canvasHolder").classList.remove("hide"); + document.querySelector("#canvas").style.display = ""; + document.querySelector("#theme-color").content = platformColor.header; stage.enableDOMEvents(true); window.scroll(0, 0); - docById('buttoncontainerBOTTOM').style.display = 'block'; - docById('buttoncontainerTOP').style.display = 'block'; + docById("buttoncontainerBOTTOM").style.display = "block"; + docById("buttoncontainerTOP").style.display = "block"; }; this.showPlanet = function () { - this.planet.open(this.mainCanvas.toDataURL('image/png')); - this.iframe.style.display = 'block'; + this.planet.open(this.mainCanvas.toDataURL("image/png")); + this.iframe.style.display = "block"; try { - this.iframe.contentWindow.document.getElementById('local-tab').click(); + this.iframe.contentWindow.document.getElementById("local-tab").click(); } catch (e) { console.debug(e); } }; this.hidePlanet = function () { - this.iframe.style.display = 'none'; + this.iframe.style.display = "none"; }; this.openPlanet = function () { - console.debug('SAVE LOCALLY'); + console.debug("SAVE LOCALLY"); this.saveLocally(); this.hideMusicBlocks(); this.showPlanet(); @@ -4501,7 +4487,7 @@ function Activity() { }; this.loadProjectFromData = function (data, merge) { - console.debug('LOAD PROJECT FROM DATA'); + console.debug("LOAD PROJECT FROM DATA"); if (merge === undefined) { merge = false; } @@ -4512,15 +4498,15 @@ function Activity() { } if (data === undefined) { - console.debug('loadRawProject: data is undefined... punting'); - errorMsg(_('project undefined')); + console.debug("loadRawProject: data is undefined... punting"); + errorMsg(_("project undefined")); return; } textMsg(this.getCurrentProjectName()); - console.debug('LOADING' + this.getCurrentProjectName()); - console.debug('loadRawProject ' + data); + console.debug("LOADING" + this.getCurrentProjectName()); + console.debug("loadRawProject " + data); loading = true; - document.body.style.cursor = 'wait'; + document.body.style.cursor = "wait"; doLoadAnimation(); _allClear(false); @@ -4528,35 +4514,35 @@ function Activity() { blocks.palettes._hideMenus(true); let __afterLoad = function () { - document.removeEventListener('finishedLoading', __afterLoad); + document.removeEventListener("finishedLoading", __afterLoad); }; if (document.addEventListener) { - document.addEventListener('finishedLoading', __afterLoad); + document.addEventListener("finishedLoading", __afterLoad); } else { - document.attachEvent('finishedLoading', __afterLoad); + document.attachEvent("finishedLoading", __afterLoad); } try { let obj = JSON.parse(data); blocks.loadNewBlocks(obj); } catch (e) { - console.debug('loadRawProject: could not parse project data'); + console.debug("loadRawProject: could not parse project data"); errorMsg(e); } loading = false; - document.body.style.cursor = 'default'; + document.body.style.cursor = "default"; }; this.loadProjectFromFile = function () { - document.querySelector('#myOpenFile').focus(); - document.querySelector('#myOpenFile').click(); + document.querySelector("#myOpenFile").focus(); + document.querySelector("#myOpenFile").click(); window.scroll(0, 0); }; this.newProject = function () { - console.debug('NEW'); + console.debug("NEW"); this.closePlanet(); this.initialiseNewProject(); that._loadStart(); @@ -4572,11 +4558,11 @@ function Activity() { this.saveLocally = function () { stage.update(event); - console.debug('overwriting session data'); + console.debug("overwriting session data"); let data = prepareExport(); let svgData = doSVG(canvas, logo, turtles, 320, 240, 320 / canvas.width); try { - if (svgData == null || svgData === '') { + if (svgData == null || svgData === "") { this.planet.ProjectStorage.saveLocally(data, null); } else { let img = new Image(); @@ -4591,18 +4577,18 @@ function Activity() { ); }; img.src = - 'data:image/svg+xml;base64,' + + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(svgData))); } } catch (e) { console.debug(e); if ( e.code === DOMException.QUOTA_EXCEEDED_ERR || - e.message === 'Not enough space to save locally' + e.message === "Not enough space to save locally" ) textMsg( _( - 'Error: Unable to save because you ran out of local storage. Try deleting some saved projects.' + "Error: Unable to save because you ran out of local storage. Try deleting some saved projects." ) ); else throw e; @@ -4641,7 +4627,7 @@ function Activity() { }; this.init = async function () { - this.iframe = document.getElementById('planet-iframe'); + this.iframe = document.getElementById("planet-iframe"); try { await this.iframe.contentWindow.makePlanet( _THIS_IS_MUSIC_BLOCKS_, @@ -4656,7 +4642,7 @@ function Activity() { this.planet.setOnConverterLoad(this.onConverterLoad.bind(this)); } catch (e) { console.debug(e); - console.debug('Planet not available'); + console.debug("Planet not available"); this.planet = null; } @@ -4666,7 +4652,7 @@ function Activity() { } try { - console.debug('TRYING TO OPEN PLANET'); + console.debug("TRYING TO OPEN PLANET"); planet = new PlanetInterface(storage); await planet.init(); } catch (e) { @@ -4675,11 +4661,11 @@ function Activity() { save = new SaveInterface(planet); save.setVariables([ - ['logo', logo], - ['turtles', turtles], - ['storage', storage], - ['printBlockSVG', _printBlockSVG], - ['planet', planet] + ["logo", logo], + ["turtles", turtles], + ["storage", storage], + ["printBlockSVG", _printBlockSVG], + ["planet", planet] ]); toolbar = new Toolbar(); @@ -4727,7 +4713,7 @@ function Activity() { saveLocally = planet.saveLocally.bind(planet); } else { __saveLocally = function () { - console.debug('overwriting session data (local)'); + console.debug("overwriting session data (local)"); let data = prepareExport(); if (sugarizerCompatibility.isInsideSugarizer()) { @@ -4739,8 +4725,8 @@ function Activity() { if (storage.currentProject === undefined) { try { - storage.currentProject = 'My Project'; - storage.allProjects = JSON.stringify(['My Project']); + storage.currentProject = "My Project"; + storage.allProjects = JSON.stringify(["My Project"]); } catch (e) { // Edge case, eg. Firefox localSorage DB corrupted console.debug(e); @@ -4749,7 +4735,7 @@ function Activity() { try { let p = storage.currentProject; - storage['SESSION' + p] = prepareExport(); + storage["SESSION" + p] = prepareExport(); } catch (e) { console.debug(e); } @@ -4762,14 +4748,14 @@ function Activity() { let bounds = bitmap.getBounds(); bitmap.cache(bounds.x, bounds.y, bounds.width, bounds.height); try { - storage['SESSIONIMAGE' + p] = bitmap.bitmapCache.getCacheDataURL(); + storage["SESSIONIMAGE" + p] = bitmap.bitmapCache.getCacheDataURL(); } catch (e) { console.debug(e); } }; img.src = - 'data:image/svg+xml;base64,' + + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(svgData))); if (sugarizerCompatibility.isInsideSugarizer()) { sugarizerCompatibility.saveLocally(); @@ -4811,54 +4797,56 @@ function Activity() { // Load any plugins saved in local storage. pluginData = storage.plugins; if (pluginData != null) { - updatePluginObj(processPluginData( - pluginData, - palettes, - blocks, - logo.evalFlowDict, - logo.evalArgDict, - logo.evalParameterDict, - logo.evalSetterDict, - logo.evalOnStartList, - logo.evalOnStopList, - palettes.pluginMacros - )) + updatePluginObj( + processPluginData( + pluginData, + palettes, + blocks, + logo.evalFlowDict, + logo.evalArgDict, + logo.evalParameterDict, + logo.evalSetterDict, + logo.evalOnStartList, + logo.evalOnStopList, + palettes.pluginMacros + ) + ); } // Load custom mode saved in local storage. let custommodeData = storage.custommode; if (custommodeData !== undefined) { customMode = JSON.parse(custommodeData); - console.debug('restoring custom mode: ' + customMode); + console.debug("restoring custom mode: " + customMode); } - fileChooser.addEventListener('click', function (event) { + fileChooser.addEventListener("click", function (event) { this.value = null; }); fileChooser.addEventListener( - 'change', + "change", function (event) { // Read file here. let reader = new FileReader(); reader.onload = function (theFile) { loading = true; - document.body.style.cursor = 'wait'; + document.body.style.cursor = "wait"; doLoadAnimation(); setTimeout(function () { let rawData = reader.result; - if (rawData == null || rawData === '') { - console.debug('rawData is ' + rawData); + if (rawData == null || rawData === "") { + console.debug("rawData is " + rawData); errorMsg( - _('Cannot load project from the file. Please check the file type.') + _("Cannot load project from the file. Please check the file type.") ); } else { - let cleanData = rawData.replace('\n', ' '); + let cleanData = rawData.replace("\n", " "); let obj; try { - if (cleanData.includes('html')) { + if (cleanData.includes("html")) { obj = JSON.parse( cleanData.match('
    (.+?)
    ')[1] ); @@ -4870,28 +4858,28 @@ function Activity() { blocks.palettes.dict[name].hideMenu(true); } - stage.removeAllEventListeners('trashsignal'); + stage.removeAllEventListeners("trashsignal"); if (!merging) { // Wait for the old blocks to be removed. let __listener = function (event) { blocks.loadNewBlocks(obj); - stage.removeAllEventListeners('trashsignal'); + stage.removeAllEventListeners("trashsignal"); if (planet) { planet.saveLocally(); } }; - stage.addEventListener('trashsignal', __listener, false); + stage.addEventListener("trashsignal", __listener, false); sendAllToTrash(false, false); - console.debug('clearing on load...'); + console.debug("clearing on load..."); _allClear(false); if (planet) { planet.closePlanet(); planet.initialiseNewProject( fileChooser.files[0].name.substr( 0, - fileChooser.files[0].name.lastIndexOf('.') + fileChooser.files[0].name.lastIndexOf(".") ) ); } @@ -4905,11 +4893,11 @@ function Activity() { } catch (e) { errorMsg( _( - 'Cannot load project from the file. Please check the file type.' + "Cannot load project from the file. Please check the file type." ) ); console.debug(e); - document.body.style.cursor = 'default'; + document.body.style.cursor = "default"; loading = false; } } @@ -4930,20 +4918,20 @@ function Activity() { reader.onload = function (theFile) { loading = true; - document.body.style.cursor = 'wait'; + document.body.style.cursor = "wait"; // doLoadAnimation(); setTimeout(function () { let rawData = reader.result; - if (rawData == null || rawData === '') { + if (rawData == null || rawData === "") { errorMsg( - _('Cannot load project from the file. Please check the file type.') + _("Cannot load project from the file. Please check the file type.") ); } else { - let cleanData = rawData.replace('\n', ' '); + let cleanData = rawData.replace("\n", " "); let obj; try { - if (cleanData.includes('html')) { + if (cleanData.includes("html")) { dat = cleanData.match('
    (.+?)
    '); obj = JSON.parse(dat[1]); } else { @@ -4953,29 +4941,29 @@ function Activity() { blocks.palettes.dict[name].hideMenu(true); } - stage.removeAllEventListeners('trashsignal'); + stage.removeAllEventListeners("trashsignal"); let __afterLoad = function () { - document.removeEventListener('finishedLoading', __afterLoad); + document.removeEventListener("finishedLoading", __afterLoad); }; // Wait for the old blocks to be removed. let __listener = function (event) { blocks.loadNewBlocks(obj); - stage.removeAllEventListeners('trashsignal'); + stage.removeAllEventListeners("trashsignal"); if (document.addEventListener) { - document.addEventListener('finishedLoading', __afterLoad); + document.addEventListener("finishedLoading", __afterLoad); } else { - document.attachEvent('finishedLoading', __afterLoad); + document.attachEvent("finishedLoading", __afterLoad); } }; - stage.addEventListener('trashsignal', __listener, false); + stage.addEventListener("trashsignal", __listener, false); sendAllToTrash(false, false); if (planet !== undefined) { planet.initialiseNewProject( - files[0].name.substr(0, files[0].name.lastIndexOf('.')) + files[0].name.substr(0, files[0].name.lastIndexOf(".")) ); } @@ -4984,9 +4972,9 @@ function Activity() { } catch (e) { console.debug(e); errorMsg( - _('Cannot load project from the file. Please check the file type.') + _("Cannot load project from the file. Please check the file type.") ); - document.body.style.cursor = 'default'; + document.body.style.cursor = "default"; loading = false; } } @@ -5004,24 +4992,24 @@ function Activity() { let __handleDragOver = function (event) { event.stopPropagation(); event.preventDefault(); - event.dataTransfer.dropEffect = 'copy'; + event.dataTransfer.dropEffect = "copy"; }; - let dropZone = docById('canvasHolder'); - dropZone.addEventListener('dragover', __handleDragOver, false); - dropZone.addEventListener('drop', __handleFileSelect, false); + let dropZone = docById("canvasHolder"); + dropZone.addEventListener("dragover", __handleDragOver, false); + dropZone.addEventListener("drop", __handleFileSelect, false); - allFilesChooser.addEventListener('click', function (event) { + allFilesChooser.addEventListener("click", function (event) { this.value = null; }); - pluginChooser.addEventListener('click', function (event) { + pluginChooser.addEventListener("click", function (event) { window.scroll(0, 0); this.value = null; }); pluginChooser.addEventListener( - 'change', + "change", function (event) { window.scroll(0, 0); @@ -5030,7 +5018,7 @@ function Activity() { reader.onload = function (theFile) { loading = true; - document.body.style.cursor = 'wait'; + document.body.style.cursor = "wait"; //doLoadAnimation(); setTimeout(function () { @@ -5060,7 +5048,7 @@ function Activity() { } }, 1000); - document.body.style.cursor = 'default'; + document.body.style.cursor = "default"; loading = false; }, 200); }; @@ -5083,28 +5071,28 @@ function Activity() { stage.enableMouseOver(10); // default is 20 cartesianBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(CARTESIAN))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(CARTESIAN))) ); polarBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(POLAR))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(POLAR))) ); trebleBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(TREBLE))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(TREBLE))) ); grandBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(GRAND))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(GRAND))) ); sopranoBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(SOPRANO))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(SOPRANO))) ); altoBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(ALTO))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(ALTO))) ); tenorBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(TENOR))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(TENOR))) ); bassBitmap = _createGrid( - 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(BASS))) + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(BASS))) ); let URL = window.location.href; @@ -5121,39 +5109,39 @@ function Activity() { let urlParts; let env = []; - if (!sugarizerCompatibility.isInsideSugarizer() && URL.indexOf('?') > 0) { + if (!sugarizerCompatibility.isInsideSugarizer() && URL.indexOf("?") > 0) { let args, url; - urlParts = URL.split('?'); - if (urlParts[1].indexOf('&') > 0) { - let newUrlParts = urlParts[1].split('&'); + urlParts = URL.split("?"); + if (urlParts[1].indexOf("&") > 0) { + let newUrlParts = urlParts[1].split("&"); for (let i = 0; i < newUrlParts.length; i++) { - if (newUrlParts[i].indexOf('=') > 0) { - args = newUrlParts[i].split('='); + if (newUrlParts[i].indexOf("=") > 0) { + args = newUrlParts[i].split("="); switch (args[0].toLowerCase()) { - case 'file': + case "file": console.debug( - 'Warning: old Music Blocks URLs will no longer work.' + "Warning: old Music Blocks URLs will no longer work." ); break; - case 'id': + case "id": projectID = args[1]; break; - case 'run': - if (args[1].toLowerCase() === 'true') flags.run = true; + case "run": + if (args[1].toLowerCase() === "true") flags.run = true; break; - case 'show': - if (args[1].toLowerCase() === 'true') flags.show = true; + case "show": + if (args[1].toLowerCase() === "true") flags.show = true; break; - case 'collapse': - if (args[1].toLowerCase() === 'true') flags.collapse = true; + case "collapse": + if (args[1].toLowerCase() === "true") flags.collapse = true; break; - case 'inurl': + case "inurl": url = args[1]; let getJSON = function (url) { return new Promise(function (resolve, reject) { let xhr = new XMLHttpRequest(); - xhr.open('get', url, true); - xhr.responseType = 'json'; + xhr.open("get", url, true); + xhr.responseType = "json"; xhr.onload = function () { let status = xhr.status; if (status === 200) { @@ -5174,27 +5162,27 @@ function Activity() { }, function (status) { alert( - 'Something went wrong reading JSON-encoded project data.' + "Something went wrong reading JSON-encoded project data." ); } ); break; - case 'outurl': + case "outurl": url = args[1]; break; default: - errorMsg(_('Invalid parameters')); + errorMsg(_("Invalid parameters")); break; } } } } else { - if (urlParts[1].indexOf('=') > 0) { - args = urlParts[1].split('='); + if (urlParts[1].indexOf("=") > 0) { + args = urlParts[1].split("="); } //ID is the only arg that can stand alone - if (args[0].toLowerCase() === 'id') { + if (args[0].toLowerCase() === "id") { projectID = args[1]; } } @@ -5202,20 +5190,20 @@ function Activity() { if (projectID != null) { setTimeout(function () { - console.debug('loading ' + projectID); + console.debug("loading " + projectID); that.loadStartWrapper(that.loadProject, projectID, flags, env); }, 200); // 2000 } else { setTimeout(function () { - console.debug('load new Start block'); + console.debug("load new Start block"); that.loadStartWrapper(that._loadStart); }, 200); // 2000 } prepSearchWidget(); - document.addEventListener('mousewheel', scrollEvent, false); - document.addEventListener('DOMMouseScroll', scrollEvent, false); + document.addEventListener("mousewheel", scrollEvent, false); + document.addEventListener("DOMMouseScroll", scrollEvent, false); document.onkeydown = __keyPressed; _hideStopButton(); diff --git a/js/block.js b/js/block.js index c2922db2df..aa42f4be74 100644 --- a/js/block.js +++ b/js/block.js @@ -175,7 +175,7 @@ class Block { // Includes workaround for a race condition. _createCache(callback, args) { let that = this; - return new Promise( (resolve, reject) =>{ + return new Promise((resolve, reject) => { let loopCount = 0; async function checkBounds(counter) { @@ -215,7 +215,7 @@ class Block { // Includes workaround for a race condition. updateCache(counter) { let that = this; - return new Promise( (resolve, reject) =>{ + return new Promise((resolve, reject) => { let loopCount = 0; async function updateBounds(counter) { @@ -318,9 +318,9 @@ class Block { } /** - * Show the highlight artwork - * @return{void} + * Show the highlight artwork. * @public + * @returns {void} */ highlight() { if (this.trash) { @@ -413,9 +413,9 @@ class Block { } /** - * Remove highlight from block - * @return{void} + * Remove highlight from block. * @public + * @returns {void} */ unhighlight() { if (this.trash) { @@ -495,10 +495,10 @@ class Block { } /** - * Resize and update number of slots in argClamp - * @param-slotList how many slots to use - * @return{void} + * Resize and update number of slots in argClamp. * @public + * @param slotList - how many slots to use + * @returns {void} */ updateArgSlots(slotList) { this.argClampSlots = slotList; @@ -508,10 +508,10 @@ class Block { /** * Resize an expandable block. - * @param-clamp which clamp to update (ifthenelse has 2 clamps) - * @param-plusMinus how many slots to add or subtract - * @return{void} * @public + * @param clamp - which clamp to update (ifthenelse has 2 clamps) + * @param plusMinus - how many slots to add or subtract + * @returns {void} */ updateSlots(clamp, plusMinus) { this.clampCount[clamp] += plusMinus; @@ -520,16 +520,15 @@ class Block { } /** - * If the block scale changes, we need to regenerate the - * artwork and recalculate the hitarea. - * @param-scale new block scale - * @return{void} + * If the block scale changes, we need to regenerate the artwork and recalculate the hitarea. * @public + * @param scale - new block scale + * @returns {void} */ resize(scale) { /** * After the new artwork is created, this function is used to add decorations. - * @return{void} + * @returns {void} * @public */ this.postProcess = () => { @@ -581,11 +580,10 @@ class Block { let that = this; /** - * After new buttons are creates, they are cached and a - * new hit are is calculated - * @param-that = this = container - * @return{void} + * After new buttons are creates, they are cached and a new hit are is calculated. * @private + * @param that - = this = container + * @returns {void} */ let _postProcess = function (that) { that.collapseButtonBitmap.scaleX = that.collapseButtonBitmap.scaleY = that.collapseButtonBitmap.scale = @@ -606,10 +604,10 @@ class Block { } /** - * Create new artwork for a block - * @param-plusMinus specifies how much a clamp block expands or contracts - * @return{void} + * Create new artwork for a block. * @private + * @param plusMinus - specifies how much a clamp block expands or contracts + * @returns {void} */ _newArtwork(plusMinus) { let proto, obj; @@ -715,15 +713,12 @@ class Block { } /** - * Load any artwork associated with the block and create any - * extra parts. Image components are loaded asynchronously so - * most the work happens in callbacks. - * - * We also need a text label for some blocks. For number and - * text blocks, this is the primary label; for parameter - * blocks, this is used to display the current block value. - * @return{void} + * Load any artwork associated with the block and create any extra parts. Image components are + * loaded asynchronously so most the work happens in callbacks. + * We also need a text label for some blocks. For number and text blocks, this is the primary + * label; for parameter blocks, this is used to display the current block value. * @public + * @returns {void} */ imageLoad() { let fontSize = 10 * this.protoblock.scale; @@ -732,18 +727,18 @@ class Block { } /** - * Add an image to a block - * @return{void} + * Add an image to a block. * @private + * @returns {void} */ _addImage() { let image = new Image(); let that = this; /** - * The loader - * @return{void} + * The loader. * @private + * @returns {void} */ image.onload = function () { let bitmap = new createjs.Bitmap(image); @@ -774,11 +769,11 @@ class Block { } /** - * Sometimes (in the case of namedboxes and nameddos) we need - * to regenerate the artwork associated with a block. - * @param-is the collapse artwork also generated? - * @return{void} + * Sometimes (in the case of namedboxes and nameddos) we need to regenerate the artwork + * associated with a block. * @public + * @param collapse -is the collapse artwork also generated? + * @returns {void} */ regenerateArtwork(collapse) { // First we need to remove the old artwork. @@ -811,9 +806,9 @@ class Block { /** * Generate the artwork for a block. - * @param-the first time, add the event handlers - * @return{void} * @public + * @param firstTime - the first time, add the event handlers + * @returns {void} */ generateArtwork(firstTime) { // Get the block labels from the protoblock. @@ -1056,8 +1051,8 @@ class Block { /** * After the block artwork has loaded, update labels, etc. - * @return{void} * @private + * @returns {void} */ _finishImageLoad() { let thisBlock = this.blocks.blockList.indexOf(this); @@ -1235,19 +1230,19 @@ class Block { } /** - * Generate the collapsed artwork - * @param postProcess = a process to run after the artwork is generated - * @return{void} + * Generate the collapsed artwork. * @private + * @param postProcess - a process to run after the artwork is generated + * @returns {void} */ _generateCollapseArtwork(postProcess) { let that = this; let thisBlock = this.blocks.blockList.indexOf(this); /** - * Run the postprocess function after the artwork is loaded - * @return{void} + * Run the postprocess function after the artwork is loaded. * @private + * @returns {void} */ let __finishCollapse = function (that) { if (postProcess !== null) { @@ -1264,10 +1259,10 @@ class Block { }; /** - * Create the artwork for the collapse buttons - * @param - that = this - * @return{void} + * Create the artwork for the collapse buttons. * @private + * @param that - = this + * @returns {void} */ let __processCollapseButton = function (that) { let image = new Image(); @@ -1294,10 +1289,10 @@ class Block { }; /** - * Create the artwork for the expand buttons - * @param - that = this - * @return{void} + * Create the artwork for the expand buttons. * @private + * @param that - = this + * @returns {void} */ let __processExpandButton = function (that) { let image = new Image(); @@ -1325,11 +1320,11 @@ class Block { }; /** - * Processing the highlighted collapsed image - * @param-bitmap = highlight artwork - * @param-that = this - * @return{void} + * Processing the highlighted collapsed image. * @private + * @param bitmap - highlight artwork + * @param that - = this + * @returns {void} */ let __processHighlightCollapseBitmap = function (bitmap, that) { that.highlightCollapseBlockBitmap = bitmap; @@ -1493,11 +1488,11 @@ class Block { }; /** - * Processing the collapsed block - * @param-bitmap = block artwork - * @param-that = this - * @return{void} + * Processing the collapsed block. * @private + * @param bitmap - block artwork + * @param that - = this + * @returns {void} */ let __processCollapseBitmap = function (bitmap, that) { that.collapseBlockBitmap = bitmap; @@ -1525,9 +1520,9 @@ class Block { } /** - * Hide this block - * @return{void} + * Hide this block. * @public + * @returns {void} */ hide() { this.container.visible = false; @@ -1543,8 +1538,8 @@ class Block { /** * Is this block disconnected from other blocks? - * @return{boolean} true if the block is disconnected from other blocks * @public + * @returns {boolean} true if the block is disconnected from other blocks */ isDisconnected() { if (this.disconnectedBitmap === null) { @@ -1579,9 +1574,9 @@ class Block { } /** - * Show this block - * @return{void} + * Show this block. * @public + * @returns {void} */ show() { // If it is not in the trash and not in collapsed, then show it. @@ -2306,10 +2301,10 @@ class Block { } /** - * Position any addition text on a block - * @param-blockscale is used to scale the text - * @return{void} + * Position any addition text on a block. * @private + * @param blockscale - used to scale the text + * @returns {void} */ _positionText(blockScale) { this.text.textBaseline = "alphabetic"; @@ -2353,13 +2348,13 @@ class Block { /** * Position media artwork on a block. - * @param-bitmap - image - * @param-width-width of canvas - * @param-height-height of canvas - * @param-blockscale-scale - * Position inserted media - * @return{void} * @private + * @param bitmap - image + * @param width - width of canvas + * @param height - height of canvas + * @param blockscale - scale + * Position inserted media. + * @returns {void} */ _positionMedia(bitmap, width, height, blockScale) { if (width > height) { @@ -2374,10 +2369,10 @@ class Block { } /** - * Position the label for a collapsed block - * @param-blockscale-scale - * @return{void} + * Position the label for a collapsed block. * @private + * @param blockscale - scale + * @returns {void} */ _positionCollapseLabel(blockScale) { if (this.isInlineCollapsible()) { @@ -2396,10 +2391,10 @@ class Block { } /** - * Determine the hit area for a block - * DEPRECATED - * @return{void} + * Determine the hit area for a block. + * @deprecated * @private + * @returns {void} */ _calculateBlockHitArea() { let hitArea = new createjs.Shape(); @@ -2411,8 +2406,8 @@ class Block { /** * These are the event handlers for block containers. - * @return{void} * @private + * @returns {void} */ _loadEventHandlers() { let that = this; @@ -2452,7 +2447,7 @@ class Block { if (that.blocks.turtles.running()) { that.blocks.logo.doStopTurtles(); - setTimeout( () => { + setTimeout(() => { that.blocks.logo.runLogoCommands(topBlock); }, 250); } else { @@ -2475,7 +2470,7 @@ class Block { } locked = true; - setTimeout( () => { + setTimeout(() => { locked = false; }, 500); @@ -2511,7 +2506,7 @@ class Block { if (that.blocks.turtles.running()) { that.blocks.logo.doStopTurtles(); - setTimeout( () => { + setTimeout(() => { that.blocks.logo.runLogoCommands(topBlk); }, 250); } else { @@ -2530,7 +2525,7 @@ class Block { if (that.blocks.turtles.running()) { that.blocks.logo.doStopTurtles(); - setTimeout( () => { + setTimeout(() => { that.blocks.logo.runLogoCommands(topBlk); }, 250); } else { @@ -2546,7 +2541,7 @@ class Block { // Track time for detecting long pause... that.blocks.mouseDownTime = new Date().getTime(); - that.blocks.longPressTimeout = setTimeout( () => { + that.blocks.longPressTimeout = setTimeout(() => { that.blocks.activeBlock = that.blocks.blockList.indexOf(that); that._triggerLongPress = true; that.blocks.triggerLongPress(); @@ -2591,7 +2586,7 @@ class Block { moved = true; } else { // Make it eaiser to select text on mobile. - setTimeout( () => { + setTimeout(() => { moved = Math.abs(event.stageX / that.blocks.getStageScale() - that.original.x) + Math.abs(event.stageY / that.blocks.getStageScale() - that.original.y) > @@ -2695,14 +2690,14 @@ class Block { } /** - * Common code for processing events - * @param-event- mouse - * @param-moved-cursor moved - * @param-haveClick-when clickd - * @param-hideDOM-hide mouse - * set cursor style to default - * @return {void} + * Common code for processing events. * @private + * @param event - mouse + * @param moved - cursor moved + * @param haveClick - when clickd + * @param hideDOM - hide mouse + * Set cursor style to default. + * @returns {void} */ _mouseoutCallback(event, moved, haveClick, hideDOM) { let thisBlock = this.blocks.blockList.indexOf(this); @@ -2923,9 +2918,9 @@ class Block { } /** - * Change the label in a parameter block - * @return{void} + * Change the label in a parameter block. * @private + * @returns {void} */ _changeLabel() { let that = this; @@ -3531,7 +3526,7 @@ class Block { } // Firefox fix - setTimeout( () => { + setTimeout(() => { that.label.style.display = ""; that.label.focus(); focused = true; @@ -3541,9 +3536,9 @@ class Block { /** * Keypress handler. Handles exit key (Tab and Enter) press. - * @param{Event} KeyPress event object - * @returns{void} * @private + * @param event - KeyPress event object + * @returns {void} */ _exitKeyPressed(event) { if ([13, 10, 9].indexOf(event.keyCode) !== -1) { @@ -3552,10 +3547,11 @@ class Block { this.label.removeEventListener("keypress", this._exitKeyPressed); } } + /** - * Check if pie menu is ok to launch - * @return{void} + * Check if pie menu is ok to launch. * @public + * @returns {void} */ piemenuOKtoLaunch() { if (this._piemenuExitTime === null) { @@ -4020,10 +4016,9 @@ class Block { } /** - * set elements to a array - * if element is string,then set element's id to element + * Set elements to a array; if element is string, then set element's id to element * @public - * @return{void} + * @returns {void} */ function $() { let elements = new Array(); diff --git a/js/blocks.js b/js/blocks.js index d83bbc3eb4..458cce1f4c 100644 --- a/js/blocks.js +++ b/js/blocks.js @@ -33,10 +33,10 @@ const PITCHBLOCKS = [ // Blocks holds the list of blocks and most of the block-associated // methods, since most block manipulations are inter-block. -/* +/** * The class for managing the collection of blocks * @public - * @return {void} + * @returns {void} */ function Blocks(activity) { if (sugarizerCompatibility.isInsideSugarizer()) { @@ -127,95 +127,95 @@ function Blocks(activity) { // as to avoid palette refresh race conditions. this.deleteActionTimeout = 0; - /* + /** * Returns the long press status * @public - * @return this.inLongPress + * @returns this.inLongPress */ this.getLongPressStatus = function() { return this.inLongPress; }; - /* + /** * Sets long press status to false * @public - * @return {void} + * @returns {void} */ this.clearLongPress = function() { this.inLongPress = false; }; - /* + /** * We need access to the canvas. * @param - canvas * @public - * @return this + * @returns this */ this.setCanvas = function(canvas) { this.canvas = canvas; return this; }; - /* + /** * We need access to the stage. * @param - stage - staging area * @public - * @return this + * @returns this */ this.setStage = function(stage) { this.stage = stage; return this; }; - /* + /** * We need to be able to refreshe the canvas. * @param - refreshCanvas - new variable * @public - * @return this + * @returns this */ this.setRefreshCanvas = function(refreshCanvas) { this.refreshCanvas = refreshCanvas; return this; }; - /* + /** * We need to access the trashcan. * @param - trashcan - new variable * @public - * @return this + * @returns this */ this.setTrashcan = function(trashcan) { this.trashcan = trashcan; return this; }; - /* + /** * We need to be able to update the stage. * @param - updateStage - new variable * @public - * @return this + * @returns this */ this.setUpdateStage = function(updateStage) { this.updateStage = updateStage; return this; }; - /* + /** * We need to access the stage scale. * @param - getStageScale - new variable * @public - * @return this + * @returns this */ this.setGetStageScale = function(getStageScale) { this.getStageScale = getStageScale; return this; }; - /* + /** * Change the scale of the blocks (and the protoblocks on the palette). * @param - scale -new variable * @public - * @return {void} + * @returns {void} */ this.setBlockScale = async function(scale) { console.debug("New block scale is " + scale); @@ -254,77 +254,77 @@ function Blocks(activity) { this.refreshCanvas(); }; - /* + /** * We need to access the message object. * @param - msgText -new variable * @public - * @return {void} + * @returns {void} */ this.setMsgText = function(msgText) { this.msgText = msgText; }; - /* + /** * We need to access the error message object. * @param - errorMsg -new variable * @public - * @return this + * @returns this */ this.setErrorMsg = function(errorMsg) { this.errorMsg = errorMsg; return this; }; - /* + /** * We need to access the macro dictionary to add data to it. * @param - obj - object * @public - * @return this + * @returns this */ this.setMacroDictionary = function(obj) { this.macroDict = obj; return this; }; - /* + /** * We need access to the turtles list because we associate a turtle * with each start block. * @param - turtles * @public - * @return this + * @returns this */ this.setTurtles = function(turtles) { this.turtles = turtles; return this; }; - /* + /** * We need to access "Logo interpreter" when we click on blocks. * @param - logo * @public - * @return this + * @returns this */ this.setLogo = function(logo) { this.logo = logo; return this; }; - /* + /** * We need to access the right-click (and long press) context menu. * @param - contextMenu * @public - * @return this + * @returns this */ this.setContextMenu = function(contextMenu) { this.contextMenu = contextMenu; return this; }; - /* + /** * The scale of the graphics is determined by screen size. * @param - scale -new variable * @public - * @return this + * @returns this */ this.setScale = function(scale) { @@ -332,10 +332,10 @@ function Blocks(activity) { return this; }; - /* + /** * Extract the blocks * @public - * @return {void} + * @returns {void} */ this.extract = function() { if (this.activeBlock != null) { @@ -346,12 +346,12 @@ function Blocks(activity) { } }; - /* + /** * Pull a block from a stack, then readjust the docks. * @param - blk - blocks * @param - adjustDock - new variable * @private - * @return {void} + * @returns {void} */ this._extractBlock = async function(blk, adjustDock) { // Remove a single block from within a stack. @@ -414,10 +414,10 @@ function Blocks(activity) { } }; - /* + /** * Find the y position of the bottom-most block * @public - * @return maxy + * @returns maxy */ this.bottomMostBlock = function() { let maxy = -1000; @@ -430,11 +430,11 @@ function Blocks(activity) { return maxy; }; - /* + /** * Toggle state of collapsible blocks, except for note blocks, * which are handled separately. * @public - * @return {void} + * @returns {void} */ this.toggleCollapsibles = function() { let allCollapsed = true; @@ -486,12 +486,12 @@ function Blocks(activity) { } }; - /* + /** * We need to access the go-home button and boundary. * @param - setHomeContainers * @param - boundary * @public - * @return this + * @returns this */ this.setHomeContainers = function(setContainers, boundary) { this._setHomeButtonContainers = setContainers; @@ -499,30 +499,30 @@ function Blocks(activity) { return this; }; - /* + /** * Is this an action block? * @param - name - block name * @private - * @return boolean + * @returns boolean */ this._actionBlock = function(name) { return ["do", "doArg", "calc", "calcArg"].indexOf(name) !== -1; }; - /* + /** * Is this a named action block? * @param - name - block name * @private - * @return boolean + * @returns boolean */ this._namedActionBlock = function(name) { return ["nameddo", "nameddoArg", "namedcalc", "namedcalcArg"].indexOf(name) !== -1; }; - /* + /** * Adjust the dock positions of all blocks in the current drag group. * @private - * @return {void} + * @returns {void} */ this._adjustBlockPositions = function() { if (this.dragGroup.length < 2) { @@ -532,13 +532,13 @@ function Blocks(activity) { this.adjustDocks(this.dragGroup[0], true); }; - /* + /** * Adjust the size of the clamp in an expandable block when * block are inserted into (or removed from) the child flow. * This is a common operation for start and action blocks, * but also for repeat, forever, if, etc. * @public - * @return {void} + * @returns {void} */ this.adjustExpandableClampBlock = function() { if (this.clampBlocksToCheck.length === 0) { @@ -561,13 +561,13 @@ function Blocks(activity) { this._adjustArgClampBlock([blk]); } - /* + /** * Adjusts the clamp size * @param - blk - block number * @param - myBlock - block * @param - clamp (1 or 2)? * @private - * @return {void} + * @returns {void} */ let __clampAdjuster = function(blk, myBlock, clamp) { // First we need to count up the number of (and size of) the @@ -608,12 +608,12 @@ function Blocks(activity) { __clampAdjuster(blk, myBlock, clamp); }; - /* + /** * Returns depth of nesting, which is used to rank order the * blocks when adjusting their sizes. * @param - blk - block number * @private - * @return depth + * @returns depth */ this._getNestingDepth = function(blk) { let rank = 0; @@ -624,11 +624,11 @@ function Blocks(activity) { return rank; }; - /* + /** * Return the block size in units of standard block size. * @param - blk - block number * @private - * @return block size + * @returns block size */ this._getBlockSize = function(blk) { let myBlock = this.blockList[blk]; @@ -640,11 +640,11 @@ function Blocks(activity) { return myBlock.size; }; - /* + /** * Adjust the slot sizes of arg clamps. * @param - argBlocksToCheck -new variable * @private - * @return {void} + * @returns {void} */ this._adjustArgClampBlock = function(argBlocksToCheck) { if (argBlocksToCheck.length === 0) { @@ -684,13 +684,13 @@ function Blocks(activity) { } }; - /* + /** * We also adjust the size of twoarg blocks. It is similar to how * we adjust clamps, but enough different that it is in its own function. * @param - argBlocksToCheck - a list of blocks that need to be checked for changes to their clamp sizes. * @private - * @return {void} + * @returns {void} */ this._adjustExpandableTwoArgBlock = function(argBlocksToCheck) { if (argBlocksToCheck.length === 0) { @@ -716,11 +716,11 @@ function Blocks(activity) { } }; - /* + /** * Add or remove the vspace blocks * @param - blk - block number * @private - * @return void + * @returns void */ this._addRemoveVspaceBlock = function(blk) { let myBlock = this.blockList[blk]; @@ -733,11 +733,11 @@ function Blocks(activity) { let that = this; - /* + /** * Checks the number of VSpace blocks are below the block we are checking against * @param - blk - block number * @private - * @return number of vspace blocks found below this block + * @returns number of vspace blocks found below this block */ let __howManyVSpaceBlocksBelow = function(blk) { let nextBlock = last(that.blockList[blk].connections); @@ -767,11 +767,11 @@ function Blocks(activity) { } else if (secondArgumentSize > vSpaceCount + 1) { // Add vspace blocks - /* + /** * Adjusts the docks of the blocks connected to the vspace block * @param - args - [this block, the next block, the vspace block * @private - * @return {void} + * @returns {void} */ let __vspaceAdjuster = function(args) { let thisBlock = args[0]; @@ -818,11 +818,11 @@ function Blocks(activity) { } }; - /* + /** * Calculate the sum of the sizes of all the blocks a stack. * @param - blk - block number * @private - * @return int + * @returns int */ this._getStackSize = function(blk) { // How many block units in this stack? @@ -903,13 +903,13 @@ function Blocks(activity) { return size; }; - /* + /** * Given a block, adjust the dock position of all its connections. * @param - blk - block * @param - resetLoopCounter (to prevent infinite loops in the case the connections are broken). * @public - * @return {void} + * @returns {void} */ this.adjustDocks = function(blk, resetLoopCounter) { let myBlock = this.blockList[blk]; @@ -1034,7 +1034,7 @@ function Blocks(activity) { } }; - /* + /** * Add an action name whenever the user removes the name from an action block. Add a box name whenever the user removes the name from a storein block. Add a Silence block @@ -1044,7 +1044,7 @@ function Blocks(activity) { * @param - oldBlock - old block * @param - skipOldBlock * @public - * @return {void} + * @returns {void} */ this.addDefaultBlock = function(parentblk, oldBlock, skipOldBlock) { if (parentblk == null) { @@ -1056,11 +1056,11 @@ function Blocks(activity) { cblk = this.blockList[parentblk].connections[1]; if (cblk == null) { let that = this; - /* + /** * Update Palette * @param - args - arguments * @public - * @return {void} + * @returns {void} */ let postProcess = function(args) { let parentblk = args[0]; @@ -1114,11 +1114,11 @@ function Blocks(activity) { } else if (this.blockList[parentblk].name === "pitch") { cblk = this.blockList[parentblk].connections[2]; if (cblk == null) { - /* + /** * Adjust Docks * @param - args - arguments * @public - * @return {void} + * @returns {void} */ let postProcess = (args) => { let parentblk = args[0]; @@ -1143,11 +1143,11 @@ function Blocks(activity) { let oblk = this.blockList[parentblk].connections[1]; if (oblk == null) { - /* + /** * Adjust Docks * @param - args - arguments * @public - * @return {void} + * @returns {void} */ let postProcess = (args) => { let parentblk = args[0]; @@ -1203,11 +1203,11 @@ function Blocks(activity) { cblk = this.blockList[parentblk].connections[1]; if (cblk == null) { let that = this; - /* + /** * Adjust Docks * @param - args - arguments * @public - * @return {void} + * @returns {void} */ let postProcess = function(args) { let parentblk = args[0]; @@ -1247,12 +1247,12 @@ function Blocks(activity) { } }; - /* + /** * Remove any pitch blocks from a Note block if Silent block is inserted. * Deprecated since we do not allow silence blocks to be dragged. * @param - thisBlock -new variable * @private - * @return {void} + * @returns {void} */ this._deletePitchBlocks = function(thisBlock) { // Find the top of the stack @@ -1309,11 +1309,11 @@ function Blocks(activity) { } }; - /* + /** * Deletes the next default element: either a Pitch block or a Silent block. * @param - thisBlock * @public - * @return {void} + * @returns {void} */ this.deleteNextDefault = function(thisBlock) { if (thisBlock == undefined) { @@ -1354,12 +1354,12 @@ function Blocks(activity) { } }; - /* + /** * Remove the Silence block from a Note block if another block is inserted anywhere after the Silence block. * @param - thisBlock -new variable * @public - * @return {void} + * @returns {void} */ this.deletePreviousDefault = function(thisBlock) { let thisBlockobj = this.blockList[thisBlock]; @@ -1404,14 +1404,14 @@ function Blocks(activity) { } }; - /* + /** * Handle connections when blocks are moved. * @param - thisBlock -new variable * @public - * @return {void} + * @returns {void} */ this.blockMoved = async function(thisBlock) { - /* + /** * When a block is moved, we have to check the following: * (0) Is it inside of a expandable block? * Is it connected to a collapsed block? @@ -1993,12 +1993,12 @@ function Blocks(activity) { this.refreshCanvas(); }; - /* + /** * Test for a valid connection between two dock types. * @param - type1 - dock type 1 * @param - type2 - dock type 2 * @private - * @return boolean + * @returns boolean */ this._testConnectionType = function(type1, type2) { // Can these two blocks dock? @@ -2077,10 +2077,10 @@ function Blocks(activity) { return false; }; - /* + /** * Ensure that all the blocks are where they are supposed to be. * @public - * @return {void} + * @returns {void} */ this.updateBlockPositions = function() { for (let blk = 0; blk < this.blockList.length; blk++) { @@ -2088,10 +2088,10 @@ function Blocks(activity) { } }; - /* + /** * Move all the blocks to the top layer of the block container. * @public - * @return {void} + * @returns {void} */ this.bringToTop = function() { this._adjustTheseStacks = []; @@ -2111,10 +2111,10 @@ function Blocks(activity) { this.refreshCanvas(); }; - /* + /** * Checks the bounds to ensure blocks are "home". * @public - * @return {void} + * @returns {void} */ this.checkBounds = function() { let onScreen = true; @@ -2136,23 +2136,23 @@ function Blocks(activity) { } }; - /* + /** * Move a block to a specified position and check the docks afterward. * @public - * @return{void} + * @returns{void} */ this.moveBlock = function(blk, x, y) { this._moveBlock(blk, x, y); this.adjustDocks(blk, true); }; - /* + /** * Move a block (and its label) to x, y. * @param - blk - block * @param - x - x position * @param - y - y position * @public - * @return {void} + * @returns {void} */ this._moveBlock = function(blk, x, y) { let myBlock = this.blockList[blk]; @@ -2167,13 +2167,13 @@ function Blocks(activity) { } }; - /* + /** * Relative move of a block (and its label) by dx, dy * @param - blk - block * @param - dx - updated x position * @param - dy - updated y position * @public - * @return {void} + * @returns {void} */ this.moveBlockRelative = function(blk, dx, dy) { this.inLongPress = false; @@ -2190,13 +2190,13 @@ function Blocks(activity) { } }; - /* + /** * Moves the blocks in a stack to a new position. * @param blk - block * @param dx - x position * @param dy - y position * @public - * @return {void} + * @returns {void} */ this.moveStackRelative = function(blk, dx, dy) { this.findDragGroup(blk); @@ -2207,13 +2207,13 @@ function Blocks(activity) { } }; - /* + /** * Moves all blocks except given stack * @param blk - exception * @param dx - delta x * @param dy - delta y * @public - * @return {void} + * @returns {void} */ this.moveAllBlocksExcept = function(blk, dx, dy) { for (let block in this.blockList){ @@ -2222,12 +2222,12 @@ function Blocks(activity) { } }; - /* + /** * Update the block labels. * When we create new blocks, we may not have assigned the value yet. * @param - blk - block * @public - * @return {void} + * @returns {void} */ this.updateBlockText = function(blk) { let myBlock = this.blockList[blk]; @@ -2380,11 +2380,11 @@ function Blocks(activity) { } }; - /* + /** * Find the top block in the stack. * @param - blk - block * @public - * @return blk + * @returns blk */ this.findTopBlock = function(blk) { // Find the top block in a stack. @@ -2426,12 +2426,12 @@ function Blocks(activity) { return blk; }; - /* + /** * Checks if two blocks are of the same flow generation. * @param - firstblk * @param - childblk * @public - * @return boolean + * @returns boolean */ this.sameGeneration = function(firstBlk, childBlk) { if (firstBlk == null || childBlk == null) { @@ -2469,12 +2469,12 @@ function Blocks(activity) { return false; }; - /* + /** * Check if there is a block type in any of the stacks. * @param - thisBlock - new variable * @param - names - names of blocks * @private - * @return boolean + * @returns boolean */ this._blockInStack = function(thisBlock, names) { // Is there a block of any of these names in this stack? @@ -2501,11 +2501,11 @@ function Blocks(activity) { return false; }; - /* + /** * Find the bottom block in the stack. * @param - blk - block * @public - * @return blk + * @returns blk */ this.findBottomBlock = function(blk) { // Find the bottom block in a stack. @@ -2537,12 +2537,12 @@ function Blocks(activity) { return blk; }; - /* + /** * Count all the blocks in the stack starting from blk. * @param - blk - block * @private * c = 0 - * @return c + * @returns c */ this._countBlocksInStack = function(blk) { let c = 0; @@ -2557,11 +2557,11 @@ function Blocks(activity) { return c; }; - /* + /** * Find any block with null in its first connection. * Push them onto the stackList. * @public - * @return {void} + * @returns {void} */ this.findStacks = function() { this.stackList = []; @@ -2572,10 +2572,10 @@ function Blocks(activity) { } }; - /* + /** * Find any clamp blocks. * @private - * @return {void} + * @returns {void} */ this._findClamps = function() { this._expandablesList = []; @@ -2588,10 +2588,10 @@ function Blocks(activity) { this._searchForArgFlow(); }; - /* + /** * Find any expandable arg blocks. * @public - * @return {void} + * @returns {void} */ this._findTwoArgs = function() { this._expandablesList = []; @@ -2604,10 +2604,10 @@ function Blocks(activity) { } }; - /* + /** * Search for argument flow blocks. * @private - * @return{void} + * @returns{void} */ this._searchForArgFlow = function() { for (let blk = 0; blk < this.blockList.length; blk++) { @@ -2619,11 +2619,11 @@ function Blocks(activity) { } }; - /* + /** * Search for expandable blocks below blk in stack. * @param - blk - block * @private - * @return {void} + * @returns {void} */ this._searchForExpandables = function(blk) { let c; @@ -2659,10 +2659,10 @@ function Blocks(activity) { } }; - /* + /** * Expand two-arg blocks as needed. * @private - * @return {void} + * @returns {void} */ this._expandTwoArgs = function() { this._findTwoArgs(); @@ -2670,10 +2670,10 @@ function Blocks(activity) { this.refreshCanvas(); }; - /* + /** * Expand expandable clamp blocks as needed. * @private - * @return {void} + * @returns {void} */ this._expandClamps = function() { this._findClamps(); @@ -2691,14 +2691,14 @@ function Blocks(activity) { this.refreshCanvas(); }; - /* + /** * Some blocks, e.g., sensor blocks for Butia, change their appearance depending upon if they have been enabled or disabled. If they have, change their disabled status * @param - name * @param - flag * @public - * @return {void} + * @returns {void} */ this.changeDisabledStatus = function(name, flag) { for (let blk in this.blockList) { @@ -2710,10 +2710,10 @@ function Blocks(activity) { } }; - /* + /** * Unhighlight all blocks. * @public - * @return {void} + * @returns {void} */ this.unhighlightAll = function() { for (let blk in this.blockList) { @@ -2721,7 +2721,7 @@ function Blocks(activity) { } }; - /* + /** * Unhighlight a block * @public * return {void} @@ -2745,12 +2745,12 @@ function Blocks(activity) { } }; - /* + /** * Highlight a block * @param - blk - block * @param - unhilight - new variable * @public - * @return {void} + * @returns {void} */ this.highlight = function(blk, unhighlight) { if (!this.visible) { @@ -2766,7 +2766,7 @@ function Blocks(activity) { } }; - /* + /** * Hide all of the blocks. * @public * return {void} @@ -2778,7 +2778,7 @@ function Blocks(activity) { this.visible = false; }; - /* + /** * Show all the blocks. * @public * return {void} @@ -2790,7 +2790,7 @@ function Blocks(activity) { this.visible = true; }; - /* + /** * Make a new block with connections * @param - name - new variable * @param - blockOffset - new variable @@ -2798,7 +2798,7 @@ function Blocks(activity) { * @param - postPorcess * @param - postProcessArg - Post process Argument * @private - * @return {void} + * @returns {void} */ this._makeNewBlockWithConnections = function( name, blockOffset, connections, postProcess, postProcessArg) { @@ -2824,13 +2824,13 @@ function Blocks(activity) { } }; - /* + /** * Create new block * @param - name * @param - postProcess * @param - postProcessArg * @public - * @return {void} + * @returns {void} */ this.makeNewBlock = function(name, postProcess, postProcessArg) { // Create a new block @@ -2896,12 +2896,12 @@ function Blocks(activity) { return myBlock; }; - /* + /** * Make new blocks from proto block, which is called from Palettes * @param - name * @param - arg - argument * @public - * @return {void} + * @returns {void} */ this.makeBlock = function(name, arg) { let postProcess; @@ -3310,11 +3310,11 @@ function Blocks(activity) { return blk; }; - /* + /** * Create the drag group from the blocks connected to blk. * @param - blk - block * @public - * @return {void} + * @returns {void} */ this.findDragGroup = function(blk) { if (blk == null) { @@ -3327,11 +3327,11 @@ function Blocks(activity) { this._calculateDragGroup(blk); }; - /* + /** * Give a block, find all the blocks connected to it. * @param - blk - block * @private - * @return {void} + * @returns {void} */ this._calculateDragGroup = function(blk) { this.dragLoopCounter += 1; @@ -3375,11 +3375,11 @@ function Blocks(activity) { } }; - /* + /** * Set protoblock visibility on the Action palette. * @param - state * @public - * @return {void} + * @returns {void} */ this.setActionProtoVisiblity = function(state) { // By default, the nameddo protoblock is hidden. @@ -3403,11 +3403,11 @@ function Blocks(activity) { } }; - /* + /** * Find a unique custom name for an Action block. * @param - name * @public - * @return {void} + * @returns {void} */ this.findUniqueActionName = function(name, actionBlk) { // If we have a stack named 'action', make the protoblock visible. @@ -3438,11 +3438,11 @@ function Blocks(activity) { return value; }; - /* + /** * Finds a unique custom name for custom mode block. * @param - name - new variable * @public - * @return value + * @returns value */ this.findUniqueCustomName = function(name) { let noteNames = []; @@ -3464,11 +3464,11 @@ function Blocks(activity) { return value; }; - /* + /** * Finds a unique custom name for temperament block. * @param - name - new variable * @public - * @return value + * @returns value */ this.findUniqueTemperamentName = function(name) { let temperamentNames = []; @@ -3490,10 +3490,10 @@ function Blocks(activity) { return value; }; - /* + /** * Make sure we initialize any drum with a URL name. * @private - * @return {void} + * @returns {void} */ this._findDrumURLs = function() { for (let blk = 0; blk < this.blockList.length; blk++) { @@ -3510,7 +3510,7 @@ function Blocks(activity) { } }; - /* + /** * Rename the block boxes. * @param - oldName - old name of boxes * @param - newName - new variable @@ -3540,7 +3540,7 @@ function Blocks(activity) { } }; - /* + /** * Rename Storedin boxes. * @param - oldName - old name of boxes * @param - newName - new variable @@ -3587,7 +3587,7 @@ function Blocks(activity) { } }; - /* + /** * Rename Storedin2 boxes. * @param - oldName - old name of boxes * @param - newName - new variable @@ -3621,7 +3621,7 @@ function Blocks(activity) { } }; - /* + /** * Rename Named boxes. * @param - oldName - old name of boxes * @param - newName - new variable @@ -3656,7 +3656,7 @@ function Blocks(activity) { } }; - /* + /** * Rename Do blocks. * @param - oldName - old name of boxes * @param - newName - new variable @@ -3702,12 +3702,12 @@ function Blocks(activity) { } }; - /* + /** * Renames Named do blocks. * @param oldName * @param newName - new variable * @private - * @return 'do', 'doArg', 'calc', 'calcArg + * @returns 'do', 'doArg', 'calc', 'calcArg */ this.renameNameddos = function(oldName, newName) { if (oldName === newName) { @@ -3735,7 +3735,7 @@ function Blocks(activity) { let nameChanged = false; for (let blockId = 0; blockId < actionsPalette.protoList.length; blockId++) { let block = actionsPalette.protoList[blockId]; - if (["nameddo", "namedcalc", "nameddoArg", "namedcalcArg"].indexOf(block.name) !== -1 /* && block.defaults[0] !== _('action') */ && block.defaults[0] === oldName) { + if (["nameddo", "namedcalc", "nameddoArg", "namedcalcArg"].indexOf(block.name) !== -1 /** && block.defaults[0] !== _('action') */ && block.defaults[0] === oldName) { block.defaults[0] = newName; nameChanged = true; } @@ -3749,11 +3749,11 @@ function Blocks(activity) { } }; - /* + /** * Make a new Storein block. * @param - name - new variable * @public - * @return {void} + * @returns {void} */ this.newStoreinBlock = function(name) { if (name == null) { @@ -3785,7 +3785,7 @@ function Blocks(activity) { } }; - /* + /** * Make a new Storein2 block. * @param - name - new variable * @public @@ -3817,7 +3817,7 @@ function Blocks(activity) { } }; - /* + /** * Make a new Named Box block. * @param - name - new variable * @public @@ -3848,11 +3848,11 @@ function Blocks(activity) { myBoxBlock.palette.add(myBoxBlock, true); }; - /* + /** * Make a new Local Arg block. * @param - blk - block * @private - * @return {void} + * @returns {void} */ this._newLocalArgBlock = async function(name) { // name === 1, 2, 3, ... @@ -3880,11 +3880,11 @@ function Blocks(activity) { this.palettes.updatePalettes("action"); }; - /* + /** * Remove any unneeded Named Do blocks. * @param - name * @private - * @return {void} + * @returns {void} */ this._removeNamedoEntries = function(name) { // Delete any old palette entries. @@ -3904,7 +3904,7 @@ function Blocks(activity) { } }; - /* + /** * Depending upon the form of the associated action block, we want to add a named do, a named calc, a named do w/args, or a named calc w/args. @@ -3912,7 +3912,7 @@ function Blocks(activity) { * @param - hasReturn * @param - hasArgs * @public - * @return boolean + * @returns boolean */ this.newNameddoBlock = function(name, hasReturn, hasArgs) { if (name === _("action")) { @@ -3941,11 +3941,11 @@ function Blocks(activity) { return false; }; - /* + /** * Make a new Named Calc block. * @param - name -new variable * @public - * @return boolean + * @returns boolean */ this.newNamedcalcBlock = function(name) { if (this.protoBlockDict["myCalc_" + name] === undefined) { @@ -3963,7 +3963,7 @@ function Blocks(activity) { return false; }; - /* + /** * Make a new Named Do Arg block. * @param - name - new variable * @public @@ -3985,7 +3985,7 @@ function Blocks(activity) { return false; }; - /* + /** * Make a new Named Calc Arg block. * @param - name - new variable * @public @@ -4025,12 +4025,12 @@ function Blocks(activity) { } }; - /* + /** * Return a list of containing clamp blocks or [] * @param - blk - block * @param - clampList * @public - * @return list of clamp blocks + * @returns list of clamp blocks */ this.findNestedClampBlocks = function(blk, clampList) { if (this.blockList[blk] == null) { @@ -4057,11 +4057,11 @@ function Blocks(activity) { } }; - /* + /** * Return a containing expandable block or null. * @param - blk - block * @public - * @return expandable block + * @returns expandable block */ this.insideExpandableBlock = function(blk) { if (this.blockList[blk] == null) { @@ -4087,11 +4087,11 @@ function Blocks(activity) { } }; - /* + /** * Return a note block or null. * @param - blk - block * @public - * @return note block + * @returns note block */ this._insideNoteBlock = function(blk) { if (this.blockList[blk] == null) { @@ -4121,11 +4121,11 @@ function Blocks(activity) { } }; - /* + /** * Find an instance of a block type by name. * @param - blkName * @public - * @return boolean + * @returns boolean */ this.findBlockInstance = function(blkName) { // Returns true if block of name blkName is loaded. @@ -4138,11 +4138,11 @@ function Blocks(activity) { return false; }; - /* + /** * Return the first containing Note block, if any. * @param - blk - block * @public - * @return null or collapsible block + * @returns null or collapsible block */ this.insideInlineCollapsibleBlock = function(blk) { if (blk === null) { @@ -4164,11 +4164,11 @@ function Blocks(activity) { return this.insideInlineCollapsibleBlock(c0); }; - /* + /** * Return first Note block found. * @param - blk - block * @public - * @return note block + * @returns note block */ this.findNoteBlock = function(blk) { if (blk === null) { @@ -4188,11 +4188,11 @@ function Blocks(activity) { return this.findNoteBlock(c); }; - /* + /** * Return first Interval block found. * @param - blk - block * @public - * @return null or blk + * @returns null or blk */ this.findNestedIntervalBlock = function(blk) { if (blk === null) { @@ -4212,11 +4212,11 @@ function Blocks(activity) { return this.findNestedIntervalBlock(c); }; - /* + /** * Returns first Pitch block found. * @param - blk - block * @public - * @return null or blk + * @returns null or blk */ this.findFirstPitchBlock = function(blk) { if (blk === null) { @@ -4233,11 +4233,11 @@ function Blocks(activity) { return this.findFirstPitchBlock(c); }; - /* + /** * Return octave associated with Pitch block. * @param - blk - block * @public - * @return 4 + * @returns 4 */ this.findPitchOctave = function(blk) { if (blk === null) { @@ -4258,12 +4258,12 @@ function Blocks(activity) { } }; - /* + /** * Set octave associated with Pitch block. * @param - blk - block * @param - octave * @public - * @return {void} + * @returns {void} */ this.setPitchOctave = function(blk, octave) { if (blk === null) { @@ -4285,11 +4285,11 @@ function Blocks(activity) { } }; - /* + /** * Check if a Number block used as a modifier in an Interval block. * @param - blk - block * @public - * @return boolean + * @returns boolean */ this.intervalModifierNumber = function(blk) { if (blk === null) { @@ -4316,12 +4316,12 @@ function Blocks(activity) { return false; }; - /* + /** * Check if a Number block is being used as multipicant with a Mode-length block. * @param - blk - block * @public - * @return boolean + * @returns boolean */ this.octaveModifierNumber = function(blk) { if (blk === null) { @@ -4350,11 +4350,11 @@ function Blocks(activity) { return false; }; - /* + /** * Check if a Number block is used as a note value denominator argument. * @param - blk - block * @public - * @return boolean + * @returns boolean */ this.noteValueNumber = function(blk, c) { if (blk === null) { @@ -4412,12 +4412,12 @@ function Blocks(activity) { return false; }; - /* + /** * Return the Number block value being used as a note value denominator argument. * @param - blk - block * @public - * @return 1 + * @returns 1 */ this.noteValueValue = function(blk) { if (blk === null) { @@ -4476,11 +4476,11 @@ function Blocks(activity) { return 1; }; - /* + /** * Check if a Number block being used as an octave argument? * @param - blk - block * @public - * @return boolean + * @returns boolean */ this.octaveNumber = function(blk) { if (blk === null) { @@ -4493,11 +4493,11 @@ function Blocks(activity) { this.blockList[myBlock.connections[0]].connections[2] === blk); }; - /* + /** * Check if the meter block note value changed, update the BPM block. * @param - blk - block * @public - * @return void + * @returns void */ this.meter_block_changed = function(blk) { if (blk === null || this.blockList[blk].name !== "meter") { @@ -4561,11 +4561,11 @@ function Blocks(activity) { } }; - /* + /** * Auto-select stack for copying -- no need to actually click on the copy button. * @public - * @return {void} + * @returns {void} */ this.prepareStackForCopy = function() { if (this.activeBlock == null) { @@ -4586,10 +4586,10 @@ function Blocks(activity) { this.pasteDy = 0; }; - /* + /** * Triggers the long press of keys and clears timeout. * @public - * @return {void} + * @returns {void} */ this.triggerLongPress = function() { if (this.longPressTimeout != null) { @@ -4601,10 +4601,10 @@ function Blocks(activity) { piemenuBlockContext(this.blockList[this.activeBlock]); }; - /* + /** * Copy a stack of blocks by creating a blockObjs and pasting. * @public - * @return {void} + * @returns {void} */ this.pasteStack = function() { if (this.selectedStack == null) { @@ -4627,11 +4627,11 @@ function Blocks(activity) { } }; - /* + /** * Save a stack of blocks to local storage and the 'myblocks' palette by creating a blockObjs. * @public - * @return {void} + * @returns {void} */ this.saveStack = function() { console.debug(this.selectedStack); @@ -4668,10 +4668,10 @@ function Blocks(activity) { } }; - /* + /** * Copies the Block to objects. * @public - * @return blockObj + * @returns blockObj */ this._copyBlocksToObj = function() { let blockObjs = []; @@ -4728,12 +4728,12 @@ function Blocks(activity) { return blockObjs; }; - /* + /** * On the palette we store the macro as a basic block. * @param - name * @param - obj - object * @public - * @return {void} + * @returns {void} */ this.addToMyPalette = function(name, obj) { // FIXME: where is obj used? @@ -4751,11 +4751,11 @@ function Blocks(activity) { this.protoBlockDict[blkName].palette.add(this.protoBlockDict[blkName]); }; - /* + /** * Returns true if block of name blkName is loaded. * @param - blkName - block name * @public - * @return boolean + * @returns boolean */ this.findBlockInstance = function(blkName) { for (let blk = 0; blk < this.blockList.length; blk++) { @@ -4766,7 +4766,7 @@ function Blocks(activity) { return false; }; - /* + /** * Load new blocks. * @param - blockObj - Block Objects * @public @@ -5787,11 +5787,11 @@ function Blocks(activity) { } }; - /* + /** * If all the blocks are loaded, we can make the final adjustments. * @param - name * @public - * @return {void} + * @returns {void} */ this.cleanupAfterLoad = async function(name) { this._loadCounter -= 1; @@ -5867,10 +5867,10 @@ function Blocks(activity) { document.dispatchEvent(myCustomEvent); }; - /* + /** * Cleanup the stacks after load. * @private - * @return {void} + * @returns {void} */ this._cleanupStacks = function() { // Sort the blocks from inside to outside. @@ -5910,11 +5910,11 @@ function Blocks(activity) { } }; - /* + /** * Look for a Return block in an action stack. * @param - blk - block * @public - * @return boolean + * @returns boolean */ this.actionHasReturn = function(blk) { if (this.blockList[blk].name !== "action") { @@ -5929,11 +5929,11 @@ function Blocks(activity) { return false; }; - /* + /** * Look for an Arg block in an action stack. * @param - blk - block * @public - * @return boolean + * @returns boolean */ this.actionHasArgs = function(blk) { if (this.blockList[blk].name !== "action") { @@ -5948,11 +5948,11 @@ function Blocks(activity) { return false; }; - /* + /** * Move the stack associated with blk to the top. * @param - blk - block * @public - * @return {void} + * @returns {void} */ this.raiseStackToTop = function(blk) { let topBlk = this.findTopBlock(blk); @@ -5967,11 +5967,11 @@ function Blocks(activity) { this.refreshCanvas; }; - /* + /** * Deletes an Action block * @param - myblock - new variable * @public - * @return {void} + * @returns {void} */ this.deleteActionBlock = async function(myBlock) { let actionArg = this.blockList[myBlock.connections[1]]; @@ -6054,11 +6054,11 @@ function Blocks(activity) { } }; - /* + /** * Send a stack of blocks to the trash. * @param - myBlock * @public - * @return {void} + * @returns {void} */ this.sendStackToTrash = function(myBlock) { // First, hide the palettes as they will need updating. @@ -6167,10 +6167,10 @@ function Blocks(activity) { } }; - /** + /*** * Clears all the blocks, updates the cache and refreshes the canvas. * - * @returns {void} + * @returnss {void} */ this.clearParameterBlocks = function() { for (let blk = 0; blk < this.blockList.length; blk++) { @@ -6185,13 +6185,13 @@ function Blocks(activity) { this.refreshCanvas(); }; - /** + /*** * Updates the label on parameter blocks. * * @param logo * @param turtle * @param blk - * @returns {void} + * @returnss {void} */ this.updateParameterBlock = function(logo, turtle, blk) { let name = this.blockList[blk].name; @@ -6226,14 +6226,14 @@ function Blocks(activity) { } }; - /** + /*** * Changes a property according to a block name and a value. * * @param logo * @param blk * @param value * @param turtle - * @returns {void} + * @returnss {void} */ this.blockSetter = function(logo, blk, value, turtle) { if (typeof this.blockList[blk].protoblock.setter === "function") { @@ -6247,10 +6247,10 @@ function Blocks(activity) { } }; - /** + /*** * Hides all the blocks. * - * @returns {void} + * @returnss {void} */ this.hideBlocks = function() { this.palettes.hide(); @@ -6258,10 +6258,10 @@ function Blocks(activity) { this.refreshCanvas(); } - /** + /*** * Shows all the blocks. * - * @returns {void} + * @returnss {void} */ this.showBlocks = function() { this.palettes.show(); From acdc016273beeb40a1858d527374df30175009e8 Mon Sep 17 00:00:00 2001 From: Anindya Kundu Date: Fri, 11 Dec 2020 21:12:46 +0530 Subject: [PATCH 03/11] Fix conflicting namespace bug --- js/widgets/help.js | 8 +++----- js/widgets/statistics.js | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/js/widgets/help.js b/js/widgets/help.js index 6ce77df14d..a13d81b5f9 100644 --- a/js/widgets/help.js +++ b/js/widgets/help.js @@ -10,9 +10,9 @@ // This widget displays help about a block or a button. -const ICONSIZE = 32; - class HelpWidget { + static ICONSIZE = 32; + constructor(blocks) { this.beginnerBlocks = []; this.advancedBlocks = []; @@ -42,7 +42,7 @@ class HelpWidget { } _setup(blocks) { - let iconSize = ICONSIZE; + let iconSize = HelpWidget.ICONSIZE; // Which help page are we on? let page = 0; @@ -328,8 +328,6 @@ class HelpWidget { // called recursively to cycle through help string of all blocks (Beginner Blocks First) _blockHelp(block, blocks) { - let iconSize = ICONSIZE; - let widgetWindow = window.widgetWindows.windowFor(this, "help", "help"); this.widgetWindow = widgetWindow; widgetWindow.clear(); diff --git a/js/widgets/statistics.js b/js/widgets/statistics.js index 83365720a4..d656041d6f 100644 --- a/js/widgets/statistics.js +++ b/js/widgets/statistics.js @@ -9,9 +9,6 @@ // License along with this library; if not, write to the Free Software // Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA -const BUTTONSIZE = 53; -const ICONSIZE = 32; - /** * This widget makes displays the status of selected parameters and notes as they are being played. */ From 981e858a2453ee2f895b95108b8a029a1004cfeb Mon Sep 17 00:00:00 2001 From: Anindya Kundu Date: Sat, 12 Dec 2020 00:05:16 +0530 Subject: [PATCH 04/11] Fix regression: missing palette head icon --- js/palette.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/palette.js b/js/palette.js index 9a11fe5fe7..6e9f69c9ad 100644 --- a/js/palette.js +++ b/js/palette.js @@ -768,7 +768,7 @@ class Palette { palDiv.removeChild(x); } let labelImg = makePaletteIcons( - PALETTEICONS[name], + PALETTEICONS[this.name], this.palettes.cellSize, this.palettes.cellSize, ); From 9b45ef2326e620d6f0a6c86d59dfbbbbae033355 Mon Sep 17 00:00:00 2001 From: Anindya Kundu Date: Sat, 12 Dec 2020 03:42:58 +0530 Subject: [PATCH 05/11] Improve palette styling --- js/palette.js | 368 +++++++++++++++++++++++++++----------------------- 1 file changed, 197 insertions(+), 171 deletions(-) diff --git a/js/palette.js b/js/palette.js index 6e9f69c9ad..c4905dcca8 100644 --- a/js/palette.js +++ b/js/palette.js @@ -88,66 +88,84 @@ class Palettes { deltaY(dy) { let curr = parseInt(document.getElementById("palette").style.top); - document.getElementById("palette").style.top = curr + dy +"px" + document.getElementById("palette").style.top = curr + dy + "px"; } _makeSelectorButton(i) { console.debug("makeSelectorButton " + i); - if (!document.getElementById("palette")){ + if (!document.getElementById("palette")) { let element = document.createElement("div"); - element.setAttribute("id","palette"); - element.setAttribute("class","disable_highlighting"); - element.setAttribute("style",'position: fixed; display: none ; left :0px; top:'+this.top+'px'); - element.innerHTML ='
    '; + element.id = "palette"; + element.setAttribute("class", "disable_highlighting"); + element.setAttribute( + "style", + "position: fixed; display: none ; left :0px; top:" + this.top + "px" + ); + element.innerHTML = + '
    '; + element.childNodes[0].style.border = `1px solid ${platformColor.selectorSelected}`; document.body.appendChild(element); } - let palette = document.getElementById("palette"); - let tr = palette.children[0].children[0].children[0].children[0]; + let tr = docById("palette").children[0].children[0].children[0].children[0]; let td = tr.insertCell(); - td.width=1.5*this.cellSize; - td.height=1.5*this.cellSize; - td.appendChild(makePaletteIcons(PALETTEICONS[MULTIPALETTEICONS[i]] - .replace( - "background_fill_color", - platformColor.selectorBackground + td.width = 1.5 * this.cellSize; + td.height = 1.5 * this.cellSize; + td.style.position = "relative"; + td.appendChild( + makePaletteIcons( + PALETTEICONS[MULTIPALETTEICONS[i]] + .replace("background_fill_color", platformColor.selectorBackground) + .replace(/stroke_color/g, platformColor.ruleColor) + .replace(/fill_color/g, platformColor.background), + 1.5 * this.cellSize, + 1.5 * this.cellSize ) - .replace(/stroke_color/g, platformColor.ruleColor) - .replace(/fill_color/g, platformColor.background), - 1.5*this.cellSize, - 1.5*this.cellSize)); - td.onmouseover = (evt) =>{ - this.showSelection(i,tr); + ); + const cover = document.createElement("div"); + cover.style.position = "absolute"; + cover.style.zIndex = "10"; + cover.style.top = "0"; + cover.style.width = "100%"; + cover.style.height = "1px"; + cover.style.background = platformColor.selectorBackground; + td.appendChild(cover); + td.onmouseover = () => { + this.showSelection(i, tr); this.makePalettes(i); - } + }; } - showSelection(i,tr) { + showSelection(i, tr) { //selector menu design. - for (let j = 0; j < MULTIPALETTES.length ; j++) { + for (let j = 0; j < MULTIPALETTES.length; j++) { let img; if (j === i) { - img = makePaletteIcons(PALETTEICONS[MULTIPALETTEICONS[j]] - .replace( - "background_fill_color", - platformColor.selectorSelected - ) - .replace(/stroke_color/g, platformColor.ruleColor) - .replace(/fill_color/g, platformColor.background) - ,this.cellSize - ,this.cellSize); + img = makePaletteIcons( + PALETTEICONS[MULTIPALETTEICONS[j]] + .replace("background_fill_color", platformColor.selectorSelected) + .replace(/stroke_color/g, platformColor.ruleColor) + .replace(/fill_color/g, platformColor.background), + this.cellSize, + this.cellSize + ); + tr.children[j].children[1].style.background = platformColor.selectorSelected; } else { - img = makePaletteIcons(PALETTEICONS[MULTIPALETTEICONS[j]] - .replace( - "background_fill_color", - platformColor.selectorBackground - ) - .replace(/stroke_color/g, platformColor.ruleColor) - .replace(/fill_color/g, platformColor.background) - ,this.cellSize - ,this.cellSize); + img = makePaletteIcons( + PALETTEICONS[MULTIPALETTEICONS[j]] + .replace("background_fill_color", platformColor.selectorBackground) + .replace(/stroke_color/g, platformColor.ruleColor) + .replace(/fill_color/g, platformColor.background), + this.cellSize, + this.cellSize + ); + tr.children[j].children[1].style.background = platformColor.selectorBackground; } - tr.children[j].children[0].src= img.src; + tr.children[j].children[0].src = img.src; } } @@ -166,7 +184,7 @@ class Palettes { } setBlocksContainer(bloc) { - this.blocksContainer = bloc ; + this.blocksContainer = bloc; return this; } @@ -201,8 +219,10 @@ class Palettes { // How many protoblocks are in palette name? let n = 0; for (let b in this.blocks.protoBlockDict) { - if (this.blocks.protoBlockDict[b].palette !== null && - this.blocks.protoBlockDict[b].palette.name === name) { + if ( + this.blocks.protoBlockDict[b].palette !== null && + this.blocks.protoBlockDict[b].palette.name === name + ) { n += 1; } } @@ -213,13 +233,21 @@ class Palettes { getProtoNameAndPalette(name) { for (let b in this.blocks.protoBlockDict) { // Don't return deprecated blocks. - if (name === this.blocks.protoBlockDict[b].name && - !this.blocks.protoBlockDict[b].hidden) { - return [b, this.blocks.protoBlockDict[b].palette.name, - this.blocks.protoBlockDict[b].name]; + if ( + name === this.blocks.protoBlockDict[b].name && + !this.blocks.protoBlockDict[b].hidden + ) { + return [ + b, + this.blocks.protoBlockDict[b].palette.name, + this.blocks.protoBlockDict[b].name + ]; } else if (name === b && !this.blocks.protoBlockDict[b].hidden) { - return [b, this.blocks.protoBlockDict[b].palette.name, - this.blocks.protoBlockDict[b].name]; + return [ + b, + this.blocks.protoBlockDict[b].palette.name, + this.blocks.protoBlockDict[b].name + ]; } } @@ -230,46 +258,47 @@ class Palettes { let palette = docById("palette"); let listBody = palette.children[0].children[1].children[1]; listBody.parentNode.removeChild(listBody); - listBody = palette.children[0].children[1].appendChild( - document.createElement("tbody")); + listBody = palette.children[0].children[1].appendChild(document.createElement("tbody")); // Make an icon/button for each palette - this.makeButton("search", - makePaletteIcons(PALETTEICONS["search"], this.cellSize, - this.cellSize), listBody); + this.makeButton( + "search", + makePaletteIcons(PALETTEICONS["search"], this.cellSize, this.cellSize), + listBody + ); for (let name of MULTIPALETTES[i]) { if (beginnerMode && SKIPPALETTES.indexOf(name) !== -1) { continue; } - if (name ==="myblocks" ) { - let n = this.countProtoBlocks("myblocks"); - if (n === 0) { - continue; - } + if (name === "myblocks") { + if (this.countProtoBlocks("myblocks") === 0) continue; } - this.makeButton(name, - makePaletteIcons(PALETTEICONS[name], this.cellSize, - this.cellSize), listBody); + this.makeButton( + name, + makePaletteIcons(PALETTEICONS[name], this.cellSize, this.cellSize), + listBody + ); } } - makeButton (name,icon,listBody){ - let row = listBody.insertRow(-1); - let img = row.insertCell(-1); - let label = row.insertCell(-1); + makeButton(name, icon, listBody) { + const row = listBody.insertRow(-1); + const img = row.insertCell(-1); + const label = row.insertCell(-1); img.appendChild(icon); - // Add tooltip for palette buttons - row.setAttribute("style","width: 126px"); - if (localStorage.kanaPreference === "kana") { - label.textContent = toTitleCase(_(name)) ; - label.setAttribute( - "style", "font-size: 12px; color:platformColor.paletteText"); - } else { - label.textContent = toTitleCase(_(name)) ; - label.setAttribute( - "style", "font-size: 16px; color:platformColor.paletteText"); - } - - this._loadPaletteButtonHandler(name,row); + img.style.padding = "4px"; + img.style.boxSizing = "content-box"; + img.style.width = `${this.cellSize}px`; + img.style.height = `${this.cellSize}px`; + label.textContent = toTitleCase(_(name)); + label.style.color = platformColor.paletteText; + label.style.fontSize = localStorage.kanaPreference === "kana" ? "12px" : "16px"; + label.style.padding = "4px"; + row.style.display = "flex"; + row.style.flexDirection = "row"; + row.style.alignItems = "center"; + row.style.width = "126px"; + + this._loadPaletteButtonHandler(name, row); } showPalette(name) { @@ -281,8 +310,7 @@ class Palettes { this.dict[name].showMenu(true); } - _showMenus() { - } + _showMenus() {} _hideMenus() { // Hide the menu buttons and the palettes themselves. @@ -291,7 +319,6 @@ class Palettes { if (docById("PaletteBody")) docById("PaletteBody").parentNode.removeChild(docById("PaletteBody")); - } getInfo() { @@ -304,7 +331,7 @@ class Palettes { if (showPalette != null) { // Show the action palette after adding/deleting new // nameddo blocks. - if (showPalette in this.dict){ + if (showPalette in this.dict) { let wasOpen = false; if (docById("PaletteBody")) { wasOpen = true; @@ -344,30 +371,31 @@ class Palettes { _loadPaletteButtonHandler(name, row) { row.onmouseover = (evt) => { document.body.style.cursor = "pointer"; - } + }; row.onclick = (evt) => { if (name == "search") { this.showSearchWidget(); } else { - this.showPalette(name) + this.showPalette(name); } - } + }; row.onmouseup = (evt) => { document.body.style.cursor = "default"; - } + }; row.onmouseleave = (evt) => { document.body.style.cursor = "default"; - } - + }; } removeActionPrototype(actionName) { let blockRemoved = false; for (let blk = 0; blk < this.dict["action"].protoList.length; blk++) { let actionBlock = this.dict["action"].protoList[blk]; - if (["nameddo", "namedcalc", "nameddoArg", "namedcalcArg"].indexOf( - actionBlock.name) !== -1 && - actionBlock.defaults[0] === actionName) { + if ( + ["nameddo", "namedcalc", "nameddoArg", "namedcalcArg"].indexOf(actionBlock.name) !== + -1 && + actionBlock.defaults[0] === actionName + ) { // Remove the palette protoList entry for this block. this.dict["action"].remove(actionBlock, actionName); @@ -376,13 +404,10 @@ class Palettes { delete this.blocks.protoBlockDict["myDo_" + actionName]; } else if (this.blocks.protoBlockDict["myCalc_" + actionName]) { delete this.blocks.protoBlockDict["myCalc_" + actionName]; - } else if (this.blocks.protoBlockDict[ - "myDoArg_" + actionName]) { + } else if (this.blocks.protoBlockDict["myDoArg_" + actionName]) { delete this.blocks.protoBlockDict["myDoArg_" + actionName]; - } else if (this.blocks.protoBlockDict[ - "myCalcArg_" + actionName]) { - delete this.blocks.protoBlockDict[ - "myCalcArg_" + actionName]; + } else if (this.blocks.protoBlockDict["myCalcArg_" + actionName]) { + delete this.blocks.protoBlockDict["myCalcArg_" + actionName]; } blockRemoved = true; break; @@ -394,7 +419,6 @@ class Palettes { this.updatePalettes("action"); } } - } // Kind of a model, but it only keeps a list of SVGs @@ -721,77 +745,93 @@ class Palette { } hideMenu() { + docById("palette").childNodes[0].style.borderRight = + `1px solid ${platformColor.selectorSelected}`; this._hideMenuItems(); } showMenu(createHeader) { - - let palDiv = docById("palette"); - if (docById("PaletteBody")) - palDiv.removeChild(docById("PaletteBody")); - let x = document.createElement("table"); - x.setAttribute("id","PaletteBody"); - x.setAttribute("bgcolor","white"); - x.setAttribute("style","float: left"); - x.innerHTML = ''; - palDiv.appendChild(x); - - let buttonContainers = document.createDocumentFragment(); - let down = makePaletteIcons(DOWNICON,15,15); - down.style.position = "relative"; - down.style.left = "-10px"; - down.style.top = (window.innerHeight-this.palettes.top-this.palettes.cellSize-20)+"px"; - buttonContainers.appendChild(down); - - this.menuContainer=x ; - docById("PaletteBody_items").onscroll = () => { - let list = docById("PaletteBody_items"); - if( list.scrollTop >= (list.scrollHeight - list.offsetHeight)){ - down.style.visibility = "hidden"; - } else { - down.style.visibility = "visible"; - } - } + const palDiv = docById("palette"); + palDiv.childNodes[0].style.borderRight = "0"; + if (docById("PaletteBody")) palDiv.removeChild(docById("PaletteBody")); + const palBody = document.createElement("table"); + palBody.id = "PaletteBody"; + const palBodyHeight = window.innerHeight - this.palettes.top - this.palettes.cellSize - 26; + palBody.innerHTML = + ``; + palBody.style.minWidth = "180px"; + palBody.style.background = platformColor.paletteBackground; + palBody.style.float = "left"; + palBody.style.border = `1px solid ${platformColor.selectorSelected}`; + [palBody.childNodes[0], palBody.childNodes[1]].forEach((item) => { + item.style.boxSizing = "border-box"; + item.style.padding = "8px"; + }); + palDiv.appendChild(palBody); + + this.menuContainer = palBody; if (createHeader) { let header = this.menuContainer.children[0]; header = header.insertRow(); header.style.background = platformColor.selectorSelected; - header.innerHTML=''; + header.innerHTML = + ''; header = header.children[0]; - let closeImg = makePaletteIcons( - CLOSEICON.replace("fill_color", platformColor.selectorSelected), - this.palettes.cellSize, - this.palettes.cellSize, - ); - closeImg.onclick = () => { - palDiv.removeChild(x); - } - let labelImg = makePaletteIcons( + header.style.padding = "8px"; + + const labelImg = makePaletteIcons( PALETTEICONS[this.name], this.palettes.cellSize, - this.palettes.cellSize, + this.palettes.cellSize ); - closeImg.onmouseover = (evt) => { - document.body.style.cursor = "pointer"; - } - closeImg.onmouseleave = (evt) => { - document.body.style.cursor = "default"; - } + labelImg.style.borderRadius = "4px"; + labelImg.style.padding = "2px"; + labelImg.style.backgroundColor = platformColor.paletteBackground; header.appendChild(labelImg); - let label = document.createElement("span"); + const label = document.createElement("span"); label.textContent = toTitleCase(_(this.name)); + label.style.fontWeight = "bold"; + label.style.color = platformColor.paletteBackground; header.appendChild(label); - let closeDownImg = document.createElement("span"); + const closeDownImg = document.createElement("span"); + closeDownImg.style.height = `${this.palettes.cellSize}px`; + const closeImg = makePaletteIcons( + CLOSEICON.replace("fill_color", platformColor.selectorSelected), + this.palettes.cellSize, + this.palettes.cellSize + ); + closeImg.onclick = () => this.hideMenu(); + closeImg.onmouseover = () => document.body.style.cursor = "pointer"; + closeImg.onmouseleave = () => document.body.style.cursor = "default"; closeDownImg.appendChild(closeImg); - closeDownImg.appendChild(buttonContainers) ; - closeDownImg.style = "float: right;"; + header.appendChild(closeDownImg); + } - header.appendChild(closeDownImg) + const updateScrollBtnVisibility = () => { + const list = docById("PaletteBody_items"); + upBtn.style.opacity = list.scrollTop === 0 ? "0" : "0.3"; + dnBtn.style.opacity = + list.scrollTop >= list.scrollHeight - list.offsetHeight ? "0" : "0.3"; } + const buttonContainers = document.createDocumentFragment(); + const upBtn = makePaletteIcons(UPICON, this.palettes.cellSize, this.palettes.cellSize); + const dnBtn = makePaletteIcons(DOWNICON, this.palettes.cellSize, this.palettes.cellSize); + upBtn.style.position = dnBtn.style.position = "absolute"; + upBtn.style.right = dnBtn.style.right = "8px"; + upBtn.style.top = "42px"; + dnBtn.style.bottom = "0"; + upBtn.style.zIndex = dnBtn.style.zIndex = "10"; + upBtn.style.transition = dnBtn.style.transition = "opacity 0.5s ease"; + updateScrollBtnVisibility(); + docById("PaletteBody_items").onscroll = updateScrollBtnVisibility; + buttonContainers.appendChild(upBtn); + buttonContainers.appendChild(dnBtn); + palBody.appendChild(buttonContainers); + this._showMenuItems(); } @@ -804,11 +844,8 @@ class Palette { } _showMenuItems() { - this.model.update(); let paletteList = docById("PaletteBody_items"); - let padding = paletteList.insertRow(); - padding.style.height = "7px"; this.setupGrabScroll(paletteList); @@ -825,11 +862,7 @@ class Palette { } let itemRow = paletteList.insertRow(); let itemCell = itemRow.insertCell(); - let right = itemRow.insertCell(); - right.innerHTML ="   "; - let img = makePaletteIcons( - b.artwork - ); + let img = makePaletteIcons(b.artwork); // Use artwork.js strings as images for: // cameraPALETTE, videoPALETTE, mediaPALETTE @@ -837,19 +870,11 @@ class Palette { img = makePaletteIcons(eval(b.blkname+"PALETTE")); } - img.onmouseover = (evt) => { - document.body.style.cursor = "pointer"; - } - - img.onmouseleave = (evt) => { - document.body.style.cursor = "default"; - } + img.onmouseover = () => document.body.style.cursor = "pointer"; + img.onmouseleave = () => document.body.style.cursor = "default"; - // Image Drag initiates a browser defined drag, - // which needs to be stoped. - img.ondragstart = () => { - return false; - }; + // Image Drag initiates a browser defined drag, which needs to be stoped. + img.ondragstart = () => false; const down = (event) => { // (1) prepare to moving: make absolute and on top by z-index @@ -917,7 +942,8 @@ class Palette { img.ontouchstart = down; img.onmousedown = down; - itemCell.setAttribute("style","width: "+img.width+"px "); + itemCell.style.width = `${img.width}px`; + itemCell.style.paddingRight = `${this.palettes.cellSize}px`; itemCell.appendChild(img); } From 01967148f2477721288b79e7804f4d09cb732486 Mon Sep 17 00:00:00 2001 From: Anindya Kundu Date: Sat, 12 Dec 2020 03:44:49 +0530 Subject: [PATCH 06/11] Format code --- js/palette.js | 283 +++++++++++++++++++++++--------------------------- 1 file changed, 132 insertions(+), 151 deletions(-) diff --git a/js/palette.js b/js/palette.js index c4905dcca8..1cac542b5a 100644 --- a/js/palette.js +++ b/js/palette.js @@ -441,8 +441,7 @@ class PaletteModel { // } // Create a proto block for each palette entry. - this.blocks.push(this.makeBlockInfo(blk, block, block.name, - block.name)); + this.blocks.push(this.makeBlockInfo(blk, block, block.name, block.name)); } } @@ -618,14 +617,19 @@ class PaletteModel { } } - if (["do", - "nameddo", - "namedbox", - "namedcalc", - "doArg", - "calcArg", - "nameddoArg", - "namedcalcArg"].indexOf(protoBlock.name) != -1 && label != null) { + if ( + [ + "do", + "nameddo", + "namedbox", + "namedcalc", + "doArg", + "calcArg", + "nameddoArg", + "namedcalcArg" + ].indexOf(protoBlock.name) != -1 && + label != null + ) { if (getTextWidth(label, "bold 20pt Sans") > TEXTWIDTH) { label = label.substr(0, STRINGLEN) + "..."; } @@ -646,31 +650,31 @@ class PaletteModel { let height; switch (protoBlock.name) { case "namedbox": - case "namedarg": - // so the label will fit - svg = new SVG(); - svg.setScale(protoBlock.scale); - svg.setExpand(60, 0, 0, 0); - svg.setOutie(true); - artwork = svg.basicBox(); - docks = svg.docks; - height = svg.getHeight(); - break; - case "nameddo": - // so the label will fit - svg = new SVG(); - svg.setScale(protoBlock.scale); - svg.setExpand(60, 0, 0, 0); - artwork = svg.basicBlock(); - docks = svg.docks; - height = svg.getHeight(); - break; - default: - let obj = protoBlock.generator(); - artwork = obj[0]; - docks = obj[1]; - height = obj[3]; - break; + case "namedarg": + // so the label will fit + svg = new SVG(); + svg.setScale(protoBlock.scale); + svg.setExpand(60, 0, 0, 0); + svg.setOutie(true); + artwork = svg.basicBox(); + docks = svg.docks; + height = svg.getHeight(); + break; + case "nameddo": + // so the label will fit + svg = new SVG(); + svg.setScale(protoBlock.scale); + svg.setExpand(60, 0, 0, 0); + artwork = svg.basicBlock(); + docks = svg.docks; + height = svg.getHeight(); + break; + default: + let obj = protoBlock.generator(); + artwork = obj[0]; + docks = obj[1]; + height = obj[3]; + break; } protoBlock.scale = saveScale; @@ -682,16 +686,13 @@ class PaletteModel { .replace("block_label", safeSVG(label)); } else { artwork = artwork - .replace(/fill_color/g, - PALETTEFILLCOLORS[protoBlock.palette.name]) - .replace(/stroke_color/g, - PALETTESTROKECOLORS[protoBlock.palette.name]) + .replace(/fill_color/g, PALETTEFILLCOLORS[protoBlock.palette.name]) + .replace(/stroke_color/g, PALETTESTROKECOLORS[protoBlock.palette.name]) .replace("block_label", safeSVG(label)); } for (let i = 0; i <= protoBlock.args; i++) { - artwork = artwork.replace("arg_label_" + i, - protoBlock.staticLabels[i] || ""); + artwork = artwork.replace("arg_label_" + i, protoBlock.staticLabels[i] || ""); } return { @@ -702,8 +703,8 @@ class PaletteModel { actualHeight: height, label, artwork, - artwork64: "data:image/svg+xml;base64," + - window.btoa(unescape(encodeURIComponent(artwork))), + artwork64: + "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(artwork))), docks, image: block.image, scale: block.scale, @@ -745,8 +746,9 @@ class Palette { } hideMenu() { - docById("palette").childNodes[0].style.borderRight = - `1px solid ${platformColor.selectorSelected}`; + docById( + "palette" + ).childNodes[0].style.borderRight = `1px solid ${platformColor.selectorSelected}`; this._hideMenuItems(); } @@ -757,8 +759,7 @@ class Palette { const palBody = document.createElement("table"); palBody.id = "PaletteBody"; const palBodyHeight = window.innerHeight - this.palettes.top - this.palettes.cellSize - 26; - palBody.innerHTML = - ``; + palBody.innerHTML = ``; palBody.style.minWidth = "180px"; palBody.style.background = platformColor.paletteBackground; palBody.style.float = "left"; @@ -804,8 +805,8 @@ class Palette { this.palettes.cellSize ); closeImg.onclick = () => this.hideMenu(); - closeImg.onmouseover = () => document.body.style.cursor = "pointer"; - closeImg.onmouseleave = () => document.body.style.cursor = "default"; + closeImg.onmouseover = () => (document.body.style.cursor = "pointer"); + closeImg.onmouseleave = () => (document.body.style.cursor = "default"); closeDownImg.appendChild(closeImg); header.appendChild(closeDownImg); } @@ -815,7 +816,7 @@ class Palette { upBtn.style.opacity = list.scrollTop === 0 ? "0" : "0.3"; dnBtn.style.opacity = list.scrollTop >= list.scrollHeight - list.offsetHeight ? "0" : "0.3"; - } + }; const buttonContainers = document.createDocumentFragment(); const upBtn = makePaletteIcons(UPICON, this.palettes.cellSize, this.palettes.cellSize); @@ -839,8 +840,7 @@ class Palette { if (this.name === "search" && this.palettes.hideSearchWidget !== null) { this.palettes.hideSearchWidget(true); } - if (docById("PaletteBody")) - docById("palette").removeChild(docById("PaletteBody")); + if (docById("PaletteBody")) docById("palette").removeChild(docById("PaletteBody")); } _showMenuItems() { @@ -851,9 +851,8 @@ class Palette { let blocks = this.model.blocks; blocks.reverse(); - let protoListScope = [...this.protoList] ; - if (last(blocks).blkname != last(protoListScope).name) - protoListScope.reverse(); + let protoListScope = [...this.protoList]; + if (last(blocks).blkname != last(protoListScope).name) protoListScope.reverse(); for (let blk in blocks) { let b = blocks[blk]; @@ -866,21 +865,21 @@ class Palette { // Use artwork.js strings as images for: // cameraPALETTE, videoPALETTE, mediaPALETTE - if (b.image){ - img = makePaletteIcons(eval(b.blkname+"PALETTE")); + if (b.image) { + img = makePaletteIcons(eval(b.blkname + "PALETTE")); } - img.onmouseover = () => document.body.style.cursor = "pointer"; - img.onmouseleave = () => document.body.style.cursor = "default"; + img.onmouseover = () => (document.body.style.cursor = "pointer"); + img.onmouseleave = () => (document.body.style.cursor = "default"); // Image Drag initiates a browser defined drag, which needs to be stoped. img.ondragstart = () => false; const down = (event) => { // (1) prepare to moving: make absolute and on top by z-index - let posit = img.style.position ; - let zInd = img.style.zIndex ; - img.style.position = 'absolute'; + let posit = img.style.position; + let zInd = img.style.zIndex; + img.style.position = "absolute"; img.style.zIndex = 1000; // move it out of any current parents directly into body @@ -889,13 +888,13 @@ class Palette { // centers the img at (pageX, pageY) coordinates const moveAt = (pageX, pageY) => { - img.style.left = pageX - img.offsetWidth / 2 + 'px'; - img.style.top = pageY - img.offsetHeight / 2 + 'px'; - } + img.style.left = pageX - img.offsetWidth / 2 + "px"; + img.style.top = pageY - img.offsetHeight / 2 + "px"; + }; const onMouseMove = (e) => { let x, y; - if (e.type === "touchmove"){ + if (e.type === "touchmove") { x = e.touches[0].clientX; y = e.touches[0].clientY; } else { @@ -903,20 +902,20 @@ class Palette { y = e.pageY; } moveAt(x, y); - } + }; onMouseMove(event); - document.addEventListener('touchmove', onMouseMove); - document.addEventListener('mousemove', onMouseMove); + document.addEventListener("touchmove", onMouseMove); + document.addEventListener("mousemove", onMouseMove); - const up = (event) => { + const up = (event) => { document.body.style.cursor = "default"; - document.removeEventListener('mousemove', onMouseMove); + document.removeEventListener("mousemove", onMouseMove); img.onmouseup = null; let x, y; - x = parseInt (img.style.left); - y = parseInt (img.style.top); + x = parseInt(img.style.left); + y = parseInt(img.style.top); img.style.position = posit; img.style.zIndex = zInd; @@ -950,14 +949,13 @@ class Palette { if (this.palettes.mobile) { this.hide(); } - } setupGrabScroll(paletteList) { - let posY,top; + let posY, top; const mouseUpGrab = (evt) => { - paletteList.onmousemove= null ; + paletteList.onmousemove = null; document.body.style.cursor = "default"; }; const mouseMoveGrab = (evt) => { @@ -969,9 +967,9 @@ class Palette { posY = evt.clientY; top = paletteList.scrollTop; - paletteList.onmousemove = mouseMoveGrab; - paletteList.onmouseup = mouseUpGrab; - paletteList.onmouseleave = mouseUpGrab; + paletteList.onmousemove = mouseMoveGrab; + paletteList.onmouseup = mouseUpGrab; + paletteList.onmouseleave = mouseUpGrab; }; paletteList.onmousedown = mouseDownGrab; } @@ -992,26 +990,29 @@ class Palette { } for (let i = 0; i < this.model.blocks.length; i++) { - if (["nameddo", "nameddoArg", "namedcalc", "namedcalcArg"].indexOf( - this.model.blocks[i].blkname) !== -1 && - this.model.blocks[i].modname === name) { + if ( + ["nameddo", "nameddoArg", "namedcalc", "namedcalcArg"].indexOf( + this.model.blocks[i].blkname + ) !== -1 && + this.model.blocks[i].modname === name + ) { this.model.blocks.splice(i, 1); break; } else if ( ["storein"].indexOf(this.model.blocks[i].blkname) !== -1 && - this.model.blocks[i].modname === _("store in") + " " + name) { + this.model.blocks[i].modname === _("store in") + " " + name + ) { this.model.blocks.splice(i, 1); break; } } - } add(protoblock, top) { // Add a new palette entry to the end of the list (default) or // to the top. if (this.protoList.indexOf(protoblock) === -1) { - if (top)this.protoList.push(protoblock); + if (top) this.protoList.push(protoblock); else this.protoList.push(protoblock); } return this; @@ -1044,8 +1045,9 @@ class Palette { break; case "storein2": // Use the name of the box in the label - console.debug("storein2" + " " + protoblk.defaults[0] + " " + - protoblk.staticLabels[0]); + console.debug( + "storein2" + " " + protoblk.defaults[0] + " " + protoblk.staticLabels[0] + ); blkname = "store in2 " + protoblk.defaults[0]; newBlk = protoblk.name; arg = protoblk.staticLabels[0]; @@ -1146,48 +1148,29 @@ class Palette { let lastBlock = this.palettes.blocks.blockList.length; - if (["namedbox", - "nameddo", - "namedcalc", - "nameddoArg", - "namedcalcArg"].indexOf(protoblk.name) === -1 && - blockIsMacro(blkname)) { - this._makeBlockFromProtoblock( - protoblk, - true, - blkname, - null, - 100, - 100 - ); + if ( + ["namedbox", "nameddo", "namedcalc", "nameddoArg", "namedcalcArg"].indexOf( + protoblk.name + ) === -1 && + blockIsMacro(blkname) + ) { + this._makeBlockFromProtoblock(protoblk, true, blkname, null, 100, 100); callback(lastBlock); - } else if (["namedbox", - "nameddo", - "namedcalc", - "nameddoArg", - "namedcalcArg"].indexOf(protoblk.name) === -1 && - blkname in this.palettes.pluginMacros) { - this._makeBlockFromProtoblock( - protoblk, - true, - blkname, - null, - 100, - 100 - ); + } else if ( + ["namedbox", "nameddo", "namedcalc", "nameddoArg", "namedcalcArg"].indexOf( + protoblk.name + ) === -1 && + blkname in this.palettes.pluginMacros + ) { + this._makeBlockFromProtoblock(protoblk, true, blkname, null, 100, 100); callback(lastBlock); } else { - let newBlock = paletteBlockButtonPush( - this.palettes.blocks, - newBlk, - arg - ); + let newBlock = paletteBlockButtonPush(this.palettes.blocks, newBlk, arg); callback(newBlock); } } - _makeBlockFromProtoblock( - protoblk, moved, blkname, event, saveX, saveY) { + _makeBlockFromProtoblock(protoblk, moved, blkname, event, saveX, saveY) { let newBlock; const __myCallback = (newBlock) => { @@ -1195,29 +1178,35 @@ class Palette { this.palettes.blocks.findDragGroup(newBlock); for (let i in this.palettes.blocks.dragGroup) { this.palettes.blocks.moveBlockRelative( - this.palettes.blocks.dragGroup[i], saveX, saveY); + this.palettes.blocks.dragGroup[i], + saveX, + saveY + ); } // Dock with other blocks if needed this.palettes.blocks.blockMoved(newBlock); this.palettes.blocks.checkBounds(); - } + }; if (moved) { moved = false; this.draggingProtoBlock = false; let macroExpansion = null; - if (["namedbox", - "nameddo", - "namedcalc", - "nameddoArg", - "namedcalcArg"].indexOf(protoblk.name) === -1) { + if ( + ["namedbox", "nameddo", "namedcalc", "nameddoArg", "namedcalcArg"].indexOf( + protoblk.name + ) === -1 + ) { macroExpansion = getMacroExpansion(blkname, saveX, saveY); if (macroExpansion === null) { // Maybe it is a plugin macro? if (blkname in this.palettes.pluginMacros) { macroExpansion = this.palettes.getPluginMacroExpansion( - blkname, saveX, saveY); + blkname, + saveX, + saveY + ); } } } @@ -1232,8 +1221,7 @@ class Palette { // We need to copy the macro data so it is not overwritten. let obj = []; - for (let b = 0; b < this.palettes.macroDict[macroName].length; - b++) { + for (let b = 0; b < this.palettes.macroDict[macroName].length; b++) { let valueEntry = this.palettes.macroDict[macroName][b][1]; let newValue = []; if (typeof valueEntry === "string") { @@ -1248,16 +1236,13 @@ class Palette { if (valueEntry[0] === "number") { newValue = [valueEntry[0], valueEntry[1]]; } else { - newValue = [valueEntry[0], - valueEntry[1].toString()]; + newValue = [valueEntry[0], valueEntry[1].toString()]; } } else { if (valueEntry[0] === "number") { - newValue = [valueEntry[0], - Number(valueEntry[1]["value"])]; + newValue = [valueEntry[0], Number(valueEntry[1]["value"])]; } else { - newValue = [valueEntry[0], - {value: valueEntry[1]["value"]}]; + newValue = [valueEntry[0], { value: valueEntry[1]["value"] }]; } } @@ -1273,8 +1258,8 @@ class Palette { // Set the position of the top block in the stack // before loading. - obj[0][2] = saveX - obj[0][3] = saveY + obj[0][2] = saveX; + obj[0][3] = saveY; this.palettes.blocks.loadNewBlocks(obj); // Ensure collapse state of new stack is set properly. @@ -1284,12 +1269,10 @@ class Palette { this.palettes.blocks.blockList[topBlk].collapseToggle(); }, 500); } else { - newBlock = this._makeBlockFromPalette( - protoblk, blkname, __myCallback); + newBlock = this._makeBlockFromPalette(protoblk, blkname, __myCallback); } } - }; - + } } async function initPalettes(palettes) { @@ -1310,12 +1293,10 @@ const MODEDRAG = 1; const MODESCROLL = 2; const DECIDEDISTANCE = 20; -function makePaletteIcons(data,width,height) { +function makePaletteIcons(data, width, height) { let img = new Image(); - img.src = - "data:image/svg+xml;base64," + - window.btoa(unescape(encodeURIComponent(data))); - if (width)img.width=width; - if (height)img.height=height; - return img + img.src = "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(data))); + if (width) img.width = width; + if (height) img.height = height; + return img; } From df804e0804c30ce6a67fabfa9652fbc3a3866625 Mon Sep 17 00:00:00 2001 From: Kumar Saurabh Raj <39027928+ksraj123@users.noreply.github.com> Date: Sat, 12 Dec 2020 14:41:30 +0530 Subject: [PATCH 07/11] Port widgets/modewidget.js to ES6 * widgets/modewidget - port to es6 * widgets/modewidget - fixes #2594 * widgets/modeWidget - removes redundant _logo, global instance used * logo - _modeBlock to modeBlock * widgets/modeWidget - made constants static * widgets/modeWidget - format code * widgets/modeWidget - added some jsDocs style docs * widgets/modewidget - suggested changes --- js/blocks/IntervalsBlocks.js | 2 +- js/blocks/WidgetBlocks.js | 10 +- js/logo.js | 4 +- js/piemenus.js | 2 +- js/widgets/meterwidget.js | 3 + js/widgets/modewidget.js | 801 ++++++++++++++++------------------ js/widgets/musickeyboard.js | 3 + js/widgets/pitchdrummatrix.js | 3 + js/widgets/temperament.js | 3 + js/widgets/timbre.js | 3 + 10 files changed, 399 insertions(+), 435 deletions(-) diff --git a/js/blocks/IntervalsBlocks.js b/js/blocks/IntervalsBlocks.js index 209f7034a7..eb094043ad 100644 --- a/js/blocks/IntervalsBlocks.js +++ b/js/blocks/IntervalsBlocks.js @@ -795,7 +795,7 @@ function setupIntervalsBlocks() { flow(args, logo, turtle, blk) { if (args.length === 2) { let modename = Singer.IntervalsActions.GetModename(args[1]); - logo._modeBlock = blocks.blockList[blk].connections[2]; + logo.modeBlock = blocks.blockList[blk].connections[2]; Singer.IntervalsActions.setKey(args[0], args[1], turtle, blk); diff --git a/js/blocks/WidgetBlocks.js b/js/blocks/WidgetBlocks.js index 4b629f04b5..574f67ea38 100644 --- a/js/blocks/WidgetBlocks.js +++ b/js/blocks/WidgetBlocks.js @@ -461,17 +461,13 @@ function setupWidgetBlocks() { } flow(args, logo, turtle, blk) { - if (logo.modeWidget === null) { - logo.modeWidget = new ModeWidget(); - } - logo.insideModeWidget = true; - + let listenerName = "_modewidget_" + turtle; logo.setDispatchBlock(blk, turtle, listenerName); - + let __listener = function(event) { - logo.modeWidget.init(logo, logo._modeBlock); + logo.modeWidget = new ModeWidget(); logo.insideModeWidget = false; }; diff --git a/js/logo.js b/js/logo.js index 01a716411d..27646f71fd 100644 --- a/js/logo.js +++ b/js/logo.js @@ -180,7 +180,7 @@ class Logo { } // Mode widget - this._modeBlock = null; + this.modeBlock = null; // Meter widget this._meterBlock = null; @@ -1236,7 +1236,7 @@ class Logo { this.pitchBlocks = []; this.drumBlocks = []; this.tuplet = false; - this._modeBlock = null; + this.modeBlock = null; this._meterBlock = null; // Remove any listeners that might be still active diff --git a/js/piemenus.js b/js/piemenus.js index 937af77e35..a68a5ce601 100644 --- a/js/piemenus.js +++ b/js/piemenus.js @@ -321,7 +321,7 @@ piemenuPitches = function( if (that.connections[0] !== null && ["setkey", "setkey2"].indexOf( that.blocks.blockList[that.connections[0]].name) !== -1) { // We may need to update the mode widget. - that.blocks.logo._modeBlock = that.blocks.blockList.indexOf(that); + that.blocks.logo.modeBlock = that.blocks.blockList.indexOf(that); } __pitchPreview(); }; diff --git a/js/widgets/meterwidget.js b/js/widgets/meterwidget.js index a94cdac31f..37d9a33324 100644 --- a/js/widgets/meterwidget.js +++ b/js/widgets/meterwidget.js @@ -234,6 +234,9 @@ function MeterWidget() { this.__playOneBeat(0, noteBeatValue); }; + /** + * @deprecated + */ this._addButton = (row, icon, iconSize, label) => { let cell = row.insertCell(-1); cell.innerHTML = diff --git a/js/widgets/modewidget.js b/js/widgets/modewidget.js index 82cd24c3ae..893e4a3484 100644 --- a/js/widgets/modewidget.js +++ b/js/widgets/modewidget.js @@ -9,152 +9,127 @@ // License along with this library; if not, write to the Free Software // Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA -function ModeWidget() { - const ROTATESPEED = 125; - const BUTTONDIVWIDTH = 535; - const BUTTONSIZE = 53; - const ICONSIZE = 32; - - this.init = function(logo, modeBlock) { - this._logo = logo; - this._modeBlock = modeBlock; +class ModeWidget { + static ICONSIZE = 32; + static BUTTONSIZE = 53; + static ROTATESPEED = 125; + static BUTTONDIVWIDTH = 535; + + constructor() { + this._modeBlock = logo.modeBlock; this._locked = false; - this._pitch = this._logo.turtles.ithTurtle(0).singer.keySignature[0]; + this._pitch = turtles.ithTurtle(0).singer.keySignature[0]; this._noteValue = 0.333; this._undoStack = []; this._playing = false; this._selectedNotes = []; this._newPattern = []; - let w = window.innerWidth; + const w = window.innerWidth; this._cellScale = w / 1200; - let iconSize = ICONSIZE * this._cellScale; + const iconSize = ModeWidget.ICONSIZE * this._cellScale; - let widgetWindow = window.widgetWindows.windowFor(this, "custom mode"); - this.widgetWindow = widgetWindow; - widgetWindow.clear(); - widgetWindow.show(); - - // For the button callbacks - let that = this; + this.widgetWindow = window.widgetWindows.windowFor(this, "custom mode"); + this.widgetWindow.clear(); + this.widgetWindow.show(); + // The mode table (holds a pie menu and a label) this.modeTableDiv = document.createElement("div"); - widgetWindow.getWidgetBody().append(this.modeTableDiv); - - widgetWindow.onclose = function() { - that._logo.hideMsgs(); - this.destroy(); + this.modeTableDiv.style.display = "inline"; + this.modeTableDiv.style.visibility = "visible"; + this.modeTableDiv.style.border = "0px"; + this.modeTableDiv.innerHTML = '
    '; + this.modeTableDiv.innerHTML += '
    '; + this.modeTableDiv.innerHTML += '
    '; + + this.widgetWindow.getWidgetBody().append(this.modeTableDiv); + + this.widgetWindow.onclose = () => { + logo.hideMsgs(); + this.widgetWindow.destroy(); }; - this._playButton = widgetWindow.addButton( + this._playButton = this.widgetWindow.addButton( "play-button.svg", - ICONSIZE, + ModeWidget.ICONSIZE, _("Play") ); - this._playButton.onclick = function() { - that._logo.resetSynth(0); - if (that._playingStatus()) { - that._playing = false; + this._playButton.onclick = () => { + logo.resetSynth(0); + if (this._playingStatus()) { + this._playing = false; - this.innerHTML = + this._playButton.innerHTML = '  ' +
                     _(  '; } else { - that._playing = true; + this._playing = true; - this.innerHTML = + this._playButton.innerHTML = '  ' +
                     _(  '; - that._playAll(); + this._playAll(); } }; - widgetWindow.addButton( + this.widgetWindow.addButton( "export-chunk.svg", - ICONSIZE, + ModeWidget.ICONSIZE, _("Save") - ).onclick = function() { - that._save(); - }; + ).onclick = this._save.bind(this); - widgetWindow.addButton( + this.widgetWindow.addButton( "erase-button.svg", - ICONSIZE, + ModeWidget.ICONSIZE, _("Clear") - ).onclick = function() { - that._clear(); - }; + ).onclick = this._clear.bind(this); - widgetWindow.addButton( + this.widgetWindow.addButton( "rotate-left.svg", - ICONSIZE, + ModeWidget.ICONSIZE, _("Rotate counter clockwise") - ).onclick = function() { - that._rotateLeft(); - }; + ).onclick = this._rotateLeft.bind(this); - widgetWindow.addButton( + this.widgetWindow.addButton( "rotate-right.svg", - ICONSIZE, + ModeWidget.ICONSIZE, _("Rotate clockwise") - ).onclick = function() { - that._rotateRight(); - }; + ).onclick = this._rotateRight.bind(this); - widgetWindow.addButton( + this.widgetWindow.addButton( "invert.svg", - ICONSIZE, + ModeWidget.ICONSIZE, _("Invert") - ).onclick = function() { - that._invert(); - }; + ).onclick = this._invert.bind(this); - widgetWindow.addButton( + this.widgetWindow.addButton( "restore-button.svg", - ICONSIZE, + ModeWidget.ICONSIZE, _("Undo") - ).onclick = function() { - that._undo(); - }; - - // The mode table (holds a pie menu and a label) - let modeTableDiv = this.modeTableDiv; - modeTableDiv.style.display = "inline"; - modeTableDiv.style.visibility = "visible"; - modeTableDiv.style.border = "0px"; - // modeTableDiv.innerHTML = '
    '; - modeTableDiv.innerHTML = '
    '; - modeTableDiv.innerHTML += '
    '; - modeTableDiv.innerHTML += '
    '; + ).onclick = this._undo.bind(this); this._piemenuMode(); - let table = docById("modeTable"); + const table = docById("modeTable"); - /* - // Set up the pie menu - let row = table.insertRow(); - let cell = row.insertCell(); - cell.innerHTML = '
    '; - */ // A row for the current mode label - let row = table.insertRow(); - let cell = row.insertCell(); + const row = table.insertRow(); + const cell = row.insertCell(); // cell.colSpan = 18; cell.innerHTML = " "; cell.style.backgroundColor = platformColor.selectorBackground; @@ -163,18 +138,23 @@ function ModeWidget() { this._setMode(); //.TRANS: A circle of notes represents the musical mode. - this._logo.textMsg( - _("Click in the circle to select notes for the mode.") - ); - widgetWindow.sendToCenter(); - }; - - this._playingStatus = function() { + logo.textMsg(_("Click in the circle to select notes for the mode.")); + setTimeout(this.widgetWindow.sendToCenter, 0); + } + + /** + * @private + * @returns {boolean} + */ + _playingStatus() { return this._playing; - }; + } - this._addButton = function(row, icon, iconSize, label) { - let cell = row.insertCell(-1); + /** + * @deprecated + */ + _addButton(row, icon, iconSize, label) { + const cell = row.insertCell(-1); cell.innerHTML = '    '; - cell.style.width = BUTTONSIZE + "px"; + cell.style.width = ModeWidget.BUTTONSIZE + "px"; cell.style.minWidth = cell.style.width; cell.style.maxWidth = cell.style.width; cell.style.height = cell.style.width; @@ -195,34 +175,36 @@ function ModeWidget() { cell.style.maxHeight = cell.style.height; cell.style.backgroundColor = platformColor.selectorBackground; - cell.onmouseover = function() { + cell.onmouseover = function () { this.style.backgroundColor = platformColor.selectorBackgroundHOVER; }; - cell.onmouseout = function() { + cell.onmouseout = function () { this.style.backgroundColor = platformColor.selectorBackground; }; return cell; - }; + } - this._setMode = function() { + /** + * @private + * @returns {void} + */ + _setMode() { // Read in the current mode to start - let currentModeName = - keySignatureToMode(this._logo.turtles.ithTurtle(0).singer.keySignature); - let currentMode = MUSICALMODES[currentModeName[1]]; + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); + const currentMode = MUSICALMODES[currentModeName[1]]; // Add the mode name in the bottom row of the table. - let table = docById("modeTable"); - let n = table.rows.length - 1; + const table = docById("modeTable"); + const n = table.rows.length - 1; console.debug(_(currentModeName[1])); - let name = currentModeName[0] + " " + _(currentModeName[1]); + const name = currentModeName[0] + " " + _(currentModeName[1]); table.rows[n].cells[0].innerHTML = name; this.widgetWindow.updateTitle(name); // Set the notes for this mode. - let that = this; let k = 0; let j = 0; for (let i = 0; i < 12; i++) { @@ -239,10 +221,14 @@ function ModeWidget() { if (currentModeName[0] === "C") { this._showPiano(); } - }; - - this._showPiano = function() { - let modePianoDiv = docById("modePianoDiv"); + } + + /** + * @private + * @returns {void} + */ + _showPiano() { + const modePianoDiv = docById("modePianoDiv"); modePianoDiv.style.display = "inline"; modePianoDiv.style.visibility = "visible"; modePianoDiv.style.border = "0px"; @@ -250,7 +236,7 @@ function ModeWidget() { modePianoDiv.style.left = "0px"; modePianoDiv.innerHTML = ''; - let highlightImgs = [ + const highlightImgs = [ "images/highlights/sel_c.png", "images/highlights/sel_c_sharp.png", "images/highlights/sel_d.png", @@ -264,32 +250,30 @@ function ModeWidget() { "images/highlights/sel_a_sharp.png", "images/highlights/sel_b.png" ]; - let currentModeName = - keySignatureToMode(this._logo.turtles.ithTurtle(0).singer.keySignature); - let letterName = currentModeName[0]; - let modeName = currentModeName[1]; + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); + const letterName = currentModeName[0]; - let startDict = { + const startDict = { "C♭": 11, - C: 0, + "C": 0, "C♯": 1, "D♭": 1, - D: 2, + "D": 2, "D♯": 3, "E♭": 3, - E: 4, + "E": 4, "E♯": 5, "F♭": 4, - F: 5, + "F": 5, "F♯": 6, "G♭": 6, - G: 7, + "G": 7, "G♯": 8, "A♭": 8, - A: 9, + "A": 9, "A♯": 10, "A♭": 10, - B: 11, + "B": 11, "B♯": 0 }; let startingPosition; @@ -329,9 +313,12 @@ function ModeWidget() { document.getElementById("pkey_" + i).src = highlightImgs[(i + startingPosition) % 12]; } - }; - - this._invert = function() { + } + /** + * @private + * @returns {void} + */ + _invert() { if (this._locked) { return; } @@ -340,15 +327,19 @@ function ModeWidget() { this._saveState(); this.__invertOnePair(1); - let currentModeName = - keySignatureToMode(this._logo.turtles.ithTurtle(0).singer.keySignature); + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); if (currentModeName[0] === "C") { this._showPiano(); } - }; - - this.__invertOnePair = function(i) { - let tmp = this._selectedNotes[i]; + } + + /** + * @private + * @param {number} i + * @returns {void} + */ + __invertOnePair(i) { + const tmp = this._selectedNotes[i]; this._selectedNotes[i] = this._selectedNotes[12 - i]; if (this._selectedNotes[i]) { this._noteWheel.navItems[i].navItem.show(); @@ -366,52 +357,57 @@ function ModeWidget() { if (i === 5) { this._saveState(); this._setModeName(); - let currentModeName = keySignatureToMode( - this._logo.turtles.ithTurtle(0).singer.keySignature - ); + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); if (currentModeName[0] === "C") { this._showPiano(); } this._locked = false; } else { - let that = this; - - setTimeout(function() { - that.__invertOnePair(i + 1); - }, ROTATESPEED); + setTimeout(() => { + this.__invertOnePair(i + 1); + }, ModeWidget.ROTATESPEED); } - }; + } - this._resetNotes = function() { + /** + * @private + * @returns {void} + */ + _resetNotes() { for (let i = 0; i < this._selectedNotes.length; i++) { if (this._selectedNotes[i]) { this._noteWheel.navItems[i].navItem.show(); } else { this._noteWheel.navItems[i].navItem.hide(); } - this._playWheel.navItems[i].navItem.hide(); } - }; + } - this._rotateRight = function() { + /** + * @private + * @returns {void} + */ + _rotateRight() { if (this._locked) { return; } - this._locked = true; - this._saveState(); this._newPattern = []; this._newPattern.push(this._selectedNotes[11]); for (let i = 0; i < 11; i++) { this._newPattern.push(this._selectedNotes[i]); } - this.__rotateRightOneCell(1); - }; - - this.__rotateRightOneCell = function(i, cellColors) { + } + + /** + * @private + * @param {number} i + * @returns {void} + */ + __rotateRightOneCell(i) { this._selectedNotes[i] = this._newPattern[i]; if (this._selectedNotes[i]) { this._noteWheel.navItems[i].navItem.show(); @@ -419,35 +415,37 @@ function ModeWidget() { this._noteWheel.navItems[i].navItem.hide(); } - let that = this; - if (i === 0) { - setTimeout(function() { - if (that._selectedNotes[0]) { + setTimeout(() => { + if (this._selectedNotes[0]) { // We are done. - that._saveState(); - that._setModeName(); - let currentModeName = keySignatureToMode( - that._logo.turtles.ithTurtle(0).singer.keySignature + this._saveState(); + this._setModeName(); + const currentModeName = keySignatureToMode( + turtles.ithTurtle(0).singer.keySignature ); if (currentModeName[0] === "C") { - that._showPiano(); + this._showPiano(); } - that._locked = false; + this._locked = false; } else { // Keep going until first note is selected. - that._locked = false; - that._rotateRight(); + this._locked = false; + this._rotateRight(); } - }, ROTATESPEED); + }, ModeWidget.ROTATESPEED); } else { - setTimeout(function() { - that.__rotateRightOneCell((i + 1) % 12); - }, ROTATESPEED); + setTimeout(() => { + this.__rotateRightOneCell((i + 1) % 12); + }, ModeWidget.ROTATESPEED); } - }; + } - this._rotateLeft = function() { + /** + * @private + * @returns {void} + */ + _rotateLeft() { if (this._locked) { return; } @@ -463,9 +461,14 @@ function ModeWidget() { this._newPattern.push(this._selectedNotes[0]); this.__rotateLeftOneCell(11); - }; - - this.__rotateLeftOneCell = function(i) { + } + + /** + * @private + * @param {number} i + * @returns {void} + */ + __rotateLeftOneCell(i) { this._selectedNotes[i] = this._newPattern[i]; if (this._selectedNotes[i]) { this._noteWheel.navItems[i].navItem.show(); @@ -473,41 +476,43 @@ function ModeWidget() { this._noteWheel.navItems[i].navItem.hide(); } - let that = this; - if (i === 0) { - setTimeout(function() { - if (that._selectedNotes[0]) { + setTimeout(() => { + if (this._selectedNotes[0]) { // We are done. - that._saveState(); - that._setModeName(); - let currentModeName = keySignatureToMode( - that._logo.turtles.ithTurtle(0).singer.keySignature + this._saveState(); + this._setModeName(); + const currentModeName = keySignatureToMode( + turtles.ithTurtle(0).singer.keySignature ); if (currentModeName[0] === "C") { - that._showPiano(); + this._showPiano(); } - that._locked = false; + this._locked = false; } else { // Keep going until first note is selected. - that._locked = false; - that._rotateLeft(); + this._locked = false; + this._rotateLeft(); } - }, ROTATESPEED); + }, ModeWidget.ROTATESPEED); } else { - setTimeout(function() { - that.__rotateLeftOneCell(i - 1); - }, ROTATESPEED); + setTimeout(() => { + this.__rotateLeftOneCell(i - 1); + }, ModeWidget.ROTATESPEED); } - }; + } - this._playAll = function() { + /** + * @private + * @returns {void} + */ + _playAll() { // Play all of the notes in the widget. if (this._locked) { return; } - this._logo.synth.stop(); + logo.synth.stop(); this._locked = true; // Make a list of notes to play @@ -534,10 +539,15 @@ function ModeWidget() { if (this._playing) { this.__playNextNote(0); } - }; - - this.__playNextNote = function(i) { - let highlightImgs = [ + } + + /** + * @private + * @param {number} i - note to play + * @returns {void} + */ + __playNextNote(i) { + const highlightImgs = [ "images/highlights/sel_c.png", "images/highlights/sel_c_sharp.png", "images/highlights/sel_d.png", @@ -552,7 +562,7 @@ function ModeWidget() { "images/highlights/sel_b.png" ]; - let animationImgs = [ + const animationImgs = [ "images/animations/sel_c1.png", "images/animations/sel_c_sharp1.png", "images/animations/sel_d1.png", @@ -567,172 +577,138 @@ function ModeWidget() { "images/animations/sel_b1.png" ]; - let startingposition = 0; - time = this._noteValue + 0.125; - let that = this; + const startingposition = 0; + const time = this._noteValue + 0.125; - let currentKey = - keySignatureToMode(this._logo.turtles.ithTurtle(0).singer.keySignature)[0]; + const currentKey = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature)[0]; if (currentKey === "C") { if (i > this._notesToPlay.length - 1) { - setTimeout(function() { + setTimeout(() => { // Did we just play the last note? - that._playing = false; - let note_key = document.getElementById("pkey_" + 0); + this._playing = false; + const note_key = document.getElementById("pkey_" + 0); if (note_key !== null) { note_key.src = highlightImgs[0]; } - that._playButton.innerHTML = + this._playButton.innerHTML = '  ' +
                         _(  '; - that._resetNotes(); - that._locked = false; + this._resetNotes(); + this._locked = false; }, 1000 * time); return; } - setTimeout(function() { - if (that._lastNotePlayed !== null) { - that._playWheel.navItems[ - that._lastNotePlayed % 12 - ].navItem.hide(); - let note_key = document.getElementById( - "pkey_" + (that._lastNotePlayed % 12) - ); + setTimeout(() => { + if (this._lastNotePlayed !== null) { + this._playWheel.navItems[this._lastNotePlayed % 12].navItem.hide(); + const note_key = document.getElementById("pkey_" + (this._lastNotePlayed % 12)); if (note_key !== null) { note_key.src = - highlightImgs[ - (that._lastNotePlayed + startingposition) % 12 - ]; + highlightImgs[(this._lastNotePlayed + startingposition) % 12]; } } - note = that._notesToPlay[i]; - that._playWheel.navItems[note % 12].navItem.show(); + const note = this._notesToPlay[i]; + this._playWheel.navItems[note % 12].navItem.show(); if (note !== 12) { - let note_key = document.getElementById( - "pkey_" + (note % 12) - ); + const note_key = document.getElementById("pkey_" + (note % 12)); if (note_key !== null) { - note_key.src = - animationImgs[(note + startingposition) % 12]; + note_key.src = animationImgs[(note + startingposition) % 12]; } } - that._lastNotePlayed = note; - let ks = that._logo.turtles.ithTurtle(0).singer.keySignature; - let noteToPlay = getNote( - that._pitch, - 4, - note, - ks, - false, - null, - that._logo.errorMsg - ); - that._logo.synth.trigger( + this._lastNotePlayed = note; + const ks = turtles.ithTurtle(0).singer.keySignature; + const noteToPlay = getNote(this._pitch, 4, note, ks, false, null, logo.errorMsg); + logo.synth.trigger( 0, - noteToPlay[0].replace(/♯/g, "#").replace(/♭/g, "b") + - noteToPlay[1], - that._noteValue, + noteToPlay[0].replace(/♯/g, "#").replace(/♭/g, "b") + noteToPlay[1], + this._noteValue, DEFAULTVOICE, null, null ); - if (that._playing) { - that.__playNextNote(i + 1); + if (this._playing) { + this.__playNextNote(i + 1); } else { - that._locked = false; - setTimeout(that._resetNotes(), 500); + this._locked = false; + setTimeout(this._resetNotes(), 500); return; } }, 1000 * time); } else { if (i > this._notesToPlay.length - 1) { - setTimeout(function() { + setTimeout(() => { // Did we just play the last note? - that._playing = false; - that._playButton.innerHTML = + this._playing = false; + this._playButton.innerHTML = '  ' +
                         _(  '; - that._resetNotes(); - that._locked = false; + this._resetNotes(); + this._locked = false; }, 1000 * time); return; } - setTimeout(function() { - if (that._lastNotePlayed !== null) { - that._playWheel.navItems[ - that._lastNotePlayed % 12 - ].navItem.hide(); + setTimeout(() => { + if (this._lastNotePlayed !== null) { + this._playWheel.navItems[this._lastNotePlayed % 12].navItem.hide(); } - note = that._notesToPlay[i]; - that._playWheel.navItems[note % 12].navItem.show(); - that._lastNotePlayed = note; - - let ks = that._logo.turtles.ithTurtle(0).singer.keySignature; - let noteToPlay = getNote( - that._pitch, - 4, - note, - ks, - false, - null, - that._logo.errorMsg - ); - that._logo.synth.trigger( + const note = this._notesToPlay[i]; + this._playWheel.navItems[note % 12].navItem.show(); + this._lastNotePlayed = note; + + const ks = turtles.ithTurtle(0).singer.keySignature; + const noteToPlay = getNote(this._pitch, 4, note, ks, false, null, logo.errorMsg); + logo.synth.trigger( 0, - noteToPlay[0].replace(/♯/g, "#").replace(/♭/g, "b") + - noteToPlay[1], - that._noteValue, + noteToPlay[0].replace(/♯/g, "#").replace(/♭/g, "b") + noteToPlay[1], + this._noteValue, DEFAULTVOICE, null, null ); - if (that._playing) { - that.__playNextNote(i + 1); + if (this._playing) { + this.__playNextNote(i + 1); } else { - that._locked = false; - setTimeout(that._resetNotes(), 500); + this._locked = false; + setTimeout(this._resetNotes(), 500); return; } }, 1000 * time); } - }; - - this._playNote = function(i) { - let ks = this._logo.turtles.ithTurtle(0).singer.keySignature; - - let noteToPlay = getNote( - this._pitch, - 4, - i, - ks, - false, - null, - this._logo.errorMsg - ); - this._logo.synth.trigger( + } + + /** + * @private + * @param {number} i - note to play + * @returns {void} + */ + _playNote(i) { + const ks = turtles.ithTurtle(0).singer.keySignature; + + const noteToPlay = getNote(this._pitch, 4, i, ks, false, null, logo.errorMsg); + logo.synth.trigger( 0, noteToPlay[0].replace(/♯/g, "#").replace(/♭/g, "b") + noteToPlay[1], this._noteValue, @@ -740,33 +716,44 @@ function ModeWidget() { null, null ); - }; - - this._saveState = function() { - state = JSON.stringify(this._selectedNotes); + } + + /** + * @private + * @returns {void} + */ + _saveState() { + const state = JSON.stringify(this._selectedNotes); if (state !== last(this._undoStack)) { this._undoStack.push(JSON.stringify(this._selectedNotes)); } - }; + } - this._undo = function() { + /** + * @private + * @returns {void} + */ + _undo() { if (this._undoStack.length > 0) { - let prevState = JSON.parse(this._undoStack.pop()); + const prevState = JSON.parse(this._undoStack.pop()); for (let i = 0; i < 12; i++) { this._selectedNotes[i] = prevState[i]; } this._resetNotes(); this._setModeName(); - let currentModeName = - keySignatureToMode(this._logo.turtles.ithTurtle(0).singer.keySignature); + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); if (currentModeName[0] === "C") { this._showPiano(); } } - }; + } - this._clear = function() { + /** + * @private + * @returns {void} + */ + _clear() { // "Unclick" every entry in the widget. this._saveState(); @@ -777,16 +764,18 @@ function ModeWidget() { this._resetNotes(); this._setModeName(); - let currentModeName = - keySignatureToMode(this._logo.turtles.ithTurtle(0).singer.keySignature); + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); if (currentModeName[0] === "C") { this._showPiano(); } - }; - - this._calculateMode = function() { - let currentMode = []; - let table = docById("modeTable"); + } + + /** + * @private + * @returns {Array} + */ + _calculateMode() { + const currentMode = []; let j = 1; for (let i = 1; i < 12; i++) { if (this._selectedNotes[i]) { @@ -799,38 +788,37 @@ function ModeWidget() { currentMode.push(j); return currentMode; - }; - - this._setModeName = function() { - let table = docById("modeTable"); - let n = table.rows.length - 1; - let currentMode = JSON.stringify(this._calculateMode()); - let currentKey = - keySignatureToMode(this._logo.turtles.ithTurtle(0).singer.keySignature)[0]; + } + + /** + * @private + * @returns {void} + */ + _setModeName() { + const table = docById("modeTable"); + const n = table.rows.length - 1; + const currentMode = JSON.stringify(this._calculateMode()); + const currentKey = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature)[0]; for (let mode in MUSICALMODES) { if (JSON.stringify(MUSICALMODES[mode]) === currentMode) { // Update the value of the modename block inside of // the mode widget block. if (this._modeBlock != null) { - for (let i in this._logo.blocks.blockList) { - if (this._logo.blocks.blockList[i].name == "modename") { - this._logo.blocks.blockList[i].value = mode; - this._logo.blocks.blockList[i].text.text = _(mode); - this._logo.blocks.blockList[i].updateCache(); - } else if ( - this._logo.blocks.blockList[i].name == "notename" - ) { - this._logo.blocks.blockList[i].value = currentKey; - this._logo.blocks.blockList[i].text.text = _( - currentKey - ); + for (let i in logo.blocks.blockList) { + if (logo.blocks.blockList[i].name == "modename") { + logo.blocks.blockList[i].value = mode; + logo.blocks.blockList[i].text.text = _(mode); + logo.blocks.blockList[i].updateCache(); + } else if (logo.blocks.blockList[i].name == "notename") { + logo.blocks.blockList[i].value = currentKey; + logo.blocks.blockList[i].text.text = _(currentKey); } } - this._logo.refreshCanvas(); + logo.refreshCanvas(); } - let name = currentKey + " " + _(mode); + const name = currentKey + " " + _(mode); table.rows[n].cells[0].innerHTML = name; this.widgetWindow.updateTitle(name); return; @@ -840,11 +828,15 @@ function ModeWidget() { // console.debug('setModeName:' + 'not found'); table.rows[n].cells[0].innerHTML = ""; this.widgetWindow.updateTitle(""); - }; + } - this._save = function() { - let table = docById("modeTable"); - let n = table.rows.length - 1; + /** + * @private + * @returns {void} + */ + _save() { + const table = docById("modeTable"); + const n = table.rows.length - 1; // If the mode is not in the list, save it as the new custom mode. if (table.rows[n].cells[0].innerHTML === "") { @@ -871,19 +863,19 @@ function ModeWidget() { for (let i = 0; i < 12; i++) { // Reverse the order so that Do is last. - let j = 11 - i; + const j = 11 - i; if (!this._selectedNotes[j]) { continue; } p += 1; - let pitch = NOTESTABLE[(j + 1) % 12]; - let octave = 4; + const pitch = NOTESTABLE[(j + 1) % 12]; + const octave = 4; console.debug(pitch + " " + octave); - let pitchidx = newStack.length; - let notenameidx = pitchidx + 1; - let octaveidx = pitchidx + 2; + const pitchidx = newStack.length; + const notenameidx = pitchidx + 1; + const octaveidx = pitchidx + 2; if (p === modeLength) { newStack.push([ @@ -902,27 +894,15 @@ function ModeWidget() { [previousBlock, notenameidx, octaveidx, pitchidx + 3] ]); } - newStack.push([ - notenameidx, - ["solfege", { value: pitch }], - 0, - 0, - [pitchidx] - ]); - newStack.push([ - octaveidx, - ["number", { value: octave }], - 0, - 0, - [pitchidx] - ]); + newStack.push([notenameidx, ["solfege", { value: pitch }], 0, 0, [pitchidx]]); + newStack.push([octaveidx, ["number", { value: octave }], 0, 0, [pitchidx]]); previousBlock = pitchidx; } // Create a new stack for the chunk. console.debug(newStack); - this._logo.blocks.loadNewBlocks(newStack); - this._logo.textMsg(_("New action block generated!")); + logo.blocks.loadNewBlocks(newStack); + logo.textMsg(_("New action block generated!")); // And save a stack of pitchnumbers to be used with the define mode newStack = [ @@ -942,24 +922,12 @@ function ModeWidget() { } p += 1; - let idx = newStack.length; + const idx = newStack.length; if (p === modeLength) { - newStack.push([ - idx, - "pitchnumber", - 0, - 0, - [previousBlock, idx + 1, null] - ]); + newStack.push([idx, "pitchnumber", 0, 0, [previousBlock, idx + 1, null]]); } else { - newStack.push([ - idx, - "pitchnumber", - 0, - 0, - [previousBlock, idx + 1, idx + 2] - ]); + newStack.push([idx, "pitchnumber", 0, 0, [previousBlock, idx + 1, idx + 2]]); } newStack.push([idx + 1, ["number", { value: i }], 0, 0, [idx]]); @@ -968,14 +936,16 @@ function ModeWidget() { // Create a new stack for the chunk. console.debug(newStack); - let that = this; - setTimeout(function() { - // that._logo.blocks.palettes.hide(); - that._logo.blocks.loadNewBlocks(newStack); + setTimeout(() => { + logo.blocks.loadNewBlocks(newStack); }, 2000); - }; + } - this._piemenuMode = function() { + /** + * @private + * @returns {void} + */ + _piemenuMode() { // pie menu for mode definition docById("meterWheelDiv").style.display = ""; @@ -1006,20 +976,7 @@ function ModeWidget() { // this._modeWheel.selectedNavItemIndex = 2; this._modeWheel.animatetime = 0; // 300; - let labels = [ - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11" - ]; + const labels = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]; let noteList = []; for (let i = 0; i < 12; i++) { noteList.push(labels[i]); @@ -1069,47 +1026,43 @@ function ModeWidget() { this._playWheel.navItems[i].navItem.hide(); } - let that = this; - // If a modeWheel sector is selected, show the corresponding // note wheel sector. - let __setNote = function() { - let i = that._modeWheel.selectedNavItemIndex; - that._saveState(); - that._selectedNotes[i] = true; - that._noteWheel.navItems[i].navItem.show(); - that._playNote(i); - that._setModeName(); - let currentModeName = - keySignatureToMode(that._logo.turtles.ithTurtle(0).singer.keySignature); + const __setNote = () => { + const i = this._modeWheel.selectedNavItemIndex; + this._saveState(); + this._selectedNotes[i] = true; + this._noteWheel.navItems[i].navItem.show(); + this._playNote(i); + this._setModeName(); + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); if (currentModeName[0] === "C") { - that._showPiano(); + this._showPiano(); } }; // If a noteWheel sector is selected, hide it. - let __clearNote = function() { - let i = that._noteWheel.selectedNavItemIndex; + const __clearNote = () => { + const i = this._noteWheel.selectedNavItemIndex; if (i == 0) { return; // Never hide the first note. } - that._noteWheel.navItems[i].navItem.hide(); - that._saveState(); - that._selectedNotes[i] = false; - that._setModeName(); - let currentModeName = - keySignatureToMode(that._logo.turtles.ithTurtle(0).singer.keySignature); + this._noteWheel.navItems[i].navItem.hide(); + this._saveState(); + this._selectedNotes[i] = false; + this._setModeName(); + const currentModeName = keySignatureToMode(turtles.ithTurtle(0).singer.keySignature); if (currentModeName[0] === "C") { - that._showPiano(); + this._showPiano(); } }; for (let i = 0; i < 12; i++) { - that._modeWheel.navItems[i].navigateFunction = __setNote; - that._noteWheel.navItems[i].navigateFunction = __clearNote; + this._modeWheel.navItems[i].navigateFunction = __setNote; + this._noteWheel.navItems[i].navigateFunction = __clearNote; // Start with all notes hidden. - that._noteWheel.navItems[i].navItem.hide(); + this._noteWheel.navItems[i].navItem.hide(); } - }; + } } diff --git a/js/widgets/musickeyboard.js b/js/widgets/musickeyboard.js index c08a17fb88..f0fd65e4ac 100644 --- a/js/widgets/musickeyboard.js +++ b/js/widgets/musickeyboard.js @@ -2785,6 +2785,9 @@ function MusicKeyboard() { this.octaves = []; }; + /** + * @deprecated + */ this._addButton = function(row, icon, iconSize, label) { let cell = row.insertCell(-1); cell.innerHTML = diff --git a/js/widgets/pitchdrummatrix.js b/js/widgets/pitchdrummatrix.js index e8d719cfa0..01fc8a5c99 100644 --- a/js/widgets/pitchdrummatrix.js +++ b/js/widgets/pitchdrummatrix.js @@ -315,6 +315,9 @@ function PitchDrumMatrix() { this._logo.textMsg(_("Click in the grid to map notes to drums.")); }; + /** + * @deprecated + */ this._addButton = function(row, icon, iconSize, label) { let cell = row.insertCell(-1); cell.innerHTML = diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 62ab7505f2..3e3fb140a1 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -30,6 +30,9 @@ function TemperamentWidget() { this.circleIsVisible = true; this.playbackForward = true; + /** + * @deprecated + */ this._addButton = function(row, icon, iconSize, label) { let cell = row.insertCell(-1); cell.innerHTML = diff --git a/js/widgets/timbre.js b/js/widgets/timbre.js index 6758a74515..9d24a9d4d9 100644 --- a/js/widgets/timbre.js +++ b/js/widgets/timbre.js @@ -103,6 +103,9 @@ function TimbreWidget() { this.blockNo = null; // index no. of the timbre widget block this.instrumentName = "custom"; + /** + * @deprecated + */ this._addButton = function(row, icon, iconSize, label) { let cell = row.insertCell(-1); cell.innerHTML = From 01a4afe0a417a320534232bb680f37259b301666 Mon Sep 17 00:00:00 2001 From: ricknjacky Date: Sun, 13 Dec 2020 17:53:01 +0530 Subject: [PATCH 08/11] oscilloscope missing file fix --- documentation/oscilloscope_block.svg | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 documentation/oscilloscope_block.svg 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 @@ + + + + + + image/svg+xml + + + + + + + + + + oscilloscope + + + + + + print + + + + + + + start + + + From 58e6b6bceec28de263bdd68261b3a35d3c7dac3d Mon Sep 17 00:00:00 2001 From: ricknjacky Date: Sun, 13 Dec 2020 19:11:02 +0530 Subject: [PATCH 09/11] note counter --- documentation/notecounter2_block.svg | 68 ++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 documentation/notecounter2_block.svg 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 @@ + + + + + + image/svg+xml + + + + + + + + + + + note counter + + + From 1b6053accb6f186348c7e8e3395d0aca98b4a885 Mon Sep 17 00:00:00 2001 From: Nirali Sanghvi <58932139+Nirali0029@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:01:01 -0800 Subject: [PATCH 10/11] Port widgets/pitchslider.js to ES6 class * Update pitchslider.js * Update pitchslider.js * Update pitchslider.js * Minor fixes Co-authored-by: Anindya Kundu --- js/widgets/pitchslider.js | 143 ++++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 68 deletions(-) diff --git a/js/widgets/pitchslider.js b/js/widgets/pitchslider.js index 214c9d819b..a963e285e4 100644 --- a/js/widgets/pitchslider.js +++ b/js/widgets/pitchslider.js @@ -13,75 +13,56 @@ // from given frequency to nextoctave frequency(two times the given frequency) // in continuous manner. -function PitchSlider() { - const ICONSIZE = 32; - this._delta = 0; - const SEMITONE = Math.pow(2, 1 / 12); - - this._save = (frequency) => { - for (let name in this._logo.blocks.palettes.dict) { - this._logo.blocks.palettes.dict[name].hideMenu(true); - } - - this._logo.refreshCanvas(); - - let newStack = [ - [0, "note", 100 + this._delta, 100 + this._delta, [null, 1, 2, null]], - [1, ["number", { value: 8 }], 0, 0, [0]] - ]; - this._delta += 21; - - let endOfStackIdx = 0; - let previousBlock = 0; - - let hertzIdx = newStack.length; - let frequencyIdx = hertzIdx + 1; - let hiddenIdx = hertzIdx + 2; - newStack.push([hertzIdx, "hertz", 0, 0, [previousBlock, frequencyIdx, hiddenIdx]]); - newStack.push([frequencyIdx, ["number", { value: frequency }], 0, 0, [hertzIdx]]); - newStack.push([hiddenIdx, "hidden", 0, 0, [hertzIdx, null]]); +class PitchSlider { + static ICONSIZE = 32; + static SEMITONE = Math.pow(2, 1 / 12); - this._logo.blocks.loadNewBlocks(newStack); - }; + constructor() { + this._delta = 0; + this.sliders = {}; + this._cellScale = 0; + } - this.init = (logo) => { + init() { if (window.widgetWindows.openWindows["slider"]) return; if (!this.frequencies || !this.frequencies.length) this.frequencies = [392]; - this._logo = logo; - let oscillators = []; - this.sliders = {}; - for (let freq in this.frequencies) { - let osc = new Tone.AMSynth().toDestination(); + const oscillators = []; + for (const _ in this.frequencies) { + const osc = new Tone.AMSynth().toDestination(); oscillators.push(osc); } + this._cellScale = 1.0; - let iconSize = ICONSIZE; - let widgetWindow = window.widgetWindows.windowFor(this, "pitch slider", "slider"); - this.widgetWindow = widgetWindow; - widgetWindow.onclose = () => { - for (let osc of oscillators) osc.triggerRelease(); - widgetWindow.destroy(); + this.widgetWindow = window.widgetWindows.windowFor(this, "pitch slider", "slider"); + this.widgetWindow.onclose = () => { + for (const osc of oscillators) osc.triggerRelease(); + this.widgetWindow.destroy(); }; - let makeToolbar = (id) => { - let toolBarDiv = document.createElement("div"); - widgetWindow._toolbar.appendChild(toolBarDiv); + const MakeToolbar = (id) => { + const toolBarDiv = document.createElement("div"); + this.widgetWindow._toolbar.appendChild(toolBarDiv); toolBarDiv.style.float = "left"; - let min = this.frequencies[id] / 2; - let max = this.frequencies[id] * 2; - - let slider = widgetWindow.addRangeSlider( + const min = this.frequencies[id] / 2; + const max = this.frequencies[id] * 2; + const slider = this.widgetWindow.addRangeSlider( this.frequencies[id], toolBarDiv, min, max, "pitchSlider" ); - this.sliders[id] = slider; - let changeFreq = () => { + // label for frequency + const freqLabel = document.createElement("div"); + freqLabel.className = "wfbtItem"; + toolBarDiv.appendChild(freqLabel); + freqLabel.innerHTML = ""; + + this.sliders[id] = slider; + const changeFreq = () => { this.frequencies[id] = this.sliders[id].value; oscillators[id].frequency.linearRampToValueAtTime( this.frequencies[id], @@ -89,52 +70,78 @@ function PitchSlider() { ); freqLabel.innerHTML = ""; }; + slider.oninput = () => { oscillators[id].triggerAttack(this.frequencies[id]); changeFreq(); }; slider.onchange = () => { - this._save(this.frequencies[id]); + // this._save(this.frequencies[id]); oscillators[id].triggerRelease(); }; - // label for frequency - let freqLabel = document.createElement("div"); - freqLabel.className = "wfbtItem"; - toolBarDiv.appendChild(freqLabel); - freqLabel.innerHTML = ""; - widgetWindow.addButton("up.svg", iconSize, _("Move up"), toolBarDiv).onclick = () => { - slider.value = Math.min(slider.value * SEMITONE, max); //value is a string + this.widgetWindow.addButton( + "up.svg", + PitchSlider.ICONSIZE, + _("Move up"), + toolBarDiv + ).onclick = () => { + slider.value = Math.min(slider.value * PitchSlider.SEMITONE, max); //value is a string changeFreq(); oscillators[id].triggerAttackRelease(this.frequencies[id], "4n"); }; - widgetWindow.addButton( + this.widgetWindow.addButton( "down.svg", - iconSize, + PitchSlider.ICONSIZE, _("Move down"), toolBarDiv ).onclick = () => { - slider.value = Math.max(slider.value / SEMITONE, min); //value is a string + slider.value = Math.max(slider.value / PitchSlider.SEMITONE, min); //value is a string changeFreq(); oscillators[id].triggerAttackRelease(this.frequencies[id], "4n"); }; - widgetWindow.addButton( + this.widgetWindow.addButton( "export-chunk.svg", - ICONSIZE, + PitchSlider.ICONSIZE, _("Save"), toolBarDiv ).onclick = () => { - //osc.triggerRelease(); this._save(this.frequencies[id]); }; }; - for (let id in this.frequencies) { - makeToolbar(id); + for (const id in this.frequencies) { + MakeToolbar(id); + } + + logo.textMsg(_("Click on the slider to create a note block.")); + setTimeout(this.widgetWindow.sendToCenter, 0); + } + + _save(frequency) { + for (const name in logo.blocks.palettes.dict) { + logo.blocks.palettes.dict[name].hideMenu(true); } - this._logo.textMsg(_("Click on the slider to create a note block.")); - }; + logo.refreshCanvas(); + + const newStack = [ + [0, "note", 100 + this._delta, 100 + this._delta, [null, 1, 2, null]], + [1, ["number", { value: 8 }], 0, 0, [0]] + ]; + this._delta += 21; + + const previousBlock = 0; + + const hertzIdx = newStack.length; + const frequencyIdx = hertzIdx + 1; + const hiddenIdx = hertzIdx + 2; + newStack.push([hertzIdx, "hertz", 0, 0, [previousBlock, frequencyIdx, hiddenIdx]]); + newStack.push([frequencyIdx, ["number", { value: frequency }], 0, 0, [hertzIdx]]); + newStack.push([hiddenIdx, "hidden", 0, 0, [hertzIdx, null]]); + + logo.blocks.loadNewBlocks(newStack); + } } From 52f0b3601ad36b36eda82bf822df21ea102ae296 Mon Sep 17 00:00:00 2001 From: Kumar Saurabh Raj <39027928+ksraj123@users.noreply.github.com> Date: Thu, 17 Dec 2020 01:37:57 +0530 Subject: [PATCH 11/11] Port widgets/phrasemaker.js to ES6 conventions * widgets/phrasemaker - PitchTimeMatrix to PhraseMaker * widget/phrasemaker - es6 classes * widgets/phrasemaker - arrow functions * widgets/phrasemaker - existing issues with additional drums * widgets/phrasemaker - fix issues with graphics and pen * widgets/phrasemaker - let const globals * widgets/phrasemaker - logos & turtles * widgets/phrasemaker - format code --- .eslintrc.json | 9 +- js/activity.js | 2 +- js/blocks/DrumBlocks.js | 6 +- js/blocks/GraphicsBlocks.js | 48 +- js/blocks/PenBlocks.js | 36 +- js/blocks/PitchBlocks.js | 6 +- js/blocks/RhythmBlockPaletteBlocks.js | 4 +- js/blocks/WidgetBlocks.js | 30 +- js/logo.js | 2 +- js/turtle-singer.js | 26 +- js/turtleactions/PitchActions.js | 22 +- js/turtleactions/ToneActions.js | 2 +- js/utils/utils.js | 4 + js/widgets/phrasemaker.js | 3031 ++++++++++--------------- 14 files changed, 1275 insertions(+), 1953 deletions(-) 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/js/activity.js b/js/activity.js index 0b6b1ed3ec..d44dddba99 100644 --- a/js/activity.js +++ b/js/activity.js @@ -934,7 +934,7 @@ function Activity() { if (false) { // _THIS_IS_MUSIC_BLOCKS_ && docById('ptmDiv').style.visibility === 'visible') { - logo.pitchTimeMatrix.playAll(); + logo.phraseMaker.playAll(); } else if (!turtles.running()) { logo.runLogoCommands(); } else { diff --git a/js/blocks/DrumBlocks.js b/js/blocks/DrumBlocks.js index eeec176678..7668bb5b73 100644 --- a/js/blocks/DrumBlocks.js +++ b/js/blocks/DrumBlocks.js @@ -270,10 +270,10 @@ function setupDrumBlocks() { logo.drumBlocks.push(blk); } } else if (logo.inMatrix) { - logo.pitchTimeMatrix.rowLabels.push(drumname); - logo.pitchTimeMatrix.rowArgs.push(-1); + logo.phraseMaker.rowLabels.push(drumname); + logo.phraseMaker.rowArgs.push(-1); - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.drumBlocks.indexOf(blk) === -1) { logo.drumBlocks.push(blk); } diff --git a/js/blocks/GraphicsBlocks.js b/js/blocks/GraphicsBlocks.js index 337df3dfdd..9773becf51 100644 --- a/js/blocks/GraphicsBlocks.js +++ b/js/blocks/GraphicsBlocks.js @@ -150,14 +150,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string" || typeof args[1] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push([args[0], args[1]]); + logo.phraseMaker.rowArgs.push([args[0], args[1]]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -360,14 +360,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string" || typeof args[1] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push([args[0], args[1]]); + logo.phraseMaker.rowArgs.push([args[0], args[1]]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -411,14 +411,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -459,14 +459,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string" || typeof args[1] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push([args[0], args[1]]); + logo.phraseMaker.rowArgs.push([args[0], args[1]]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -512,14 +512,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -566,14 +566,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -617,14 +617,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -668,14 +668,14 @@ function setupGraphicsBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { diff --git a/js/blocks/PenBlocks.js b/js/blocks/PenBlocks.js index 6c10c83b53..3760c90e62 100644 --- a/js/blocks/PenBlocks.js +++ b/js/blocks/PenBlocks.js @@ -546,15 +546,15 @@ function setupPenBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -592,15 +592,15 @@ function setupPenBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -639,15 +639,15 @@ function setupPenBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -688,15 +688,15 @@ function setupPenBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -734,15 +734,15 @@ function setupPenBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { @@ -781,15 +781,15 @@ function setupPenBlocks() { if (typeof args[0] === "string") { logo.errorMsg(NANERRORMSG, blk); } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( logo.blocks.blockList[blk].name ); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowArgs.push(args[0]); } else if (tur.singer.inNoteBlock.length > 0) { tur.singer.embeddedGraphics[last(tur.singer.inNoteBlock)].push(blk); } else { diff --git a/js/blocks/PitchBlocks.js b/js/blocks/PitchBlocks.js index a9372fccbb..0e83836836 100644 --- a/js/blocks/PitchBlocks.js +++ b/js/blocks/PitchBlocks.js @@ -1429,13 +1429,13 @@ function setupPitchBlocks() { logo.errorMsg(INVALIDPITCH, blk); logo.stopTurtle = true; } else if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push(logo.blocks.blockList[blk].name); - logo.pitchTimeMatrix.rowArgs.push(arg.toFixed(0)); + logo.phraseMaker.rowLabels.push(logo.blocks.blockList[blk].name); + logo.phraseMaker.rowArgs.push(arg.toFixed(0)); // convert hertz to note/octave let note = obj; tur.singer.lastNotePlayed = [note[0] + note[1], 4]; diff --git a/js/blocks/RhythmBlockPaletteBlocks.js b/js/blocks/RhythmBlockPaletteBlocks.js index d7ac6c3bf1..52d722ad3e 100644 --- a/js/blocks/RhythmBlockPaletteBlocks.js +++ b/js/blocks/RhythmBlockPaletteBlocks.js @@ -55,7 +55,7 @@ function setupRhythmBlockPaletteBlocks() { if (logo.inMatrix || logo.tuplet) { if (logo.inMatrix) { - logo.pitchTimeMatrix.addColBlock(blk, arg0); + logo.phraseMaker.addColBlock(blk, arg0); } for (let i = 0; i < args[0]; i++) { @@ -654,7 +654,7 @@ function setupRhythmBlockPaletteBlocks() { let noteBeatValue = (1 / arg1) * logo.turtles.ithTurtle(turtle).singer.beatFactor; if (logo.inMatrix || logo.tuplet) { - logo.pitchTimeMatrix.addColBlock(blk, arg0); + logo.phraseMaker.addColBlock(blk, arg0); if (logo.tuplet) { // The simple-tuplet block is inside. for (let i = 0; i < arg0; i++) { diff --git a/js/blocks/WidgetBlocks.js b/js/blocks/WidgetBlocks.js index 574f67ea38..f7ca7cd073 100644 --- a/js/blocks/WidgetBlocks.js +++ b/js/blocks/WidgetBlocks.js @@ -1022,17 +1022,17 @@ function setupWidgetBlocks() { flow(args, logo, turtle, blk) { logo.inMatrix = true; - if (logo.pitchTimeMatrix === null) { - logo.pitchTimeMatrix = new PitchTimeMatrix(); + if (logo.phraseMaker === null) { + logo.phraseMaker = new PhraseMaker(); } - logo.pitchTimeMatrix.blockNo = blk; + logo.phraseMaker.blockNo = blk; - logo.pitchTimeMatrix._instrumentName = DEFAULTVOICE; + logo.phraseMaker._instrumentName = DEFAULTVOICE; - logo.pitchTimeMatrix.rowLabels = []; - logo.pitchTimeMatrix.rowArgs = []; - logo.pitchTimeMatrix.graphicsBlocks = []; - logo.pitchTimeMatrix.clearBlocks(); + logo.phraseMaker.rowLabels = []; + logo.phraseMaker.rowArgs = []; + logo.phraseMaker.graphicsBlocks = []; + logo.phraseMaker.clearBlocks(); logo.tupletRhythms = []; logo.tupletParams = []; @@ -1044,7 +1044,7 @@ function setupWidgetBlocks() { let __listener = function(event) { if ( logo.tupletRhythms.length === 0 || - logo.pitchTimeMatrix.rowLabels.length === 0 + logo.phraseMaker.rowLabels.length === 0 ) { logo.errorMsg( _( @@ -1054,9 +1054,9 @@ function setupWidgetBlocks() { ); } else { // Process queued up rhythms. - logo.pitchTimeMatrix.blockNo = blk; - logo.pitchTimeMatrix.sorted = false; - logo.pitchTimeMatrix.init(logo); + logo.phraseMaker.blockNo = blk; + logo.phraseMaker.sorted = false; + logo.phraseMaker.init(logo); for (let i = 0; i < logo.tupletRhythms.length; i++) { // We have two cases: (1) notes in a tuplet; @@ -1078,10 +1078,10 @@ function setupWidgetBlocks() { ); } - logo.pitchTimeMatrix.addTuplet(tupletParam); + logo.phraseMaker.addTuplet(tupletParam); break; default: - logo.pitchTimeMatrix.addNotes( + logo.phraseMaker.addNotes( logo.tupletRhythms[i][1], logo.tupletRhythms[i][2] ); @@ -1089,7 +1089,7 @@ function setupWidgetBlocks() { } } - logo.pitchTimeMatrix.makeClickable(); + logo.phraseMaker.makeClickable(); } }; diff --git a/js/logo.js b/js/logo.js index 27646f71fd..c2e4cbbd25 100644 --- a/js/logo.js +++ b/js/logo.js @@ -75,7 +75,7 @@ class Logo { this.showBlocksAfterRun = false; // Widgets - this.pitchTimeMatrix = null; + this.phraseMaker = null; this.pitchDrumMatrix = null; this.rhythmRuler = null; this.timbre = null; diff --git a/js/turtle-singer.js b/js/turtle-singer.js index 88073d84d5..5ffa8b3dc7 100644 --- a/js/turtle-singer.js +++ b/js/turtle-singer.js @@ -190,13 +190,13 @@ class Singer { let obj = frequencyToPitch(args[0]); if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - logo.pitchTimeMatrix.rowLabels.push(logo.blocks.blockList[blk].name); - logo.pitchTimeMatrix.rowArgs.push(args[0]); + logo.phraseMaker.rowLabels.push(logo.blocks.blockList[blk].name); + logo.phraseMaker.rowArgs.push(args[0]); } else if (logo.inPitchSlider) { logo.pitchSlider.frequency = args[0]; } else { @@ -748,7 +748,7 @@ class Singer { } } else if (logo.inMatrix) { if (note.toLowerCase() !== "rest") { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } @@ -784,24 +784,24 @@ class Singer { // If we are in a setdrum clamp, override the pitch. if (tur.singer.drumStyle.length > 0) { - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( last(tur.singer.drumStyle) ); - logo.pitchTimeMatrix.rowArgs.push(-1); + logo.phraseMaker.rowArgs.push(-1); } else { // Was the pitch arg a note name or solfege name? if ( SOLFEGENAMES1.indexOf(note) !== -1 && noteObj[0] in SOLFEGECONVERSIONTABLE ) { - logo.pitchTimeMatrix.rowLabels.push( + logo.phraseMaker.rowLabels.push( SOLFEGECONVERSIONTABLE[noteObj[0]] ); } else { - logo.pitchTimeMatrix.rowLabels.push(noteObj[0]); + logo.phraseMaker.rowLabels.push(noteObj[0]); } - logo.pitchTimeMatrix.rowArgs.push(noteObj[1]); + logo.phraseMaker.rowArgs.push(noteObj[1]); } } } else if (tur.singer.inNoteBlock.length > 0) { @@ -1170,19 +1170,19 @@ class Singer { tur.singer.lastNotePlayed = [noteObj[0] + noteObj[1], noteBeatValue]; } else if (logo.inMatrix || logo.tuplet) { if (tur.singer.inNoteBlock.length > 0) { - logo.pitchTimeMatrix.addColBlock(blk, 1); + logo.phraseMaker.addColBlock(blk, 1); // block ID of parent "matrix" block - let mat_block = logo.pitchTimeMatrix.blockNo || -1; + let mat_block = logo.phraseMaker.blockNo || -1; for (let i = 0; i < logo.pitchBlocks.length; i++) { - logo.pitchTimeMatrix.addNode( + logo.phraseMaker.addNode( logo.pitchBlocks[i], blk, 0, mat_block ); } for (let i = 0; i < logo.drumBlocks.length; i++) { - logo.pitchTimeMatrix.addNode( + logo.phraseMaker.addNode( logo.drumBlocks[i], blk, 0, mat_block ); } diff --git a/js/turtleactions/PitchActions.js b/js/turtleactions/PitchActions.js index 254efaa2af..c58be93583 100644 --- a/js/turtleactions/PitchActions.js +++ b/js/turtleactions/PitchActions.js @@ -132,32 +132,32 @@ function setupPitchActions() { transposition = 0; if (logo.inMatrix) { - logo.pitchTimeMatrix.addRowBlock(blk); + logo.phraseMaker.addRowBlock(blk); if (logo.pitchBlocks.indexOf(blk) === -1) { logo.pitchBlocks.push(blk); } - if (logo.pitchTimeMatrix.rowLabels.length > 0) { - if (last(logo.pitchTimeMatrix.rowLabels) === "hertz") { + if (logo.phraseMaker.rowLabels.length > 0) { + if (last(logo.phraseMaker.rowLabels) === "hertz") { let freq = pitchToFrequency( noteObj[0], noteObj[1], 0, tur.singer.keySignature ); - logo.pitchTimeMatrix.rowLabels.push("hertz"); - logo.pitchTimeMatrix.rowArgs.push(parseInt(freq)); + logo.phraseMaker.rowLabels.push("hertz"); + logo.phraseMaker.rowArgs.push(parseInt(freq)); } else { - if (SOLFEGENAMES1.indexOf(last(logo.pitchTimeMatrix.rowLabels)) !== -1) { - logo.pitchTimeMatrix.rowLabels.push( + if (SOLFEGENAMES1.indexOf(last(logo.phraseMaker.rowLabels)) !== -1) { + logo.phraseMaker.rowLabels.push( SOLFEGECONVERSIONTABLE[noteObj1[0]] ); } else { - logo.pitchTimeMatrix.rowLabels.push(noteObj1[0]); + logo.phraseMaker.rowLabels.push(noteObj1[0]); } - logo.pitchTimeMatrix.rowArgs.push(noteObj1[1]); + logo.phraseMaker.rowArgs.push(noteObj1[1]); } } else { - logo.pitchTimeMatrix.rowLabels.push(noteObj1[0]); - logo.pitchTimeMatrix.rowArgs.push(noteObj1[1]); + logo.phraseMaker.rowLabels.push(noteObj1[0]); + logo.phraseMaker.rowArgs.push(noteObj1[1]); } tur.singer.previousNotePlayed = tur.singer.lastNotePlayed; diff --git a/js/turtleactions/ToneActions.js b/js/turtleactions/ToneActions.js index 38abac842b..9867edf0f5 100644 --- a/js/turtleactions/ToneActions.js +++ b/js/turtleactions/ToneActions.js @@ -47,7 +47,7 @@ function setupToneActions() { } if (logo.inMatrix) { - logo.pitchTimeMatrix._instrumentName = synth; + logo.phraseMaker._instrumentName = synth; } if (tur.singer.instrumentNames.indexOf(synth) === -1) { diff --git a/js/utils/utils.js b/js/utils/utils.js index 08e2708c7f..9a4399c552 100644 --- a/js/utils/utils.js +++ b/js/utils/utils.js @@ -228,6 +228,10 @@ function docByName(name) { return document.getElementsByName(name); } +function docBySelector(selector) { + return document.querySelector(selector); +} + function last(myList) { let i = myList.length; if (i === 0) { diff --git a/js/widgets/phrasemaker.js b/js/widgets/phrasemaker.js index 9b508fac0d..5d9f555585 100644 --- a/js/widgets/phrasemaker.js +++ b/js/widgets/phrasemaker.js @@ -10,6 +10,39 @@ // License along with this library; if not, write to the Free Software // Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA +/*global logo, turtles, _, platformColor, docById, MATRIXSOLFEHEIGHT, toFraction, Singer, + SOLFEGECONVERSIONTABLE, slicePath, wheelnav, delayExecution, DEFAULTVOICE, getDrumName, + MATRIXSOLFEWIDTH, getDrumIcon, noteIsSolfege, isCustom, i18nSolfege, getNote, DEFAULTDRUM, + last, DRUMS, SHARP, FLAT, PREVIEWVOLUME, DEFAULTVOLUME, noteToFrequency, getDrumIndex, LCD, + calcNoteValueToDisplay, NOTESYMBOLS, EIGHTHNOTEWIDTH, saveLocally, docBySelector*/ + +/* + Globals location + - lib/wheelnav + slicePath, wheelnav + + - js/utils/musicutils.js + EIGHTHNOTEWIDTH, NOTESYMBOLS, calcNoteValueToDisplay, getDrumIndex, noteToFrequency, + FLAT, SHARP, DRUMS, MATRIXSOLFEHEIGHT, toFraction, SOLFEGECONVERSIONTABLE, DEFAULTVOICE, + getDrumName, MATRIXSOLFEWIDTH, getDrumIcon, noteIsSolfege, isCustom, i18nSolfege, + getNote, DEFAULTDRUM + + - js/utils/utils.js + _, delayExecution, last, LCD, docById, docBySelector + + - js/turtle-singer.js + Singer + + - js/utils/platformstyle.js + platformColorcl + + - js/logo.js + PREVIEWVOLUME, DEFAULTVOLUME + + - js/activity.js + saveLocally(window, planet) + */ + const MATRIXGRAPHICS = [ "forward", "back", @@ -26,100 +59,102 @@ const MATRIXGRAPHICS = [ const MATRIXGRAPHICS2 = ["arc", "setxy"]; const MATRIXSYNTHS = ["sine", "triangle", "sawtooth", "square", "hertz"]; // Deprecated -function PitchTimeMatrix() { +class PhraseMaker { // The phrasemaker widget - const BUTTONDIVWIDTH = 535; // 8 buttons 535 = (55 + 4) * 9 - const OUTERWINDOWWIDTH = 758; - const INNERWINDOWWIDTH = 630; - const BUTTONSIZE = 53; - const ICONSIZE = 24; - - this._stopOrCloseClicked = false; - this._instrumentName = DEFAULTVOICE; - - this.paramsEffects = { - doVibrato: false, - doDistortion: false, - doTremolo: false, - doPhaser: false, - doChorus: false, - vibratoIntensity: 0, - vibratoFrequency: 0, - distortionAmount: 0, - tremoloFrequency: 0, - tremoloDepth: 0, - rate: 0, - octaves: 0, - baseFrequency: 0, - chorusRate: 0, - delayTime: 0, - chorusDepth: 0 - }; - - // rowLabels can contain either a pitch, a drum, or a graphics commands - this.rowLabels = []; - // rowArgs can contain an octave or the arg(s) to a graphics command - this.rowArgs = []; - - // We need to treat note blocks differently since they have both - // pitch and rhythm. - this._noteBlocks = false; - - this.sorted = false; - this._notesToPlay = []; - this._outputAsTuplet = []; // do we output 1/12 or 1/(3x4)? - this._matrixHasTuplets = false; - this._notesCounter = 0; - this._noteStored = []; - - // The pitch-block number associated with a row; a rhythm block is - // associated with a column. We need to keep track of which - // intersections in the grid are populated. The blockMap is a - // list of selected nodes in the matrix that map pitch blocks to - // rhythm blocks (note that rhythm blocks can span multiple - // columns). - - // These arrays get created each time the matrix is built. - this._rowBlocks = []; // pitch-block number - this._colBlocks = []; // [rhythm-block number, note number] - - // This array keeps track of the position of the rows after sorting. - this._rowMap = []; - // And offsets due to deleting duplicates. - this._rowOffset = []; - - // Track a number of DOM elements locally - this._rows = []; - this._headcols = []; - this._labelcols = []; - this._tupletNoteLabel = null; - this._tupletValueLabel = null; - this._tupletNoteValueLabel = null; - - this._tupletNoteValueRow = null; - this._tupletValueRow = null; - this._noteValueRow = null; - - // This array is preserved between sessions. - // We populate the blockMap whenever a note is selected and - // restore any notes that might be present. - this._blockMap = {}; - - this.blockNo = null; - this.notesBlockMap = []; - this._blockMapHelper = []; - this.columnBlocksMap = []; - - this.clearBlocks = function() { + static BUTTONDIVWIDTH = 535; // 8 buttons 535 = (55 + 4) * 9 + static OUTERWINDOWWIDTH = 758; + static INNERWINDOWWIDTH = 630; + static BUTTONSIZE = 53; + static ICONSIZE = 24; + + constructor() { + this._stopOrCloseClicked = false; + this._instrumentName = DEFAULTVOICE; + + this.paramsEffects = { + doVibrato: false, + doDistortion: false, + doTremolo: false, + doPhaser: false, + doChorus: false, + vibratoIntensity: 0, + vibratoFrequency: 0, + distortionAmount: 0, + tremoloFrequency: 0, + tremoloDepth: 0, + rate: 0, + octaves: 0, + baseFrequency: 0, + chorusRate: 0, + delayTime: 0, + chorusDepth: 0 + }; + + // rowLabels can contain either a pitch, a drum, or a graphics commands + this.rowLabels = []; + // rowArgs can contain an octave or the arg(s) to a graphics command + this.rowArgs = []; + + // We need to treat note blocks differently since they have both + // pitch and rhythm. + this._noteBlocks = false; + + this.sorted = false; + this._notesToPlay = []; + this._outputAsTuplet = []; // do we output 1/12 or 1/(3x4)? + this._matrixHasTuplets = false; + this._notesCounter = 0; + this._noteStored = []; + + // The pitch-block number associated with a row; a rhythm block is + // associated with a column. We need to keep track of which + // intersections in the grid are populated. The blockMap is a + // list of selected nodes in the matrix that map pitch blocks to + // rhythm blocks (note that rhythm blocks can span multiple + // columns). + + // These arrays get created each time the matrix is built. + this._rowBlocks = []; // pitch-block number + this._colBlocks = []; // [rhythm-block number, note number] + + // This array keeps track of the position of the rows after sorting. + this._rowMap = []; + // And offsets due to deleting duplicates. + this._rowOffset = []; + + // Track a number of DOM elements locally + this._rows = []; + this._headcols = []; + this._labelcols = []; + this._tupletNoteLabel = null; + this._tupletValueLabel = null; + this._tupletNoteValueLabel = null; + + this._tupletNoteValueRow = null; + this._tupletValueRow = null; + this._noteValueRow = null; + + // This array is preserved between sessions. + // We populate the blockMap whenever a note is selected and + // restore any notes that might be present. + this._blockMap = {}; + + this.blockNo = null; + this.notesBlockMap = []; + this._blockMapHelper = []; + this.columnBlocksMap = []; + } + + clearBlocks() { // When creating a new matrix, we want to clear out any old // block references. this._rowBlocks = []; this._colBlocks = []; this._rowMap = []; this._rowOffset = []; - }; + } - this.addRowBlock = function(rowBlock) { + addRowBlock(rowBlock) { // When creating a matrix, we add rows whenever we encounter a // pitch or drum block (and some graphics blocks). this._rowMap.push(this._rowBlocks.length); @@ -131,9 +166,9 @@ function PitchTimeMatrix() { } this._rowBlocks.push(rowBlock); - }; + } - this.addColBlock = function(rhythmBlock, n) { + addColBlock(rhythmBlock, n) { // When creating a matrix, we add columns when we encounter // rhythm blocks. // Search for previous instance of the same block (from a @@ -150,9 +185,9 @@ function PitchTimeMatrix() { for (let i = startIdx; i < n + startIdx; i++) { this._colBlocks.push([rhythmBlock, i]); } - }; + } - this.addNode = function(rowBlock, rhythmBlock, n, blk) { + addNode(rowBlock, rhythmBlock, n, blk) { // A node exists for each cell in the matrix. It is used to // preserve and restore the state of the cell. if (this._blockMap[blk] === undefined) { @@ -163,41 +198,33 @@ function PitchTimeMatrix() { let obj; for (let i = 0; i < this._blockMap[blk].length; i++) { obj = this._blockMap[blk][i]; - if ( - obj[0] === rowBlock && - obj[1][0] === rhythmBlock && - obj[1][1] === n - ) { + if (obj[0] === rowBlock && obj[1][0] === rhythmBlock && obj[1][1] === n) { console.debug("node is already in the list"); j += 1; } } this._blockMap[blk].push([rowBlock, [rhythmBlock, n], j]); - }; + } - this.removeNode = function(rowBlock, rhythmBlock, n) { + removeNode(rowBlock, rhythmBlock, n) { // When the matrix is changed, we may need to remove nodes. - let blk = this.blockNo; + const blk = this.blockNo; let obj; for (let i = 0; i < this._blockMap[blk].length; i++) { obj = this._blockMap[blk][i]; - if ( - obj[0] === rowBlock && - obj[1][0] === rhythmBlock && - obj[1][1] === n - ) { + if (obj[0] === rowBlock && obj[1][0] === rhythmBlock && obj[1][1] === n) { this._blockMap[blk].splice(i, 1); } } - }; + } - this._get_save_lock = function() { + _get_save_lock() { // Debounce the save button. return this._save_lock; - }; + } - this.init = function(logo) { + init(logo) { // Initializes the matrix. First removes the previous matrix // and then make another one in DOM (document object model) let tempTable; @@ -205,15 +232,15 @@ function PitchTimeMatrix() { this._noteStored = []; this._noteBlocks = false; this._rests = 0; - this._logo = logo; + logo = logo; this.playingNow = false; - let w = window.innerWidth; + const w = window.innerWidth; this._cellScale = Math.max(1, w / 1200); - let iconSize = ICONSIZE * this._cellScale; + const iconSize = PhraseMaker.ICONSIZE * this._cellScale; - let widgetWindow = window.widgetWindows.windowFor(this, "phrase maker"); + const widgetWindow = window.widgetWindows.windowFor(this, "phrase maker"); this.widgetWindow = widgetWindow; widgetWindow.clear(); widgetWindow.show(); @@ -224,85 +251,72 @@ function PitchTimeMatrix() { this._matrixHasTuplets = false; // Add the buttons to the top row. - let that = this; - widgetWindow.onclose = function() { - that._rowOffset = []; - for (let i = 0; i < that._rowMap.length; i++) { - that._rowMap[i] = i; + widgetWindow.onclose = () => { + this._rowOffset = []; + for (let i = 0; i < this._rowMap.length; i++) { + this._rowMap[i] = i; } - that._logo.synth.stopSound(0, that._instrumentName); - that._logo.synth.stop(); - that._stopOrCloseClicked = true; - that._logo.hideMsgs(); + logo.synth.stopSound(0, this._instrumentName); + logo.synth.stop(); + this._stopOrCloseClicked = true; + logo.hideMsgs(); docById("wheelDivptm").style.display = "none"; widgetWindow.destroy(); }; - widgetWindow.addButton( - "play-button.svg", - ICONSIZE, - _("Play") - ).onclick = function() { - that._logo.turtleDelay = 0; - - that._logo.resetSynth(0); - that.playAll(); + widgetWindow.addButton("play-button.svg", PhraseMaker.ICONSIZE, _("Play")).onclick = () => { + logo.turtleDelay = 0; + + logo.resetSynth(0); + this.playAll(); }; this._save_lock = false; widgetWindow.addButton( "export-chunk.svg", - ICONSIZE, + PhraseMaker.ICONSIZE, _("Save") - ).onclick = async function() { + ).onclick = async () => { // Debounce the save button - if (!that._get_save_lock()) { - that._save_lock = true; - that._save(); + if (!this._get_save_lock()) { + this._save_lock = true; + this._save(); await delayExecution(1000); - that._save_lock = false; + this._save_lock = false; if (window.innerWidth <= 600) // Mobile - that.widgetWindow.close(); + this.widgetWindow.close(); } }; widgetWindow.addButton( "erase-button.svg", - ICONSIZE, + PhraseMaker.ICONSIZE, _("Clear") - ).onclick = function() { - that._clear(); - }; + ).onclick = this._clear.bind(this); if (!localStorage.beginnerMode) { widgetWindow.addButton( "export-button.svg", - ICONSIZE, + PhraseMaker.ICONSIZE, _("Export") - ).onclick = function() { - that._export(); - }; + ).onclick = this._export.bind(this); } widgetWindow.addButton( "sort.svg", - ICONSIZE, + PhraseMaker.ICONSIZE, _("Sort") - ).onclick = function() { - that._sort(); - }; + ).onclick = this._sort.bind(this); - let cell = widgetWindow.addButton("add2.svg", ICONSIZE, _("Add note")); + let cell = widgetWindow.addButton("add2.svg", PhraseMaker.ICONSIZE, _("Add note")); cell.setAttribute("id", "addnotes"); - cell.onclick = function() { - that._createAddRowPieSubmenu(); - }; + cell.onclick = this._createAddRowPieSubmenu.bind(this); - let ptmTable = document.createElement("table"); + const ptmTable = document.createElement("table"); ptmTable.setAttribute("cellpadding", "0px"); widgetWindow.getWidgetBody().append(ptmTable); @@ -314,15 +328,12 @@ function PitchTimeMatrix() { // first column and a table of buttons in the second column. if (!this.sorted) { this.columnBlocksMap = this._mapNotesBlocks("all", true); - for (i = 0; i < this.columnBlocksMap.length; i++) { + for (let i = 0; i < this.columnBlocksMap.length; i++) { if ( MATRIXGRAPHICS.indexOf(this.columnBlocksMap[i][1]) !== -1 || - MATRIXGRAPHICS2.indexOf(this.columnBlocksMap[i][1]) !== - -1 || + MATRIXGRAPHICS2.indexOf(this.columnBlocksMap[i][1]) !== -1 || MATRIXSYNTHS.indexOf(this.columnBlocksMap[i][1]) !== -1 || - ["playdrum", "pitch"].indexOf( - this.columnBlocksMap[i][1] - ) !== -1 + ["playdrum", "pitch"].indexOf(this.columnBlocksMap[i][1]) !== -1 ) { continue; } @@ -362,12 +373,9 @@ function PitchTimeMatrix() { cell = ptmTableRow.insertCell(); cell.style.backgroundColor = cellColor; cell.style.fontSize = this._cellScale * 100 + "%"; - cell.style.height = - Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + 1 + "px"; - cell.style.width = - Math.floor(MATRIXSOLFEWIDTH * this._cellScale) + "px"; - cell.style.minWidth = - Math.floor(MATRIXSOLFEWIDTH * this._cellScale) + "px"; + cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + 1 + "px"; + cell.style.width = Math.floor(MATRIXSOLFEWIDTH * this._cellScale) + "px"; + cell.style.minWidth = Math.floor(MATRIXSOLFEWIDTH * this._cellScale) + "px"; cell.style.maxWidth = cell.style.minWidth; cell.className = "headcol"; // This cell is fixed horizontally. cell.innerHTML = ""; @@ -454,10 +462,7 @@ function PitchTimeMatrix() { '" width="' + cell.style.width + '" vertical-align="middle">'; - } else if ( - ["C", "do"].indexOf(noteName) !== -1 && - this.rowArgs[i] === 5 - ) { + } else if (["C", "do"].indexOf(noteName) !== -1 && this.rowArgs[i] === 5) { cell.innerHTML = ' { let eCell = event.target; if (eCell.getAttribute("alt") === null) { eCell = eCell.parentNode; } - let index = eCell.getAttribute("alt").split("__")[0]; - let condition = eCell.getAttribute("alt").split("__")[1]; - that._createColumnPieSubmenu(index, condition); + const index = eCell.getAttribute("alt").split("__")[0]; + const condition = eCell.getAttribute("alt").split("__")[1]; + this._createColumnPieSubmenu(index, condition); }; this._noteStored.push(drumName); @@ -508,109 +510,82 @@ function PitchTimeMatrix() { cell.style.fontSize = Math.floor(this._cellScale * 14) + "px"; cell.setAttribute("alt", i + "__" + "synthsblocks"); - cell.onclick = function(event) { + cell.onclick = (event) => { let eCell = event.target; if (eCell.getAttribute("alt") === null) { eCell = eCell.parentNode; } - let index = eCell.getAttribute("alt").split("__")[0]; - let condition = eCell.getAttribute("alt").split("__")[1]; - that._createMatrixGraphicsPieSubmenu( - index, - condition, - null - ); + const index = eCell.getAttribute("alt").split("__")[0]; + const condition = eCell.getAttribute("alt").split("__")[1]; + this._createMatrixGraphicsPieSubmenu(index, condition, null); }; this._noteStored.push(this.rowArgs[i]); } else if (MATRIXGRAPHICS.indexOf(this.rowLabels[i]) !== -1) { - blockLabel = this._logo.blocks.protoBlockDict[ - this.rowLabels[i] - ]["staticLabels"][0]; + blockLabel = logo.blocks.protoBlockDict[this.rowLabels[i]]["staticLabels"][0]; cell.innerHTML = blockLabel + "
    " + this.rowArgs[i]; cell.style.fontSize = Math.floor(this._cellScale * 12) + "px"; cell.setAttribute("alt", i + "__" + "graphicsblocks"); - cell.onclick = function(event) { - eCell = event.target; + cell.onclick = (event) => { + let eCell = event.target; if (eCell.getAttribute("alt") === null) { eCell = eCell.parentNode; } - let index = eCell.getAttribute("alt").split("__")[0]; - let condition = eCell.getAttribute("alt").split("__")[1]; - that._createMatrixGraphicsPieSubmenu( - index, - condition, - null - ); + const index = eCell.getAttribute("alt").split("__")[0]; + const condition = eCell.getAttribute("alt").split("__")[1]; + this._createMatrixGraphicsPieSubmenu(index, condition, null); }; - this._noteStored.push( - this.rowLabels[i] + ": " + this.rowArgs[i] - ); + this._noteStored.push(this.rowLabels[i] + ": " + this.rowArgs[i]); } else if (MATRIXGRAPHICS2.indexOf(this.rowLabels[i]) !== -1) { - blockLabel = this._logo.blocks.protoBlockDict[ - this.rowLabels[i] - ]["staticLabels"][0]; + blockLabel = logo.blocks.protoBlockDict[this.rowLabels[i]]["staticLabels"][0]; cell.innerHTML = - blockLabel + - "
    " + - this.rowArgs[i][0] + - " " + - this.rowArgs[i][1]; + blockLabel + "
    " + this.rowArgs[i][0] + " " + this.rowArgs[i][1]; cell.style.fontSize = Math.floor(this._cellScale * 12) + "px"; cell.setAttribute("alt", i + "__" + "graphicsblocks2"); - cell.onclick = function(event) { + cell.onclick = (event) => { let eCell = event.target; if (eCell.getAttribute("alt") === null) { eCell = eCell.parentNode; } - let index = eCell.getAttribute("alt").split("__")[0]; - let condition = eCell.getAttribute("alt").split("__")[1]; - that._createMatrixGraphics2PieSubmenu(index, null); + const index = eCell.getAttribute("alt").split("__")[0]; + const condition = eCell.getAttribute("alt").split("__")[1]; + this._createMatrixGraphics2PieSubmenu(index, null); }; this._noteStored.push( - this.rowLabels[i] + - ": " + - this.rowArgs[i][0] + - ": " + - this.rowArgs[i][1] + this.rowLabels[i] + ": " + this.rowArgs[i][0] + ": " + this.rowArgs[i][1] ); } else { - if ( - noteIsSolfege(this.rowLabels[i]) && - !isCustom(this._logo.synth.inTemperament) - ) { + if (noteIsSolfege(this.rowLabels[i]) && !isCustom(logo.synth.inTemperament)) { cell.innerHTML = - i18nSolfege(this.rowLabels[i]) + - this.rowArgs[i].toString().sub(); + i18nSolfege(this.rowLabels[i]) + this.rowArgs[i].toString().sub(); noteObj = getNote( this.rowLabels[i], this.rowArgs[i], 0, - this._logo.turtles.ithTurtle(0).singer.keySignature, + turtles.ithTurtle(0).singer.keySignature, false, null, - this._logo.errorMsg, - this._logo.synth.inTemperament + logo.errorMsg, + logo.synth.inTemperament ); } else { - cell.innerHTML = - this.rowLabels[i] + this.rowArgs[i].toString().sub(); + cell.innerHTML = this.rowLabels[i] + this.rowArgs[i].toString().sub(); noteObj = [this.rowLabels[i], this.rowArgs[i]]; } cell.setAttribute("alt", i + "__" + "pitchblocks"); - cell.onclick = function(event) { + cell.onclick = (event) => { let eCell = event.target; if (eCell.getAttribute("alt") === null) { eCell = eCell.parentNode; } - let index = eCell.getAttribute("alt").split("__")[0]; - let condition = eCell.getAttribute("alt").split("__")[1]; - that._createColumnPieSubmenu(index, condition); + const index = eCell.getAttribute("alt").split("__")[0]; + const condition = eCell.getAttribute("alt").split("__")[1]; + this._createColumnPieSubmenu(index, condition); }; this._noteStored.push(noteObj[0] + noteObj[1]); @@ -672,20 +647,20 @@ function PitchTimeMatrix() { // Sort them if there are note blocks. if (!this.sorted) { - setTimeout(function() { + setTimeout(() => { console.debug("sorting"); - that._sort(); + this._sort(); }, 1000); } else { this.sorted = false; } - this._logo.textMsg(_("Click on the table to add notes.")); + logo.textMsg(_("Click on the table to add notes.")); this.widgetWindow.sendToCenter(); - }; + } - this._createAddRowPieSubmenu = function() { + _createAddRowPieSubmenu() { // This menu is used to add new rows to the matrix. docById("wheelDivptm").style.display = ""; const VALUESLABEL = ["pitch", "hertz", "drum", "graphics", "pen"]; @@ -696,14 +671,14 @@ function PitchTimeMatrix() { "imgsrc: images/mouse.svg", "imgsrc: images/pen.svg" ]; - let valueLabel = []; + const valueLabel = []; let label; for (let i = 0; i < VALUES.length; i++) { label = _(VALUES[i]); valueLabel.push(label); } - let graphicLabels = []; + const graphicLabels = []; for (let i = 0; i < MATRIXGRAPHICS.length; i++) { graphicLabels.push(MATRIXGRAPHICS[i]); } @@ -752,45 +727,44 @@ function PitchTimeMatrix() { this._exitWheel.clickModeRotate = false; this._exitWheel.createWheel(["×", " "]); - let x = docById("addnotes").getBoundingClientRect().x; - let y = docById("addnotes").getBoundingClientRect().y; + const x = docById("addnotes").getBoundingClientRect().x; + const y = docById("addnotes").getBoundingClientRect().y; docById("wheelDivptm").style.position = "absolute"; docById("wheelDivptm").style.height = "300px"; docById("wheelDivptm").style.width = "300px"; docById("wheelDivptm").style.left = Math.min( - this._logo.blocks.turtles._canvas.width - 200, - Math.max(0, x * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.width - 200, + Math.max(0, x * logo.blocks.getStageScale()) ) + "px"; docById("wheelDivptm").style.top = Math.min( - this._logo.blocks.turtles._canvas.height - 250, - Math.max(0, y * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.height - 250, + Math.max(0, y * logo.blocks.getStageScale()) ) + "px"; - let that = this; - this._exitWheel.navItems[0].navigateFunction = function() { + this._exitWheel.navItems[0].navigateFunction = () => { docById("wheelDivptm").style.display = "none"; - that._menuWheel.removeWheel(); - that._exitWheel.removeWheel(); + this._menuWheel.removeWheel(); + this._exitWheel.removeWheel(); }; - let __subMenuChanged = function() { + const __subMenuChanged = () => { __selectionChanged(); }; - let __selectionChanged = function() { - label = VALUESLABEL[that._menuWheel.selectedNavItemIndex]; + let __selectionChanged = () => { + label = VALUESLABEL[this._menuWheel.selectedNavItemIndex]; console.debug(label); let rLabel = null; let rArg = null; - let blockLabel = ""; - let newBlock = that._logo.blocks.blockList.length; + const blockLabel = ""; + const newBlock = logo.blocks.blockList.length; switch (label) { case "pitch": console.debug("loading new pitch block"); - that._logo.blocks.loadNewBlocks([ + logo.blocks.loadNewBlocks([ [0, ["pitch", {}], 0, 0, [null, 1, 2, null]], [1, ["solfege", { value: "sol" }], 0, 0, [0]], [2, ["number", { value: 4 }], 0, 0, [0]] @@ -800,7 +774,7 @@ function PitchTimeMatrix() { break; case "hertz": console.debug("loading new Hertz block"); - that._logo.blocks.loadNewBlocks([ + logo.blocks.loadNewBlocks([ [0, ["hertz", {}], 0, 0, [null, 1, null]], [1, ["number", { value: 392 }], 0, 0, [0]] ]); @@ -809,7 +783,7 @@ function PitchTimeMatrix() { break; case "drum": console.debug("loading new playdrum block"); - that._logo.blocks.loadNewBlocks([ + logo.blocks.loadNewBlocks([ [0, ["playdrum", {}], 0, 0, [null, 1, null]], [1, ["drumname", { value: DEFAULTDRUM }], 0, 0, [0]] ]); @@ -818,7 +792,7 @@ function PitchTimeMatrix() { break; case "graphics": console.debug("loading new forward block"); - that._logo.blocks.loadNewBlocks([ + logo.blocks.loadNewBlocks([ [0, ["forward", {}], 0, 0, [null, 1, null]], [1, ["number", { value: 100 }], 0, 0, [0]] ]); @@ -827,7 +801,7 @@ function PitchTimeMatrix() { break; case "pen": console.debug("loading new setcolor block"); - that._logo.blocks.loadNewBlocks([ + logo.blocks.loadNewBlocks([ [0, ["setcolor", {}], 0, 0, [null, 1, null]], [1, ["number", { value: 0 }], 0, 0, [0]] ]); @@ -846,7 +820,7 @@ function PitchTimeMatrix() { case "graphics": case "pen": for (let i = graphicLabels.length - 1; i >= 0; i--) { - blocksNo = that._mapNotesBlocks(graphicLabels[i]); + blocksNo = this._mapNotesBlocks(graphicLabels[i]); if (blocksNo.length >= 1) { aboveBlock = last(blocksNo); console.debug(aboveBlock); @@ -855,19 +829,19 @@ function PitchTimeMatrix() { } break; case "drum": - blocksNo = that._mapNotesBlocks("playdrum"); + blocksNo = this._mapNotesBlocks("playdrum"); if (blocksNo.length >= 1) { aboveBlock = last(blocksNo); } break; case "hertz": - blocksNo = that._mapNotesBlocks("hertz"); + blocksNo = this._mapNotesBlocks("hertz"); if (blocksNo.length >= 1) { aboveBlock = last(blocksNo); } break; case "pitch": - blocksNo = that._mapNotesBlocks("pitch"); + blocksNo = this._mapNotesBlocks("pitch"); if (blocksNo.length >= 1) { aboveBlock = last(blocksNo); } @@ -877,73 +851,61 @@ function PitchTimeMatrix() { if (aboveBlock === null) { console.debug("WARNING: aboveBlock is null"); // Look for a pitch block. - blocksNo = that._mapNotesBlocks("pitch"); + blocksNo = this._mapNotesBlocks("pitch"); if (blocksNo.length >= 1) { aboveBlock = last(blocksNo); } // The top? if (aboveBlock === null) { - aboveBlock = that.blockNo; + aboveBlock = this.blockNo; } } - if (aboveBlock === that.blockNo) { - setTimeout( - that._addNotesBlockBetween(aboveBlock, newBlock, true), - 500 - ); - that.rowLabels.splice(0, 0, rLabel); - that.rowArgs.splice(0, 0, rArg); - that._rowBlocks.splice(0, 0, newBlock); + if (aboveBlock === this.blockNo) { + setTimeout(this._addNotesBlockBetween(aboveBlock, newBlock, true), 500); + this.rowLabels.splice(0, 0, rLabel); + this.rowArgs.splice(0, 0, rArg); + this._rowBlocks.splice(0, 0, newBlock); } else { - setTimeout( - that._addNotesBlockBetween(aboveBlock, newBlock, false), - 500 - ); - for (let i = 0; i < that.columnBlocksMap.length; i++) { - if (that.columnBlocksMap[i][0] === aboveBlock) { + setTimeout(this._addNotesBlockBetween(aboveBlock, newBlock, false), 500); + let i; + for (i = 0; i < this.columnBlocksMap.length; i++) { + if (this.columnBlocksMap[i][0] === aboveBlock) { break; } } - that.rowLabels.splice(i + 1, 0, rLabel); - that.rowArgs.splice(i + 1, 0, rArg); - that._rowBlocks.splice(i + 1, 0, newBlock); + this.rowLabels.splice(i + 1, 0, rLabel); + this.rowArgs.splice(i + 1, 0, rArg); + this._rowBlocks.splice(i + 1, 0, newBlock); } - that.sorted = false; - that.init(that._logo); + this.sorted = false; + this.init(logo); let tupletParam; - for (let i = 0; i < that._logo.tupletRhythms.length; i++) { - switch (that._logo.tupletRhythms[i][0]) { + for (let i = 0; i < logo.tupletRhythms.length; i++) { + switch (logo.tupletRhythms[i][0]) { case "simple": case "notes": - tupletParam = [that._logo.tupletParams[that._logo.tupletRhythms[i][1]]]; + tupletParam = [logo.tupletParams[logo.tupletRhythms[i][1]]]; tupletParam.push([]); - for ( - let j = 2; - j < that._logo.tupletRhythms[i].length; - j++ - ) { - tupletParam[1].push(that._logo.tupletRhythms[i][j]); + for (let j = 2; j < logo.tupletRhythms[i].length; j++) { + tupletParam[1].push(logo.tupletRhythms[i][j]); } - that.addTuplet(tupletParam); + this.addTuplet(tupletParam); break; default: - that.addNotes( - that._logo.tupletRhythms[i][1], - that._logo.tupletRhythms[i][2] - ); + this.addNotes(logo.tupletRhythms[i][1], logo.tupletRhythms[i][2]); break; } } - that.makeClickable(); + this.makeClickable(); if (label === "pitch") { - setTimeout(function() { - that.pitchBlockAdded(newBlock); + setTimeout(() => { + this.pitchBlockAdded(newBlock); }, 200); } }; @@ -951,9 +913,9 @@ function PitchTimeMatrix() { for (let i = 0; i < valueLabel.length; i++) { this._menuWheel.navItems[i].navigateFunction = __subMenuChanged; } - }; + } - this.pitchBlockAdded = function(blockN) { + pitchBlockAdded(blockN) { let i; for (i = 0; i < this.columnBlocksMap.length; i++) { if (this.columnBlocksMap[i][0] === blockN) { @@ -962,44 +924,23 @@ function PitchTimeMatrix() { } setTimeout(this._createColumnPieSubmenu(i, "pitchblocks", true), 500); - }; + } - this._createMatrixGraphics2PieSubmenu = function(blockIndex, blk) { + _createMatrixGraphics2PieSubmenu(blockIndex, blk) { // A wheel for modifying 2-arg graphics blocks docById("wheelDivptm").style.display = ""; - let arcRadiusLabel = [ - "10", - "20", - "30", - "40", - "50", - "60", - "70", - "80", - "90", - "100" - ]; - let arcAngleLabel = ["0", "30", "45", "60", "90", "180"]; - let setxyValueLabel = ["-200", "-100", "0", "100", "200"]; + const arcRadiusLabel = ["10", "20", "30", "40", "50", "60", "70", "80", "90", "100"]; + const arcAngleLabel = ["0", "30", "45", "60", "90", "180"]; + const setxyValueLabel = ["-200", "-100", "0", "100", "200"]; this._pitchWheel = new wheelnav("wheelDivptm", null, 600, 600); this._exitWheel = new wheelnav("_exitWheel", this._pitchWheel.raphael); - this._blockLabelsWheel = new wheelnav( - "_blockLabelsWheel", - this._pitchWheel.raphael - ); - this._blockLabelsWheel2 = new wheelnav( - "_blockLabelsWheel2", - this._pitchWheel.raphael - ); - let _blockNames = MATRIXGRAPHICS2.slice(); - let _blockLabels = []; + this._blockLabelsWheel = new wheelnav("_blockLabelsWheel", this._pitchWheel.raphael); + this._blockLabelsWheel2 = new wheelnav("_blockLabelsWheel2", this._pitchWheel.raphael); + const _blockNames = MATRIXGRAPHICS2.slice(); + const _blockLabels = []; for (let i = 0; i < _blockNames.length; i++) { - _blockLabels.push( - this._logo.blocks.protoBlockDict[_blockNames[i]][ - "staticLabels" - ][0] - ); + _blockLabels.push(logo.blocks.protoBlockDict[_blockNames[i]]["staticLabels"][0]); } wheelnav.cssMode = true; @@ -1048,21 +989,21 @@ function PitchTimeMatrix() { this._blockLabelsWheel.animatetime = 0; this._blockLabelsWheel.createWheel(_blockLabels); - let x = this._labelcols[blockIndex].getBoundingClientRect().x; - let y = this._labelcols[blockIndex].getBoundingClientRect().y; + const x = this._labelcols[blockIndex].getBoundingClientRect().x; + const y = this._labelcols[blockIndex].getBoundingClientRect().y; docById("wheelDivptm").style.position = "absolute"; docById("wheelDivptm").style.height = "300px"; docById("wheelDivptm").style.width = "300px"; docById("wheelDivptm").style.left = Math.min( - this._logo.blocks.turtles._canvas.width - 200, - Math.max(0, x * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.width - 200, + Math.max(0, x * logo.blocks.getStageScale()) ) + "px"; docById("wheelDivptm").style.top = Math.min( - this._logo.blocks.turtles._canvas.height - 250, - Math.max(0, y * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.height - 250, + Math.max(0, y * logo.blocks.getStageScale()) ) + "px"; let thisBlock = this.columnBlocksMap[blockIndex][0]; @@ -1070,13 +1011,11 @@ function PitchTimeMatrix() { thisBlock = blk; } - let blockLabel = this._logo.blocks.blockList[thisBlock].name; - let xblockLabelValue = this._logo.blocks.blockList[ - this._logo.blocks.blockList[thisBlock].connections[1] - ].value; - let yblockLabelValue = this._logo.blocks.blockList[ - this._logo.blocks.blockList[thisBlock].connections[2] - ].value; + const blockLabel = logo.blocks.blockList[thisBlock].name; + const xblockLabelValue = + logo.blocks.blockList[logo.blocks.blockList[thisBlock].connections[1]].value; + const yblockLabelValue = + logo.blocks.blockList[logo.blocks.blockList[thisBlock].connections[2]].value; if (blockLabel === "arc") { this._blockLabelsWheel2.createWheel(arcAngleLabel); @@ -1093,131 +1032,95 @@ function PitchTimeMatrix() { this.yblockValue = [yblockLabelValue.toString(), "y"]; this._exitWheel.createWheel(["×", ""]); - let that = this; - this._exitWheel.navItems[0].navigateFunction = function() { + this._exitWheel.navItems[0].navigateFunction = () => { docById("wheelDivptm").style.display = "none"; - that._pitchWheel.removeWheel(); - that._exitWheel.removeWheel(); - that._blockLabelsWheel.removeWheel(); - that._blockLabelsWheel2.removeWheel(); + this._pitchWheel.removeWheel(); + this._exitWheel.removeWheel(); + this._blockLabelsWheel.removeWheel(); + this._blockLabelsWheel2.removeWheel(); }; - let __enterArgValue1 = function() { - that.xblockValue[0] = - that._blockLabelsWheel2.navItems[ - that._blockLabelsWheel2.selectedNavItemIndex - ].title; + const __enterArgValue1 = () => { + this.xblockValue[0] = this._blockLabelsWheel2.navItems[ + this._blockLabelsWheel2.selectedNavItemIndex + ].title; __selectionChanged(true); }; - let __enterArgValue2 = function() { - that.yblockValue[0] = - that._pitchWheel.navItems[ - that._pitchWheel.selectedNavItemIndex - ].title; + const __enterArgValue2 = () => { + this.yblockValue[0] = this._pitchWheel.navItems[ + this._pitchWheel.selectedNavItemIndex + ].title; __selectionChanged(true); }; if (blockLabel === "arc") { for (let i = 0; i < arcAngleLabel.length; i++) { - this._blockLabelsWheel2.navItems[ - i - ].navigateFunction = __enterArgValue1; + this._blockLabelsWheel2.navItems[i].navigateFunction = __enterArgValue1; } for (let i = 0; i < arcRadiusLabel.length; i++) { - this._pitchWheel.navItems[ - i - ].navigateFunction = __enterArgValue2; + this._pitchWheel.navItems[i].navigateFunction = __enterArgValue2; } } else if (blockLabel === "setxy") { for (let i = 0; i < setxyValueLabel.length; i++) { - this._blockLabelsWheel2.navItems[ - i - ].navigateFunction = __enterArgValue1; - this._pitchWheel.navItems[ - i - ].navigateFunction = __enterArgValue2; + this._blockLabelsWheel2.navItems[i].navigateFunction = __enterArgValue1; + this._pitchWheel.navItems[i].navigateFunction = __enterArgValue2; } } - let __selectionChanged = async function(updatingArgs) { - let thisBlockName = - _blockNames[that._blockLabelsWheel.selectedNavItemIndex]; + let __selectionChanged = async (updatingArgs) => { + const thisBlockName = _blockNames[this._blockLabelsWheel.selectedNavItemIndex]; let argBlock, z; if (updatingArgs === undefined) { // Creating a new block and removing the old one. - let newBlock = that._logo.blocks.blockList.length; - that._logo.blocks.loadNewBlocks([ + const newBlock = logo.blocks.blockList.length; + logo.blocks.loadNewBlocks([ [0, thisBlockName, 0, 0, [null, 1, 2, null]], - [ - 1, - ["number", { value: parseInt(that.xblockValue[0]) }], - 0, - 0, - [0] - ], - [ - 2, - ["number", { value: parseInt(that.yblockValue[0]) }], - 0, - 0, - [0] - ] + [1, ["number", { value: parseInt(this.xblockValue[0]) }], 0, 0, [0]], + [2, ["number", { value: parseInt(this.yblockValue[0]) }], 0, 0, [0]] ]); await delayExecution(500); - that._blockReplace(thisBlock, newBlock); - that.columnBlocksMap[blockIndex][0] = newBlock; + this._blockReplace(thisBlock, newBlock); + this.columnBlocksMap[blockIndex][0] = newBlock; thisBlock = newBlock; - that._createMatrixGraphics2PieSubmenu(blockIndex, newBlock); + this._createMatrixGraphics2PieSubmenu(blockIndex, newBlock); } else { // Just updating a block arg value - argBlock = - that._logo.blocks.blockList[thisBlock].connections[1]; - that._logo.blocks.blockList[argBlock].text.text = - that.xblockValue[0]; - that._logo.blocks.blockList[argBlock].value = parseInt( - that.xblockValue[0] - ); + argBlock = logo.blocks.blockList[thisBlock].connections[1]; + logo.blocks.blockList[argBlock].text.text = this.xblockValue[0]; + logo.blocks.blockList[argBlock].value = parseInt(this.xblockValue[0]); - z = - that._logo.blocks.blockList[argBlock].container.children - .length - 1; - that._logo.blocks.blockList[argBlock].container.setChildIndex( - that._logo.blocks.blockList[argBlock].text, + z = logo.blocks.blockList[argBlock].container.children.length - 1; + logo.blocks.blockList[argBlock].container.setChildIndex( + logo.blocks.blockList[argBlock].text, z ); - that._logo.blocks.blockList[argBlock].updateCache(); - - argBlock = - that._logo.blocks.blockList[thisBlock].connections[2]; - that._logo.blocks.blockList[argBlock].text.text = - that.yblockValue[0]; - that._logo.blocks.blockList[argBlock].value = parseInt( - that.yblockValue[0] - ); + logo.blocks.blockList[argBlock].updateCache(); - z = - that._logo.blocks.blockList[argBlock].container.children - .length - 1; - that._logo.blocks.blockList[argBlock].container.setChildIndex( - that._logo.blocks.blockList[argBlock].text, + argBlock = logo.blocks.blockList[thisBlock].connections[2]; + logo.blocks.blockList[argBlock].text.text = this.yblockValue[0]; + logo.blocks.blockList[argBlock].value = parseInt(this.yblockValue[0]); + + z = logo.blocks.blockList[argBlock].container.children.length - 1; + logo.blocks.blockList[argBlock].container.setChildIndex( + logo.blocks.blockList[argBlock].text, z ); - that._logo.blocks.blockList[argBlock].updateCache(); + logo.blocks.blockList[argBlock].updateCache(); } // Update the stored values for this node. - that.rowLabels[blockIndex] = thisBlockName; - that.rowArgs[blockIndex][0] = parseInt(that.xblockValue); - that.rowArgs[blockIndex][1] = parseInt(that.yblockValue); + this.rowLabels[blockIndex] = thisBlockName; + this.rowArgs[blockIndex][0] = parseInt(this.xblockValue); + this.rowArgs[blockIndex][1] = parseInt(this.yblockValue); // Update the cell label. let blockLabel; - cell = that._headcols[blockIndex]; - iconSize = ICONSIZE * (window.innerWidth / 1200); - if (MATRIXGRAPHICS2.indexOf(that.rowLabels[blockIndex]) !== -1) { + let cell = this._headcols[blockIndex]; + const iconSize = PhraseMaker.ICONSIZE * (window.innerWidth / 1200); + if (MATRIXGRAPHICS2.indexOf(this.rowLabels[blockIndex]) !== -1) { cell.innerHTML = '    '; } - cell = that._labelcols[blockIndex]; - if (MATRIXGRAPHICS2.indexOf(that.rowLabels[blockIndex]) !== -1) { + cell = this._labelcols[blockIndex]; + if (MATRIXGRAPHICS2.indexOf(this.rowLabels[blockIndex]) !== -1) { blockLabel = - that._logo.blocks.protoBlockDict[ - that.rowLabels[blockIndex] - ]["staticLabels"][0]; + logo.blocks.protoBlockDict[this.rowLabels[blockIndex]]["staticLabels"][0]; cell.innerHTML = blockLabel + "
    " + - that.rowArgs[blockIndex][0] + + this.rowArgs[blockIndex][0] + " " + - that.rowArgs[blockIndex][1]; - cell.style.fontSize = Math.floor(that._cellScale * 12) + "px"; + this.rowArgs[blockIndex][1]; + cell.style.fontSize = Math.floor(this._cellScale * 12) + "px"; } - noteStored = - that.rowLabels[blockIndex] + + const noteStored = + this.rowLabels[blockIndex] + ": " + - that.rowArgs[blockIndex][0] + + this.rowArgs[blockIndex][0] + ": " + - that.rowArgs[blockIndex][1]; + this.rowArgs[blockIndex][1]; - that._noteStored[blockIndex] = noteStored; + this._noteStored[blockIndex] = noteStored; }; for (let i = 0; i < _blockLabels.length; i++) { - this._blockLabelsWheel.navItems[ - i - ].navigateFunction = __selectionChanged; + this._blockLabelsWheel.navItems[i].navigateFunction = __selectionChanged; } - }; + } - this._createMatrixGraphicsPieSubmenu = function( - blockIndex, - condition, - blk - ) { + _createMatrixGraphicsPieSubmenu(blockIndex, condition, blk) { // A wheel for modifying 1-arg blocks (graphics and hertz) docById("wheelDivptm").style.display = ""; - let valueLabel, forwardBackLabel, leftRightLabel, setHeadingLabel, - setPenSizeLabel, setLabel; + let valueLabel, + forwardBackLabel, + leftRightLabel, + setHeadingLabel, + setPenSizeLabel, + setLabel; // Different blocks get different arg wheel values. if (condition === "synthsblocks") { - valueLabel = [ - "261", - "294", - "327", - "348", - "392", - "436", - "490", - "523" - ]; + valueLabel = ["261", "294", "327", "348", "392", "436", "490", "523"]; } else { valueLabel = [ "50", @@ -1297,43 +1187,18 @@ function PitchTimeMatrix() { ]; forwardBackLabel = ["1", "5", "10", "25", "50", "100", "200"]; leftRightLabel = ["15", "30", "45", "60", "90", "180"]; - setHeadingLabel = [ - "0", - "45", - "90", - "135", - "180", - "225", - "270", - "315" - ]; + setHeadingLabel = ["0", "45", "90", "135", "180", "225", "270", "315"]; setPenSizeLabel = ["1", "5", "10", "25", "50"]; - setLabel = [ - "0", - "10", - "20", - "30", - "40", - "5n0", - "60", - "70", - "80", - "90", - "100" - ]; + setLabel = ["0", "10", "20", "30", "40", "5n0", "60", "70", "80", "90", "100"]; } this._pitchWheel = new wheelnav("wheelDivptm", null, 800, 800); this._exitWheel = new wheelnav("_exitWheel", this._pitchWheel.raphael); - let blockNamesGraphics, blockLabelsGraphics, blockNamesPen, - blockLabelsPen, name; - blockLabelsPen; + let blockNamesGraphics, blockLabelsGraphics, blockNamesPen, blockLabelsPen, name; + blockLabelsPen; if (condition === "graphicsblocks") { - this._blockLabelsWheel = new wheelnav( - "_blockLabelsWheel", - this._pitchWheel.raphael - ); + this._blockLabelsWheel = new wheelnav("_blockLabelsWheel", this._pitchWheel.raphael); blockNamesGraphics = []; blockLabelsGraphics = []; blockNamesPen = []; @@ -1341,16 +1206,12 @@ function PitchTimeMatrix() { for (let i = 0; i < 5; i++) { name = MATRIXGRAPHICS[i]; blockNamesGraphics.push(name); - blockLabelsGraphics.push( - this._logo.blocks.protoBlockDict[name]["staticLabels"][0] - ); + blockLabelsGraphics.push(logo.blocks.protoBlockDict[name]["staticLabels"][0]); } for (let i = 5; i < MATRIXGRAPHICS.length; i++) { name = MATRIXGRAPHICS[i]; blockNamesPen.push(name); - blockLabelsPen.push( - this._logo.blocks.protoBlockDict[name]["staticLabels"][0] - ); + blockLabelsPen.push(logo.blocks.protoBlockDict[name]["staticLabels"][0]); } } @@ -1391,21 +1252,21 @@ function PitchTimeMatrix() { this._blockLabelsWheel.animatetime = 0; } - let x = this._labelcols[blockIndex].getBoundingClientRect().x; - let y = this._labelcols[blockIndex].getBoundingClientRect().y; + const x = this._labelcols[blockIndex].getBoundingClientRect().x; + const y = this._labelcols[blockIndex].getBoundingClientRect().y; docById("wheelDivptm").style.position = "absolute"; docById("wheelDivptm").style.height = "300px"; docById("wheelDivptm").style.width = "300px"; docById("wheelDivptm").style.left = Math.min( - this._logo.blocks.turtles._canvas.width - 200, - Math.max(0, x * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.width - 200, + Math.max(0, x * logo.blocks.getStageScale()) ) + "px"; docById("wheelDivptm").style.top = Math.min( - this._logo.blocks.turtles._canvas.height - 250, - Math.max(0, y * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.height - 250, + Math.max(0, y * logo.blocks.getStageScale()) ) + "px"; let thisBlock = this.columnBlocksMap[blockIndex][0]; @@ -1413,10 +1274,9 @@ function PitchTimeMatrix() { thisBlock = blk; } - let blockLabel = this._logo.blocks.blockList[thisBlock].name; - let blockLabelValue = this._logo.blocks.blockList[ - this._logo.blocks.blockList[thisBlock].connections[1] - ].value; + let blockLabel = logo.blocks.blockList[thisBlock].name; + const blockLabelValue = + logo.blocks.blockList[logo.blocks.blockList[thisBlock].connections[1]].value; if (condition === "graphicsblocks") { if (blockLabel === "forward" || blockLabel === "back") { @@ -1442,56 +1302,43 @@ function PitchTimeMatrix() { this.blockValue = blockLabelValue.toString(); this._exitWheel.createWheel(["×", ""]); - let that = this; - this._exitWheel.navItems[0].navigateFunction = function() { + this._exitWheel.navItems[0].navigateFunction = () => { docById("wheelDivptm").style.display = "none"; - that._pitchWheel.removeWheel(); - that._exitWheel.removeWheel(); + this._pitchWheel.removeWheel(); + this._exitWheel.removeWheel(); if (condition === "graphicsblocks") { - that._blockLabelsWheel.removeWheel(); + this._blockLabelsWheel.removeWheel(); } }; - let __enterArgValue = function() { - that.blockValue = - that._pitchWheel.navItems[ - that._pitchWheel.selectedNavItemIndex - ].title; - docById("wheelnav-_exitWheel-title-1").children[0].textContent = - that.blockValue; + const __enterArgValue = () => { + this.blockValue = this._pitchWheel.navItems[ + this._pitchWheel.selectedNavItemIndex + ].title; + docById("wheelnav-_exitWheel-title-1").children[0].textContent = this.blockValue; __selectionChanged(true); }; if (condition === "graphicsblocks") { if (blockLabel === "forward" || blockLabel === "back") { for (let i = 0; i < forwardBackLabel.length; i++) { - this._pitchWheel.navItems[ - i - ].navigateFunction = __enterArgValue; + this._pitchWheel.navItems[i].navigateFunction = __enterArgValue; } } else if (blockLabel === "right" || blockLabel === "left") { for (let i = 0; i < leftRightLabel.length; i++) { - this._pitchWheel.navItems[ - i - ].navigateFunction = __enterArgValue; + this._pitchWheel.navItems[i].navigateFunction = __enterArgValue; } } else if (blockLabel === "setheading") { for (let i = 0; i < setHeadingLabel.length; i++) { - this._pitchWheel.navItems[ - i - ].navigateFunction = __enterArgValue; + this._pitchWheel.navItems[i].navigateFunction = __enterArgValue; } } else if (blockLabel === "setpensize") { for (let i = 0; i < setPenSizeLabel.length; i++) { - this._pitchWheel.navItems[ - i - ].navigateFunction = __enterArgValue; + this._pitchWheel.navItems[i].navigateFunction = __enterArgValue; } } else { for (let i = 0; i < setLabel.length; i++) { - this._pitchWheel.navItems[ - i - ].navigateFunction = __enterArgValue; + this._pitchWheel.navItems[i].navigateFunction = __enterArgValue; } } } else if (condition === "synthsblocks") { @@ -1500,14 +1347,12 @@ function PitchTimeMatrix() { } } - let __selectionChanged = async function(updatingArgs) { + let __selectionChanged = async (updatingArgs) => { let thisBlockName = "hertz"; let label, newBlock, argBlock, z; if (condition === "graphicsblocks") { - label = - that._blockLabelsWheel.navItems[ - that._blockLabelsWheel.selectedNavItemIndex - ].title; + label = this._blockLabelsWheel.navItems[this._blockLabelsWheel.selectedNavItemIndex] + .title; let i = blockLabelsGraphics.indexOf(label); if (i === -1) { i = blockLabelsPen.indexOf(label); @@ -1520,55 +1365,39 @@ function PitchTimeMatrix() { } if (updatingArgs === undefined) { - newBlock = that._logo.blocks.blockList.length; - that._logo.blocks.loadNewBlocks([ + newBlock = logo.blocks.blockList.length; + logo.blocks.loadNewBlocks([ [0, thisBlockName, 0, 0, [null, 1, null]], - [ - 1, - ["number", { value: parseInt(that.blockValue) }], - 0, - 0, - [0] - ] + [1, ["number", { value: parseInt(this.blockValue) }], 0, 0, [0]] ]); await delayExecution(500); - that._blockReplace(thisBlock, newBlock); - that.columnBlocksMap[blockIndex][0] = newBlock; + this._blockReplace(thisBlock, newBlock); + this.columnBlocksMap[blockIndex][0] = newBlock; thisBlock = newBlock; - that._createMatrixGraphicsPieSubmenu( - blockIndex, - condition, - newBlock - ); + this._createMatrixGraphicsPieSubmenu(blockIndex, condition, newBlock); } else { // Just updating a block arg value - argBlock = - that._logo.blocks.blockList[thisBlock].connections[1]; - that._logo.blocks.blockList[argBlock].text.text = - that.blockValue; - that._logo.blocks.blockList[argBlock].value = parseInt( - that.blockValue - ); + argBlock = logo.blocks.blockList[thisBlock].connections[1]; + logo.blocks.blockList[argBlock].text.text = this.blockValue; + logo.blocks.blockList[argBlock].value = parseInt(this.blockValue); - z = - that._logo.blocks.blockList[argBlock].container.children - .length - 1; - that._logo.blocks.blockList[argBlock].container.setChildIndex( - that._logo.blocks.blockList[argBlock].text, + z = logo.blocks.blockList[argBlock].container.children.length - 1; + logo.blocks.blockList[argBlock].container.setChildIndex( + logo.blocks.blockList[argBlock].text, z ); - that._logo.blocks.blockList[argBlock].updateCache(); + logo.blocks.blockList[argBlock].updateCache(); } // Update the stored values for this node. - that.rowLabels[blockIndex] = thisBlockName; - that.rowArgs[blockIndex] = parseInt(that.blockValue); + this.rowLabels[blockIndex] = thisBlockName; + this.rowArgs[blockIndex] = parseInt(this.blockValue); // Update the cell label. - let cell = that._headcols[blockIndex]; - let iconSize = ICONSIZE * (window.innerWidth / 1200); - if (MATRIXSYNTHS.indexOf(that.rowLabels[blockIndex]) !== -1) { + let cell = this._headcols[blockIndex]; + const iconSize = PhraseMaker.ICONSIZE * (window.innerWidth / 1200); + if (MATRIXSYNTHS.indexOf(this.rowLabels[blockIndex]) !== -1) { cell.innerHTML = '    '; - } else if ( - MATRIXGRAPHICS.indexOf(that.rowLabels[blockIndex]) !== -1 - ) { + } else if (MATRIXGRAPHICS.indexOf(this.rowLabels[blockIndex]) !== -1) { cell.innerHTML = '    '; } - cell = that._labelcols[blockIndex]; - if (MATRIXSYNTHS.indexOf(that.rowLabels[blockIndex]) !== -1) { - cell.innerHTML = that.rowArgs[blockIndex]; + cell = this._labelcols[blockIndex]; + if (MATRIXSYNTHS.indexOf(this.rowLabels[blockIndex]) !== -1) { + cell.innerHTML = this.rowArgs[blockIndex]; cell.style.fontSize = Math.floor(this._cellScale * 14) + "px"; - } else if ( - MATRIXGRAPHICS.indexOf(that.rowLabels[blockIndex]) !== -1 - ) { + } else if (MATRIXGRAPHICS.indexOf(this.rowLabels[blockIndex]) !== -1) { blockLabel = - that._logo.blocks.protoBlockDict[ - that.rowLabels[blockIndex] - ]["staticLabels"][0]; - cell.innerHTML = blockLabel + "
    " + that.rowArgs[blockIndex]; - cell.style.fontSize = Math.floor(that._cellScale * 12) + "px"; + logo.blocks.protoBlockDict[this.rowLabels[blockIndex]]["staticLabels"][0]; + cell.innerHTML = blockLabel + "
    " + this.rowArgs[blockIndex]; + cell.style.fontSize = Math.floor(this._cellScale * 12) + "px"; } let noteStored = null; if (condition === "graphicsblocks") { - noteStored = - that.rowLabels[blockIndex] + - ": " + - that.rowArgs[blockIndex]; + noteStored = this.rowLabels[blockIndex] + ": " + this.rowArgs[blockIndex]; } else if (condition === "synthsblocks") { - noteStored = that.rowArgs[blockIndex]; + noteStored = this.rowArgs[blockIndex]; } - that._noteStored[blockIndex] = - that.rowLabels[blockIndex] + ": " + that.rowArgs[blockIndex]; + this._noteStored[blockIndex] = + this.rowLabels[blockIndex] + ": " + this.rowArgs[blockIndex]; }; if (condition === "graphicsblocks") { if (blockLabel === "forward" || blockLabel === "back") { for (let i = 0; i < blockLabelsGraphics.length; i++) { - this._blockLabelsWheel.navItems[ - i - ].navigateFunction = __selectionChanged; + this._blockLabelsWheel.navItems[i].navigateFunction = __selectionChanged; } } else if (blockLabel === "right" || blockLabel === "left") { for (let i = 0; i < blockLabelsGraphics.length; i++) { - this._blockLabelsWheel.navItems[ - i - ].navigateFunction = __selectionChanged; + this._blockLabelsWheel.navItems[i].navigateFunction = __selectionChanged; } } else if (blockLabel === "setheading") { for (let i = 0; i < blockLabelsGraphics.length; i++) { - this._blockLabelsWheel.navItems[ - i - ].navigateFunction = __selectionChanged; + this._blockLabelsWheel.navItems[i].navigateFunction = __selectionChanged; } } else if (blockLabel === "setpensize") { for (let i = 0; i < blockLabelsPen.length; i++) { - this._blockLabelsWheel.navItems[ - i - ].navigateFunction = __selectionChanged; + this._blockLabelsWheel.navItems[i].navigateFunction = __selectionChanged; } } else { for (let i = 0; i < blockLabelsPen.length; i++) { - this._blockLabelsWheel.navItems[ - i - ].navigateFunction = __selectionChanged; + this._blockLabelsWheel.navItems[i].navigateFunction = __selectionChanged; } } } - }; + } - this._createColumnPieSubmenu = function(index, condition, sortedClose) { + _createColumnPieSubmenu(index, condition, sortedClose) { index = parseInt(index); docById("wheelDivptm").style.display = ""; - let accidentals = ["𝄪", "♯", "♮", "♭", "𝄫"]; + const accidentals = ["𝄪", "♯", "♮", "♭", "𝄫"]; let noteLabels = ["ti", "la", "sol", "fa", "mi", "re", "do"]; - let drumLabels = []; + const drumLabels = []; let label; for (let i = 0; i < DRUMS.length; i++) { label = _(DRUMS[i]); @@ -1668,29 +1478,10 @@ function PitchTimeMatrix() { } let categories; - let colors = []; + const colors = []; if (condition === "drumblocks") { noteLabels = drumLabels; - categories = [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2 - ]; + categories = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2]; const COLORS = platformColor.piemenuVoicesColors; for (let i = 0; i < drumLabels.length; i++) { @@ -1707,14 +1498,8 @@ function PitchTimeMatrix() { // this._pitchWheel = new wheelnav('wheelDivptm', null, 600, 600); this._exitWheel = new wheelnav("_exitWheel", this._pitchWheel.raphael); if (condition === "pitchblocks") { - this._accidentalsWheel = new wheelnav( - "_accidentalsWheel", - this._pitchWheel.raphael - ); - this._octavesWheel = new wheelnav( - "_octavesWheel", - this._pitchWheel.raphael - ); + this._accidentalsWheel = new wheelnav("_accidentalsWheel", this._pitchWheel.raphael); + this._octavesWheel = new wheelnav("_octavesWheel", this._pitchWheel.raphael); } wheelnav.cssMode = true; @@ -1749,13 +1534,12 @@ function PitchTimeMatrix() { this._exitWheel.clickModeRotate = false; this._exitWheel.createWheel(["×", " "]); - let accidentalLabels = []; + const accidentalLabels = []; let octaveLabels = []; let block, noteValue, octaveValue, accidentalsValue; if (condition === "pitchblocks") { - this._accidentalsWheel.colors = - platformColor.accidentalsWheelcolors; + this._accidentalsWheel.colors = platformColor.accidentalsWheelcolors; this._accidentalsWheel.slicePathFunction = slicePath().DonutSlice; this._accidentalsWheel.slicePathCustom = slicePath().DonutSliceCustomization(); this._accidentalsWheel.slicePathCustom.minRadiusPercent = 0.5; @@ -1769,9 +1553,7 @@ function PitchTimeMatrix() { for (let i = 0; i < 9; i++) { accidentalLabels.push(null); - this._accidentalsWheel.colors.push( - platformColor.accidentalsWheelcolorspush - ); + this._accidentalsWheel.colors.push(platformColor.accidentalsWheelcolorspush); } this._accidentalsWheel.animatetime = 0; // 300; @@ -1811,84 +1593,79 @@ function PitchTimeMatrix() { this._octavesWheel.createWheel(octaveLabels); } - let x = this._labelcols[index].getBoundingClientRect().x; - let y = this._labelcols[index].getBoundingClientRect().y; + const x = this._labelcols[index].getBoundingClientRect().x; + const y = this._labelcols[index].getBoundingClientRect().y; docById("wheelDivptm").style.position = "absolute"; docById("wheelDivptm").style.height = "300px"; docById("wheelDivptm").style.width = "300px"; docById("wheelDivptm").style.left = Math.min( - this._logo.blocks.turtles._canvas.width - 200, - Math.max(0, x * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.width - 200, + Math.max(0, x * logo.blocks.getStageScale()) ) + "px"; docById("wheelDivptm").style.top = Math.min( - this._logo.blocks.turtles._canvas.height - 250, - Math.max(0, y * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.height - 250, + Math.max(0, y * logo.blocks.getStageScale()) ) + "px"; if (!this._noteBlocks) { block = this.columnBlocksMap[index][0]; - noteValue = this._logo.blocks.blockList[ - this._logo.blocks.blockList[block].connections[1] - ].value; + noteValue = logo.blocks.blockList[logo.blocks.blockList[block].connections[1]].value; if (condition === "pitchblocks") { - octaveValue = this._logo.blocks.blockList[ - this._logo.blocks.blockList[block].connections[2] - ].value; + octaveValue = + logo.blocks.blockList[logo.blocks.blockList[block].connections[2]].value; accidentalsValue = 2; for (let i = 0; i < accidentals.length; i++) { if (noteValue.indexOf(accidentals[i]) !== -1) { accidentalsValue = i; - noteValue = noteValue.substr( - 0, - noteValue.indexOf(accidentals[i]) - ); + noteValue = noteValue.substr(0, noteValue.indexOf(accidentals[i])); break; } } this._accidentalsWheel.navigateWheel(accidentalsValue); - this._octavesWheel.navigateWheel( - octaveLabels.indexOf(octaveValue.toString()) + this._octavesWheel.navigateWheel(octaveLabels.indexOf(octaveValue.toString())); + } + if (condition === "drumblocks") { + this._pitchWheel.navigateWheel( + noteLabels.indexOf( + docBySelector('.labelcol[alt="' + index + '__drumblocks"]').innerText + ) ); + } else { + this._pitchWheel.navigateWheel(noteLabels.indexOf(noteValue)); } - this._pitchWheel.navigateWheel(noteLabels.indexOf(noteValue)); } - let that = this; - this._exitWheel.navItems[0].navigateFunction = function() { + this._exitWheel.navItems[0].navigateFunction = () => { docById("wheelDivptm").style.display = "none"; - that._pitchWheel.removeWheel(); - that._exitWheel.removeWheel(); + this._pitchWheel.removeWheel(); + this._exitWheel.removeWheel(); if (condition === "pitchblocks") { - that._accidentalsWheel.removeWheel(); - that._octavesWheel.removeWheel(); + this._accidentalsWheel.removeWheel(); + this._octavesWheel.removeWheel(); } - that.sorted = false; + this.sorted = false; if (sortedClose === true) { - that._sort(); + this._sort(); } }; - let __selectionChanged = function() { - let label = - that._pitchWheel.navItems[that._pitchWheel.selectedNavItemIndex] - .title; - let i = noteLabels.indexOf(label); + const __selectionChanged = () => { + let label = this._pitchWheel.navItems[this._pitchWheel.selectedNavItemIndex].title; + const i = noteLabels.indexOf(label); let attr, flag, z; let noteLabelBlock; let octave, noteObj; if (condition === "pitchblocks") { - attr = - that._accidentalsWheel.navItems[ - that._accidentalsWheel.selectedNavItemIndex - ].title; + attr = this._accidentalsWheel.navItems[this._accidentalsWheel.selectedNavItemIndex] + .title; flag = false; if (attr !== "♮") { label += attr; @@ -1898,34 +1675,27 @@ function PitchTimeMatrix() { this.sorted = false; } - if (!that._noteBlocks) { - noteLabelBlock = - that._logo.blocks.blockList[block].connections[1]; - that._logo.blocks.blockList[noteLabelBlock].text.text = label; - that._logo.blocks.blockList[noteLabelBlock].value = label; - - z = - that._logo.blocks.blockList[noteLabelBlock].container.children - .length - 1; - that._logo.blocks.blockList[noteLabelBlock].container.setChildIndex( - that._logo.blocks.blockList[noteLabelBlock].text, + if (!this._noteBlocks) { + noteLabelBlock = logo.blocks.blockList[block].connections[1]; + logo.blocks.blockList[noteLabelBlock].text.text = label; + logo.blocks.blockList[noteLabelBlock].value = label; + + z = logo.blocks.blockList[noteLabelBlock].container.children.length - 1; + logo.blocks.blockList[noteLabelBlock].container.setChildIndex( + logo.blocks.blockList[noteLabelBlock].text, z ); - that._logo.blocks.blockList[noteLabelBlock].updateCache(); + logo.blocks.blockList[noteLabelBlock].updateCache(); } if (condition === "pitchblocks") { octave = Number( - that._octavesWheel.navItems[ - that._octavesWheel.selectedNavItemIndex - ].title + this._octavesWheel.navItems[this._octavesWheel.selectedNavItemIndex].title ); - if (!that._noteBlocks) { - that._logo.blocks.blockList[ - noteLabelBlock - ].blocks.setPitchOctave( - that._logo.blocks.blockList[noteLabelBlock].connections[0], + if (!this._noteBlocks) { + logo.blocks.blockList[noteLabelBlock].blocks.setPitchOctave( + logo.blocks.blockList[noteLabelBlock].connections[0], octave ); } @@ -1936,21 +1706,21 @@ function PitchTimeMatrix() { label, octave, 0, - that._logo.turtles.ithTurtle(0).singer.keySignature, + turtles.ithTurtle(0).singer.keySignature, false, null, - that._logo.errorMsg, - that._logo.synth.inTemperament + logo.errorMsg, + logo.synth.inTemperament ); } - that.rowLabels[index] = noteObj[0]; - that.rowArgs[index] = noteObj[1]; + this.rowLabels[index] = noteObj[0]; + this.rowArgs[index] = noteObj[1]; } else if (condition === "drumblocks") { - that.rowLabels[index] = label; + this.rowLabels[index] = label; } - let cell = that._headcols[index]; - let drumName = getDrumName(that.rowLabels[index]); + let cell = this._headcols[index]; + const drumName = getDrumName(this.rowLabels[index]); const BELLSETIDX = { C: 1, D: 2, @@ -1967,9 +1737,9 @@ function PitchTimeMatrix() { la: 6, ti: 7 }; - let noteName = that.rowLabels[index]; - let w = window.innerWidth; - let iconSize = ICONSIZE * (w / 1200); + const noteName = this.rowLabels[index]; + const w = window.innerWidth; + const iconSize = PhraseMaker.ICONSIZE * (w / 1200); if (drumName != null) { cell.innerHTML = '    '; - } else if (noteName in BELLSETIDX && that.rowArgs[index] === 4) { + } else if (noteName in BELLSETIDX && this.rowArgs[index] === 4) { cell.innerHTML = ''; - } else if (noteName === "C" && that.rowArgs[index] === 5) { + } else if (noteName === "C" && this.rowArgs[index] === 5) { cell.innerHTML = ''; } - cell = that._labelcols[index]; + cell = this._labelcols[index]; if (drumName != null) { cell.innerHTML = _(drumName); cell.style.fontSize = Math.floor(this._cellScale * 14) + "px"; - } else if ( - noteIsSolfege(that.rowLabels[i]) && - !isCustom(that._logo.synth.inTemperament) - ) { + } else if (noteIsSolfege(this.rowLabels[i]) && !isCustom(logo.synth.inTemperament)) { cell.innerHTML = - i18nSolfege(that.rowLabels[index]) + - that.rowArgs[index].toString().sub(); + i18nSolfege(this.rowLabels[index]) + this.rowArgs[index].toString().sub(); noteObj = getNote( - that.rowLabels[index], - that.rowArgs[index], + this.rowLabels[index], + this.rowArgs[index], 0, - that._logo.turtles.ithTurtle(0).singer.keySignature, + turtles.ithTurtle(0).singer.keySignature, false, null, - that._logo.errorMsg, - that._logo.synth.inTemperament + logo.errorMsg, + logo.synth.inTemperament ); } else { - cell.innerHTML = - that.rowLabels[index] + - that.rowArgs[index].toString().sub(); - noteObj = [that.rowLabels[index], that.rowArgs[index]]; + cell.innerHTML = this.rowLabels[index] + this.rowArgs[index].toString().sub(); + noteObj = [this.rowLabels[index], this.rowArgs[index]]; } let noteStored = null; @@ -2036,51 +1800,38 @@ function PitchTimeMatrix() { noteStored = drumName; } - that._noteStored[index] = noteStored; + this._noteStored[index] = noteStored; }; - let __pitchPreview = function() { - let label = - that._pitchWheel.navItems[that._pitchWheel.selectedNavItemIndex] - .title; + const __pitchPreview = () => { + let label = this._pitchWheel.navItems[this._pitchWheel.selectedNavItemIndex].title; let timeout = 0; let attr, octave, obj, tur; if (condition === "pitchblocks") { - attr = - that._accidentalsWheel.navItems[ - that._accidentalsWheel.selectedNavItemIndex - ].title; + attr = this._accidentalsWheel.navItems[this._accidentalsWheel.selectedNavItemIndex] + .title; if (attr !== "♮") { label += attr; } octave = Number( - that._octavesWheel.navItems[ - that._octavesWheel.selectedNavItemIndex - ].title + this._octavesWheel.navItems[this._octavesWheel.selectedNavItemIndex].title ); obj = getNote( label, octave, 0, - that._logo.turtles.ithTurtle(0).singer.keySignature, + turtles.ithTurtle(0).singer.keySignature, false, null, - that._logo.errorMsg, - that._logo.synth.inTemperament - ); - obj[0] = obj[0].replace(SHARP, '#').replace(FLAT, 'b'); - that._logo.synth.setMasterVolume(PREVIEWVOLUME); - Singer.setSynthVolume(that._logo, 0, DEFAULTVOICE, PREVIEWVOLUME); - that._logo.synth.trigger( - 0, - [obj[0] + obj[1]], - 1 / 8, - DEFAULTVOICE, - null, - null + logo.errorMsg, + logo.synth.inTemperament ); + obj[0] = obj[0].replace(SHARP, "#").replace(FLAT, "b"); + logo.synth.setMasterVolume(PREVIEWVOLUME); + Singer.setSynthVolume(logo, 0, DEFAULTVOICE, PREVIEWVOLUME); + logo.synth.trigger(0, [obj[0] + obj[1]], 1 / 8, DEFAULTVOICE, null, null); } else if (condition === "drumblocks") { - tur = that._logo.turtles.ithTurtle(0); + tur = turtles.ithTurtle(0); if ( tur.singer.instrumentNames.length === 0 || @@ -2088,29 +1839,21 @@ function PitchTimeMatrix() { ) { tur.singer.instrumentNames.push(label); if (label === DEFAULTVOICE) { - that._logo.synth.createDefaultSynth(0); + logo.synth.createDefaultSynth(0); } - that._logo.synth.loadSynth(0, label); + logo.synth.loadSynth(0, label); // give the synth time to load timeout = 500; } else { timeout = 0; } - setTimeout(function() { - that._logo.synth.setMasterVolume(DEFAULTVOLUME); - Singer.setSynthVolume(that._logo, 0, label, DEFAULTVOLUME); - that._logo.synth.trigger( - 0, - "G4", - 1 / 4, - label, - null, - null, - false - ); - that._logo.synth.start(); + setTimeout(() => { + logo.synth.setMasterVolume(DEFAULTVOLUME); + Singer.setSynthVolume(logo, 0, label, DEFAULTVOLUME); + logo.synth.trigger(0, "G4", 1 / 4, label, null, null, false); + logo.synth.start(); }, timeout); } __selectionChanged(); @@ -2121,36 +1864,30 @@ function PitchTimeMatrix() { } if (condition === "pitchblocks") { for (let i = 0; i < accidentals.length; i++) { - this._accidentalsWheel.navItems[i] - .navigateFunction = __pitchPreview; + this._accidentalsWheel.navItems[i].navigateFunction = __pitchPreview; } for (let i = 0; i < 8; i++) { - this._octavesWheel.navItems[i] - .navigateFunction = __pitchPreview; + this._octavesWheel.navItems[i].navigateFunction = __pitchPreview; } } - }; + } - this._blockReplace = function(oldblk, newblk) { + _blockReplace(oldblk, newblk) { // Find the connections from the old block - let c0 = this._logo.blocks.blockList[oldblk].connections[0]; - let c1 = last(this._logo.blocks.blockList[oldblk].connections); + const c0 = logo.blocks.blockList[oldblk].connections[0]; + const c1 = last(logo.blocks.blockList[oldblk].connections); // Connect the new block - this._logo.blocks.blockList[newblk].connections[0] = c0; - this._logo.blocks.blockList[newblk].connections[ - this._logo.blocks.blockList[newblk].connections.length - 1 + logo.blocks.blockList[newblk].connections[0] = c0; + logo.blocks.blockList[newblk].connections[ + logo.blocks.blockList[newblk].connections.length - 1 ] = c1; if (c0 != null) { - for ( - let i = 0; - i < this._logo.blocks.blockList[c0].connections.length; - i++ - ) { - if (this._logo.blocks.blockList[c0].connections[i] === oldblk) { - this._logo.blocks.blockList[c0].connections[i] = newblk; + for (let i = 0; i < logo.blocks.blockList[c0].connections.length; i++) { + if (logo.blocks.blockList[c0].connections[i] === oldblk) { + logo.blocks.blockList[c0].connections[i] = newblk; break; } } @@ -2158,93 +1895,83 @@ function PitchTimeMatrix() { // Look for a containing clamp, which may need to be resized. let blockAbove = c0; while (blockAbove !== this.blockNo) { - if (this._logo.blocks.blockList[blockAbove].isClampBlock()) { - this._logo.blocks.clampBlocksToCheck.push([blockAbove, 0]); + if (logo.blocks.blockList[blockAbove].isClampBlock()) { + logo.blocks.clampBlocksToCheck.push([blockAbove, 0]); } - blockAbove = this._logo.blocks.blockList[blockAbove] - .connections[0]; + blockAbove = logo.blocks.blockList[blockAbove].connections[0]; } - this._logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); + logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); } if (c1 != null) { - for ( - let i = 0; - i < this._logo.blocks.blockList[c1].connections.length; - i++ - ) { - if (this._logo.blocks.blockList[c1].connections[i] === oldblk) { - this._logo.blocks.blockList[c1].connections[i] = newblk; + for (let i = 0; i < logo.blocks.blockList[c1].connections.length; i++) { + if (logo.blocks.blockList[c1].connections[i] === oldblk) { + logo.blocks.blockList[c1].connections[i] = newblk; break; } } } // Refresh the dock positions - this._logo.blocks.adjustDocks(c0, true); + logo.blocks.adjustDocks(c0, true); // Send the old block to the trash - this._logo.blocks.blockList[oldblk].connections[0] = null; - this._logo.blocks.blockList[oldblk].connections[ - this._logo.blocks.blockList[oldblk].connections.length - 1 + logo.blocks.blockList[oldblk].connections[0] = null; + logo.blocks.blockList[oldblk].connections[ + logo.blocks.blockList[oldblk].connections.length - 1 ] = null; - this._logo.blocks.sendStackToTrash(this._logo.blocks.blockList[oldblk]); + logo.blocks.sendStackToTrash(logo.blocks.blockList[oldblk]); - this._logo.refreshCanvas(); - }; + logo.refreshCanvas(); + } - this._addNotesBlockBetween = function(aboveBlock, block, topBlock) { + _addNotesBlockBetween(aboveBlock, block, topBlock) { let belowBlock; if (topBlock) { - belowBlock = this._logo.blocks.blockList[aboveBlock] - .connections[1]; - this._logo.blocks.blockList[aboveBlock].connections[1] = block; + belowBlock = logo.blocks.blockList[aboveBlock].connections[1]; + logo.blocks.blockList[aboveBlock].connections[1] = block; } else { - belowBlock = last( - this._logo.blocks.blockList[aboveBlock].connections - ); - this._logo.blocks.blockList[aboveBlock].connections[ - this._logo.blocks.blockList[aboveBlock].connections.length - 1 + belowBlock = last(logo.blocks.blockList[aboveBlock].connections); + logo.blocks.blockList[aboveBlock].connections[ + logo.blocks.blockList[aboveBlock].connections.length - 1 ] = block; } - this._logo.blocks.blockList[belowBlock].connections[0] = block; - this._logo.blocks.blockList[block].connections[0] = aboveBlock; - this._logo.blocks.blockList[block].connections[ - this._logo.blocks.blockList[block].connections.length - 1 + logo.blocks.blockList[belowBlock].connections[0] = block; + logo.blocks.blockList[block].connections[0] = aboveBlock; + logo.blocks.blockList[block].connections[ + logo.blocks.blockList[block].connections.length - 1 ] = belowBlock; - this._logo.blocks.adjustDocks(this.blockNo, true); - this._logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); - this._logo.blocks.refreshCanvas(); - }; - - this._removePitchBlock = function(blockNo) { - let c0 = this._logo.blocks.blockList[blockNo].connections[0]; - let c1 = last(this._logo.blocks.blockList[blockNo].connections); - this._logo.blocks.blockList[c0].connections[ - this._logo.blocks.blockList[c0].connections.length - 1 + logo.blocks.adjustDocks(this.blockNo, true); + logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); + logo.blocks.refreshCanvas(); + } + + _removePitchBlock(blockNo) { + const c0 = logo.blocks.blockList[blockNo].connections[0]; + const c1 = last(logo.blocks.blockList[blockNo].connections); + logo.blocks.blockList[c0].connections[ + logo.blocks.blockList[c0].connections.length - 1 ] = c1; - this._logo.blocks.blockList[c1].connections[0] = c0; + logo.blocks.blockList[c1].connections[0] = c0; - this._logo.blocks.blockList[blockNo].connections[ - this._logo.blocks.blockList[blockNo].connections.length - 1 + logo.blocks.blockList[blockNo].connections[ + logo.blocks.blockList[blockNo].connections.length - 1 ] = null; - this._logo.blocks.sendStackToTrash( - this._logo.blocks.blockList[blockNo] - ); - this._logo.blocks.adjustDocks(this.blockNo, true); - this._logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); - this._logo.blocks.refreshCanvas(); - }; - - this._generateDataURI = function(file) { - let data = "data: text/html;charset=utf-8, " + encodeURIComponent(file); + logo.blocks.sendStackToTrash(logo.blocks.blockList[blockNo]); + logo.blocks.adjustDocks(this.blockNo, true); + logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); + logo.blocks.refreshCanvas(); + } + + _generateDataURI(file) { + const data = "data: text/html;charset=utf-8, " + encodeURIComponent(file); return data; - }; + } - this._sort = function() { + _sort() { if (this.sorted) { console.debug("already sorted"); return; @@ -2266,7 +1993,7 @@ function PitchTimeMatrix() { this._markedColsInRow.push(thisRow); } - let sortableList = []; + const sortableList = []; let drumName, drumIndex; // Make a list to sort, skipping drums and graphics. // frequency;label;arg;row index @@ -2298,7 +2025,7 @@ function PitchTimeMatrix() { sortableList.push([ noteToFrequency( this.rowLabels[i] + this.rowArgs[i], - this._logo.turtles.ithTurtle(0).singer.keySignature + turtles.ithTurtle(0).singer.keySignature ), this.rowLabels[i], this.rowArgs[i], @@ -2346,7 +2073,7 @@ function PitchTimeMatrix() { } } - let sortedList = sortableList.sort(function(a, b) { + let sortedList = sortableList.sort((a, b) => { return a[0] - b[0]; }); @@ -2362,8 +2089,8 @@ function PitchTimeMatrix() { for (let i = 0; i < sortedList.length; i++) { this._rowMapper.push(sortedList[i][3]); } - let newColumnBlockMap = []; - let oldColumnBlockMap = this.columnBlocksMap; + const newColumnBlockMap = []; + const oldColumnBlockMap = this.columnBlocksMap; for (let i = 0; i < this._rowMapper.length; i++) { newColumnBlockMap.push(this.columnBlocksMap[this._rowMapper[i]]); } @@ -2379,23 +2106,15 @@ function PitchTimeMatrix() { if (i === 0) { this._sortedRowMap.push(0); } else if (i > 0 && obj[1] !== "hertz" && obj[1] === last(this.rowLabels)) { - console.debug( - "skipping " + obj[1] + " " + last(this.rowLabels) - ); + console.debug("skipping " + obj[1] + " " + last(this.rowLabels)); this._sortedRowMap.push(last(this._sortedRowMap)); if (oldColumnBlockMap[sortedList[lastObj][3]] != undefined) { setTimeout( - this._removePitchBlock( - oldColumnBlockMap[sortedList[lastObj][3]][0] - ), + this._removePitchBlock(oldColumnBlockMap[sortedList[lastObj][3]][0]), 500 ); - this.columnBlocksMap = this.columnBlocksMap.filter(function( - ele - ) { - return ( - ele[0] !== oldColumnBlockMap[sortedList[lastObj][3]][0] - ); + this.columnBlocksMap = this.columnBlocksMap.filter((ele) => { + return ele[0] !== oldColumnBlockMap[sortedList[lastObj][3]][0]; }); lastObj = i; } @@ -2418,67 +2137,58 @@ function PitchTimeMatrix() { this._matrixHasTuplets = false; // Force regeneration of tuplet rows. this.sorted = true; - this.init(this._logo); + this.init(logo); this.sorted = true; let tupletParam; - for (let i = 0; i < this._logo.tupletRhythms.length; i++) { - switch (this._logo.tupletRhythms[i][0]) { + for (let i = 0; i < logo.tupletRhythms.length; i++) { + switch (logo.tupletRhythms[i][0]) { case "simple": case "notes": - tupletParam = [ - this._logo.tupletParams[this._logo.tupletRhythms[i][1]] - ]; + tupletParam = [logo.tupletParams[logo.tupletRhythms[i][1]]]; tupletParam.push([]); - for ( - let j = 2; - j < this._logo.tupletRhythms[i].length; - j++ - ) { - tupletParam[1].push(this._logo.tupletRhythms[i][j]); + for (let j = 2; j < logo.tupletRhythms[i].length; j++) { + tupletParam[1].push(logo.tupletRhythms[i][j]); } this.addTuplet(tupletParam); break; default: - this.addNotes( - this._logo.tupletRhythms[i][1], - this._logo.tupletRhythms[i][2] - ); + this.addNotes(logo.tupletRhythms[i][1], logo.tupletRhythms[i][2]); break; } } this.makeClickable(); - }; + } - this._export = function() { - let exportWindow = window.open(""); + _export() { + const exportWindow = window.open(""); console.debug(exportWindow); - let exportDocument = exportWindow.document; + const exportDocument = exportWindow.document; if (exportDocument === undefined) { console.debug("Could not create export window"); return; } - let title = exportDocument.createElement("title"); + const title = exportDocument.createElement("title"); title.innerHTML = "Music Matrix"; exportDocument.head.appendChild(title); - let w = exportDocument.createElement("H3"); + const w = exportDocument.createElement("H3"); w.innerHTML = "Music Matrix"; exportDocument.body.appendChild(w); - let x = exportDocument.createElement("TABLE"); + const x = exportDocument.createElement("TABLE"); x.setAttribute("id", "exportTable"); x.style.textAlign = "center"; exportDocument.body.appendChild(x); - let exportTable = exportDocument.getElementById("exportTable"); + const exportTable = exportDocument.getElementById("exportTable"); - let header = exportTable.createTHead(); + const header = exportTable.createTHead(); let exportLabel, exportRow, drumName, blockLabel, exportCell; let noteValueRow, col; @@ -2490,43 +2200,28 @@ function PitchTimeMatrix() { drumName = getDrumName(this.rowLabels[i]); if (drumName != null) { exportLabel.innerHTML = _(drumName); - exportLabel.style.fontSize = - Math.floor(this._cellScale * 14) + "px"; + exportLabel.style.fontSize = Math.floor(this._cellScale * 14) + "px"; } else if (this.rowLabels[i].slice(0, 4) === "http") { exportLabel.innerHTML = this.rowLabels[i]; - exportLabel.style.fontSize = - Math.floor(this._cellScale * 14) + "px"; + exportLabel.style.fontSize = Math.floor(this._cellScale * 14) + "px"; } else if (MATRIXSYNTHS.indexOf(this.rowLabels[i]) !== -1) { exportLabel.innerHTML = this.rowArgs[i]; - exportLabel.style.fontSize = - Math.floor(this._cellScale * 14) + "px"; + exportLabel.style.fontSize = Math.floor(this._cellScale * 14) + "px"; } else if (MATRIXGRAPHICS.indexOf(this.rowLabels[i]) !== -1) { - blockLabel = this._logo.blocks.protoBlockDict[ - this.rowLabels[i] - ]["staticLabels"][0]; + blockLabel = logo.blocks.protoBlockDict[this.rowLabels[i]]["staticLabels"][0]; exportLabel.innerHTML = blockLabel + "
    " + this.rowArgs[i]; - exportLabel.style.fontSize = - Math.floor(this._cellScale * 12) + "px"; + exportLabel.style.fontSize = Math.floor(this._cellScale * 12) + "px"; } else if (MATRIXGRAPHICS2.indexOf(this.rowLabels[i]) !== -1) { - blockLabel = this._logo.blocks.protoBlockDict[ - this.rowLabels[i] - ]["staticLabels"][0]; + blockLabel = logo.blocks.protoBlockDict[this.rowLabels[i]]["staticLabels"][0]; exportLabel.innerHTML = - blockLabel + - "
    " + - this.rowArgs[i][0] + - " " + - this.rowArgs[i][1]; - exportLabel.style.fontSize = - Math.floor(this._cellScale * 12) + "px"; + blockLabel + "
    " + this.rowArgs[i][0] + " " + this.rowArgs[i][1]; + exportLabel.style.fontSize = Math.floor(this._cellScale * 12) + "px"; } else { if (noteIsSolfege(this.rowLabels[i])) { exportLabel.innerHTML = - i18nSolfege(this.rowLabels[i]) + - this.rowArgs[i].toString().sub(); + i18nSolfege(this.rowLabels[i]) + this.rowArgs[i].toString().sub(); } else { - exportLabel.innerHTML = - this.rowLabels[i] + this.rowArgs[i].toString().sub(); + exportLabel.innerHTML = this.rowLabels[i] + this.rowArgs[i].toString().sub(); } } @@ -2613,8 +2308,8 @@ function PitchTimeMatrix() { exportCell.style.padding = 1 + "px"; } - let saveDocument = exportDocument; - let uriData = saveDocument.documentElement.outerHTML; + const saveDocument = exportDocument; + const uriData = saveDocument.documentElement.outerHTML; exportDocument.body.innerHTML += '
    Download Matrix"; exportDocument.getElementById("downloadb1").download = "MusicMatrix"; - exportDocument.getElementById( - "downloadb1" - ).href = this._generateDataURI(uriData); + exportDocument.getElementById("downloadb1").href = this._generateDataURI(uriData); exportDocument.close(); - }; + } // Deprecated - this.note2Solfege = function(note, index) { + note2Solfege(note, index) { let octave, newNote; if (["♭", "♯"].indexOf(note[1]) === -1) { octave = note[1]; @@ -2642,17 +2335,17 @@ function PitchTimeMatrix() { } this.rowLabels[index] = newNote; this.rowArgs[index] = octave; - }; + } - this.addTuplet = function(param) { + addTuplet(param) { // The first two parameters are the interval for the tuplet, // e.g., 1/4; the rest of the parameters are the list of notes // to be added to the tuplet, e.g., 1/8, 1/8, 1/8. - let tupletTimeFactor = param[0][0] / param[0][1]; - let numberOfNotes = param[1].length; + const tupletTimeFactor = param[0][0] / param[0][1]; + const numberOfNotes = param[1].length; let totalNoteInterval = 0; - let ptmTable = docById("ptmTable"); + const ptmTable = docById("ptmTable"); let lcd; for (let i = 0; i < numberOfNotes; i++) { if (i === 0) { @@ -2671,26 +2364,20 @@ function PitchTimeMatrix() { } } - let noteValue = param[0][1] / param[0][0]; + const noteValue = param[0][1] / param[0][0]; // The tuplet is note value is calculated as #notes x note value - let noteValueToDisplay = calcNoteValueToDisplay( - param[0][1], - param[0][0], - this._cellScale - ); + let noteValueToDisplay = calcNoteValueToDisplay(param[0][1], param[0][0], this._cellScale); if (noteValue > 12) { - noteValueToDisplay = '.'; + noteValueToDisplay = + '.'; } // Set the cells to 'rest' for (let i = 0; i < numberOfNotes; i++) { // The tuplet time factor * percentage of the tuplet that // is dedicated to this note - this._notesToPlay.push([ - ["R"], - (totalNoteInterval * param[0][1]) / (32 / param[1][i]) - ]); + this._notesToPlay.push([["R"], (totalNoteInterval * param[0][1]) / (32 / param[1][i])]); this._outputAsTuplet.push([numberOfNotes, noteValue]); } @@ -2703,10 +2390,8 @@ function PitchTimeMatrix() { labelCell = this._tupletNoteLabel; labelCell.innerHTML = _("note value"); labelCell.style.fontSize = this._cellScale * 75 + "%"; - labelCell.style.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; - labelCell.style.width = - Math.floor(2 * MATRIXSOLFEWIDTH * this._cellScale) + "px"; + labelCell.style.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + labelCell.style.width = Math.floor(2 * MATRIXSOLFEWIDTH * this._cellScale) + "px"; labelCell.style.minWidth = labelCell.style.width; labelCell.style.maxWidth = labelCell.style.width; labelCell.style.backgroundColor = platformColor.labelColor; @@ -2714,10 +2399,8 @@ function PitchTimeMatrix() { labelCell = this._tupletValueLabel; labelCell.innerHTML = _("tuplet value"); labelCell.style.fontSize = this._cellScale * 75 + "%"; - labelCell.style.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; - labelCell.style.width = - Math.floor(2 * MATRIXSOLFEWIDTH * this._cellScale) + "px"; + labelCell.style.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + labelCell.style.width = Math.floor(2 * MATRIXSOLFEWIDTH * this._cellScale) + "px"; labelCell.style.minWidth = labelCell.style.width; labelCell.style.maxWidth = labelCell.style.width; labelCell.style.backgroundColor = platformColor.labelColor; @@ -2732,24 +2415,22 @@ function PitchTimeMatrix() { cell.style.width = firstRow.cells[i].style.width; cell.style.minWidth = firstRow.cells[i].style.minWidth; cell.style.maxWidth = firstRow.cells[i].style.maxWidth; - cell.style.height = - Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px"; cell = valueRow.insertCell(); cell.style.backgroundColor = platformColor.tupletBackground; cell.style.width = firstRow.cells[i].style.width; cell.style.minWidth = firstRow.cells[i].style.minWidth; cell.style.maxWidth = firstRow.cells[i].style.maxWidth; - cell.style.height = - Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px"; } } // Now add the tuplet to the matrix. - let tupletNoteValue = noteValue * tupletValue; + const tupletNoteValue = noteValue * tupletValue; let numerator, thisNoteValue, obj; let cellWidth, cellColor; - let ptmRow, drumname; + let ptmRow, drumName; // Add the tuplet notes for (let i = 0; i < numberOfNotes; i++) { // Add the notes to the tuplet notes row too. @@ -2757,38 +2438,33 @@ function PitchTimeMatrix() { noteRow = this._tupletNoteValueRow; cell = noteRow.insertCell(-1); numerator = 32 / param[1][i]; - thisNoteValue = - 1 / (numerator / (totalNoteInterval / tupletTimeFactor)); + thisNoteValue = 1 / (numerator / (totalNoteInterval / tupletTimeFactor)); cell.style.backgroundColor = platformColor.tupletBackground; cell.style.width = this._noteWidth(thisNoteValue) + "px"; cell.style.minWidth = cell.style.width; cell.style.maxWidth = cell.style.width; - cell.style.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + cell.style.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; cell.setAttribute("id", 1 / tupletNoteValue); cell.style.lineHeight = 60 + "%"; cell.style.fontSize = this._cellScale * 75 + "%"; cell.style.textAlign = "center"; - obj = toFraction( - numerator / (totalNoteInterval / tupletTimeFactor) - ); + obj = toFraction(numerator / (totalNoteInterval / tupletTimeFactor)); if (obj[1] < 13) { - if (NOTESYMBOLS != undefined && obj[1] in NOTESYMBOLS) { - cell.innerHTML = - obj[0] + - "

    " + - obj[1] + - "
    " + - '.'; @@ -2895,8 +2558,8 @@ function PitchTimeMatrix() { this._outputAsTuplet.push([numBeats, noteValue]); } - let rowCount = this.rowLabels.length - this._rests; - let drumname, row, cell; + const rowCount = this.rowLabels.length - this._rests; + let drumName, row, cell, cellColor; for (let j = 0; j < numBeats; j++) { for (let i = 0; i < rowCount; i++) { // Depending on the row, we choose a different background color. @@ -2920,8 +2583,7 @@ function PitchTimeMatrix() { cell.setAttribute("cellColor", cellColor); cell.style.borderRadius = "6px"; - cell.style.height = - Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px"; cell.style.width = this._noteWidth(noteValue) + "px"; cell.style.minWidth = cell.style.width; cell.style.maxWidth = cell.style.width; @@ -2929,18 +2591,15 @@ function PitchTimeMatrix() { // Using the alt attribute to store the note value cell.setAttribute("alt", 1 / noteValue); - cell.onmouseover = function() { - if (this.style.backgroundColor !== "black") { - this.style.backgroundColor = - platformColor.selectorSelected; + cell.onmouseover = (event) => { + if (event.target.style.backgroundColor !== "black") { + event.target.style.backgroundColor = platformColor.selectorSelected; } }; - cell.onmouseout = function() { - if (this.style.backgroundColor !== "black") { - this.style.backgroundColor = this.getAttribute( - "cellColor" - ); + cell.onmouseout = (event) => { + if (event.target.style.backgroundColor !== "black") { + event.target.style.backgroundColor = event.target.getAttribute("cellColor"); } }; } @@ -2951,8 +2610,7 @@ function PitchTimeMatrix() { cell.style.width = this._noteWidth(noteValue) + "px"; cell.style.minWidth = cell.style.width; cell.style.maxWidth = cell.style.width; - cell.style.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + cell.style.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; cell.style.fontSize = Math.floor(this._cellScale * 75) + "%"; cell.style.lineHeight = 60 + "%"; cell.style.textAlign = "center"; @@ -2968,12 +2626,8 @@ function PitchTimeMatrix() { cell.style.width = this._noteWidth(noteValue) + "px"; cell.style.minWidth = cell.style.width; cell.style.maxWidth = cell.style.width; - cell.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + - "px"; - cell.style.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + - "px"; + cell.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + cell.style.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; cell.style.backgroundColor = platformColor.tupletBackground; row = this._tupletValueRow; @@ -2981,20 +2635,16 @@ function PitchTimeMatrix() { cell.style.width = this._noteWidth(noteValue) + "px"; cell.style.minWidth = cell.style.width; cell.style.maxWidth = cell.style.width; - cell.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + - "px"; - cell.style.height = - Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + - "px"; + cell.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; + cell.style.height = Math.floor(1.5 * MATRIXSOLFEHEIGHT * this._cellScale) + "px"; cell.style.backgroundColor = platformColor.tupletBackground; } } - }; + } - this._lookForNoteBlocksOrRepeat = function() { + _lookForNoteBlocksOrRepeat() { this._noteBlocks = false; - let bno = this.blockNo; + const bno = this.blockNo; let blk; for (let i = 0; i < this._blockMap[bno].length; i++) { blk = this._blockMap[bno][i][1][0]; @@ -3002,29 +2652,29 @@ function PitchTimeMatrix() { continue; } - if (this._logo.blocks.blockList[blk] === null) { + if (logo.blocks.blockList[blk] === null) { continue; } - if (this._logo.blocks.blockList[blk] === undefined) { + if (logo.blocks.blockList[blk] === undefined) { console.debug("block " + blk + " is undefined"); continue; } if ( - this._logo.blocks.blockList[blk].name === "newnote" || - this._logo.blocks.blockList[blk].name === "repeat" + logo.blocks.blockList[blk].name === "newnote" || + logo.blocks.blockList[blk].name === "repeat" ) { console.debug("FOUND A NOTE OR REPEAT BLOCK."); this._noteBlocks = true; break; } } - }; + } - this._syncMarkedBlocks = function() { - let newBlockMap = []; - let blk = this.blockNo; + _syncMarkedBlocks() { + const newBlockMap = []; + const blk = this.blockNo; for (let i = 0; i < this._blockMap[blk].length; i++) { if (this._blockMap[blk][i][0] === -1) { continue; @@ -3035,11 +2685,7 @@ function PitchTimeMatrix() { JSON.stringify(this._blockMap[blk][i][1]) === JSON.stringify(this._blockMapHelper[j][0]) ) { - for ( - let k = 0; - k < this._blockMapHelper[j][1].length; - k++ - ) { + for (let k = 0; k < this._blockMapHelper[j][1].length; k++) { newBlockMap.push([ this._blockMap[blk][i][0], this._colBlocks[this._blockMapHelper[j][1][k]], @@ -3053,56 +2699,46 @@ function PitchTimeMatrix() { this._blockMap[blk] = newBlockMap.filter((el, i) => { return ( i === - newBlockMap.findIndex(ele => { + newBlockMap.findIndex((ele) => { return JSON.stringify(ele) === JSON.stringify(el); }) ); }); - }; + } - this.blockConnection = function(len, bottomOfClamp) { - let n = this._logo.blocks.blockList.length - len; + blockConnection(len, bottomOfClamp) { + const n = logo.blocks.blockList.length - len; let c; if (bottomOfClamp == null) { - this._logo.blocks.blockList[this.blockNo].connections[2] = n; - this._logo.blocks.blockList[n].connections[0] = this.blockNo; + logo.blocks.blockList[this.blockNo].connections[2] = n; + logo.blocks.blockList[n].connections[0] = this.blockNo; } else { - c = - this._logo.blocks.blockList[bottomOfClamp].connections.length - - 1; - this._logo.blocks.blockList[bottomOfClamp].connections[c] = n; - this._logo.blocks.blockList[n].connections[0] = bottomOfClamp; + c = logo.blocks.blockList[bottomOfClamp].connections.length - 1; + logo.blocks.blockList[bottomOfClamp].connections[c] = n; + logo.blocks.blockList[n].connections[0] = bottomOfClamp; } - this._logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); - this._logo.blocks.adjustDocks(this.blockNo, true); - }; + logo.blocks.clampBlocksToCheck.push([this.blockNo, 0]); + logo.blocks.adjustDocks(this.blockNo, true); + } - this._deleteRhythmBlock = function(blockToDelete) { - if ( - last(this._logo.blocks.blockList[blockToDelete].connections) !== - null - ) { - this._logo.blocks.sendStackToTrash( - this._logo.blocks.blockList[ - last(this._logo.blocks.blockList[blockToDelete].connections) - ] + _deleteRhythmBlock(blockToDelete) { + if (last(logo.blocks.blockList[blockToDelete].connections) !== null) { + logo.blocks.sendStackToTrash( + logo.blocks.blockList[last(logo.blocks.blockList[blockToDelete].connections)] ); } - this._logo.blocks.sendStackToTrash( - this._logo.blocks.blockList[blockToDelete] - ); - this._logo.blocks.adjustDocks(this.blockNo, true); - this._logo.blocks.refreshCanvas(); - }; - - this._addRhythmBlock = function(value, times) { + logo.blocks.sendStackToTrash(logo.blocks.blockList[blockToDelete]); + logo.blocks.adjustDocks(this.blockNo, true); + logo.blocks.refreshCanvas(); + } + + _addRhythmBlock(value, times) { let RHYTHMOBJ = []; value = toFraction(value); - let topOfClamp = this._logo.blocks.blockList[this.blockNo] - .connections[1]; - let bottomOfClamp = this._logo.blocks.findBottomBlock(topOfClamp); - if (this._logo.blocks.blockList[bottomOfClamp].name === "vspace") { + const topOfClamp = logo.blocks.blockList[this.blockNo].connections[1]; + const bottomOfClamp = logo.blocks.findBottomBlock(topOfClamp); + if (logo.blocks.blockList[bottomOfClamp].name === "vspace") { RHYTHMOBJ = [ [0, ["rhythm2", {}], 0, 0, [null, 1, 2, 5]], [1, ["number", { value: times }], 0, 0, [0]], @@ -3122,76 +2758,59 @@ function PitchTimeMatrix() { [6, ["vspace", {}], 0, 0, [1, null]] ]; } - this._logo.blocks.loadNewBlocks(RHYTHMOBJ); - let that = this; - if (this._logo.blocks.blockList[bottomOfClamp].name === "vspace") { - setTimeout(that.blockConnection(6, bottomOfClamp), 500); + logo.blocks.loadNewBlocks(RHYTHMOBJ); + if (logo.blocks.blockList[bottomOfClamp].name === "vspace") { + setTimeout(this.blockConnection(6, bottomOfClamp), 500); } else { - setTimeout(that.blockConnection(7, bottomOfClamp), 500); + setTimeout(this.blockConnection(7, bottomOfClamp), 500); } - this._logo.blocks.refreshCanvas(); - }; + logo.blocks.refreshCanvas(); + } - this._update = function(i, value, k, noteCase) { - let updates = []; + _update(i, value, k, noteCase) { + const updates = []; value = toFraction(value); if (noteCase === "tupletnote") { updates.push( - this._logo.blocks.blockList[ - this._logo.blocks.blockList[i].connections[1] - ].connections[1] + logo.blocks.blockList[logo.blocks.blockList[i].connections[1]].connections[1] ); updates.push( - this._logo.blocks.blockList[ - this._logo.blocks.blockList[i].connections[1] - ].connections[2] + logo.blocks.blockList[logo.blocks.blockList[i].connections[1]].connections[2] ); } else { updates.push( - this._logo.blocks.blockList[ - this._logo.blocks.blockList[i].connections[2] - ].connections[1] + logo.blocks.blockList[logo.blocks.blockList[i].connections[2]].connections[1] ); updates.push( - this._logo.blocks.blockList[ - this._logo.blocks.blockList[i].connections[2] - ].connections[2] + logo.blocks.blockList[logo.blocks.blockList[i].connections[2]].connections[2] ); } if (noteCase === "rhythm" || noteCase === "stupletvalue") { - updates.push(this._logo.blocks.blockList[i].connections[1]); - this._logo.blocks.blockList[updates[2]].value = parseFloat(k); - this._logo.blocks.blockList[updates[2]].text.text = k.toString(); - this._logo.blocks.blockList[updates[2]].updateCache(); + updates.push(logo.blocks.blockList[i].connections[1]); + logo.blocks.blockList[updates[2]].value = parseFloat(k); + logo.blocks.blockList[updates[2]].text.text = k.toString(); + logo.blocks.blockList[updates[2]].updateCache(); } if ( noteCase === "rhythm" || noteCase === "stuplet" || (noteCase === "tupletnote" && value !== null) ) { - this._logo.blocks.blockList[updates[0]].value = parseFloat( - value[1] - ); - this._logo.blocks.blockList[ - updates[0] - ].text.text = value[1].toString(); - this._logo.blocks.blockList[updates[0]].updateCache(); - this._logo.blocks.blockList[updates[1]].value = parseFloat( - value[0] - ); - this._logo.blocks.blockList[ - updates[1] - ].text.text = value[0].toString(); - this._logo.blocks.blockList[updates[1]].updateCache(); - this._logo.refreshCanvas(); + logo.blocks.blockList[updates[0]].value = parseFloat(value[1]); + logo.blocks.blockList[updates[0]].text.text = value[1].toString(); + logo.blocks.blockList[updates[0]].updateCache(); + logo.blocks.blockList[updates[1]].value = parseFloat(value[0]); + logo.blocks.blockList[updates[1]].text.text = value[0].toString(); + logo.blocks.blockList[updates[1]].updateCache(); + logo.refreshCanvas(); } saveLocally(); - }; + } - this._mapNotesBlocks = function(blockName, withName) { - let notesBlockMap = []; - let blk = this._logo.blocks.blockList[this.blockNo].connections[1]; - let myBlock = this._logo.blocks.blockList[blk]; + _mapNotesBlocks(blockName, withName) { + const notesBlockMap = []; + let blk = logo.blocks.blockList[this.blockNo].connections[1]; + let myBlock = logo.blocks.blockList[blk]; let bottomBlockLoop = 0; if ( @@ -3210,14 +2829,14 @@ function PitchTimeMatrix() { while (last(myBlock.connections) != null) { bottomBlockLoop += 1; - if (bottomBlockLoop > 2 * this._logo.blocks.blockList) { + if (bottomBlockLoop > 2 * logo.blocks.blockList) { // Could happen if the block data is malformed. console.debug("infinite loop finding bottomBlock?"); break; } blk = last(myBlock.connections); - myBlock = this._logo.blocks.blockList[blk]; + myBlock = logo.blocks.blockList[blk]; if ( myBlock.name === blockName || (blockName === "all" && @@ -3234,18 +2853,18 @@ function PitchTimeMatrix() { } return notesBlockMap; - }; + } - this.recalculateBlocks = function() { - let adjustedNotes = []; - adjustedNotes.push([this._logo.tupletRhythms[0][2], 1]); + recalculateBlocks() { + const adjustedNotes = []; + adjustedNotes.push([logo.tupletRhythms[0][2], 1]); let startidx = 1; - for (let i = 1; i < this._logo.tupletRhythms.length; i++) { - if (this._logo.tupletRhythms[i][2] === last(adjustedNotes)[0]) { + for (let i = 1; i < logo.tupletRhythms.length; i++) { + if (logo.tupletRhythms[i][2] === last(adjustedNotes)[0]) { startidx += 1; } else { adjustedNotes[adjustedNotes.length - 1][1] = startidx; - adjustedNotes.push([this._logo.tupletRhythms[i][2], 1]); + adjustedNotes.push([logo.tupletRhythms[i][2], 1]); startidx = 1; } } @@ -3253,31 +2872,21 @@ function PitchTimeMatrix() { adjustedNotes[adjustedNotes.length - 1][1] = startidx; } return adjustedNotes; - }; + } - this._readjustNotesBlocks = function() { + _readjustNotesBlocks() { let notesBlockMap = this._mapNotesBlocks("rhythm2"); - let adjustedNotes = this.recalculateBlocks(); + const adjustedNotes = this.recalculateBlocks(); - let colBlocks = []; - let n = adjustedNotes.length - notesBlockMap.length; + const colBlocks = []; + const n = adjustedNotes.length - notesBlockMap.length; if (n >= 0) { for (let i = 0; i < notesBlockMap.length; i++) { - this._update( - notesBlockMap[i], - adjustedNotes[i][0], - adjustedNotes[i][1], - "rhythm" - ); + this._update(notesBlockMap[i], adjustedNotes[i][0], adjustedNotes[i][1], "rhythm"); } } else { for (let i = 0; i < adjustedNotes.length; i++) { - this._update( - notesBlockMap[i], - adjustedNotes[i][0], - adjustedNotes[i][1], - "rhythm" - ); + this._update(notesBlockMap[i], adjustedNotes[i][0], adjustedNotes[i][1], "rhythm"); } } @@ -3297,74 +2906,60 @@ function PitchTimeMatrix() { } } this._colBlocks = colBlocks; - }; + } - this._restartGrid = function(that) { + _restartGrid() { this._matrixHasTuplets = false; // Force regeneration of tuplet rows. this.sorted = true; - this.init(this._logo); + this.init(logo); this.sorted = false; let tupletParam; - for (let i = 0; i < this._logo.tupletRhythms.length; i++) { - switch (this._logo.tupletRhythms[i][0]) { + for (let i = 0; i < logo.tupletRhythms.length; i++) { + switch (logo.tupletRhythms[i][0]) { case "simple": case "notes": - tupletParam = [this._logo.tupletParams[this._logo.tupletRhythms[i][1]]]; + tupletParam = [logo.tupletParams[logo.tupletRhythms[i][1]]]; tupletParam.push([]); - for ( - let j = 2; - j < this._logo.tupletRhythms[i].length; - j++ - ) { - tupletParam[1].push(this._logo.tupletRhythms[i][j]); + for (let j = 2; j < logo.tupletRhythms[i].length; j++) { + tupletParam[1].push(logo.tupletRhythms[i][j]); } this.addTuplet(tupletParam); break; default: - this.addNotes( - this._logo.tupletRhythms[i][1], - this._logo.tupletRhythms[i][2] - ); + this.addNotes(logo.tupletRhythms[i][1], logo.tupletRhythms[i][2]); break; } } this.makeClickable(); docById("wheelDivptm").style.display = "none"; - that._menuWheel.removeWheel(); - that._exitWheel.removeWheel(); - }; + this._menuWheel.removeWheel(); + this._exitWheel.removeWheel(); + } - this._addNotes = function(that, noteToDivide, notesToAdd) { + _addNotes(noteToDivide, notesToAdd) { noteToDivide = parseInt(noteToDivide); this._blockMapHelper = []; for (let i = 0; i <= noteToDivide; i++) { this._blockMapHelper.push([this._colBlocks[i], [i]]); } - for ( - let i = noteToDivide + 1; - i < this._logo.tupletRhythms.length; - i++ - ) { - this._blockMapHelper.push([ - this._colBlocks[i], - [i + parseInt(notesToAdd)] - ]); + for (let i = noteToDivide + 1; i < logo.tupletRhythms.length; i++) { + this._blockMapHelper.push([this._colBlocks[i], [i + parseInt(notesToAdd)]]); } for (let i = 0; i < parseInt(notesToAdd); i++) { - this._logo.tupletRhythms = this._logo.tupletRhythms + logo.tupletRhythms = logo.tupletRhythms .slice(0, noteToDivide + i + 1) - .concat(this._logo.tupletRhythms.slice(noteToDivide + i)); + .concat(logo.tupletRhythms.slice(noteToDivide + i)); } this._readjustNotesBlocks(); this._syncMarkedBlocks(); - this._restartGrid(that); - }; + this._restartGrid.call(this); + } - this._deleteNotes = function(that, noteToDivide) { - if (this._logo.tupletRhythms.length === 1) { + _deleteNotes(noteToDivide) { + if (logo.tupletRhythms.length === 1) { return; } noteToDivide = parseInt(noteToDivide); @@ -3372,44 +2967,40 @@ function PitchTimeMatrix() { for (let i = 0; i < noteToDivide; i++) { this._blockMapHelper.push([this._colBlocks[i], [i]]); } - for ( - let i = noteToDivide + 1; - i < this._logo.tupletRhythms.length; - i++ - ) { + for (let i = noteToDivide + 1; i < logo.tupletRhythms.length; i++) { this._blockMapHelper.push([this._colBlocks[i], [i - 1]]); } - this._logo.tupletRhythms = this._logo.tupletRhythms + logo.tupletRhythms = logo.tupletRhythms .slice(0, noteToDivide) - .concat(this._logo.tupletRhythms.slice(noteToDivide + 1)); + .concat(logo.tupletRhythms.slice(noteToDivide + 1)); this._readjustNotesBlocks(); this._syncMarkedBlocks(); - this._restartGrid(that); - }; + this._restartGrid.call(this); + } - this._divideNotes = function(that, noteToDivide, divideNoteBy) { + _divideNotes(noteToDivide, divideNoteBy) { noteToDivide = parseInt(noteToDivide); this._blockMapHelper = []; for (let i = 0; i < noteToDivide; i++) { this._blockMapHelper.push([this._colBlocks[i], [i]]); } - this._logo.tupletRhythms = this._logo.tupletRhythms + logo.tupletRhythms = logo.tupletRhythms .slice(0, noteToDivide) .concat([ [ - this._logo.tupletRhythms[noteToDivide][0], - this._logo.tupletRhythms[noteToDivide][1], - this._logo.tupletRhythms[noteToDivide][2] * divideNoteBy + logo.tupletRhythms[noteToDivide][0], + logo.tupletRhythms[noteToDivide][1], + logo.tupletRhythms[noteToDivide][2] * divideNoteBy ] ]) - .concat(this._logo.tupletRhythms.slice(noteToDivide + 1)); + .concat(logo.tupletRhythms.slice(noteToDivide + 1)); this._blockMapHelper.push([this._colBlocks[noteToDivide], []]); let j = 0; for (let i = 0; i < divideNoteBy - 1; i++) { - this._logo.tupletRhythms = this._logo.tupletRhythms + logo.tupletRhythms = logo.tupletRhythms .slice(0, noteToDivide + i + 1) - .concat(this._logo.tupletRhythms.slice(noteToDivide + i)); + .concat(logo.tupletRhythms.slice(noteToDivide + i)); j = noteToDivide + i; this._blockMapHelper[noteToDivide][1].push(j); } @@ -3421,10 +3012,10 @@ function PitchTimeMatrix() { } this._readjustNotesBlocks(); this._syncMarkedBlocks(); - this._restartGrid(that); - }; + this._restartGrid.call(this); + } - this._tieNotes = function(mouseDownCell, mouseUpCell) { + _tieNotes(mouseDownCell, mouseUpCell) { let downCellId = null; let upCellId = null; if (mouseDownCell.id < mouseUpCell.id) { @@ -3444,65 +3035,42 @@ function PitchTimeMatrix() { this._blockMapHelper.push([this._colBlocks[i], [j]]); } j++; - for ( - let i = parseInt(upCellId) + 1; - i < this._logo.tupletRhythms.length; - i++ - ) { + for (let i = parseInt(upCellId) + 1; i < logo.tupletRhythms.length; i++) { this._blockMapHelper.push([this._colBlocks[i], [j]]); j++; } let newNote = 0; for (let i = downCellId; i <= upCellId; i++) { - newNote = newNote + 1 / parseFloat(this._logo.tupletRhythms[i][2]); + newNote = newNote + 1 / parseFloat(logo.tupletRhythms[i][2]); } - this._logo.tupletRhythms = this._logo.tupletRhythms + logo.tupletRhythms = logo.tupletRhythms .slice(0, downCellId) .concat([ - [ - this._logo.tupletRhythms[downCellId][0], - this._logo.tupletRhythms[downCellId][1], - 1 / newNote - ] + [logo.tupletRhythms[downCellId][0], logo.tupletRhythms[downCellId][1], 1 / newNote] ]) - .concat(this._logo.tupletRhythms.slice(parseInt(upCellId) + 1)); + .concat(logo.tupletRhythms.slice(parseInt(upCellId) + 1)); this._readjustNotesBlocks(); this._syncMarkedBlocks(); - this._restartGrid(that); - }; + this._restartGrid.call(this); + } - this._updateTuplet = function(that, noteToDivide, newNoteValue, condition) { - this._logo.tupletParams[noteToDivide][1] = newNoteValue; - this._restartGrid(that); + _updateTuplet(noteToDivide, newNoteValue, condition) { + logo.tupletParams[noteToDivide][1] = newNoteValue; + this._restartGrid.call(this); let notesBlockMap; if (condition === "simpletupletnote") { notesBlockMap = this._mapNotesBlocks("stuplet"); - this._update( - notesBlockMap[noteToDivide], - newNoteValue, - 0, - "stuplet" - ); + this._update(notesBlockMap[noteToDivide], newNoteValue, 0, "stuplet"); } else { notesBlockMap = this._mapNotesBlocks("tuplet4"); - this._update( - notesBlockMap[noteToDivide], - newNoteValue, - 0, - "tupletnote" - ); + this._update(notesBlockMap[noteToDivide], newNoteValue, 0, "tupletnote"); } - }; - - this._updateTupletValue = function( - that, - noteToDivide, - oldTupletValue, - newTupletValue - ) { + } + + _updateTupletValue(noteToDivide, oldTupletValue, newTupletValue) { noteToDivide = parseInt(noteToDivide); oldTupletValue = parseInt(oldTupletValue); newTupletValue = parseInt(newTupletValue); @@ -3511,39 +3079,23 @@ function PitchTimeMatrix() { let k = 0; let l; if (oldTupletValue < newTupletValue) { - for (let i = 0; i <= this._logo.tupletRhythms.length; i++) { + for (let i = 0; i <= logo.tupletRhythms.length; i++) { if (i == noteToDivide) { break; } - for ( - let j = 0; - j < this._logo.tupletRhythms[i].length - 2; - j++ - ) { + for (let j = 0; j < logo.tupletRhythms[i].length - 2; j++) { this._blockMapHelper.push([this._colBlocks[k], [k]]); k++; } } - for ( - let j = 0; - j < this._logo.tupletRhythms[noteToDivide].length - 2; - j++ - ) { + for (let j = 0; j < logo.tupletRhythms[noteToDivide].length - 2; j++) { this._blockMapHelper.push([this._colBlocks[k], [k]]); k++; } l = k; k = k + newTupletValue - oldTupletValue; - for ( - let i = noteToDivide + 1; - i < this._logo.tupletRhythms.length; - i++ - ) { - for ( - let j = 0; - j < this._logo.tupletRhythms[i].length - 2; - j++ - ) { + for (let i = noteToDivide + 1; i < logo.tupletRhythms.length; i++) { + for (let j = 0; j < logo.tupletRhythms[i].length - 2; j++) { this._blockMapHelper.push([this._colBlocks[l], [k]]); l++; k++; @@ -3551,84 +3103,59 @@ function PitchTimeMatrix() { } for (let i = oldTupletValue; i < newTupletValue; i++) { - this._logo.tupletRhythms[ - noteToDivide - ] = this._logo.tupletRhythms[noteToDivide] - .slice(0, this._logo.tupletRhythms[noteToDivide].length) + logo.tupletRhythms[noteToDivide] = logo.tupletRhythms[noteToDivide] + .slice(0, logo.tupletRhythms[noteToDivide].length) .concat( - this._logo.tupletRhythms[noteToDivide].slice( - this._logo.tupletRhythms[noteToDivide].length - 1 + logo.tupletRhythms[noteToDivide].slice( + logo.tupletRhythms[noteToDivide].length - 1 ) ); } } else { k = 0; - for (let i = 0; i <= this._logo.tupletRhythms.length; i++) { + for (let i = 0; i <= logo.tupletRhythms.length; i++) { if (i === noteToDivide) { break; } - for ( - let j = 0; - j < this._logo.tupletRhythms[i].length - 2; - j++ - ) { + for (let j = 0; j < logo.tupletRhythms[i].length - 2; j++) { this._blockMapHelper.push([this._colBlocks[k], [k]]); k++; } } for (let i = oldTupletValue; i > newTupletValue; i--) { - this._logo.tupletRhythms[ - noteToDivide - ] = this._logo.tupletRhythms[noteToDivide].slice( + logo.tupletRhythms[noteToDivide] = logo.tupletRhythms[noteToDivide].slice( 0, - this._logo.tupletRhythms[noteToDivide].length - 1 + logo.tupletRhythms[noteToDivide].length - 1 ); } - for ( - let j = 0; - j < this._logo.tupletRhythms[noteToDivide].length - 2; - j++ - ) { + for (let j = 0; j < logo.tupletRhythms[noteToDivide].length - 2; j++) { this._blockMapHelper.push([this._colBlocks[k], [k]]); k++; } l = k + oldTupletValue - newTupletValue; - for ( - let i = noteToDivide + 1; - i < this._logo.tupletRhythms.length; - i++ - ) { - for ( - let j = 0; - j < this._logo.tupletRhythms[i].length - 2; - j++ - ) { + for (let i = noteToDivide + 1; i < logo.tupletRhythms.length; i++) { + for (let j = 0; j < logo.tupletRhythms[i].length - 2; j++) { this._blockMapHelper.push([this._colBlocks[l], [k]]); l++; k++; } } } - let notesBlockMap = this._mapNotesBlocks("stuplet"); - let colBlocks = []; - for (let i = 0; i < this._logo.tupletRhythms.length; i++) { - for (let j = 0; j < this._logo.tupletRhythms[i].length - 2; j++) { + const notesBlockMap = this._mapNotesBlocks("stuplet"); + const colBlocks = []; + for (let i = 0; i < logo.tupletRhythms.length; i++) { + for (let j = 0; j < logo.tupletRhythms[i].length - 2; j++) { colBlocks.push([notesBlockMap[i], j]); } } this._colBlocks = colBlocks; - this._restartGrid(that); + this._restartGrid.call(this); this._syncMarkedBlocks(); - this._update( - notesBlockMap[noteToDivide], - null, - newTupletValue, - "stupletvalue" - ); - }; - - this._createpiesubmenu = function(noteToDivide, tupletValue, condition) { + this._update(notesBlockMap[noteToDivide], null, newTupletValue, "stupletvalue"); + } + + _createpiesubmenu(noteToDivide, tupletValue, condition) { docById("wheelDivptm").style.display = ""; this._menuWheel = new wheelnav("wheelDivptm", null, 800, 800); @@ -3636,52 +3163,15 @@ function PitchTimeMatrix() { let mainTabsLabels = []; if (condition === "tupletvalue") { - mainTabsLabels = [ - "1", - "2", - "3", - "-", - "4", - "5", - "6", - "7", - "8", - "+", - "9", - "10" - ]; + mainTabsLabels = ["1", "2", "3", "-", "4", "5", "6", "7", "8", "+", "9", "10"]; this.newNoteValue = String(tupletValue); - } else if ( - condition === "simpletupletnote" || - condition === "tupletnote" - ) { - mainTabsLabels = [ - "<-", - "Enter", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10" - ]; + } else if (condition === "simpletupletnote" || condition === "tupletnote") { + mainTabsLabels = ["<-", "Enter", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]; this.newNoteValue = "/"; } else if (condition === "rhythmnote") { - this._tabsWheel = new wheelnav( - "_tabsWheel", - this._menuWheel.raphael - ); + this._tabsWheel = new wheelnav("_tabsWheel", this._menuWheel.raphael); this.newNoteValue = 2; - mainTabsLabels = [ - "divide", - "delete", - "duplicate", - String(this.newNoteValue) - ]; + mainTabsLabels = ["divide", "delete", "duplicate", String(this.newNoteValue)]; } wheelnav.cssMode = true; @@ -3710,10 +3200,7 @@ function PitchTimeMatrix() { this._exitWheel.slicePathCustom.minRadiusPercent = 0.0; this._exitWheel.slicePathCustom.maxRadiusPercent = 0.4; - } else if ( - condition === "simpletupletnote" || - condition === "tupletnote" - ) { + } else if (condition === "simpletupletnote" || condition === "tupletnote") { exitTabLabel = ["x", this.newNoteValue]; this._menuWheel.slicePathCustom.minRadiusPercent = 0.5; @@ -3773,72 +3260,55 @@ function PitchTimeMatrix() { docById("wheelDivptm").style.height = "250px"; docById("wheelDivptm").style.width = "250px"; - let x = 0, y = 0; + let x = 0, + y = 0; if (noteToDivide !== null) { - let ntd = this._noteValueRow.cells[noteToDivide]; + const ntd = this._noteValueRow.cells[noteToDivide]; x = ntd.getBoundingClientRect().x; y = ntd.getBoundingClientRect().y; } docById("wheelDivptm").style.left = Math.min( - this._logo.blocks.turtles._canvas.width - 200, - Math.max(0, x * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.width - 200, + Math.max(0, x * logo.blocks.getStageScale()) ) + "px"; docById("wheelDivptm").style.top = Math.min( - this._logo.blocks.turtles._canvas.height - 250, - Math.max(0, y * this._logo.blocks.getStageScale()) + logo.blocks.turtles._canvas.height - 250, + Math.max(0, y * logo.blocks.getStageScale()) ) + "px"; - let that = this; - this._exitWheel.navItems[0].navigateFunction = function() { + this._exitWheel.navItems[0].navigateFunction = () => { docById("wheelDivptm").style.display = "none"; - that._menuWheel.removeWheel(); - that._exitWheel.removeWheel(); + this._menuWheel.removeWheel(); + this._exitWheel.removeWheel(); }; if (condition === "tupletvalue") { - let __enterValue = function() { - let i = that._menuWheel.selectedNavItemIndex; - let value = mainTabsLabels[i]; - - that.newNoteValue = String(value); - docById("wheelnav-_exitWheel-title-1").children[0].textContent = - that.newNoteValue; - that._updateTupletValue( - that, - noteToDivide, - tupletValue, - that.newNoteValue - ); + const __enterValue = () => { + const i = this._menuWheel.selectedNavItemIndex; + const value = mainTabsLabels[i]; + + this.newNoteValue = String(value); + docById("wheelnav-_exitWheel-title-1").children[0].textContent = this.newNoteValue; + this._updateTupletValue(this, noteToDivide, tupletValue, this.newNoteValue); }; - this._menuWheel.navItems[3].navigateFunction = function() { - if (that.newNoteValue > 1) { - that.newNoteValue = String(parseInt(that.newNoteValue) - 1); + this._menuWheel.navItems[3].navigateFunction = () => { + if (this.newNoteValue > 1) { + this.newNoteValue = String(parseInt(this.newNoteValue) - 1); docById( "wheelnav-_exitWheel-title-1" - ).children[0].textContent = that.newNoteValue; - that._updateTupletValue( - that, - noteToDivide, - tupletValue, - that.newNoteValue - ); + ).children[0].textContent = this.newNoteValue; + this._updateTupletValue(this, noteToDivide, tupletValue, this.newNoteValue); } }; - this._menuWheel.navItems[9].navigateFunction = function() { - that.newNoteValue = String(parseInt(that.newNoteValue) + 1); - docById("wheelnav-_exitWheel-title-1").children[0].textContent = - that.newNoteValue; - that._updateTupletValue( - that, - noteToDivide, - tupletValue, - that.newNoteValue - ); + this._menuWheel.navItems[9].navigateFunction = () => { + this.newNoteValue = String(parseInt(this.newNoteValue) + 1); + docById("wheelnav-_exitWheel-title-1").children[0].textContent = this.newNoteValue; + this._updateTupletValue(noteToDivide, tupletValue, this.newNoteValue); }; for (let i = 0; i < mainTabsLabels.length; i++) { @@ -3848,55 +3318,51 @@ function PitchTimeMatrix() { this._menuWheel.navItems[i].navigateFunction = __enterValue; } - } else if ( - condition === "simpletupletnote" || - condition === "tupletnote" - ) { + } else if (condition === "simpletupletnote" || condition === "tupletnote") { let first = false; let second = false; - let __enterValue = function() { - let i = that._menuWheel.selectedNavItemIndex; - let value = mainTabsLabels[i]; + const __enterValue = () => { + const i = this._menuWheel.selectedNavItemIndex; + const value = mainTabsLabels[i]; if (!first) { - that.newNoteValue = String(value) + "/"; + this.newNoteValue = String(value) + "/"; docById( "wheelnav-_exitWheel-title-1" - ).children[0].textContent = that.newNoteValue; + ).children[0].textContent = this.newNoteValue; first = true; } else { if (!second) { - that.newNoteValue = that.newNoteValue + String(value); + this.newNoteValue = this.newNoteValue + String(value); docById( "wheelnav-_exitWheel-title-1" - ).children[0].textContent = that.newNoteValue; + ).children[0].textContent = this.newNoteValue; second = true; } } }; - this._menuWheel.navItems[0].navigateFunction = function() { + this._menuWheel.navItems[0].navigateFunction = () => { if (second && first) { - let word = that.newNoteValue.split("/"); - that.newNoteValue = word[0] + "/"; + const word = this.newNoteValue.split("/"); + this.newNoteValue = word[0] + "/"; docById( "wheelnav-_exitWheel-title-1" - ).children[0].textContent = that.newNoteValue; + ).children[0].textContent = this.newNoteValue; second = false; } else if (first) { - that.newNoteValue = "/"; + this.newNoteValue = "/"; docById( "wheelnav-_exitWheel-title-1" - ).children[0].textContent = that.newNoteValue; + ).children[0].textContent = this.newNoteValue; first = false; } }; - this._menuWheel.navItems[1].navigateFunction = function() { + this._menuWheel.navItems[1].navigateFunction = () => { if (second && first) { - let word = that.newNoteValue.split("/"); - that._updateTuplet( - that, + const word = this.newNoteValue.split("/"); + this._updateTuplet( noteToDivide, parseInt(word[1]) / parseInt(word[0]), condition @@ -3909,25 +3375,25 @@ function PitchTimeMatrix() { } } else if (condition === "rhythmnote") { let flag = 0; - this._menuWheel.navItems[0].navigateFunction = function() { - that._divideNotes(that, noteToDivide, that.newNoteValue); + this._menuWheel.navItems[0].navigateFunction = () => { + this._divideNotes(noteToDivide, this.newNoteValue); }; - this._menuWheel.navItems[1].navigateFunction = function() { - that._deleteNotes(that, noteToDivide); + this._menuWheel.navItems[1].navigateFunction = () => { + this._deleteNotes(noteToDivide); }; - this._menuWheel.navItems[2].navigateFunction = function() { - that._addNotes(that, noteToDivide, that.newNoteValue); + this._menuWheel.navItems[2].navigateFunction = () => { + this._addNotes(noteToDivide, this.newNoteValue); }; - this._menuWheel.navItems[3].navigateFunction = function() { + this._menuWheel.navItems[3].navigateFunction = () => { if (!flag) { for (let i = 12; i < 19; i++) { docById( "wheelnav-wheelDivptm-title-3" - ).children[0].textContent = that.newNoteValue; - that._tabsWheel.navItems[i].navItem.show(); + ).children[0].textContent = this.newNoteValue; + this._tabsWheel.navItems[i].navItem.show(); } flag = 1; @@ -3935,8 +3401,8 @@ function PitchTimeMatrix() { for (let i = 12; i < 19; i++) { docById( "wheelnav-wheelDivptm-title-3" - ).children[0].textContent = that.newNoteValue; - that._tabsWheel.navItems[i].navItem.hide(); + ).children[0].textContent = this.newNoteValue; + this._tabsWheel.navItems[i].navItem.hide(); } flag = 0; @@ -3944,24 +3410,21 @@ function PitchTimeMatrix() { }; for (let i = 12; i < 19; i++) { - this._tabsWheel.navItems[i].navigateFunction = function() { - let j = that._tabsWheel.selectedNavItemIndex; - that.newNoteValue = tabsLabels[j]; - docById( - "wheelnav-wheelDivptm-title-3" - ).children[0].textContent = tabsLabels[j]; + this._tabsWheel.navItems[i].navigateFunction = () => { + const j = this._tabsWheel.selectedNavItemIndex; + this.newNoteValue = tabsLabels[j]; + docById("wheelnav-wheelDivptm-title-3").children[0].textContent = tabsLabels[j]; }; } } - }; + } - this.makeClickable = function() { + makeClickable() { // Once the entire matrix is generated, this function makes it // clickable. - let rowNote = this._noteValueRow; - let rowTuplet = this._tupletValueRow; + const rowNote = this._noteValueRow; + const rowTuplet = this._tupletValueRow; let cell, cellTuplet; - let that = this; for (let j = 0; j < rowNote.cells.length; j++) { cell = rowNote.cells[j]; cell.setAttribute("id", j); @@ -3971,48 +3434,42 @@ function PitchTimeMatrix() { cellTuplet.setAttribute("id", j); } - __mouseDownHandler = function(event) { - that._mouseDownCell = event.target; + const __mouseDownHandler = (event) => { + this._mouseDownCell = event.target; }; - __mouseUpHandler = function(event) { - that._mouseUpCell = event.target; - if (that._mouseDownCell !== that._mouseUpCell) { - that._tieNotes(that._mouseDownCell, that._mouseUpCell); + const __mouseUpHandler = (event) => { + this._mouseUpCell = event.target; + if (this._mouseDownCell !== this._mouseUpCell) { + this._tieNotes(this._mouseDownCell, this._mouseUpCell); } else { - let nodes = Array.prototype.slice.call( - this.parentElement.children - ); - that._createpiesubmenu( - nodes.indexOf(this), - this.getAttribute("alt"), + const nodes = Array.prototype.slice.call(event.target.parentElement.children); + this._createpiesubmenu( + nodes.indexOf(event.target), + event.target.getAttribute("alt"), "rhythmnote" ); } }; if (cellTuplet !== undefined) { - if (this._logo.tupletRhythms[0][0] === "notes") { - cell.onclick = function() { - that._createpiesubmenu( - this.getAttribute("id"), - null, - "tupletnote" - ); + if (logo.tupletRhythms[0][0] === "notes") { + cell.onclick = (event) => { + this._createpiesubmenu(event.target.getAttribute("id"), null, "tupletnote"); }; } else { - cell.onclick = function() { - that._createpiesubmenu( - this.getAttribute("id"), + cell.onclick = (event) => { + this._createpiesubmenu( + event.target.getAttribute("id"), null, "simpletupletnote" ); }; - cellTuplet.onclick = function() { - that._createpiesubmenu( - this.getAttribute("id"), - this.getAttribute("colspan"), + cellTuplet.onclick = (event) => { + this._createpiesubmenu( + event.target.getAttribute("id"), + event.target.getAttribute("colspan"), "tupletvalue" ); }; @@ -4026,7 +3483,7 @@ function PitchTimeMatrix() { } } - let rowCount = this.rowLabels.length; + const rowCount = this.rowLabels.length; let row; for (let i = 0; i < rowCount; i++) { row = this._rows[i]; @@ -4051,40 +3508,36 @@ function PitchTimeMatrix() { isMouseDown = false; - cell.onmousedown = function() { + cell.onmousedown = (evt) => { isMouseDown = true; - let i = Number(this.getAttribute("data-i")); - let j = Number(this.getAttribute("data-j")); - if (this.style.backgroundColor === "black") { - this.style.backgroundColor = this.getAttribute( - "cellColor" - ); - that._notesToPlay[j][0] = ["R"]; - if (!that._noteBlocks) that._setNotes(j, i, false); + const i = Number(evt.target.getAttribute("data-i")); + const j = Number(evt.target.getAttribute("data-j")); + if (evt.target.style.backgroundColor === "black") { + evt.target.style.backgroundColor = evt.target.getAttribute("cellColor"); + this._notesToPlay[j][0] = ["R"]; + if (!this._noteBlocks) this._setNotes(j, i, false); } else { - this.style.backgroundColor = "black"; - if (!that._noteBlocks) that._setNotes(j, i, true); + evt.target.style.backgroundColor = "black"; + if (!this._noteBlocks) this._setNotes(j, i, true); } }; - cell.onmouseover = function() { - let i = Number(this.getAttribute("data-i")); - let j = Number(this.getAttribute("data-j")); + cell.onmouseover = (evt) => { + const i = Number(evt.target.getAttribute("data-i")); + const j = Number(evt.target.getAttribute("data-j")); if (isMouseDown) { - if (this.style.backgroundColor === "black") { - this.style.backgroundColor = this.getAttribute( - "cellColor" - ); - that._notesToPlay[j][0] = ["R"]; - if (!that._noteBlocks) that._setNotes(j, i, false); + if (evt.target.style.backgroundColor === "black") { + evt.target.style.backgroundColor = evt.target.getAttribute("cellColor"); + this._notesToPlay[j][0] = ["R"]; + if (!this._noteBlocks) this._setNotes(j, i, false); } else { - this.style.backgroundColor = "black"; - if (!that._noteBlocks) that._setNotes(j, i, true); + evt.target.style.backgroundColor = "black"; + if (!this._noteBlocks) this._setNotes(j, i, true); } } }; - cell.onmouseup = function() { + cell.onmouseup = () => { isMouseDown = false; }; } @@ -4125,12 +3578,9 @@ function PitchTimeMatrix() { // Slice length of comparing id from end // of augmented id and compare - idsliced = - this._rowBlocks[j] - .toString() - .slice(-obj[0].toString().length); - if (idsliced === obj[0].toString()) { - if ((c++) === n) { + idsliced = this._rowBlocks[j].toString().slice(-obj[0]?.toString()?.length); + if (idsliced === obj[0]?.toString()) { + if (c++ === n) { rIdx = j; break; } @@ -4143,9 +3593,7 @@ function PitchTimeMatrix() { continue; } - r = - this._rowMap[rIdx] + - this._rowOffset[this._rowMap[rIdx]]; + r = this._rowMap[rIdx] + this._rowOffset[this._rowMap[rIdx]]; c = -1; for (let j = 0; j < this._colBlocks.length; j++) { @@ -4186,21 +3634,16 @@ function PitchTimeMatrix() { } } } - }; + } - this.playAll = function() { + playAll() { // Play all of the notes in the matrix. this.playingNow = !this.playingNow; if (this.playingNow) { - this.widgetWindow.modifyButton( - 0, - "stop-button.svg", - ICONSIZE, - _("stop") - ); + this.widgetWindow.modifyButton(0, "stop-button.svg", PhraseMaker.ICONSIZE, _("stop")); - this._logo.synth.stop(); + logo.synth.stop(); // Retrieve list of note to play, from matrix state this.collectNotesToPlay(); @@ -4208,11 +3651,11 @@ function PitchTimeMatrix() { this._notesCounter = 0; // We have an array of pitches and note values. - let note = this._notesToPlay[this._notesCounter][0]; - let pitchNotes = []; - let synthNotes = []; - let drumNotes = []; - let drumname, obj; + const note = this._notesToPlay[this._notesCounter][0]; + const pitchNotes = []; + const synthNotes = []; + const drumNotes = []; + let drumName, obj; // Note can be a chord, hence it is an array. for (let i = 0; i < note.length; i++) { @@ -4238,16 +3681,14 @@ function PitchTimeMatrix() { this._processGraphics(obj); } } else { - pitchNotes.push( - note[i].replace(/♭/g, "b").replace(/♯/g, "#") - ); + pitchNotes.push(note[i].replace(/♭/g, "b").replace(/♯/g, "#")); } } this._stopOrCloseClicked = false; } - let noteValue = this._notesToPlay[this._notesCounter][1]; + const noteValue = this._notesToPlay[this._notesCounter][1]; this._notesCounter += 1; @@ -4257,7 +3698,7 @@ function PitchTimeMatrix() { let row = this._noteValueRow; // Highlight first note. - let cell = row.cells[this._colIndex]; + const cell = row.cells[this._colIndex]; cell.style.backgroundColor = platformColor.selectorBackground; let tupletCell; @@ -4267,8 +3708,7 @@ function PitchTimeMatrix() { this._spanCounter = 1; row = this._tupletNoteValueRow; tupletCell = row.cells[this._colIndex]; - tupletCell.style.backgroundColor = - platformColor.selectorBackground; + tupletCell.style.backgroundColor = platformColor.selectorBackground; } else { this._spanCounter = 0; this._colIndex += 1; @@ -4279,7 +3719,7 @@ function PitchTimeMatrix() { } for (let i = 0; i < synthNotes.length; i++) { - this._logo.synth.trigger( + logo.synth.trigger( 0, [Number(synthNotes[i])], Singer.defaultBPMFactor / noteValue, @@ -4290,41 +3730,83 @@ function PitchTimeMatrix() { } for (let i = 0; i < drumNotes.length; i++) { - this._logo.synth.trigger( - 0, "C2", Singer.defaultBPMFactor / noteValue, drumNotes[i], null, null + logo.synth.trigger( + 0, + "C2", + Singer.defaultBPMFactor / noteValue, + drumNotes[i], + null, + null ); } this.__playNote(0, 0); } else { this._stopOrCloseClicked = true; - this.widgetWindow.modifyButton( - 0, - "play-button.svg", - ICONSIZE, - _("Play") - ); + this.widgetWindow.modifyButton(0, "play-button.svg", PhraseMaker.ICONSIZE, _("Play")); } - }; + } - this.collectNotesToPlay = function() { + collectNotesToPlay() { // Generate the list of notes to play, on the fly from // row labels and note value (from "alt" attribute of // corresponding cells in the row) // list of half-tones with solfeges const MATRIXHALFTONES = [ - "do", "C", "C♯", "D♭", "re", "D", "D♯", "E♭", - "mi", "E", "fa", "F", "F♯", "G♭", "sol", "G", - "G♯", "A♭", "la", "A", "A♯", "B♭", "ti", "B" + "do", + "C", + "C♯", + "D♭", + "re", + "D", + "D♯", + "E♭", + "mi", + "E", + "fa", + "F", + "F♯", + "G♭", + "sol", + "G", + "G♯", + "A♭", + "la", + "A", + "A♯", + "B♭", + "ti", + "B" ]; // list of half-tones in letter representations const MATRIXHALFTONES2 = [ - "C", "C", "C♯", "D♭", "D", "D", "D♯", "E♭", - "E", "E", "F", "F", "F♯", "G♭", "G", "G", - "G♯", "A♭", "A", "A", "A♯", "B♭", "B", "B" + "C", + "C", + "C♯", + "D♭", + "D", + "D", + "D♯", + "E♭", + "E", + "E", + "F", + "F", + "F♯", + "G♭", + "G", + "G", + "G♯", + "A♭", + "A", + "A", + "A♯", + "B♭", + "B", + "B" ]; - let notes = []; + const notes = []; let row, cell, note; for (let i = 0; i < this._colBlocks.length; i++) { note = []; @@ -4349,9 +3831,8 @@ function PitchTimeMatrix() { ) { // push "halftone" + "notevalue" note.push( - MATRIXHALFTONES2[ - MATRIXHALFTONES.indexOf(this.rowLabels[j]) - ] + this.rowArgs[j] + MATRIXHALFTONES2[MATRIXHALFTONES.indexOf(this.rowLabels[j])] + + this.rowArgs[j] ); } else { // if drum push drum name @@ -4367,7 +3848,7 @@ function PitchTimeMatrix() { this._notesToPlay = notes; } - this._resetMatrix = function() { + _resetMatrix() { let row = this._noteValueRow; let cell; for (let i = 0; i < row.cells.length; i++) { @@ -4375,68 +3856,65 @@ function PitchTimeMatrix() { cell.style.backgroundColor = platformColor.rhythmcellcolor; } - if (that._matrixHasTuplets) { + if (this._matrixHasTuplets) { row = this._tupletNoteValueRow; for (let i = 0; i < row.cells.length; i++) { cell = row.cells[i]; cell.style.backgroundColor = platformColor.tupletBackground; } } - }; + } - this.__playNote = function(time, noteCounter) { + __playNote(time, noteCounter) { // If the widget is closed, stop playing. if (!this.widgetWindow.isVisible()) { return; } - noteValue = this._notesToPlay[noteCounter][1]; + let noteValue = this._notesToPlay[noteCounter][1]; time = 1 / noteValue; - let that = this; - setTimeout(function() { + setTimeout(() => { let row, cell, tupletCell; // Did we just play the last note? - if (noteCounter === that._notesToPlay.length - 1) { - that._resetMatrix(); + if (noteCounter === this._notesToPlay.length - 1) { + this._resetMatrix(); - that.widgetWindow.modifyButton( + this.widgetWindow.modifyButton( 0, "play-button.svg", - ICONSIZE, + PhraseMaker.ICONSIZE, _("Play") ); - that.playingNow = false; + this.playingNow = false; } else { - row = that._noteValueRow; - cell = row.cells[that._colIndex]; + row = this._noteValueRow; + cell = row.cells[this._colIndex]; if (cell != undefined) { - cell.style.backgroundColor = - platformColor.selectorBackground; + cell.style.backgroundColor = platformColor.selectorBackground; if (cell.colSpan > 1) { - row = that._tupletNoteValueRow; - tupletCell = row.cells[that._notesCounter]; - tupletCell.style.backgroundColor = - platformColor.selectorBackground; + row = this._tupletNoteValueRow; + tupletCell = row.cells[this._notesCounter]; + tupletCell.style.backgroundColor = platformColor.selectorBackground; } } - if (that._notesCounter >= that._notesToPlay.length) { - that._notesCounter = 1; - that._logo.synth.stop(); + if (this._notesCounter >= this._notesToPlay.length) { + this._notesCounter = 1; + logo.synth.stop(); } - note = that._notesToPlay[that._notesCounter][0]; - noteValue = that._notesToPlay[that._notesCounter][1]; - that._notesCounter += 1; + const note = this._notesToPlay[this._notesCounter][0]; + noteValue = this._notesToPlay[this._notesCounter][1]; + this._notesCounter += 1; - let pitchNotes = []; - let synthNotes = []; - let drumNotes = []; - let drumname, obj; + const pitchNotes = []; + const synthNotes = []; + const drumNotes = []; + let drumName, obj; // Note can be a chord, hence it is an array. - if (!that._stopOrCloseClicked) { + if (!this._stopOrCloseClicked) { for (let i = 0; i < note.length; i++) { if (typeof note[i] === "number") { drumName = null; @@ -4457,186 +3935,155 @@ function PitchTimeMatrix() { synthNotes.push(note[i]); continue; } else if (MATRIXGRAPHICS.indexOf(obj[0]) !== -1) { - that._processGraphics(obj); + this._processGraphics(obj); } else if (MATRIXGRAPHICS2.indexOf(obj[0]) !== -1) { - that._processGraphics(obj); + this._processGraphics(obj); } else { - pitchNotes.push( - note[i] - .replace(/♭/g, "b") - .replace(/♯/g, "#") - ); + pitchNotes.push(note[i].replace(/♭/g, "b").replace(/♯/g, "#")); } } } } if (note[0] !== "R" && pitchNotes.length > 0) { - that._playChord(pitchNotes, Singer.defaultBPMFactor / noteValue); + this._playChord(pitchNotes, Singer.defaultBPMFactor / noteValue); } for (let i = 0; i < synthNotes.length; i++) { - that._logo.synth.trigger( + logo.synth.trigger( 0, [Number(synthNotes[i])], Singer.defaultBPMFactor / noteValue, - that._instrumentName, + this._instrumentName, null, null ); } for (let i = 0; i < drumNotes.length; i++) { - that._logo.synth.trigger( - 0, ["C2"], Singer.defaultBPMFactor / noteValue, drumNotes[i], null, null + logo.synth.trigger( + 0, + ["C2"], + Singer.defaultBPMFactor / noteValue, + drumNotes[i], + null, + null ); } } - row = that._noteValueRow; - cell = row.cells[that._colIndex]; + row = this._noteValueRow; + cell = row.cells[this._colIndex]; if (cell != undefined) { if (cell.colSpan > 1) { - that._spanCounter += 1; - if (that._spanCounter === cell.colSpan) { - that._spanCounter = 0; - that._colIndex += 1; + this._spanCounter += 1; + if (this._spanCounter === cell.colSpan) { + this._spanCounter = 0; + this._colIndex += 1; } } else { - that._spanCounter = 0; - that._colIndex += 1; + this._spanCounter = 0; + this._colIndex += 1; } noteCounter += 1; - if (noteCounter < that._notesToPlay.length && that.playingNow) { - that.__playNote(time, noteCounter); + if (noteCounter < this._notesToPlay.length && this.playingNow) { + this.__playNote(time, noteCounter); } else { - that._resetMatrix(); - that.widgetWindow.modifyButton( + this._resetMatrix(); + this.widgetWindow.modifyButton( 0, "play-button.svg", - ICONSIZE, + PhraseMaker.ICONSIZE, _("Play") ); } } - }, Singer.defaultBPMFactor * 1000 * time + that._logo.turtleDelay); - }; - - this._playChord = function(notes, noteValue) { - let that = this; - setTimeout(function() { - that._logo.synth.trigger( - 0, - notes[0], - noteValue, - that._instrumentName, - null, - null - ); + }, Singer.defaultBPMFactor * 1000 * time + logo.turtleDelay); + } + + _playChord(notes, noteValue) { + setTimeout(() => { + logo.synth.trigger(0, notes[0], noteValue, this._instrumentName, null, null); }, 1); if (notes.length > 1) { - setTimeout(function() { - that._logo.synth.trigger( - 0, - notes[1], - noteValue, - that._instrumentName, - null, - null - ); + setTimeout(() => { + logo.synth.trigger(0, notes[1], noteValue, this._instrumentName, null, null); }, 1); } if (notes.length > 2) { - setTimeout(function() { - that._logo.synth.trigger( - 0, - notes[2], - noteValue, - that._instrumentName, - null, - null - ); + setTimeout(() => { + logo.synth.trigger(0, notes[2], noteValue, this._instrumentName, null, null); }, 1); } if (notes.length > 3) { - setTimeout(function() { - that._logo.synth.trigger( - 0, - notes[3], - noteValue, - that._instrumentName, - null, - null - ); + setTimeout(() => { + logo.synth.trigger(0, notes[3], noteValue, this._instrumentName, null, null); }, 1); } - }; + } - this._processGraphics = function(obj) { + _processGraphics(obj) { switch (obj[0]) { case "forward": - this._logo.turtles.turtleList[0].painter.doForward(obj[1]); + turtles.turtleList[0].painter.doForward(obj[1]); break; case "back": - this._logo.turtles.turtleList[0].painter.doForward(-obj[1]); + turtles.turtleList[0].painter.doForward(-obj[1]); break; case "right": - this._logo.turtles.turtleList[0].painter.doRight(obj[1]); + turtles.turtleList[0].painter.doRight(obj[1]); break; case "left": - this._logo.turtles.turtleList[0].painter.doRight(-obj[1]); + turtles.turtleList[0].painter.doRight(-obj[1]); break; case "setcolor": - this._logo.turtles.turtleList[0].painter.doSetColor(obj[1]); + turtles.turtleList[0].painter.doSetColor(obj[1]); break; case "sethue": - this._logo.turtles.turtleList[0].painter.doSetHue(obj[1]); + turtles.turtleList[0].painter.doSetHue(obj[1]); break; case "setshade": - this._logo.turtles.turtleList[0].painter.doSetValue(obj[1]); + turtles.turtleList[0].painter.doSetValue(obj[1]); break; case "setgrey": - this._logo.turtles.turtleList[0].painter.doSetChroma(obj[1]); + turtles.turtleList[0].painter.doSetChroma(obj[1]); break; case "settranslucency": - let alpha = 1.0 - obj[1] / 100; - this._logo.turtles.turtleList[0].painter.doSetPenAlpha(alpha); + turtles.turtleList[0].painter.doSetPenAlpha(1.0 - obj[1] / 100); break; case "setpensize": - this._logo.turtles.turtleList[0].painter.doSetPensize(obj[1]); + turtles.turtleList[0].painter.doSetPensize(obj[1]); break; case "setheading": - this._logo.turtles.turtleList[0].painter.doSetHeading(obj[1]); + turtles.turtleList[0].painter.doSetHeading(obj[1]); break; case "arc": - this._logo.turtles.turtleList[0].painter.doArc(obj[1], obj[2]); + turtles.turtleList[0].painter.doArc(obj[1], obj[2]); break; case "setxy": - this._logo.turtles.turtleList[0].painter.doSetXY(obj[1], obj[2]); + turtles.turtleList[0].painter.doSetXY(obj[1], obj[2]); break; default: console.debug("unknown graphics command " + obj[0]); break; } - }; + } - this._setNotes = function(colIndex, rowIndex, playNote) { + _setNotes(colIndex, rowIndex, playNote) { // Sets corresponding note when user clicks on any cell and // plays that note - let rowBlock = this._rowBlocks[ + const rowBlock = this._rowBlocks[ this._rowMap.indexOf(rowIndex - this._rowOffset[rowIndex]) ]; - let rhythmBlockObj = this._colBlocks[colIndex]; + const rhythmBlockObj = this._colBlocks[colIndex]; if (playNote) { - this.addNode( - rowBlock, rhythmBlockObj[0], rhythmBlockObj[1], this.blockNo - ); + this.addNode(rowBlock, rhythmBlockObj[0], rhythmBlockObj[1], this.blockNo); } else { this.removeNode(rowBlock, rhythmBlockObj[0], rhythmBlockObj[1]); } @@ -4649,11 +4096,11 @@ function PitchTimeMatrix() { this._setNoteCell(j, colIndex, cell, playNote); } } - }; + } - this._setNoteCell = function(j, colIndex, cell, playNote) { - let note = this._noteStored[j]; - let drumName, graphicsBlock, obj; + _setNoteCell(j, colIndex, cell, playNote) { + const note = this._noteStored[j]; + let drumName, graphicsBlock, graphicNote, obj; if (this.rowLabels[j] === "hertz") { drumName = null; graphicsBlock = false; @@ -4672,25 +4119,18 @@ function PitchTimeMatrix() { obj = note.split(": "); } - let row = this._rows[j]; + const row = this._rows[j]; cell = row.cells[colIndex]; // Using the alt attribute to store the note value - let noteValue = cell.getAttribute("alt") * Singer.defaultBPMFactor; + const noteValue = cell.getAttribute("alt") * Singer.defaultBPMFactor; if (obj.length === 1) { if (playNote) { if (drumName != null) { - this._logo.synth.trigger( - 0, - "C2", - noteValue, - drumName, - null, - null - ); + logo.synth.trigger(0, "C2", noteValue, drumName, null, null); } else if (this.rowLabels[j] === "hertz") { - this._logo.synth.trigger( + logo.synth.trigger( 0, Number(note), noteValue, @@ -4700,7 +4140,7 @@ function PitchTimeMatrix() { ); } else if (graphicsBlock !== true) { if (typeof note === "string") { - this._logo.synth.trigger( + logo.synth.trigger( 0, note.replace(/♭/g, "b").replace(/♯/g, "#"), noteValue, @@ -4709,32 +4149,18 @@ function PitchTimeMatrix() { null ); } else { - this._logo.synth.trigger( - 0, - note, - noteValue, - this._instrumentName, - null, - null - ); + logo.synth.trigger(0, note, noteValue, this._instrumentName, null, null); } } else { console.debug("Cannot parse note object: " + obj); } } } else if (MATRIXSYNTHS.indexOf(obj[0]) !== -1) { - this._logo.synth.trigger( - 0, - [Number(obj[1])], - noteValue, - obj[0], - null, - null - ); + logo.synth.trigger(0, [Number(obj[1])], noteValue, obj[0], null, null); } - }; + } - this._clear = function() { + _clear() { // 'Unclick' every entry in the matrix. let row, cell; for (let i = 0; i < this.rowLabels.length; i++) { @@ -4748,26 +4174,20 @@ function PitchTimeMatrix() { } } } - }; + } - this._save = function() { + _save() { /* Saves the current matrix as an action stack consisting of * note and pitch blocks (saving as chunks is deprecated). */ // First, hide the palettes as they will need updating. - for (let name in this._logo.blocks.palettes.dict) { - this._logo.blocks.palettes.dict[name].hideMenu(true); + for (const name in logo.blocks.palettes.dict) { + logo.blocks.palettes.dict[name].hideMenu(true); } - this._logo.refreshCanvas(); - - let newStack = [ - [ - 0, - ["action", { collapsed: true }], - 100, - 100, - [null, 1, null, null] - ], + logo.refreshCanvas(); + + const newStack = [ + [0, ["action", { collapsed: true }], 100, 100, [null, 1, null, null]], [1, ["text", { value: _("action") }], 0, 0, [0]] ]; let endOfStackIdx = 0; @@ -4785,13 +4205,7 @@ function PitchTimeMatrix() { // Add the Note block and its value idx = newStack.length; - newStack.push([ - idx, - "newnote", - 0, - 0, - [endOfStackIdx, idx + 1, idx + 2, null] - ]); + newStack.push([idx, "newnote", 0, 0, [endOfStackIdx, idx + 1, idx + 2, null]]); n = newStack[idx][4].length; if (i === 0) { // the action block @@ -4807,8 +4221,7 @@ function PitchTimeMatrix() { // which case we output 1 / (3 x 4) instead of 1 / 12. if ( this._outputAsTuplet[i][0] !== 1 && - parseInt(this._outputAsTuplet[i][1]) === - this._outputAsTuplet[i][1] + parseInt(this._outputAsTuplet[i][1]) === this._outputAsTuplet[i][1] ) { // We don't reformat dotted tuplets since they are too complicated. // We are adding 6 blocks: vspace, divide, number, multiply, number, number @@ -4818,28 +4231,10 @@ function PitchTimeMatrix() { newStack.push([idx + 1, "vspace", 0, 0, [idx, idx + delta]]); // note value is saved as a fraction - newStack.push([ - idx + 2, - "divide", - 0, - 0, - [idx, idx + 3, idx + 4] - ]); + newStack.push([idx + 2, "divide", 0, 0, [idx, idx + 3, idx + 4]]); - newStack.push([ - idx + 3, - ["number", { value: 1 }], - 0, - 0, - [idx + 2] - ]); - newStack.push([ - idx + 4, - "multiply", - 0, - 0, - [idx + 2, idx + 5, idx + 6] - ]); + newStack.push([idx + 3, ["number", { value: 1 }], 0, 0, [idx + 2]]); + newStack.push([idx + 4, "multiply", 0, 0, [idx + 2, idx + 5, idx + 6]]); newStack.push([ idx + 5, ["number", { value: this._outputAsTuplet[i][0] }], @@ -4862,46 +4257,16 @@ function PitchTimeMatrix() { newStack.push([idx + 1, "vspace", 0, 0, [idx, idx + delta]]); // note value is saved as a fraction - newStack.push([ - idx + 2, - "divide", - 0, - 0, - [idx, idx + 3, idx + 4] - ]); + newStack.push([idx + 2, "divide", 0, 0, [idx, idx + 3, idx + 4]]); if (parseInt(note[1]) < note[1]) { // dotted note obj = toFraction(note[1]); - newStack.push([ - idx + 3, - ["number", { value: obj[1] }], - 0, - 0, - [idx + 2] - ]); - newStack.push([ - idx + 4, - ["number", { value: obj[0] }], - 0, - 0, - [idx + 2] - ]); + newStack.push([idx + 3, ["number", { value: obj[1] }], 0, 0, [idx + 2]]); + newStack.push([idx + 4, ["number", { value: obj[0] }], 0, 0, [idx + 2]]); } else { - newStack.push([ - idx + 3, - ["number", { value: 1 }], - 0, - 0, - [idx + 2] - ]); - newStack.push([ - idx + 4, - ["number", { value: note[1] }], - 0, - 0, - [idx + 2] - ]); + newStack.push([idx + 3, ["number", { value: 1 }], 0, 0, [idx + 2]]); + newStack.push([idx + 4, ["number", { value: note[1] }], 0, 0, [idx + 2]]); } } @@ -4909,7 +4274,7 @@ function PitchTimeMatrix() { newStack[idx][4][1] = idx + 2; // divide block newStack[idx][4][2] = idx + 1; // vspace block - let x = idx + delta; + const x = idx + delta; let lastConnection, previousBlock, thisBlock; if (note[0][0] === "R" || note[0][0] == undefined) { @@ -4923,13 +4288,7 @@ function PitchTimeMatrix() { delta -= 2; thisBlock = idx + delta; - newStack.push([ - thisBlock + 1, - "rest2", - 0, - 0, - [previousBlock, lastConnection] - ]); + newStack.push([thisBlock + 1, "rest2", 0, 0, [previousBlock, lastConnection]]); previousBlock += delta; } else { // Add the pitch and/or playdrum blocks to the Note block @@ -5041,12 +4400,7 @@ function PitchTimeMatrix() { obj[0], 0, 0, - [ - previousBlock, - thisBlock + 1, - thisBlock + 2, - lastConnection - ] + [previousBlock, thisBlock + 1, thisBlock + 2, lastConnection] ]); newStack.push([ thisBlock + 1, @@ -5099,28 +4453,20 @@ function PitchTimeMatrix() { } if (note[0][j][1] === "♯") { - if (isCustom(this._logo.synth.inTemperament)) { + if (isCustom(logo.synth.inTemperament)) { newStack.push([ thisBlock, "pitch", 0, 0, - [ - previousBlock, - thisBlock + 1, - thisBlock + 2, - lastConnection - ] + [previousBlock, thisBlock + 1, thisBlock + 2, lastConnection] ]); newStack.push([ thisBlock + 1, [ "customNote", { - value: note[0][j].substring( - 0, - note[0][j].length - 1 - ) + value: note[0][j].substring(0, note[0][j].length - 1) } ], 0, @@ -5142,22 +4488,14 @@ function PitchTimeMatrix() { "pitch", 0, 0, - [ - previousBlock, - thisBlock + 1, - thisBlock + 2, - lastConnection - ] + [previousBlock, thisBlock + 1, thisBlock + 2, lastConnection] ]); newStack.push([ thisBlock + 1, [ "solfege", { - value: - SOLFEGECONVERSIONTABLE[ - note[0][j][0] + "♯" - ] + value: SOLFEGECONVERSIONTABLE[note[0][j][0] + "♯"] } ], 0, @@ -5175,28 +4513,20 @@ function PitchTimeMatrix() { thisBlock += 3; } } else if (note[0][j][1] === "♭") { - if (isCustom(this._logo.synth.inTemperament)) { + if (isCustom(logo.synth.inTemperament)) { newStack.push([ thisBlock, "pitch", 0, 0, - [ - previousBlock, - thisBlock + 1, - thisBlock + 2, - lastConnection - ] + [previousBlock, thisBlock + 1, thisBlock + 2, lastConnection] ]); newStack.push([ thisBlock + 1, [ "customNote", { - value: note[0][j].substring( - 0, - note[0][j].length - 1 - ) + value: note[0][j].substring(0, note[0][j].length - 1) } ], 0, @@ -5218,22 +4548,14 @@ function PitchTimeMatrix() { "pitch", 0, 0, - [ - previousBlock, - thisBlock + 1, - thisBlock + 2, - lastConnection - ] + [previousBlock, thisBlock + 1, thisBlock + 2, lastConnection] ]); newStack.push([ thisBlock + 1, [ "solfege", { - value: - SOLFEGECONVERSIONTABLE[ - note[0][j][0] + "♭" - ] + value: SOLFEGECONVERSIONTABLE[note[0][j][0] + "♭"] } ], 0, @@ -5256,23 +4578,15 @@ function PitchTimeMatrix() { "pitch", 0, 0, - [ - previousBlock, - thisBlock + 1, - thisBlock + 2, - lastConnection - ] + [previousBlock, thisBlock + 1, thisBlock + 2, lastConnection] ]); - if (this._logo.synth.inTemperament == "custom") { + if (logo.synth.inTemperament == "custom") { newStack.push([ thisBlock + 1, [ "customNote", { - value: note[0][j].substring( - 0, - note[0][j].length - 1 - ) + value: note[0][j].substring(0, note[0][j].length - 1) } ], 0, @@ -5292,10 +4606,7 @@ function PitchTimeMatrix() { [ "solfege", { - value: - SOLFEGECONVERSIONTABLE[ - note[0][j][0] - ] + value: SOLFEGECONVERSIONTABLE[note[0][j][0]] } ], 0, @@ -5319,7 +4630,7 @@ function PitchTimeMatrix() { } // Create a new stack for the chunk. - this._logo.blocks.loadNewBlocks(newStack); - this._logo.textMsg(_("New action block generated!")); - }; + logo.blocks.loadNewBlocks(newStack); + logo.textMsg(_("New action block generated!")); + } }