diff --git a/js/blocks/PitchBlocks.js b/js/blocks/PitchBlocks.js index c6b0ee1b64..28d8d5947f 100644 --- a/js/blocks/PitchBlocks.js +++ b/js/blocks/PitchBlocks.js @@ -523,20 +523,20 @@ function setupPitchBlocks(activity) { // Check to see if the octave was included. const lastChar = arg1.charAt(arg1.length - 1); let foundOctave = ""; - if ("12345678".indexOf(lastChar) !== -1) { + if ("12345678".includes(lastChar)) { foundOctave = lastChar; arg1 = arg1.slice(0, arg1.length - 1); } - if (SOLFEGENAMES1.indexOf(arg1) !== -1) { + if (SOLFEGENAMES1.includes(arg1)) { let sol = arg1; let attr; - if (sol.indexOf(SHARP) != -1) { + if (sol.includes(SHARP)) { attr = SHARP; - } else if (sol.indexOf(FLAT) != -1) { + } else if (sol.includes(FLAT)) { attr = FLAT; - } else if (sol.indexOf(DOUBLEFLAT) != -1) { + } else if (sol.includes(DOUBLEFLAT)) { attr = DOUBLEFLAT; - } else if (sol.indexOf(DOUBLESHARP) != -1) { + } else if (sol.includes(DOUBLESHARP)) { attr = DOUBLESHARP; } else { attr = NATURAL; @@ -555,7 +555,7 @@ function setupPitchBlocks(activity) { } else { notePlayed += foundOctave; } - } else if (NOTENAMES1.indexOf(arg1) !== -1) { + } else if (NOTENAMES1.includes(arg1)) { if (foundOctave.length === 0) { notePlayed = arg1 + @@ -563,7 +563,7 @@ function setupPitchBlocks(activity) { } else { notePlayed = arg1 + foundOctave; } - } else if (ALLNOTENAMES.indexOf(arg1) !== -1) { + } else if (ALLNOTENAMES.includes(arg1)) { // Why would the accidental be "b or #"? if (foundOctave.length === 0) { notePlayed = @@ -1605,7 +1605,7 @@ function setupPitchBlocks(activity) { logo.stopTurtle = true; } else if (logo.inMatrix) { logo.phraseMaker.addRowBlock(blk); - if (logo.pitchBlocks.indexOf(blk) === -1) { + if (!logo.pitchBlocks.includes(blk)) { logo.pitchBlocks.push(blk); } @@ -1897,13 +1897,13 @@ function setupPitchBlocks(activity) { let scaledegree = activity.blocks.blockList[c].value; let attr; - if (scaledegree.indexOf(SHARP) !== -1) { + if (scaledegree.includes(SHARP)) { attr = SHARP; - } else if (scaledegree.indexOf(FLAT) !== -1) { + } else if (scaledegree.includes(FLAT)) { attr = FLAT; - } else if (scaledegree.indexOf(DOUBLESHARP) !== -1) { + } else if (scaledegree.includes(DOUBLESHARP)) { attr = DOUBLESHARP; - } else if (scaledegree.indexOf(DOUBLEFLAT) !== -1) { + } else if (scaledegree.includes(DOUBLEFLAT)) { attr = DOUBLEFLAT; } else { attr = NATURAL; @@ -1942,7 +1942,7 @@ function setupPitchBlocks(activity) { let semitones = ref; semitones += - NOTESFLAT.indexOf(note) !== -1 + NOTESFLAT.includes(note) ? NOTESFLAT.indexOf(note) - ref : NOTESSHARP.indexOf(note) - ref; @@ -2007,18 +2007,18 @@ function setupPitchBlocks(activity) { // Check if string ends with accidental if ( - SOLFEGENAMES1.indexOf(arg0.toLowerCase()) !== -1 || - NOTENAMES1.indexOf(arg0.toUpperCase()) !== -1 + SOLFEGENAMES1.includes(arg0.toLowerCase()) || + NOTENAMES1.includes(arg0.toUpperCase()) ) { // Store accidental let accSym = arg0.charAt(arg0.length - 1); - if ([SHARP, FLAT, DOUBLESHARP, DOUBLEFLAT].indexOf(accSym) === -1) { + if (![SHARP, FLAT, DOUBLESHARP, DOUBLEFLAT].includes(accSym)) { accSym = NATURAL; } else { arg0 = arg0.substr(0, arg0.length - 1); } note = - NOTENAMES.indexOf(arg0.toUpperCase()) !== -1 + NOTENAMES.includes(arg0.toUpperCase()) ? SOLFEGECONVERSIONTABLE[arg0.toUpperCase()] : arg0; note = accSym !== NATURAL ? note + accSym : note; // add accidental diff --git a/js/blocks/ProgramBlocks.js b/js/blocks/ProgramBlocks.js index 1d49dabde5..590194acfb 100644 --- a/js/blocks/ProgramBlocks.js +++ b/js/blocks/ProgramBlocks.js @@ -1297,18 +1297,18 @@ function setupProgramBlocks(activity) { if (i < blockArgs.length) { if (typeof blockArgs[i] === "number") { if ( - ["anyin", "numberin"].indexOf( + !["anyin", "numberin"].includes( activity.blocks.protoBlockDict[protoblk].dockTypes[i] - ) === -1 + ) ) { activity.errorMsg(_("Warning: block argument type mismatch")); } newBlock.push([i, ["number", { value: blockArgs[i] }], 0, 0, [0]]); } else if (typeof blockArgs[i] === "string") { if ( - ["anyin", "textin"].indexOf( + !["anyin", "textin"].includes( activity.blocks.protoBlockDict[protoblk].dockTypes[i] - ) === -1 + ) ) { activity.errorMsg(_("Warning: block argument type mismatch")); } diff --git a/js/blocks/VolumeBlocks.js b/js/blocks/VolumeBlocks.js index 2bd2a43484..3971080f0b 100644 --- a/js/blocks/VolumeBlocks.js +++ b/js/blocks/VolumeBlocks.js @@ -443,7 +443,7 @@ function setupVolumeBlocks(activity) { const tur = activity.turtles.ithTurtle(turtle); - if (tur.singer.instrumentNames.indexOf(synth) === -1) { + if (!tur.singer.instrumentNames.includes(synth)) { tur.singer.instrumentNames.push(synth); logo.synth.loadSynth(turtle, synth); diff --git a/js/blocks/WidgetBlocks.js b/js/blocks/WidgetBlocks.js index 8aef730b2f..d9c031e2c5 100644 --- a/js/blocks/WidgetBlocks.js +++ b/js/blocks/WidgetBlocks.js @@ -207,7 +207,7 @@ function setupWidgetBlocks(activity) { } } - if ([-12, -24, -48, -96].indexOf(args[1]) === -1) { + if (![-12, -24, -48, -96].includes(args[1])) { //.TRANS: rolloff is the steepness of a change in frequency. activity.errorMsg( _("Rolloff value should be either -12, -24, -48, or -96 decibels/octave.") diff --git a/js/js-export/generate.js b/js/js-export/generate.js index c68f9d27d5..409e041abb 100644 --- a/js/js-export/generate.js +++ b/js/js-export/generate.js @@ -162,7 +162,7 @@ class JSGenerate { while (nextBlk !== undefined) { // ignore vertical spacers and hidden blocks if (nextBlk.name !== "hidden" && nextBlk.name !== "vspace") { - if (["storein2", "nameddo"].indexOf(nextBlk.name) !== -1) { + if (["storein2", "nameddo"].includes(nextBlk.name)) { tree.push([nextBlk.name + "_" + nextBlk.privateData]); } else { tree.push([nextBlk.name]); diff --git a/js/js-export/interface.js b/js/js-export/interface.js index c07529aa3e..782c2e4612 100644 --- a/js/js-export/interface.js +++ b/js/js-export/interface.js @@ -248,7 +248,7 @@ class JSInterface { * @returns {Boolean} */ static isClampBlock(blockName) { - return JSInterface._clampBlocks.indexOf(blockName) !== -1; + return JSInterface._clampBlocks.includes(blockName); } /** @@ -288,7 +288,7 @@ class JSInterface { * @returns {Boolean} */ static methodReturns(blockName) { - return JSInterface._returningMethods.indexOf(blockName) !== -1; + return JSInterface._returningMethods.includes(blockName); } /** @@ -439,10 +439,10 @@ class JSInterface { const solfeges = ["do", "re", "mi", "fa", "sol", "la", "ti"]; const letters = ["c", "d", "e", "f", "g", "a", "b"]; if ( - solfeges.indexOf(strs[0].toLowerCase()) !== -1 || - letters.indexOf(strs[0].toLowerCase()) !== -1 + solfeges.includes(strs[0].toLowerCase()) || + letters.includes(strs[0].toLowerCase()) ) { - if (solfeges.indexOf(strs[0].toLowerCase()) !== -1) { + if (solfeges.includes(strs[0].toLowerCase())) { arg = strs[0].toLowerCase(); } else { arg = strs[0].toUpperCase(); @@ -457,7 +457,7 @@ class JSInterface { doubleflat: DOUBLEFLAT }; - if (accidentals.indexOf(strs[1]) !== -1) { + if (accidentals.includes(strs[1])) { arg += strs[1]; } else if (strs[1].toLowerCase() in accidentals2) { arg += accidentals2[strs[1].toLowerCase()]; @@ -484,9 +484,9 @@ class JSInterface { "doubleflat" ]; - if (accidentals.indexOf(arg) !== -1) { + if (accidentals.includes(arg)) { arg = accidentalOuts[accidentals.indexOf(arg)]; - } else if (accidentals2.indexOf(arg.toLowerCase()) !== -1) { + } else if (accidentals2.includes(arg.toLowerCase())) { arg = accidentalOuts[accidentals2.indexOf(arg.toLowerCase())]; } } else if (props["constraints"]["type"] === "oneof") { @@ -546,7 +546,7 @@ class JSInterface { "triangle", "vibraphone" ]; - if (instruments.indexOf(arg) !== -1) { + if (instruments.includes(arg)) { arg = arg.toLowerCase(); } else { JSEditor.logConsole( @@ -576,7 +576,7 @@ class JSInterface { "slap", "raindrop" ]; - if (drums.indexOf(arg) !== -1) { + if (drums.includes(arg)) { arg = arg.toLowerCase(); } else { JSEditor.logConsole( @@ -600,7 +600,7 @@ class JSInterface { } else if (props["constraints"]["type"] === "letterkey") { const strs = arg.split(" "); const letters = ["c", "d", "e", "f", "g", "a", "b"]; - if (letters.indexOf(strs[0].toLowerCase()) !== -1) { + if (letters.includes(strs[0].toLowerCase())) { arg = strs[0].toUpperCase(); if (strs.length > 1) { @@ -612,7 +612,7 @@ class JSInterface { doubleflat: DOUBLEFLAT }; - if (accidentals.indexOf(strs[1]) !== -1) { + if (accidentals.includes(strs[1])) { arg += strs[1]; } else if (strs[1].toLowerCase() in accidentals2) { arg += accidentals2[strs[1].toLowerCase()]; diff --git a/js/turtleactions/IntervalsActions.js b/js/turtleactions/IntervalsActions.js index d02f3feb12..fad78a7024 100644 --- a/js/turtleactions/IntervalsActions.js +++ b/js/turtleactions/IntervalsActions.js @@ -252,7 +252,7 @@ function setupIntervalsActions(activity) { const __listener = () => { MUSICALMODES[modeName] = []; - if (tur.singer.defineMode.indexOf(0) === -1) { + if (!tur.singer.defineMode.includes(0)) { tur.singer.defineMode.push(0); activity.errorMsg(_("Adding missing pitch number 0.")); } diff --git a/js/turtleactions/PitchActions.js b/js/turtleactions/PitchActions.js index d3252228a3..daa954e8fa 100644 --- a/js/turtleactions/PitchActions.js +++ b/js/turtleactions/PitchActions.js @@ -226,7 +226,7 @@ function setupPitchActions(activity) { const note = nthDegreeToPitch(tur.singer.keySignature, scaleDegree); let semitones = ref; semitones += - NOTESFLAT.indexOf(note) !== -1 + NOTESFLAT.includes(note) ? NOTESFLAT.indexOf(note) - ref : NOTESSHARP.indexOf(note) - ref; /** calculates changes in reference octave which occur a semitone before the reference key */ diff --git a/js/turtleactions/RhythmActions.js b/js/turtleactions/RhythmActions.js index 78fecbcc66..77ff057f07 100644 --- a/js/turtleactions/RhythmActions.js +++ b/js/turtleactions/RhythmActions.js @@ -86,15 +86,15 @@ function setupRhythmActions(activity) { */ const turtleID = tur.id; - if (tur.singer.beatList.indexOf("everybeat") !== -1) { + if (tur.singer.beatList.includes("everybeat")) { _enqueue(); activity.stage.dispatchEvent("__everybeat_" + turtleID + "__"); } - if (tur.singer.beatList.indexOf(beatValue) !== -1) { + if (tur.singer.beatList.includes(beatValue)) { _enqueue(); activity.stage.dispatchEvent("__beat_" + beatValue + "_" + turtleID + "__"); - } else if (beatValue > 1 && tur.singer.beatList.indexOf("offbeat") !== -1) { + } else if (beatValue > 1 && tur.singer.beatList.includes("offbeat")) { _enqueue(); activity.stage.dispatchEvent("__offbeat_" + turtleID + "__"); } diff --git a/js/turtleactions/ToneActions.js b/js/turtleactions/ToneActions.js index 73c3b5c35a..7d2527e6aa 100644 --- a/js/turtleactions/ToneActions.js +++ b/js/turtleactions/ToneActions.js @@ -88,7 +88,7 @@ function setupToneActions(activity) { activity.logo.phraseMaker._instrumentName = synth; } - if (tur.singer.instrumentNames.indexOf(synth) === -1) { + if (!tur.singer.instrumentNames.includes(synth)) { tur.singer.instrumentNames.push(synth); activity.logo.synth.loadSynth(turtle, synth); diff --git a/js/turtleactions/VolumeActions.js b/js/turtleactions/VolumeActions.js index 958f5e420b..a111c90683 100644 --- a/js/turtleactions/VolumeActions.js +++ b/js/turtleactions/VolumeActions.js @@ -250,7 +250,7 @@ function setupVolumeActions(activity) { const tur = activity.turtles.ithTurtle(turtle); - if (tur.singer.instrumentNames.indexOf(synth) === -1) { + if (!tur.singer.instrumentNames.includes(synth)) { tur.singer.instrumentNames.push(synth); activity.logo.synth.loadSynth(turtle, synth); diff --git a/js/utils/mathutils.js b/js/utils/mathutils.js index 48a4102edc..1183aee79e 100644 --- a/js/utils/mathutils.js +++ b/js/utils/mathutils.js @@ -97,8 +97,8 @@ class MathUtility { } else if ( typeof a === "string" && typeof b === "string" && - SOLFEGENAMES.indexOf(a) !== -1 && - SOLFEGENAMES.indexOf(b) !== -1 + SOLFEGENAMES.includes(a) && + SOLFEGENAMES.includes(b) ) { return GetRandomSolfege(a, b, c); } else { diff --git a/js/utils/synthutils.js b/js/utils/synthutils.js index 50d4dc5a4b..00a248efc7 100644 --- a/js/utils/synthutils.js +++ b/js/utils/synthutils.js @@ -1737,7 +1737,7 @@ function Synth() { future ); // Effects don't work with sine, sawtooth, et al. - if (["sine", "sawtooth", "triangle", "square"].indexOf(instrumentName) !== -1) { + if (["sine", "sawtooth", "triangle", "square"].includes(instrumentName)) { paramsEffects = null; } else if (paramsEffects !== null && paramsEffects !== undefined) { if (paramsEffects["vibratoIntensity"] !== 0) { diff --git a/js/utils/utils.js b/js/utils/utils.js index a1e56e0de9..289720921f 100644 --- a/js/utils/utils.js +++ b/js/utils/utils.js @@ -639,7 +639,7 @@ const processPluginData = (activity, pluginData) => { // eslint-disable-next-line no-console console.debug("adding palette " + name); activity.palettes.add(name); - if (MULTIPALETTES[2].indexOf(name) === -1) MULTIPALETTES[2].push(name); + if (!MULTIPALETTES[2].includes(name)) MULTIPALETTES[2].push(name); newPalette = true; } } diff --git a/js/widgets/arpeggio.js b/js/widgets/arpeggio.js index 4e53a0db4f..f2781f3f55 100644 --- a/js/widgets/arpeggio.js +++ b/js/widgets/arpeggio.js @@ -331,7 +331,7 @@ class Arpeggio { * @returns {boolean} true/false */ _inMode(i) { - return this._modeNumbers.indexOf(i.toString()) !== -1; + return this._modeNumbers.includes(i.toString()); } /** diff --git a/js/widgets/help.js b/js/widgets/help.js index b3d77074de..1f29c161ce 100644 --- a/js/widgets/help.js +++ b/js/widgets/help.js @@ -335,7 +335,7 @@ class HelpWidget { _("Guide"), _("About"), _("Congratulations.") - ].indexOf(HELPCONTENT[page][0]) !== -1 + ].includes(HELPCONTENT[page][0]) ) { // body = body + '

 

'; body = `
 
` ; @@ -356,7 +356,7 @@ class HelpWidget { body += `

${HELPCONTENT[page][4]}

` ; } - if ([_("Congratulations.")].indexOf(HELPCONTENT[page][0]) !== -1) { + if ([_("Congratulations.")].includes(HELPCONTENT[page][0])) { const cell = docById("right-arrow"); cell.onclick = () => { diff --git a/js/widgets/musickeyboard.js b/js/widgets/musickeyboard.js index a30c6f9db8..3a21131148 100644 --- a/js/widgets/musickeyboard.js +++ b/js/widgets/musickeyboard.js @@ -186,7 +186,7 @@ function MusicKeyboard(activity) { this.addRowBlock = (rowBlock) => { // In case there is a repeat block, use a unique block number // for each instance. - while (this._rowBlocks.indexOf(rowBlock) !== -1) { + while (this._rowBlocks.includes(rowBlock)) { rowBlock = rowBlock + 1000000; } @@ -267,14 +267,14 @@ function MusicKeyboard(activity) { */ const __startNote = (event) => { let i, id; - if (WHITEKEYS.indexOf(event.keyCode) !== -1) { + if (WHITEKEYS.includes(event.keyCode)) { i = WHITEKEYS.indexOf(event.keyCode); id = "whiteRow" + i.toString(); - } else if (BLACKKEYS.indexOf(event.keyCode) !== -1) { + } else if (BLACKKEYS.includes(event.keyCode)) { i = BLACKKEYS.indexOf(event.keyCode); - if ([2, 6, 9, 13, 16, 20].indexOf(i) !== -1) return; + if ([2, 6, 9, 13, 16, 20].includes(i)) return; id = "blackRow" + i.toString(); - } else if (HERTZKEYS.indexOf(event.keyCode) !== -1) { + } else if (HERTZKEYS.includes(event.keyCode)) { i = HERTZKEYS.indexOf(event.keyCode); id = "hertzRow" + i.toString(); } else if (SPACE == event.keyCode) { @@ -360,14 +360,14 @@ function MusicKeyboard(activity) { */ const __endNote = (event) => { let i, id; - if (WHITEKEYS.indexOf(event.keyCode) !== -1) { + if (WHITEKEYS.includes(event.keyCode)) { i = WHITEKEYS.indexOf(event.keyCode); id = "whiteRow" + i.toString(); - } else if (BLACKKEYS.indexOf(event.keyCode) !== -1) { + } else if (BLACKKEYS.includes(event.keyCode)) { i = BLACKKEYS.indexOf(event.keyCode); - if ([2, 6, 9, 13, 16, 20].indexOf(i) !== -1) return; + if ([2, 6, 9, 13, 16, 20].includes(i)) return; id = "blackRow" + i.toString(); - } else if (HERTZKEYS.indexOf(event.keyCode) !== -1) { + } else if (HERTZKEYS.includes(event.keyCode)) { i = HERTZKEYS.indexOf(event.keyCode); id = "hertzRow" + i.toString(); } else if (SPACE == event.keyCode) { @@ -1227,7 +1227,7 @@ function MusicKeyboard(activity) { this.remove = []; sortedList = sortedList.filter((item) => { - if (unique.indexOf(item.noteName + item.noteOctave) === -1) { + if (!unique.includes(item.noteName + item.noteOctave)) { unique.push(item.noteName + item.noteOctave); return true; } else if (item.noteName === "drum") { @@ -1570,9 +1570,9 @@ function MusicKeyboard(activity) { cell.style.maxWidth = cell.style.width; if ( - selectedNotes[j].blockNumber.indexOf( + selectedNotes[j].blockNumber.includes( this.displayLayout[n - i - 1].blockNumber - ) !== -1 + ) ) { ind = selectedNotes[j].blockNumber.indexOf( this.displayLayout[n - i - 1].blockNumber @@ -1997,8 +1997,8 @@ function MusicKeyboard(activity) { } if ( - pitchLabels[i].indexOf(lastNote) !== -1 || - lastNote.indexOf(pitchLabels[i]) !== -1 + pitchLabels[i].includes(lastNote) || + lastNote.includes(pitchLabels[i]) ) { break; } @@ -2081,7 +2081,7 @@ function MusicKeyboard(activity) { this._sortLayout(this.layout); this.displayLayout = this.layout.map((note) => { - if (SOLFEGENAMES.indexOf(note.noteName) !== -1) { + if (SOLFEGENAMES.includes(note.noteName)) { return { ...note, noteName: FIXEDSOLFEGE[note.noteName] }; } return note; @@ -2168,7 +2168,7 @@ function MusicKeyboard(activity) { const unique = []; this.remove = []; this.layout = this.layout.filter((item, pos) => { - if (unique.indexOf(item.noteName + item.noteOctave) === -1) { + if (!unique.includes(item.noteName + item.noteOctave)) { unique.push(item.noteName + item.noteOctave); return true; } @@ -2387,7 +2387,7 @@ function MusicKeyboard(activity) { let accidentalsValue = 2; for (let i = 0; i < accidentals.length; i++) { - if (noteValue.indexOf(accidentals[i]) !== -1) { + if (noteValue.includes(accidentals[i])) { accidentalsValue = i; noteValue = noteValue.substr(0, noteValue.indexOf(accidentals[i])); break; @@ -2619,7 +2619,7 @@ function MusicKeyboard(activity) { parenttbl2 = document.getElementById("myrow2"); newel2 = document.createElement("td"); newel2.setAttribute("id", "blackRow" + myrow2Id.toString()); - if ([2, 6, 9, 13, 16, 20].indexOf(myrow2Id) !== -1) { + if ([2, 6, 9, 13, 16, 20].includes(myrow2Id)) { parenttbl2.appendChild(newel2); el = docById("blackRow" + myrow2Id.toString()); el.style.background = "transparent"; @@ -2708,14 +2708,14 @@ function MusicKeyboard(activity) { newel.style.zIndex = "100"; parenttbl.appendChild(newel); } else if ( - this.displayLayout[p].noteName.indexOf(SHARP) !== -1 || - this.displayLayout[p].noteName.indexOf("#") !== -1 + this.displayLayout[p].noteName.includes(SHARP) || + this.displayLayout[p].noteName.includes("#") ) { parenttbl2 = document.getElementById("myrow2"); newel2 = document.createElement("td"); newel2.setAttribute("id", "blackRow" + myrow2Id.toString()); newel2.style.textAlign = "center"; - if ([2, 6, 9, 13, 16, 20].indexOf(myrow2Id) !== -1) { + if ([2, 6, 9, 13, 16, 20].includes(myrow2Id)) { parenttbl2.appendChild(newel2); el = docById("blackRow" + myrow2Id.toString()); el.style.background = "transparent"; @@ -2758,15 +2758,15 @@ function MusicKeyboard(activity) { newel2.style.zIndex = "200"; parenttbl2.appendChild(newel2); } else if ( - this.displayLayout[p].noteName.indexOf(FLAT) !== -1 || - this.displayLayout[p].noteName.indexOf("b") !== -1 + this.displayLayout[p].noteName.includes(FLAT) || + this.displayLayout[p].noteName.includes("b") ) { parenttbl2 = document.getElementById("myrow2"); newel2 = document.createElement("td"); // elementid2 = document.getElementsByTagName("td").length; newel2.setAttribute("id", "blackRow" + myrow2Id.toString()); newel2.style.textAlign = "center"; - if ([2, 6, 9, 13, 16, 20].indexOf(myrow2Id) !== -1) { + if ([2, 6, 9, 13, 16, 20].includes(myrow2Id)) { parenttbl2.appendChild(newel2); el = docById("blackRow" + myrow2Id.toString()); el.style.background = "transparent"; @@ -2797,7 +2797,7 @@ function MusicKeyboard(activity) { ]); nname = this.displayLayout[p].noteName.replace(FLAT, "").replace("b", ""); if (this.displayLayout[p].blockNumber <= FAKEBLOCKNUMBER) { - if (SOLFEGENAMES.indexOf(nname) !== -1) { + if (SOLFEGENAMES.includes(nname)) { newel2.innerHTML = "(" + String.fromCharCode(BLACKKEYS[myrow2Id]) + @@ -2843,7 +2843,7 @@ function MusicKeyboard(activity) { ]); if (this.displayLayout[p].blockNumber <= FAKEBLOCKNUMBER) { - if (SOLFEGENAMES.indexOf(this.displayLayout[p].noteName) !== -1) { + if (SOLFEGENAMES.includes(this.displayLayout[p].noteName)) { newel.innerHTML = (myrowId < WHITEKEYS.length ? "(" + @@ -3095,7 +3095,7 @@ function MusicKeyboard(activity) { 0, [previousBlock, thisBlock + 1, thisBlock + 2, lastConnection] ]); - if (["#", "b", "♯", "♭"].indexOf(note.noteOctave[j][1]) !== -1) { + if (["#", "b", "♯", "♭"].includes(note.noteOctave[j][1])) { newStack.push([ thisBlock + 1, [ diff --git a/js/widgets/phrasemaker.js b/js/widgets/phrasemaker.js index 8f36484771..bc4c460943 100644 --- a/js/widgets/phrasemaker.js +++ b/js/widgets/phrasemaker.js @@ -369,7 +369,7 @@ class PhraseMaker { this._rowOffset.push(0); // In case there is a repeat block, use a unique block number // for each instance. - while (this._rowBlocks.indexOf(rowBlock) !== -1) { + while (this._rowBlocks.includes(rowBlock)) { rowBlock = rowBlock + 1000000; } @@ -599,10 +599,10 @@ class PhraseMaker { this.columnBlocksMap = this._mapNotesBlocks("all", true); for (let i = 0; i < this.columnBlocksMap.length; i++) { if ( - MATRIXGRAPHICS.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 + MATRIXGRAPHICS.includes(this.columnBlocksMap[i][1]) || + MATRIXGRAPHICS2.includes(this.columnBlocksMap[i][1]) || + MATRIXSYNTHS.includes(this.columnBlocksMap[i][1]) || + ["playdrum", "pitch"].includes(this.columnBlocksMap[i][1]) ) { continue; } @@ -678,7 +678,7 @@ class PhraseMaker { '" width="' + iconSize / 2 + '" vertical-align="middle"/>  '; - } else if (MATRIXSYNTHS.indexOf(this.rowLabels[i]) !== -1) { + } else if (MATRIXSYNTHS.includes(this.rowLabels[i])) { cell.innerHTML = '    '; - } else if (MATRIXGRAPHICS.indexOf(this.rowLabels[i]) !== -1) { + } else if (MATRIXGRAPHICS.includes(this.rowLabels[i])) { cell.innerHTML = '    '; - } else if (MATRIXGRAPHICS2.indexOf(this.rowLabels[i]) !== -1) { + } else if (MATRIXGRAPHICS2.includes(this.rowLabels[i])) { cell.innerHTML = '  '; - } else if (["C", "do"].indexOf(noteName) !== -1 && this.rowArgs[i] === 5) { + } else if (["C", "do"].includes(noteName) && this.rowArgs[i] === 5) { cell.innerHTML = '  '; - } else if (MATRIXGRAPHICS.indexOf(this.rowLabels[blockIndex]) !== -1) { + } else if (MATRIXGRAPHICS.includes(this.rowLabels[blockIndex])) { cell.innerHTML = '  " + this.rowArgs[i]; exportLabel.style.fontSize = Math.floor(this._cellScale * 12) + "px"; - } else if (MATRIXGRAPHICS2.indexOf(this.rowLabels[i]) !== -1) { + } else if (MATRIXGRAPHICS2.includes(this.rowLabels[i])) { blockLabel = this.activity.blocks.protoBlockDict[this.rowLabels[i]][ "staticLabels" ][0]; @@ -2738,7 +2738,7 @@ class PhraseMaker { */ note2Solfege(note, index) { let octave, newNote; - if (["♭", "♯"].indexOf(note[1]) === -1) { + if (!["♭", "♯"].includes(note[1])) { octave = note[1]; newNote = SOLFEGECONVERSIONTABLE[note[0]]; } else { @@ -4233,7 +4233,7 @@ class PhraseMaker { obj = note[i].split(": "); if (obj.length > 1) { // Deprecated - if (MATRIXSYNTHS.indexOf(obj[0]) !== -1) { + if (MATRIXSYNTHS.includes(obj[0])) { synthNotes.push(note[i]); } else { this._processGraphics(obj); @@ -4582,12 +4582,12 @@ class PhraseMaker { } else { obj = note[i].split(": "); // Deprecated - if (MATRIXSYNTHS.indexOf(obj[0]) !== -1) { + if (MATRIXSYNTHS.includes(obj[0])) { synthNotes.push(note[i]); continue; - } else if (MATRIXGRAPHICS.indexOf(obj[0]) !== -1) { + } else if (MATRIXGRAPHICS.includes(obj[0])) { this._processGraphics(obj); - } else if (MATRIXGRAPHICS2.indexOf(obj[0]) !== -1) { + } else if (MATRIXGRAPHICS2.includes(obj[0])) { this._processGraphics(obj); } else { pitchNotes.push(note[i].replace(/♭/g, "b").replace(/♯/g, "#")); @@ -4869,7 +4869,7 @@ class PhraseMaker { console.debug("Cannot parse note object: " + obj); } } - } else if (MATRIXSYNTHS.indexOf(obj[0]) !== -1) { + } else if (MATRIXSYNTHS.includes(obj[0])) { this.activity.logo.synth.trigger(0, [Number(obj[1])], noteValue, obj[0], null, null); } } diff --git a/js/widgets/rhythmruler.js b/js/widgets/rhythmruler.js index 09764ebf29..50618ac353 100644 --- a/js/widgets/rhythmruler.js +++ b/js/widgets/rhythmruler.js @@ -427,7 +427,7 @@ class RhythmRuler { // Look for any old entries that we may have missed. for (let i = 0; i < this._dissectHistory.length; i++) { const drum = this._dissectHistory[i][1]; - if (drums.indexOf(drum) === -1) { + if (!drums.includes(drum)) { const history = JSON.parse(JSON.stringify(this._dissectHistory[i][0])); dissectHistory.push([history, drum]); } @@ -2273,7 +2273,7 @@ class RhythmRuler { for (let d = 0; d < DRUMNAMES.length; d++) { if (DRUMNAMES[d][1] === drum) { - if (EFFECTSNAMES.indexOf(drum) === -1) { + if (!EFFECTSNAMES.includes(drum)) { this._saveDrumMachine(selectedRuler, drum, false); } else { this._saveDrumMachine(selectedRuler, drum, true); @@ -2712,7 +2712,7 @@ class RhythmRuler { noteValues = selectedRuler[0]; for (let i = 0; i < noteValues.length; i++) { t += 1 / noteValues[i]; - if (rList.indexOf(t) === -1) { + if (!rList.includes(t)) { rList.push(t); } } @@ -2773,7 +2773,7 @@ class RhythmRuler { // Look for any old entries that we may have missed. for (let i = 0; i < this._dissectHistory.length; i++) { drum = this._dissectHistory[i][1]; - if (drums.indexOf(drum) === -1) { + if (!drums.includes(drum)) { history = JSON.parse(JSON.stringify(this._dissectHistory[i][0])); dissectHistory.push([history, drum]); } diff --git a/planet/js/helper.js b/planet/js/helper.js index 6342ced153..f9c0859410 100644 --- a/planet/js/helper.js +++ b/planet/js/helper.js @@ -80,7 +80,7 @@ function toggleText(id, a, b) { const el = document.getElementById(id); const prevHTML = el.innerHTML ; - const updatedHTML = prevHTML.indexOf(a) !== -1 ? prevHTML.replace(a,b) : prevHTML.replace(b,a) ; + const updatedHTML = prevHTML.includes(a) ? prevHTML.replace(a,b) : prevHTML.replace(b,a) ; el.innerHTML = "" ; el.insertAdjacentHTML("afterbegin", updatedHTML) ; @@ -99,7 +99,7 @@ function hideOnClickOutside(eles, other) { let ok = false; for (let i = 0; i < eles.length; i++) - if (path.indexOf(eles[i]) !== -1) + if (path.includes(eles[i])) ok = true; if (ok === false) {