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

callback to arrow function #2634

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
06191f7
callback to arrow Block.js
sj00coder Nov 28, 2020
c0ad187
callback to arrow Blocks.js
sj00coder Nov 28, 2020
c16a2cd
callback to arrow pastelbox.js
sj00coder Nov 28, 2020
fcd4319
that to this block.js
sj00coder Nov 28, 2020
abbc56d
that to this blocks.js
sj00coder Nov 28, 2020
d9e5189
callback to arrow pluginviewer.js
sj00coder Nov 28, 2020
d498228
callback to arrow saveInterfacer.js
sj00coder Nov 28, 2020
6e6df5d
callback to arrow saveInterfacer.js
sj00coder Nov 28, 2020
0114387
callback to arrow trash.js
sj00coder Nov 28, 2020
f20c4a8
Merge remote-tracking branch 'upstream/master' into arrowcallback
sj00coder Nov 28, 2020
c575852
callbacks to arrow widget/help.js
sj00coder Nov 28, 2020
ccaea80
callbacks to arrow widget/meterwidget.js
sj00coder Nov 28, 2020
cde9893
callbacks to arrow widget/modewidget.js
sj00coder Nov 28, 2020
9c0aeb2
callbacks to arrow widget/musickeyboard.js
sj00coder Nov 28, 2020
d265526
callbacks to arrow widget/phrasemaker.js
sj00coder Nov 28, 2020
8c6f959
callbacks to arrow widget/pitchdummer.js
sj00coder Nov 28, 2020
e4343f3
callbacks to arrow widget/pitchstaircase.js
sj00coder Nov 28, 2020
41c0fac
callbacks to arrow widget/rythmruler.js
sj00coder Nov 28, 2020
4a71764
callbacks to arrow widget/rythmruler.js
sj00coder Nov 28, 2020
4415799
callbacks to arrow widget/tempo.js
sj00coder Nov 28, 2020
894c210
callbacks to arrow widget/timbre.js
sj00coder Nov 28, 2020
8bacb9b
Merge remote-tracking branch 'upstream/master' into arrowcallback
sj00coder Nov 28, 2020
446b179
Merge branch 'master' into arrowcallback
meganindya Nov 29, 2020
c23e7e4
final
sj00coder Nov 30, 2020
83de6f8
final
sj00coder Nov 30, 2020
e63903f
.
sj00coder Dec 1, 2020
0adf681
block.js
sj00coder Dec 1, 2020
0fd6f44
Update index.html
sj00coder Dec 1, 2020
b4daa6c
Merge branch 'master' into arrowcallback
meganindya Dec 1, 2020
3b1f6ea
Clean up errorneous dirty code
meganindya Dec 1, 2020
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}
}
</script>

