Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function calls changed to arrow functions #3007

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions js/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,19 @@ function Blocks(activity) {

let palette;
// Regenerate all of the artwork at the new scale.
for (let blk = 0; blk < this.blockList.length; blk++) {
this.blockList[blk].resize(scale);
for (blk in this.blockList) {
blk.resize(scale);
}

this.findStacks();
for (let stack = 0; stack < this.stackList.length; stack++) {
this.adjustDocks(this.stackList[stack], true);
for (stack in this.stackList) {
this.adjustDocks(stack, true);
}

// Make sure trash is still hidden.
for (let blk = 0; blk < this.blockList.length; blk++) {
if (this.blockList[blk].trash) {
this.blockList[blk].hide();
for (blk in this.blockList.length) {
if (blk.trash) {
blk.hide();
}
}

Expand Down
64 changes: 32 additions & 32 deletions js/widgets/musickeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function MusicKeyboard(activity) {
}
};

this.addKeyboardShortcuts = function () {
this.addKeyboardShortcuts = () => {
// ;
let duration = 0;
const startTime = {};
Expand Down Expand Up @@ -231,7 +231,7 @@ function MusicKeyboard(activity) {
}
};

const __keyboarddown = function (event) {
const __keyboarddown = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing event arg

if (current.has(event.keyCode)) return;

__startNote(event);
Expand Down Expand Up @@ -328,7 +328,7 @@ function MusicKeyboard(activity) {
}
};

const __keyboardup = function (event) {
const __keyboardup = (event) => {
current.delete(event.keyCode);
__endNote(event);
//event.preventDefault();
Expand All @@ -338,7 +338,7 @@ function MusicKeyboard(activity) {
document.onkeyup = __keyboardup;
};

this.loadHandler = function (element, i, blockNumber) {
this.loadHandler = (element, i, blockNumber) => {
const temp1 = this.displayLayout[i].noteName;
let temp2;
if (temp1 === "hertz") {
Expand Down Expand Up @@ -373,7 +373,7 @@ function MusicKeyboard(activity) {
);
};

element.onmousedown = function () {
element.onmousedown = () => {
__startNote(this);
};

Expand Down Expand Up @@ -437,12 +437,12 @@ function MusicKeyboard(activity) {
}
};

element.onmouseup = function () {
element.onmouseup = () => {
__endNote(this);
};
};

this.init = function () {
this.init = () => {
this.tick = false;
this.playingNow = false;
let w = window.innerWidth;
Expand All @@ -457,7 +457,7 @@ function MusicKeyboard(activity) {
const tur = this.activity.turtles.ithTurtle(0);
this.bpm = tur.singer.bpm.length > 0 ? last(tur.singer.bpm) : Singer.masterBPM;

this.widgetWindow.onmaximize = function () {
this.widgetWindow.onmaximize = () => {
if (widgetWindow._maximized) {
widgetWindow.getWidgetBody().style.position = "absolute";
widgetWindow.getWidgetBody().style.height = "calc(100vh - 64px)";
Expand Down Expand Up @@ -604,7 +604,7 @@ function MusicKeyboard(activity) {
widgetWindow.sendToCenter();
};

this.playAll = function () {
this.playAll = () => {
if (selectedNotes.length <= 0) {
return;
}
Expand Down Expand Up @@ -681,7 +681,7 @@ function MusicKeyboard(activity) {
}
};

this.playOne = function (counter, time, playButtonCell) {
this.playOne = (counter, time, playButtonCell) => {
setTimeout(() => {
let cell, eleid, ele, notes, zx, res, maxWidth;
if (counter < selectedNotes.length) {
Expand Down Expand Up @@ -952,7 +952,7 @@ function MusicKeyboard(activity) {
return newList;
}

this._keysLayout = function () {
this._keysLayout = () => {
this.layout = [];
const sortableList = [];
for (let i = 0; i < this.noteNames.length; i++) {
Expand Down Expand Up @@ -1034,7 +1034,7 @@ function MusicKeyboard(activity) {
return newList;
};

this._setNotes = function (colIndex, playNote) {
this._setNotes = (colIndex, playNote) => {
const start = docById("cells-" + colIndex).getAttribute("start");

this._notesPlayed = this._notesPlayed.filter(function (ele) {
Expand Down Expand Up @@ -1111,7 +1111,7 @@ function MusicKeyboard(activity) {
}
};

this.makeClickable = function () {
this.makeClickable = () => {
const rowNote = docById("mkbNoteDurationRow");
let cell;

Expand Down Expand Up @@ -1170,18 +1170,18 @@ function MusicKeyboard(activity) {
}
};

cell.onmouseup = function () {
cell.onmouseup = () => {
isMouseDown = false;
};
}
}
};

this._noteWidth = function (noteValue) {
this._noteWidth = (noteValue) => {
return Math.max(Math.floor(EIGHTHNOTEWIDTH * (8 * noteValue) * this._cellScale), 15);
};

this._createTable = function () {
this._createTable = () => {
this.processSelected();
const mkbTableDiv = this.keyTable;
mkbTableDiv.style.display = "inline";
Expand Down Expand Up @@ -1343,7 +1343,7 @@ function MusicKeyboard(activity) {
this.makeClickable();
};

this._createpiesubmenu = function (cellId, start) {
this._createpiesubmenu = (cellId, start) => {
docById("wheelDivptm").style.display = "";

this._menuWheel = new wheelnav("wheelDivptm", null, 600, 600);
Expand Down Expand Up @@ -1509,7 +1509,7 @@ function MusicKeyboard(activity) {
}
};

this._updateDuration = function (start, duration) {
this._updateDuration = (start, duration) => {
start = parseInt(start);
duration = parseInt(duration[0]) / parseInt(duration[1]);
const newduration = parseFloat((Math.round(duration * 8) / 8).toFixed(3));
Expand All @@ -1523,7 +1523,7 @@ function MusicKeyboard(activity) {
this._createTable();
};

this._addNotes = function (cellId, start, divideNoteBy) {
this._addNotes = (cellId, start, divideNoteBy) => {
start = parseInt(start);
const cell = docById(cellId);
const dur = cell.getAttribute("dur");
Expand Down Expand Up @@ -1552,7 +1552,7 @@ function MusicKeyboard(activity) {
this._createTable();
};

this._deleteNotes = function (start) {
this._deleteNotes = (start) => {
start = parseInt(start);

this._notesPlayed = this._notesPlayed.filter(function (ele) {
Expand All @@ -1562,7 +1562,7 @@ function MusicKeyboard(activity) {
this._createTable();
};

this._divideNotes = function (start, divideNoteBy) {
this._divideNotes = (start, divideNoteBy) => {
start = parseInt(start);

this._notesPlayed = this._notesPlayed.reduce(function (prevValue, curValue) {
Expand Down Expand Up @@ -1600,7 +1600,7 @@ function MusicKeyboard(activity) {
this._createTable();
};

this._createAddRowPieSubmenu = function () {
this._createAddRowPieSubmenu = () => {
docById("wheelDivptm").style.display = "";
docById("wheelDivptm").style.zIndex = "300";
const pitchLabels = ["do", "re", "mi", "fa", "sol", "la", "ti"];
Expand Down Expand Up @@ -1813,7 +1813,7 @@ function MusicKeyboard(activity) {
}
};

this._addNotesBlockBetween = function (aboveBlock, block) {
this._addNotesBlockBetween = (aboveBlock, block) => {
const belowBlock = last(this.activity.blocks.blockList[aboveBlock].connections);
this.activity.blocks.blockList[aboveBlock].connections[
this.activity.blocks.blockList[aboveBlock].connections.length - 1
Expand All @@ -1835,7 +1835,7 @@ function MusicKeyboard(activity) {
this.activity.refreshCanvas();
};

this._sortLayout = function () {
this._sortLayout = () => {
this.layout.sort((a, b) => {
let aValue, bValue;
if (a.noteName == "hertz") {
Expand Down Expand Up @@ -1891,7 +1891,7 @@ function MusicKeyboard(activity) {
}
};

this._removePitchBlock = function (blockNo) {
this._removePitchBlock = (blockNo) => {
const c0 = this.activity.blocks.blockList[blockNo].connections[0];
const c1 = last(this.activity.blocks.blockList[blockNo].connections);
if (this.activity.blocks.blockList[c0].name === "musickeyboard") {
Expand All @@ -1915,7 +1915,7 @@ function MusicKeyboard(activity) {
this.activity.refreshCanvas();
};

this._createColumnPieSubmenu = function (index, condition) {
this._createColumnPieSubmenu = (index, condition) => {
index = parseInt(index);
if (
this.activity.blocks.blockList[
Expand Down Expand Up @@ -2232,7 +2232,7 @@ function MusicKeyboard(activity) {
}
};

this._createKeyboard = function () {
this._createKeyboard = () => {
document.onkeydown = null;
const mkbKeyboardDiv = this.keyboardDiv;
mkbKeyboardDiv.style.display = "flex";
Expand Down Expand Up @@ -2567,7 +2567,7 @@ function MusicKeyboard(activity) {
this.addKeyboardShortcuts();
};

this._save = function () {
this._save = () => {
this.processSelected();
const newStack = [
[0, ["action", { collapsed: false }], 100, 100, [null, 1, 2, null]],
Expand Down Expand Up @@ -2806,15 +2806,15 @@ function MusicKeyboard(activity) {
this.activity.textMsg(_("New action block generated!"));
};

this.clearBlocks = function () {
this.clearBlocks = () => {
this.noteNames = [];
this.octaves = [];
};

/**
* @deprecated
*/
this._addButton = function (row, icon, iconSize, label) {
this._addButton = (row, icon, iconSize, label) => {
const cell = row.insertCell(-1);
cell.innerHTML =
'&nbsp;&nbsp;<img src="header-icons/' +
Expand All @@ -2836,11 +2836,11 @@ function MusicKeyboard(activity) {
cell.style.maxHeight = cell.style.height;
cell.style.backgroundColor = platformColor.selectorBackground;

cell.onmouseover = function () {
cell.onmouseover = () => {
this.style.backgroundColor = platformColor.selectorBackgroundHOVER;
};

cell.onmouseout = function () {
cell.onmouseout = () => {
this.style.backgroundColor = platformColor.selectorBackground;
};

Expand Down