Skip to content

Commit f0ec800

Browse files
author
gourijain026@gmail.com
committed
revert: restore NumberBlocks, lilypond, LocalPlanet to upstream state
1 parent 7b30cb1 commit f0ec800

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

js/blocks/NumberBlocks.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ function setupNumberBlocks(activity) {
307307
return MathUtility.doSqrt(a);
308308
} catch (e) {
309309
logo.stopTurtle = true;
310-
if (e === "NanError") {
310+
if (e.message === "NanError") {
311311
activity.errorMsg(NANERRORMSG, blk);
312-
} else if (e === "NoSqrtError") {
312+
} else if (e.message === "NoSqrtError") {
313313
activity.errorMsg(NOSQRTERRORMSG, blk);
314314
return MathUtility.doSqrt(-a);
315315
}
@@ -464,9 +464,9 @@ function setupNumberBlocks(activity) {
464464
return MathUtility.doDivide(a, b);
465465
} catch (e) {
466466
logo.stopTurtle = true;
467-
if (e === "NanError") {
467+
if (e.message === "NanError") {
468468
activity.errorMsg(NANERRORMSG, blk);
469-
} else if (e === "DivByZeroError") {
469+
} else if (e.message === "DivByZeroError") {
470470
activity.errorMsg(ZERODIVIDEERRORMSG, blk);
471471
}
472472
return 0;
@@ -785,7 +785,9 @@ function setupNumberBlocks(activity) {
785785
return MathUtility.doPlus(a, b);
786786
} catch (e) {
787787
activity.errorMsg(NOINPUTERRORMSG, blk);
788+
788789
console.debug(a + " " + b);
790+
789791
console.debug(e);
790792
if (!isNaN(a)) {
791793
return a;

js/lilypond.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,10 @@ const processLilypondNotes = (lilypond, logo, turtle) => {
133133
j++; // Jump to next note.
134134
k++; // Increment notes in tuplet.
135135
} else if (logo.notation.notationStaging[turtle][i + j] === "tie") {
136-
// console.debug("adding a tie");
137136
logo.notationNotes[turtle] += "~";
138137
j++; // Jump to next note.
139138
k++; // Increment notes in tuplet.
140139
} else {
141-
// console.debug("ignoring " + notes);
142140
j++; // Jump to next note.
143141
k++; // Increment notes in tuplet.
144142
}
@@ -324,7 +322,7 @@ const processLilypondNotes = (lilypond, logo, turtle) => {
324322
}
325323

326324
modeDef += ")\n";
327-
// console.debug(modeDef);
325+
328326
lilypond.freygish += modeDef;
329327
logo.notationNotes[turtle] +=
330328
" \\key " + key + " \\" + mode.replace(/ /g, "_") + "\n";
@@ -408,7 +406,7 @@ const processLilypondNotes = (lilypond, logo, turtle) => {
408406

409407
// If it is a tuplet, look ahead to see if it is complete.
410408
// While you are at it, add up the durations.
411-
if (obj[NOTATIONTUPLETVALUE] !== null) {
409+
if (obj[NOTATIONTUPLETVALUE] != null) {
412410
let f;
413411
targetDuration = 1 / logo.notation.notationStaging[turtle][i][NOTATIONDURATION];
414412
tupletDuration = 1 / logo.notation.notationStaging[turtle][i][NOTATIONROUNDDOWN];
@@ -440,7 +438,6 @@ const processLilypondNotes = (lilypond, logo, turtle) => {
440438
}
441439

442440
if (logo.notation.notationStaging[turtle][i + j] === "tie") {
443-
// console.debug("saw a tie");
444441
k++; // Increment notes in tuplet.
445442
j++;
446443
} else if ([1, 0.5, 0.25, 0.125, 0.0625].includes(totalTupletDuration)) {
@@ -500,7 +497,7 @@ const processLilypondNotes = (lilypond, logo, turtle) => {
500497
}
501498

502499
if (
503-
obj[NOTATIONTUPLETVALUE] !== null &&
500+
obj[NOTATIONTUPLETVALUE] != null &&
504501
obj[NOTATIONTUPLETVALUE][0] * obj[NOTATIONTUPLETVALUE][1] > 0
505502
) {
506503
// Lilypond tuplets look like this: \tuplet 3/2 { f8 g a }
@@ -670,7 +667,6 @@ const saveLilypondOutput = function (activity) {
670667
let c = 0;
671668
const occupiedShortNames = [];
672669
for (const t in activity.logo.notation.notationStaging) {
673-
// console.debug('value of t: ' + t);
674670
let tNumber = t;
675671
if (typeof t === "string") {
676672
tNumber = Number(t);
@@ -681,8 +677,6 @@ const saveLilypondOutput = function (activity) {
681677
let noteCount = 0;
682678
for (let i = 0; i < activity.logo.notation.notationStaging[t].length; i++) {
683679
const obj = activity.logo.notation.notationStaging[t][i];
684-
// console.log("obj is ");
685-
// console.log(obj);
686680
if (typeof obj === "object") {
687681
for (let ii = 0; ii < obj[0].length; ii++) {
688682
if (obj[0][ii] === "R") {
@@ -762,8 +756,6 @@ const saveLilypondOutput = function (activity) {
762756
}
763757

764758
instrumentName = instrumentName.replace(/ /g, "").replace(".", "");
765-
766-
// console.log("L604: " + instrumentName);
767759
activity.logo.notationOutput += instrumentName + " = {\n";
768760
activity.logo.notationOutput += activity.logo.notationNotes[t];
769761

@@ -843,9 +835,6 @@ const saveLilypondOutput = function (activity) {
843835
}
844836
}
845837
}
846-
847-
// console.debug("instrumentName: " + instrumentName);
848-
// console.debug("shortInstrumentName: " + shortInstrumentName);
849838
}
850839

851840
activity.logo.notationOutput +=
@@ -859,7 +848,6 @@ const saveLilypondOutput = function (activity) {
859848
activity.logo.notationOutput += ' instrumentName = "' + instrumentName + '"\n';
860849
if (tNumber > startDrums - 1) {
861850
const num = tNumber - startDrums;
862-
// console.debug("shortInstrumentName = d" + num);
863851
activity.logo.notationOutput += ' shortInstrumentName = "' + "d" + num + '"\n';
864852
activity.logo.notationOutput += ' midiInstrument = "snare drum"\n';
865853
} else {
@@ -909,9 +897,6 @@ const saveLilypondOutput = function (activity) {
909897
} else {
910898
instrumentName = _("mouse");
911899
}
912-
913-
// console.debug("Source: " + instrumentName);
914-
915900
if (instrumentName === "") {
916901
instrumentName = _("mouse");
917902
}

planet/js/LocalPlanet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class LocalPlanet {
4848
this.projects = [];
4949

5050
for (const project in this.ProjectTable) {
51-
if (this.ProjectTable.hasOwnProperty(project)) {
51+
if (Object.prototype.hasOwnProperty.call(this.ProjectTable, project)) {
5252
this.projects.push([project, null]);
5353
}
5454
}
@@ -115,12 +115,12 @@ class LocalPlanet {
115115
Planet.loadProjectFromData(this.ProjectTable[id].ProjectData);
116116
}
117117

118-
mergeProject(id) {
118+
async mergeProject(id) {
119119
const Planet = this.Planet;
120-
const d = this.ProjectStorage.getCurrentProjectData();
120+
const d = await Planet.ProjectStorage.getCurrentProjectData();
121121

122122
if (d === null) {
123-
this.ProjectStorage.initialiseNewProject();
123+
await Planet.ProjectStorage.initialiseNewProject();
124124
Planet.loadProjectFromData(this.ProjectTable[id].ProjectData);
125125
} else Planet.loadProjectFromData(this.ProjectTable[id].ProjectData, true);
126126
}

0 commit comments

Comments
 (0)