<script type="text/javascript">
$(document).ready(function() {
doSearch();
Expand Down
4 changes: 2 additions & 2 deletions js/SaveInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function SaveInterface(PlanetInterface) {

this.saveHTMLNoPrompt = function() {
setTimeout(
function() {
() => {
let html = "data:text/plain;charset=utf-8," +
encodeURIComponent(this.prepareHTML());
if (this.PlanetInterface !== undefined) {
Expand All @@ -166,7 +166,7 @@ function SaveInterface(PlanetInterface) {
_("My Project").replace(" ", "_") + ".html",
html);
}
}.bind(this),
},
500
);
};
Expand Down
135 changes: 80 additions & 55 deletions js/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ class Block {
// Includes workaround for a race condition.
_createCache(callback, args) {
let that = this;
return new Promise(function (resolve, reject) {

return new Promise((resolve, reject) =>
{

let loopCount = 0;

async function checkBounds(counter) {
Expand All @@ -187,20 +190,21 @@ class Block {
throw new Error("COULD NOT CREATE CACHE");
}

that.bounds = that.container.getBounds();
this.bounds = this.container.getBounds();

if (that.bounds === null) {
if (this.bounds === null) {
await delayExecution(100);
that.regenerateArtwork(true, []);
this.regenerateArtwork(true, []);
checkBounds(loopCount + 1);
} else {
that.container.cache(
that.bounds.x,
that.bounds.y,
that.bounds.width,
that.bounds.height
);
callback(that, args);

this.container.cache(
this.bounds.x,
this.bounds.y,
this.bounds.width,
this.bounds.height);
callback(this, args);

resolve();
}
} catch (e) {
Expand All @@ -215,7 +219,8 @@ class Block {
// Includes workaround for a race condition.
updateCache(counter) {
let that = this;
return new Promise(function (resolve, reject) {

return new Promise((resolve, reject) => {
let loopCount = 0;

async function updateBounds(counter) {
Expand All @@ -228,12 +233,12 @@ class Block {
throw new Error("COULD NOT UPDATE CACHE");
}

if (that.bounds == null) {
if (this.bounds == null) {
updateBounds(loopCount + 1);
await that.pause(200);
await this.pause(200);
} else {
that.container.updateCache();
that.blocks.refreshCanvas();
this.container.updateCache();
this.blocks.refreshCanvas();
resolve();
}
} catch (e) {
Expand Down Expand Up @@ -2452,8 +2457,10 @@ class Block {
if (that.blocks.turtles.running()) {
that.blocks.logo.doStopTurtles();

setTimeout(function () {
that.blocks.logo.runLogoCommands(topBlock);

setTimeout(() => {
this.blocks.logo.runLogoCommands(topBlock);

}, 250);
} else {
that.blocks.logo.runLogoCommands(topBlock);
Expand All @@ -2475,7 +2482,9 @@ class Block {
}

locked = true;
setTimeout(function () {

setTimeout(() => {

locked = false;
}, 500);

Expand Down Expand Up @@ -2511,8 +2520,9 @@ class Block {
if (that.blocks.turtles.running()) {
that.blocks.logo.doStopTurtles();

setTimeout(function () {
that.blocks.logo.runLogoCommands(topBlk);

setTimeout(() => {
this.blocks.logo.runLogoCommands(topBlk);
}, 250);
} else {
that.blocks.logo.runLogoCommands(topBlk);
Expand All @@ -2530,8 +2540,10 @@ class Block {
if (that.blocks.turtles.running()) {
that.blocks.logo.doStopTurtles();

setTimeout(function () {
that.blocks.logo.runLogoCommands(topBlk);

setTimeout(() => {
this.blocks.logo.runLogoCommands(topBlk);

}, 250);
} else {
that.blocks.logo.runLogoCommands(topBlk);
Expand All @@ -2540,16 +2552,19 @@ class Block {
}
});

this.container.on("mousedown", function (event) {

this.container.on("mousedown", (event) => {

docById("contextWheelDiv").style.display = "none";

// Track time for detecting long pause...
that.blocks.mouseDownTime = new Date().getTime();
this.blocks.mouseDownTime = new Date().getTime();

that.blocks.longPressTimeout = setTimeout(function () {
that.blocks.activeBlock = that.blocks.blockList.indexOf(that);
that._triggerLongPress = true;
that.blocks.triggerLongPress();

this.blocks.longPressTimeout = setTimeout(() => {
this.blocks.activeBlock = this.blocks.blockList.indexOf(this);
this._triggerLongPress = true;
this.blocks.triggerLongPress();
}, LONGPRESSTIME);

// Always show the trash when there is a block selected,
Expand Down Expand Up @@ -2578,24 +2593,27 @@ class Block {
};
});

this.container.on("pressmove", function (event) {

this.container.on("pressmove", (event) => {
// FIXME: More voodoo
event.nativeEvent.preventDefault();

// Don't allow silence block to be dragged out of a note.
if (that.name === "rest2") {
if (this.name === "rest2") {
return;
}

if (window.hasMouse) {
moved = true;
} else {
// Make it eaiser to select text on mobile.
setTimeout(function () {

setTimeout(() => {
moved =
Math.abs(event.stageX / that.blocks.getStageScale() - that.original.x) +
Math.abs(event.stageY / that.blocks.getStageScale() - that.original.y) >
20 && !window.hasMouse;
Math.abs(event.stageX / this.blocks.getStageScale() -
this.original.x) +
Math.abs(event.stageY / that.blocks.getStageScale() -
this.original.y) > 20 && !window.hasMouse;
getInput = !moved;
}, 200);
}
Expand Down Expand Up @@ -2663,28 +2681,30 @@ class Block {
that.blocks.refreshCanvas();
});

this.container.on("mouseout", function (event) {
if (!that.blocks.getLongPressStatus()) {
that._mouseoutCallback(event, moved, haveClick, false);

this.container.on("mouseout", (event) => {
if (!this.blocks.getLongPressStatus()) {
this._mouseoutCallback(event, moved, haveClick, false);
} else {
clearTimeout(that.blocks.longPressTimeout);
that.blocks.longPressTimeout = null;
that.blocks.clearLongPress();
clearTimeout(this.blocks.longPressTimeout);
this.blocks.longPressTimeout = null;
this.blocks.clearLongPress();
}

that.blocks.unhighlight(thisBlock, true);
that.blocks.activeBlock = null;
this.blocks.unhighlight(thisBlock, true);
this.blocks.activeBlock = null;

moved = false;
});

this.container.on("pressup", function (event) {
if (!that.blocks.getLongPressStatus()) {
that._mouseoutCallback(event, moved, haveClick, false);

this.container.on("pressup", (event) => {
if (!this.blocks.getLongPressStatus()) {
this._mouseoutCallback(event, moved, haveClick, false);
} else {
clearTimeout(that.blocks.longPressTimeout);
that.blocks.longPressTimeout = null;
that.blocks.clearLongPress();
clearTimeout(this.blocks.longPressTimeout);
this.blocks.longPressTimeout = null;
this.blocks.clearLongPress();
}

that.blocks.unhighlight(thisBlock, true);
Expand Down Expand Up @@ -3508,8 +3528,9 @@ class Block {

this.label.addEventListener("keypress", __keypress);

this.label.addEventListener("change", function () {
that._labelChanged(false, true);

this.label.addEventListener("change", () => {
this._labelChanged(false, true);
});

this.label.style.left =
Expand All @@ -3531,9 +3552,10 @@ class Block {
}

// Firefox fix
setTimeout(function () {
that.label.style.display = "";
that.label.focus();

setTimeout(() => {
this.label.style.display = "";
this.label.focus();
focused = true;
}, 100);
}
Expand Down Expand Up @@ -4046,7 +4068,10 @@ function $() {

window.hasMouse = false;
// Mousemove is not emulated for touch
document.addEventListener("mousemove", function (e) {

document.addEventListener("mousemove", (e) => {
=======

window.hasMouse = true;
});

Expand Down
6 changes: 3 additions & 3 deletions js/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,10 +1083,10 @@ function Blocks(activity) {
for (let b = 0; b < blockPalette.protoList.length; b++) {
let protoblock = blockPalette.protoList[b];
if (protoblock.name === "nameddo" && protoblock.defaults[0] === that.blockList[oldBlock].value) {
setTimeout(function() {
setTimeout(() => {
blockPalette.remove(
protoblock,
that.blockList[oldBlock].value
this.blockList[oldBlock].value
);
delete that.protoBlockDict["myDo_" + that.blockList[oldBlock].value];
// that.palettes.hide();
Expand Down Expand Up @@ -5885,7 +5885,7 @@ function Blocks(activity) {
blocksToCheck.push([bb, this._getNestingDepth(bb), '2arg']);
}

blocksToCheck = blocksToCheck.sort(function(a, b) {
blocksToCheck = blocksToCheck.sort((a, b) => {
return a[1] - b[1];
});

Expand Down
4 changes: 2 additions & 2 deletions js/pastebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function PasteBox() {
let locked = false;
let that = this;

this._container.on("click", function(event) {
this._container.on("click", (event) =>{
// We need a lock to "debouce" the click.
if (locked) {
console.debug("debouncing click");
Expand All @@ -111,7 +111,7 @@ function PasteBox() {

locked = true;

setTimeout(function() {
setTimeout(() => {
locked = false;
}, 500);

Expand Down
8 changes: 4 additions & 4 deletions js/pluginsviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,26 +276,26 @@ function loadThumbnailContainerHandler(viewer) {

let locked = false;

viewer.container.on("click", function(event) {
viewer.container.on("click", (event) => {
// We need a lock to "debouce" the click.
if (locked) {
console.debug("debouncing click");
return;
}
locked = true;
setTimeout(function() {
setTimeout(() => {
locked = false;
}, 500);
viewerClicked(viewer, event);
});

viewer.container.on("mousedown", function(event) {
viewer.container.on("mousedown", (event) => {
startX = event.stageX;
startY = event.stageY;
locked = true;
});

viewer.container.on("pressup", function(event) {
viewer.container.on("pressup", (event) => {
endX = event.stageX;
endY = event.stageY;
if (endY > startY + 30 || endX > startX + 30) {
Expand Down
2 changes: 1 addition & 1 deletion js/trash.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function Trashcan() {
this._inAnimation = true;
let that = this;

this._animationInterval = setInterval(function() {
this._animationInterval = setInterval(() => {
that._animationLevel += 20;
if (that._animationLevel >= that.animationTime) {
that.isVisible = true;
Expand Down
8 changes: 4 additions & 4 deletions js/widgets/meterwidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function MeterWidget() {
}
}

setTimeout(function() {
setTimeout(() => {
that._click_lock = false;
}, 1000);
};
Expand Down Expand Up @@ -217,9 +217,9 @@ function MeterWidget() {
this.__playDrum("kick drum");
}

let that = this;
setTimeout(function() {
that.__playOneBeat((i + 1) % that._strongBeats.length, ms);

setTimeout(() => {
this.__playOneBeat((i + 1) % this._strongBeats.length, ms);
}, ms);
};

Expand Down
Loading