";
docById("noteInfo1").style.top = "100px";
docById("noteInfo1").style.left = "90px";
- docById("done").style.height = "30px";
- docById("done").style.lineHeight = "30px";
- docById("close").style.cursor = "pointer";
- docById("frequencySlider").oninput = () => {
- this._refreshInnerWheel();
+ docById("frequencySlider").oninput = function () {
+ that._refreshInnerWheel();
};
- docById("done").onclick = () => {
- this.tempRatios1 = this.tempRatios.slice();
- const pitchNumber = this.tempRatios1.length - 1;
- this._createOuterWheel(this.tempRatios1, pitchNumber);
+ docById("done").onclick = function () {
+ that.tempRatios1 = that.tempRatios.slice();
+ const pitchNumber = that.tempRatios1.length - 1;
+ that._createOuterWheel(that.tempRatios1, pitchNumber);
};
- docById("close").onclick = () => {
- this.tempRatios = this.tempRatios1.slice();
- const pitchNumber = this.tempRatios.length - 1;
- this._createInnerWheel(this.tempRatios, pitchNumber);
+ docById("close").onclick = function () {
+ that.tempRatios = that.tempRatios1.slice();
+ const pitchNumber = that.tempRatios.length - 1;
+ that._createInnerWheel(that.tempRatios, pitchNumber);
docById("noteInfo1").remove();
};
}
}
- }
-
- /**
- * Triggerred when in Arbritrary edit option.
- * The slider with option to slide the values of frequesncies opens for a refreshed value.
- * @returns {void}
- */
- _refreshInnerWheel() {
+ };
+
+ this._refreshInnerWheel = function () {
docById("frequencydiv").innerHTML = docById("frequencySlider").value;
const frequency = docById("frequencySlider").value;
const ratio = frequency / this.frequencies[0];
const ratioDifference = [];
this.tempRatios = this.tempRatios1.slice();
- let index;
for (let j = 0; j < this.tempRatios.length; j++) {
ratioDifference[j] = ratio - this.tempRatios[j];
ratioDifference[j] = ratioDifference[j].toFixed(2);
+ let index;
if (ratioDifference[j] < 0) {
index = j;
this.tempRatios.splice(index, 0, ratio);
break;
- }
- if (ratioDifference[j] == 0) {
+ } else if (ratioDifference[j] === 0) {
index = j;
this.tempRatios.splice(index, 1, ratio);
break;
}
}
const pitchNumber = this.tempRatios.length - 1;
- logo.resetSynth(0);
- logo.synth.trigger(
+ this._logo.resetSynth(0);
+ this._logo.synth.trigger(
0,
frequency,
Singer.defaultBPMFactor * 0.01,
@@ -1614,91 +1399,89 @@ class TemperamentWidget {
null
);
this._createInnerWheel(this.tempRatios, pitchNumber);
- }
+ };
- /**
- * Triggerred when in octave space edit option.
- * @returns {void}
- */
- octaveSpaceEdit() {
+ this.octaveSpaceEdit = function () {
this.editMode = "octave";
docById("userEdit").innerHTML = "";
const len = this.ratios.length;
const octaveRatio = this.ratios[len - 1];
const octaveSpaceEdit = docById("userEdit");
- octaveSpaceEdit.style.backgroundColor = "#FFFFFF";
+ octaveSpaceEdit.style.backgroundColor = "#c8C8C8";
octaveSpaceEdit.innerHTML =
- '
Octave Space
" +
+ _("octave space") +
+ '
:
';
octaveSpaceEdit.style.paddingLeft = "70px";
+ const that = this;
const divAppend = document.createElement("div");
divAppend.id = "divAppend";
- divAppend.innerHTML = "Done";
+ divAppend.innerHTML = "done";
divAppend.style.textAlign = "center";
+ divAppend.style.paddingTop = "5px";
divAppend.style.marginLeft = "-70px";
divAppend.style.backgroundColor = platformColor.selectorBackground;
- divAppend.style.height = "30px";
+ divAppend.style.height = "25px";
divAppend.style.marginTop = "40px";
- divAppend.style.lineHeight = divAppend.style.height;
- divAppend.style.cursor = "pointer";
+ divAppend.style.overflow = "auto";
octaveSpaceEdit.append(divAppend);
- divAppend.onclick = () => {
+ divAppend.onmouseover = function () {
+ this.style.cursor = "pointer";
+ };
+
+ divAppend.onclick = function () {
const startRatio = docById("startNote").value;
const endRatio = docById("endNote").value;
const ratio = startRatio / endRatio;
- let msg;
- if (ratio != 2) {
- msg = "Octave Space has changed. This changes temperament significantly";
- if (!confirm(msg)) {
- return;
- }
+ if (ratio !== 2) {
+ that.activity.textMsg(
+ _("The octave ratio has changed. This changes temperament significantly.")
+ );
}
const powers = [];
const compareRatios = [];
- const frequency = this.frequencies[0];
- this.frequencies = [];
+ const frequency = that.frequencies[0];
+ that.frequencies = [];
for (let i = 0; i < len; i++) {
- powers[i] = 12 * (Math.log10(this.ratios[i]) / Math.log10(this.powerBase));
- this.ratios[i] = Math.pow(ratio, powers[i] / 12);
- compareRatios[i] = this.ratios[i].toFixed(2);
- this.frequencies[i] = this.ratios[i] * frequency;
- this.frequencies[i] = this.frequencies[i].toFixed(2);
+ powers[i] = 12 * (Math.log10(that.ratios[i]) / Math.log10(that.powerBase));
+ that.ratios[i] = Math.pow(ratio, powers[i] / 12);
+ compareRatios[i] = that.ratios[i].toFixed(2);
+ that.frequencies[i] = that.ratios[i] * frequency;
+ that.frequencies[i] = that.frequencies[i].toFixed(2);
}
- this.powerBase = ratio;
- this.typeOfEdit = "nonequal";
- this.checkTemperament(compareRatios);
+ that.powerBase = ratio;
+ that.typeOfEdit = "nonequal";
+ that.checkTemperament(compareRatios);
if (ratio != 2) {
- this.octaveChanged = true;
+ that.octaveChanged = true;
}
- this._circleOfNotes();
+ that._circleOfNotes();
};
- }
+ };
- /**
- * Checks for temperament.
- * @returns {void}
- */
- checkTemperament(ratios) {
+ this.checkTemperament = function (ratios) {
const intervals = [];
let selectedTemperament;
- let t, temperamentRatios, ratiosEqual;
- for (const temperament in TEMPERAMENT) {
- if (!isCustom(temperament)) {
- t = TEMPERAMENT[temperament];
- temperamentRatios = [];
+ const keys = getTemperamentKeys();
+ for (let i = 0; i < keys.length; i++) {
+ const temperament = keys[i];
+ if (!isCustomTemperament(temperament)) {
+ const t = getTemperament(temperament);
+ const temperamentRatios = [];
for (let j = 0; j < t.interval.length; j++) {
intervals[j] = t.interval[j];
temperamentRatios[j] = t[intervals[j]];
temperamentRatios[j] = temperamentRatios[j].toFixed(2);
}
- ratiosEqual =
+ const ratiosEqual =
ratios.length == temperamentRatios.length &&
- ratios.every((element, index) => {
+ ratios.every(function (element, index) {
return element === temperamentRatios[index];
});
@@ -1715,19 +1498,14 @@ class TemperamentWidget {
this.inTemperament = "custom";
temperamentCell.innerHTML = this.inTemperament;
}
- }
+ };
- /**
- * Triggerred when Save button is pressed. New action blocks are generated.
- * @returns {void}
- */
- _save() {
+ this._save = function () {
let notesMatch = false;
- // let index = [];
+ let index = [];
this.notes = [];
- let cents, centsDiff, centsDiff1, min, idx;
- if (isCustom(this.inTemperament)) {
+ if (isCustomTemperament(this.inTemperament)) {
for (let i = 0; i < this.ratios.length; i++) {
for (let j = 0; j < this.ratiosNotesPair.length; j++) {
notesMatch = false;
@@ -1738,59 +1516,72 @@ class TemperamentWidget {
break;
}
}
+
if (!notesMatch) {
- cents = 1200 * (Math.log10(this.ratios[i]) / Math.log10(this.powerBase));
- centsDiff = [];
- centsDiff1 = [];
+ const cents = 1200 * (Math.log10(this.ratios[i]) / Math.log10(2));
+ const centsDiff = [];
+ const centsDiff1 = [];
for (let j = 0; j < this.cents.length; j++) {
centsDiff[j] = cents - this.cents[j];
centsDiff1[j] = Math.abs(cents - this.cents[j]);
}
- min = centsDiff1.reduce((a, b) => {
+ const min = centsDiff1.reduce(function (a, b) {
return Math.min(a, b);
});
- idx = centsDiff1.indexOf(min);
-
- if (centsDiff[idx] < 0) {
+ index = centsDiff1.indexOf(min);
+ if (centsDiff[index] < 0) {
this.notes[i] =
- this.ratiosNotesPair[idx][1][0] +
+ this.ratiosNotesPair[index][1][0] +
"(-" +
- centsDiff1[idx].toFixed(0) +
+ centsDiff1[index].toFixed(0) +
")" +
- this.ratiosNotesPair[idx][1][1];
+ this.ratiosNotesPair[index][1][1];
} else {
this.notes[i] =
- this.ratiosNotesPair[idx][1][0] +
+ this.ratiosNotesPair[index][1][0] +
"(+" +
- centsDiff1[idx].toFixed(0) +
+ centsDiff1[index].toFixed(0) +
")" +
- this.ratiosNotesPair[idx][1][1];
+ this.ratiosNotesPair[index][1][1];
}
}
}
}
- // Global value
- octaveRatio = this.powerBase;
+ setOctaveRatio(this.powerBase);
- const value = logo.blocks.findUniqueTemperamentName(this.inTemperament);
- this.inTemperament = value; // change from temporary "custom" to "custom1" or "custom2" ..
+ const len = this._logo.synth.startingPitch.length;
+ const note = this._logo.synth.startingPitch.substring(0, len - 1);
+ const octave = this._logo.synth.startingPitch.slice(-1);
+ const newStack1 = [
+ [0, "settemperament", 150, 150, [null, 1, 2, 3, null]],
+ [1, ["temperamentname", { value: this.inTemperament }], 0, 0, [0]],
+ [2, ["notename", { value: note }], 0, 0, [0]],
+ [3, ["number", { value: octave }], 0, 0, [0]]
+ ];
+ this.activity.blocks.loadNewBlocks(newStack1);
+
+ const value = this.activity.blocks.findUniqueTemperamentName(this.inTemperament);
+ // Change from temporary "custom" to "custom1" or "custom2" ...
+ this.inTemperament = value;
const newStack = [
- [0, "temperament1", 100, 100, [null, 1, 2, null]],
+ [0, ["temperament1", {
+ collapsed: true
+ }], 150, 100, [null, 1, 2, null]],
[1, ["text", { value: value }], 0, 0, [0]],
[2, ["storein"], 0, 0, [0, 3, 4, 5]],
- [3, ["text", { value: logo.synth.startingPitch }], 0, 0, [2]],
+ [3, ["text", { value: this._logo.synth.startingPitch }], 0, 0, [2]],
[4, ["number", { value: this.frequencies[0] }], 0, 0, [2]],
[5, ["octavespace"], 0, 0, [2, 6, 9]],
[6, ["divide"], 0, 0, [5, 7, 8]],
- [7, ["number", { value: rationalToFraction(octaveRatio)[0] }], 0, 0, [6]],
- [8, ["number", { value: rationalToFraction(octaveRatio)[1] }], 0, 0, [6]],
+ [7, ["number", { value: rationalToFraction(getOctaveRatio())[0] }], 0, 0, [6]],
+ [8, ["number", { value: rationalToFraction(getOctaveRatio())[1] }], 0, 0, [6]],
[9, "vspace", 0, 0, [5, 10]]
];
let previousBlock = 9;
for (let i = 0; i < this.pitchNumber; i++) {
- idx = newStack.length;
+ const idx = newStack.length;
if (
this.inTemperament === "equal" ||
this.inTemperament === "1/3 comma meantone" ||
@@ -1806,7 +1597,7 @@ class TemperamentWidget {
newStack.push([idx + 1, "multiply", 0, 0, [idx, idx + 2, idx + 3]]);
newStack.push([
idx + 2,
- ["namedbox", { value: logo.synth.startingPitch }],
+ ["namedbox", { value: this._logo.synth.startingPitch }],
0,
0,
[idx + 1]
@@ -1818,7 +1609,7 @@ class TemperamentWidget {
newStack.push([idx + 7, ["number", { value: this.pitchNumber }], 0, 0, [idx + 5]]);
newStack.push([idx + 8, "vspace", 0, 0, [idx, idx + 9]]);
newStack.push([idx + 9, ["pitch"], 0, 0, [idx + 8, idx + 10, idx + 11, null]]);
- if (!isCustom(this.inTemperament)) {
+ if (!isCustomTemperament(this.inTemperament)) {
newStack.push([
idx + 10,
["notename", { value: this.ratiosNotesPair[i][1][0] }],
@@ -1872,7 +1663,7 @@ class TemperamentWidget {
newStack.push([idx + 1, "multiply", 0, 0, [idx, idx + 2, idx + 3]]);
newStack.push([
idx + 2,
- ["namedbox", { value: logo.synth.startingPitch }],
+ ["namedbox", { value: this._logo.synth.startingPitch }],
0,
0,
[idx + 1]
@@ -1895,7 +1686,7 @@ class TemperamentWidget {
newStack.push([idx + 6, "vspace", 0, 0, [idx, idx + 7]]);
newStack.push([idx + 7, ["pitch"], 0, 0, [idx + 6, idx + 8, idx + 9, null]]);
- if (!isCustom(this.inTemperament)) {
+ if (!isCustomTemperament(this.inTemperament)) {
newStack.push([
idx + 8,
["notename", { value: this.ratiosNotesPair[i][1][0] }],
@@ -1940,64 +1731,54 @@ class TemperamentWidget {
previousBlock = idx + 10;
}
}
- logo.blocks.loadNewBlocks(newStack);
- logo.textMsg(_("New action block generated!"));
- const len = logo.synth.startingPitch.length;
- const note = logo.synth.startingPitch.substring(0, len - 1);
- const octave = logo.synth.startingPitch.slice(-1);
- const newStack1 = [
- [0, "settemperament", 100, 100, [null, 1, 2, 3, null]],
- [1, ["temperamentname", { value: this.inTemperament }], 0, 0, [0]],
- [2, ["notename", { value: note }], 0, 0, [0]],
- [3, ["number", { value: octave }], 0, 0, [0]]
- ];
- logo.blocks.loadNewBlocks(newStack1);
- logo.textMsg(_("New action block generated!"));
-
- let number;
- if (isCustom(this.inTemperament)) {
- TEMPERAMENT[this.inTemperament] = [];
- TEMPERAMENT[this.inTemperament]["pitchNumber"] = this.pitchNumber;
- updateTemperaments();
+ const that = this;
+ setTimeout(() => {
+ that.activity.blocks.loadNewBlocks(newStack);
+ that.activity.textMsg(_("New action block generated!"));
+ }, 500);
+
+ if (isCustomTemperament(this.inTemperament)) {
+ deleteTemperamentFromList(this.inTemperament);
+ const newTemperament = { pitchNumber: this.pitchNumber };
for (let i = 0; i < this.pitchNumber; i++) {
- number = "" + i;
- TEMPERAMENT[this.inTemperament][number] = [
+ const number = "" + i;
+ newTemperament[number] = [
this.ratios[i],
this.notes[i].substring(0, this.notes[i].length - 1),
- this.notes[i].slice(-1),
- this.notes[i].substring(0, this.notes[i].length - 1)
+ this.notes[i].slice(-1)
];
}
+ // eslint-disable-next-line no-console
+ console.log(newTemperament);
+ addTemperamentToDictionary(this.inTemperament, newTemperament);
+ updateTemperaments();
}
- if (isCustom(this.inTemperament)) {
- logo.customTemperamentDefined = true;
- logo.blocks.protoBlockDict["custompitch"].hidden = false;
- logo.blocks.palettes.updatePalettes("pitch");
+ if (isCustomTemperament(this.inTemperament)) {
+ this._logo.customTemperamentDefined = true;
+ this.activity.blocks.protoBlockDict["custompitch"].hidden = false;
+ this.activity.blocks.palettes.updatePalettes("pitch");
}
- }
-
- /**
- * Triggerred when play button is pressed on a single note in table.
- * Notes are displayed in sequence and can be played one after another.
- * @returns {void}
- */
- playNote(pitchNumber) {
- logo.resetSynth(0);
+ };
+
+ this.playNote = function (pitchNumber) {
+ this._logo.resetSynth(0);
const duration = 1 / 2;
let notes;
+
if (docById("wheelDiv4") == null) {
notes = this.frequencies[pitchNumber];
- if (this.editMode == "equal" && this.eqTempHzs && this.eqTempHzs.length)
+ if (this.editMode == "equal" && this.eqTempHzs && this.eqTempHzs.length) {
notes = this.eqTempHzs[pitchNumber];
- else if (this.editMode == "ratio" && this.NEqTempHzs && this.NEqTempHzs.length)
+ } else if (this.editMode == "ratio" && this.NEqTempHzs && this.NEqTempHzs.length) {
notes = this.NEqTempHzs[pitchNumber];
+ }
} else {
notes = this.tempRatios1[pitchNumber] * this.frequencies[0];
}
- logo.synth.trigger(
+ this._logo.synth.trigger(
0,
notes,
Singer.defaultBPMFactor * duration,
@@ -2005,21 +1786,14 @@ class TemperamentWidget {
null,
null
);
- }
-
- /**
- * Triggerred when play button is pressed.
- * All Notes are played in sequence from the start.
- * @returns {void}
- */
- playAll() {
+ };
+
+ this.playAll = function () {
let p = 0;
this.playbackForward = true;
this._playing = !this._playing;
- if (!this._playing) {
- return;
- }
- logo.resetSynth(0);
+
+ this._logo.resetSynth(0);
const cell = this.playButton;
if (this._playing) {
@@ -2031,14 +1805,29 @@ class TemperamentWidget {
'" alt="' +
_("Stop") +
'" height="' +
- TemperamentWidget.ICONSIZE +
+ ICONSIZE +
'" width="' +
- TemperamentWidget.ICONSIZE +
+ ICONSIZE +
+ '" vertical-align="middle" align-content="center"> ';
+ } else {
+ this._logo.synth.setMasterVolume(0);
+ this._logo.synth.stop();
+ cell.innerHTML =
+ '
';
}
const duration = 1 / 2;
- const startingPitch = logo.synth.startingPitch;
+ const startingPitch = this._logo.synth.startingPitch;
const startingPitchOcatve = Number(startingPitch.slice(-1));
const octave = startingPitchOcatve - 1;
const startPitch = pitchToFrequency(
@@ -2048,32 +1837,27 @@ class TemperamentWidget {
"C Major"
);
+ const that = this;
let pitchNumber = this.pitchNumber;
- if (this.editMode == "equal" && this.eqTempPitchNumber)
+ if (this.editMode == "equal" && this.eqTempPitchNumber) {
pitchNumber = this.eqTempPitchNumber;
- else if (this.editMode == "ratio" && this.NEqTempPitchNumber)
+ } else if (this.editMode == "ratio" && this.NEqTempPitchNumber) {
pitchNumber = this.NEqTempPitchNumber;
+ }
+
if (docById("wheelDiv4") !== null) {
pitchNumber = this.tempRatios1.length - 1;
}
- const updateNotesCircle = (index,color) => {
- this.notesCircle.navItems[index].fillAttr = color;
- this.notesCircle.navItems[index].sliceHoverAttr.fill = color;
- this.notesCircle.navItems[index].slicePathAttr.fill = color;
- this.notesCircle.navItems[index].sliceSelectedAttr.fill = color;
- };
-
- const __playLoop = (i) => {
- let j;
+ const __playLoop = function (i) {
if (i === pitchNumber) {
- this.playbackForward = false;
+ that.playbackForward = false;
}
if (i === 0) {
p++;
}
- if (this._playing) {
- logo.synth.trigger(
+ if (that._playing) {
+ that._logo.synth.trigger(
0,
startPitch,
Singer.defaultBPMFactor * duration,
@@ -2081,121 +1865,104 @@ class TemperamentWidget {
null,
null
);
- this.playNote(i);
+ that.playNote(i);
}
- if (this.circleIsVisible == false && docById("wheelDiv4") == null) {
+
+ if (that.circleIsVisible == false && docById("wheelDiv4") == null) {
if (i === pitchNumber) {
- updateNotesCircle(0,TemperamentWidget.DARKGREY);
+ that.notesCircle.navItems[0].fillAttr = "#808080";
+ that.notesCircle.navItems[0].sliceHoverAttr.fill = "#808080";
+ that.notesCircle.navItems[0].slicePathAttr.fill = "#808080";
+ that.notesCircle.navItems[0].sliceSelectedAttr.fill = "#808080";
} else {
- updateNotesCircle(i,TemperamentWidget.DARKGREY);
+ that.notesCircle.navItems[i].fillAttr = "#808080";
+ that.notesCircle.navItems[i].sliceHoverAttr.fill = "#808080";
+ that.notesCircle.navItems[i].slicePathAttr.fill = "#808080";
+ that.notesCircle.navItems[i].sliceSelectedAttr.fill = "#808080";
}
- if (this.playbackForward == false && i < pitchNumber) {
+ if (that.playbackForward == false && i < pitchNumber) {
if (i === pitchNumber - 1) {
- updateNotesCircle(0,TemperamentWidget.GREY);
+ that.notesCircle.navItems[0].fillAttr = "#c8C8C8";
+ that.notesCircle.navItems[0].sliceHoverAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[0].slicePathAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[0].sliceSelectedAttr.fill = "#c8C8C8";
} else {
- updateNotesCircle(i + 1,TemperamentWidget.GREY);
+ that.notesCircle.navItems[i + 1].fillAttr = "#c8C8C8";
+ that.notesCircle.navItems[i + 1].sliceHoverAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[i + 1].slicePathAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[i + 1].sliceSelectedAttr.fill = "#c8C8C8";
}
} else {
if (i !== 0) {
- updateNotesCircle(i - 1,TemperamentWidget.GREY);
+ that.notesCircle.navItems[i - 1].fillAttr = "#c8C8C8";
+ that.notesCircle.navItems[i - 1].sliceHoverAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[i - 1].slicePathAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = "#c8C8C8";
}
}
- this.notesCircle.refreshWheel();
- } else if (this.circleIsVisible == true && docById("wheelDiv4") == null) {
+ that.notesCircle.refreshWheel();
+ } else if (that.circleIsVisible == true && docById("wheelDiv4") == null) {
docById("pitchNumber_" + i).style.background = platformColor.labelColor;
- if (this.playbackForward == false && i < pitchNumber) {
- j = i + 1;
+ if (that.playbackForward == false && i < pitchNumber) {
+ const j = i + 1;
docById("pitchNumber_" + j).style.background = platformColor.selectorBackground;
} else {
if (i !== 0) {
- j = i - 1;
+ const j = i - 1;
docById("pitchNumber_" + j).style.background =
platformColor.selectorBackground;
}
}
} else if (docById("wheelDiv4") !== null) {
if (i === pitchNumber) {
- updateNotesCircle(0,TemperamentWidget.DARKGREY);
+ that.wheel1.navItems[0].fillAttr = "#808080";
+ that.wheel1.navItems[0].sliceHoverAttr.fill = "#808080";
+ that.wheel1.navItems[0].slicePathAttr.fill = "#808080";
+ that.wheel1.navItems[0].sliceSelectedAttr.fill = "#808080";
} else {
- updateNotesCircle(i,TemperamentWidget.DARKGREY);
+ that.wheel1.navItems[i].fillAttr = "#808080";
+ that.wheel1.navItems[i].sliceHoverAttr.fill = "#808080";
+ that.wheel1.navItems[i].slicePathAttr.fill = "#808080";
+ that.wheel1.navItems[i].sliceSelectedAttr.fill = "#808080";
}
- if (this.playbackForward == false && i < pitchNumber) {
+ if (that.playbackForward == false && i < pitchNumber) {
if (i === pitchNumber - 1) {
- updateNotesCircle(0,TemperamentWidget.LIGHTGREY);
+ that.wheel1.navItems[0].fillAttr = "#e0e0e0";
+ that.wheel1.navItems[0].sliceHoverAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[0].slicePathAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[0].sliceSelectedAttr.fill = "#e0e0e0";
} else {
- updateNotesCircle(i + 1,TemperamentWidget.LIGHTGREY);
+ that.wheel1.navItems[i + 1].fillAttr = "#e0e0e0";
+ that.wheel1.navItems[i + 1].sliceHoverAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[i + 1].slicePathAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[i + 1].sliceSelectedAttr.fill = "#e0e0e0";
}
} else {
if (i !== 0) {
- updateNotesCircle(i - 1,TemperamentWidget.LIGHTGREY);
+ that.wheel1.navItems[i - 1].fillAttr = "#e0e0e0";
+ that.wheel1.navItems[i - 1].sliceHoverAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[i - 1].slicePathAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[i - 1].sliceSelectedAttr.fill = "#e0e0e0";
}
}
- this.wheel1.refreshWheel();
+ that.wheel1.refreshWheel();
}
- if (this.playbackForward) {
+ if (that.playbackForward) {
i += 1;
} else {
i -= 1;
}
- if (i <= pitchNumber && i >= 0 && p < 2) {
- setTimeout(() => {
- if (this.closed) {
- this.closed = !this.closed;
- return;
- } else if (!this._playing) {
- cell.innerHTML =
- '
';
- if (i !== -1) {
- if (this.circleIsVisible == false && docById("wheelDiv4") == null) {
- updateNotesCircle(i - 1,TemperamentWidget.GREY);
- if (i == 11) {
- //on completion of a full circle and on hitting '0' note in clockwise direction
- updateNotesCircle(0,TemperamentWidget.GREY);
- } else if (i < 11) {
- //in case of counter-clockwise direction, i.e., when this.playbackForward = false
- updateNotesCircle(i + 1,TemperamentWidget.GREY);
- }
- this.notesCircle.refreshWheel();
- } else if (
- this.circleIsVisible == true &&
- docById("wheelDiv4") == null
- ) {
- docById("pitchNumber_" + (i - 1)).style.background =
- platformColor.selectorBackground;
- } else if (docById("wheelDiv4") !== null) {
- this.wheel1.navItems[i - 1].fillAttr = TemperamentWidget.LIGHTGREY;
- this.wheel1.navItems[i - 1].sliceHoverAttr.fill =
- TemperamentWidget.LIGHTGREY;
- this.wheel1.navItems[i - 1].slicePathAttr.fill =
- TemperamentWidget.LIGHTGREY;
- this.wheel1.navItems[i - 1].sliceSelectedAttr.fill =
- TemperamentWidget.LIGHTGREY;
- this.wheel1.refreshWheel();
- }
- }
- this._playing = false;
- } else {
- __playLoop(i);
- }
+ if (i <= pitchNumber && i >= 0 && that._playing && p < 2) {
+ setTimeout(function () {
+ __playLoop(i);
}, Singer.defaultBPMFactor * 1000 * duration);
} else {
- this._playing = false;
cell.innerHTML =
'
';
+ if (i !== -1) {
+ setTimeout(function () {
+ if (that.circleIsVisible == false && docById("wheelDiv4") == null) {
+ that.notesCircle.navItems[i - 1].fillAttr = "#c8C8C8";
+ that.notesCircle.navItems[i - 1].sliceHoverAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[i - 1].slicePathAttr.fill = "#c8C8C8";
+ that.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = "#c8C8C8";
+ that.notesCircle.refreshWheel();
+ } else if (that.circleIsVisible == true && docById("wheelDiv4") == null) {
+ const j = i - 1;
+ docById("pitchNumber_" + j).style.background =
+ platformColor.selectorBackground;
+ } else if (docById("wheelDiv4") !== null) {
+ that.wheel1.navItems[i - 1].fillAttr = "#e0e0e0";
+ that.wheel1.navItems[i - 1].sliceHoverAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[i - 1].slicePathAttr.fill = "#e0e0e0";
+ that.wheel1.navItems[i - 1].sliceSelectedAttr.fill = "#e0e0e0";
+ that.wheel1.refreshWheel();
+ }
+ }, Singer.defaultBPMFactor * 1000 * duration);
+ }
+ that._playing = false;
}
};
if (this._playing) {
__playLoop(0);
}
- }
+ };
+
+ this.init = function (activity) {
+ this.activity = activity;
+ this._logo = this.activity.logo;
+
+ const w = window.innerWidth;
+ this._cellScale = w / 1200;
+
+ const widgetWindow = window.widgetWindows.windowFor(this, "temperament");
+ this.widgetWindow = widgetWindow;
+ widgetWindow.clear();
+ widgetWindow.show();
+
+ widgetWindow.getWidgetBody().append(temperamentTableDiv);
+ widgetWindow.getWidgetBody().style.height = "500px";
+ widgetWindow.getWidgetBody().style.width = "500px";
+
+ const that = this;
+
+ widgetWindow.onclose = function () {
+ that._logo.synth.setMasterVolume(0);
+ that._logo.synth.stop();
+ if (docById("wheelDiv2") != null) {
+ docById("wheelDiv2").style.display = "none";
+ that.notesCircle.removeWheel();
+ }
+ if (docById("wheelDiv3") != null) {
+ docById("wheelDiv3").style.display = "none";
+ that.wheel.removeWheel();
+ }
+ if (docById("wheelDiv4") != null) {
+ docById("wheelDiv4").style.display = "none";
+ that.wheel1.removeWheel();
+ }
+
+ this.destroy();
+ };
+
+ this._playing = false;
+
+ const buttonTable = document.createElement("table");
+ const header = buttonTable.createTHead();
+ const row = header.insertRow(0);
+ row.id = "buttonsRow";
+
+ temperamentCell = row.insertCell();
+ temperamentCell.innerHTML = this.inTemperament;
+ temperamentCell.style.width = 2 * BUTTONSIZE + "px";
+ temperamentCell.style.minWidth = temperamentCell.style.width;
+ temperamentCell.style.maxWidth = temperamentCell.style.width;
+ temperamentCell.style.height = BUTTONSIZE + "px";
+ temperamentCell.style.minHeight = temperamentCell.style.height;
+ temperamentCell.style.maxHeight = temperamentCell.style.height;
+ temperamentCell.style.textAlign = "center";
+ temperamentCell.style.backgroundColor = platformColor.selectorBackground;
+
+ this.playButton = widgetWindow.addButton("play-button.svg", ICONSIZE, _("Play all"));
+ this.playButton.onclick = function () {
+ that.playAll();
+ };
+
+ widgetWindow.addButton("export-chunk.svg", ICONSIZE, _("Save")).onclick = function () {
+ that._save();
+ };
+
+ var noteCell = widgetWindow.addButton("play-button.svg", ICONSIZE, _("Table"));
+
+ let t = getTemperament(this.inTemperament);
+ this.pitchNumber = t.pitchNumber;
+ this.octaveChanged = false;
+ this.scale = this.scale[0] + " " + this.scale[1];
+ this.scaleNotes = buildScale(this.scale);
+ this.scaleNotes = this.scaleNotes[0];
+ this.powerBase = 2;
+ const startingPitch = this._logo.synth.startingPitch;
+ const str = [];
+ const note = [];
+ this.notes = [];
+ this.frequencies = [];
+ this.cents = [];
+ this.intervals = [];
+ this.ratios = [];
+ this.ratiosNotesPair = [];
+
+ for (let i = 0; i <= this.pitchNumber; i++) {
+ if (isCustomTemperament(this.inTemperament) && t["0"] !== undefined && t["0"][1] !== undefined) {
+ //If temperament selected is custom and it is defined by user.
+ const pitchNumber = i + "";
+ if (i === this.pitchNumber) {
+ this.notes[i] = [t["0"][1], Number(t["0"][2]) + 1];
+ this.ratios[i] = this.powerBase;
+ } else {
+ this.notes[i] = [t[pitchNumber][1], t[pitchNumber][2]];
+ this.ratios[i] = t[pitchNumber][0];
+ }
+ this.frequencies[i] = this._logo.synth
+ .getCustomFrequency(
+ this.notes[i][0] + this.notes[i][1] + "",
+ this.inTemperament
+ )
+ .toFixed(2);
+ this.cents[i] = 1200 * (Math.log10(this.ratios[i]) / Math.log10(2));
+ this.ratiosNotesPair[i] = [this.ratios[i], this.notes[i]];
+ } else {
+ if (isCustomTemperament(this.inTemperament)) {
+ // If temperament selected is custom and it is not
+ // yet defined by the user then custom temperament
+ // behaves like equal temperament.
+ t = getTemperament("equal");
+ }
+ str[i] = getNoteFromInterval(startingPitch, t.interval[i]);
+ this.notes[i] = str[i];
+ note[i] = str[i][0];
+
+ if (
+ str[i][0].substring(1, str[i][0].length) === FLAT ||
+ str[i][0].substring(1, str[i][0].length) === "b"
+ ) {
+ note[i] = str[i][0].replace(FLAT, "b");
+ } else if (
+ str[i][0].substring(1, str[i][0].length) === SHARP ||
+ str[i][0].substring(1, str[i][0].length) === "#"
+ ) {
+ note[i] = str[i][0].replace(SHARP, "#");
+ }
+
+ str[i] = note[i] + str[i][1];
+ this.frequencies[i] = this._logo.synth
+ ._getFrequency(str[i], true, this.inTemperament)
+ .toFixed(2);
+ this.intervals[i] = t.interval[i];
+ this.ratios[i] = t[this.intervals[i]];
+ this.cents[i] = 1200 * (Math.log10(this.ratios[i]) / Math.log10(2));
+ this.ratiosNotesPair[i] = [this.ratios[i], this.notes[i]];
+ }
+ }
+ this.toggleNotesButton = function () {
+ if (this.circleIsVisible) {
+ noteCell.getElementsByTagName("img")[0].src = "header-icons/circle.svg";
+ noteCell.getElementsByTagName("img")[0].title = "circle";
+ noteCell.getElementsByTagName("img")[0].alt = "circle";
+ } else {
+ noteCell.getElementsByTagName("img")[0].src = "header-icons/table.svg";
+ noteCell.getElementsByTagName("img")[0].title = "table";
+ noteCell.getElementsByTagName("img")[0].alt = "table";
+ }
+ };
+
+ this._circleOfNotes();
+
+ // eslint-disable-next-line no-unused-vars
+ noteCell.onclick = function (event) {
+ that.editMode = null;
+ if (that.circleIsVisible) {
+ that._circleOfNotes();
+ } else {
+ that._graphOfNotes();
+ }
+ };
+
+ widgetWindow.addButton(
+ "add2.svg",
+ ICONSIZE,
+ _("Add pitches")
+ // eslint-disable-next-line no-unused-vars
+ ).onclick = function (event) {
+ that.edit();
+ };
+
+ widgetWindow.sendToCenter();
+ };
}
diff --git a/js/widgets/tempo.js b/js/widgets/tempo.js
index 9cdf4f782e..a045a03728 100644
--- a/js/widgets/tempo.js
+++ b/js/widgets/tempo.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-19 Walter Bender
+// Copyright (c) 2016-21 Walter Bender
// Copyright (c) 2016 Hemant Kasat
// This program is free software; you can redistribute it and/or
// modify it under the terms of the The GNU Affero General Public
@@ -12,19 +12,20 @@
// This widget enable us to manipulate the beats per minute. It
// behaves like a metronome and updates the master BPM block.
-/* global logo, _, saveLocally, getDrumSynthName */
+/*
+ global
+ _, getDrumSynthName
+ */
/*
Global locations
- js/activity.js
- logo, saveLocally
js/utils/musicutils.js
getDrumSynthName
js/utils/utils.js
_
*/
-/*exported Tempo */
+/* exported Tempo */
class Tempo {
static TEMPOSYNTH = "bottle";
static TEMPOINTERVAL = 5;
@@ -43,7 +44,8 @@ class Tempo {
this.tempoCanvases = [];
}
- init() {
+ init(activity) {
+ this.activity = activity;
this._directions = [];
this._widgetFirstTimes = [];
this._widgetNextTimes = [];
@@ -55,7 +57,7 @@ class Tempo {
}
this._intervalID = null;
- logo.synth.loadSynth(0, getDrumSynthName(Tempo.TEMPOSYNTH));
+ this.activity.logo.synth.loadSynth(0, getDrumSynthName(Tempo.TEMPOSYNTH));
if (this._intervalID != null) {
clearInterval(this._intervalID);
@@ -125,7 +127,7 @@ class Tempo {
let r1, r2, r3, tcCell;
for (let i = 0; i < this.BPMs.length; i++) {
this._directions.push(1);
- this._widgetFirstTimes.push(logo.firstNoteTime);
+ this._widgetFirstTimes.push(this.activity.logo.firstNoteTime);
if (this.BPMs[i] <= 0) {
this.BPMs[i] = 30;
}
@@ -189,7 +191,7 @@ class Tempo {
);
}
- logo.textMsg(_("Adjust the tempo with the buttons."));
+ this.activity.textMsg(_("Adjust the tempo with the buttons."));
this.resume();
widgetWindow.sendToCenter();
@@ -205,13 +207,13 @@ class Tempo {
let blockNumber;
if (this.BPMBlocks[i] != null) {
- blockNumber = logo.blocks.blockList[this.BPMBlocks[i]].connections[1];
+ blockNumber = this.activity.blocks.blockList[this.BPMBlocks[i]].connections[1];
if (blockNumber != null) {
- logo.blocks.blockList[blockNumber].value = parseFloat(this.BPMs[i]);
- logo.blocks.blockList[blockNumber].text.text = this.BPMs[i];
- logo.blocks.blockList[blockNumber].updateCache();
- logo.refreshCanvas();
- saveLocally();
+ this.activity.blocks.blockList[blockNumber].value = parseFloat(this.BPMs[i]);
+ this.activity.blocks.blockList[blockNumber].text.text = this.BPMs[i];
+ this.activity.blocks.blockList[blockNumber].updateCache();
+ this.activity.refreshCanvas();
+ this.activity.saveLocally();
}
}
}
@@ -256,10 +258,10 @@ class Tempo {
this.BPMs[i] = this.BPMInputs[i].value;
if (this.BPMs[i] > 1000) {
this.BPMs[i] = 1000;
- logo.errorMsg(_("The beats per minute must be between 30 and 1000."));
+ this.activity.errorMsg(_("The beats per minute must be between 30 and 1000."));
} else if (this.BPMs[i] < 30) {
this.BPMs[i] = 30;
- logo.errorMsg(_("The beats per minute must be between 30 and 1000."));
+ this.activity.errorMsg(_("The beats per minute must be between 30 and 1000."));
}
this._updateBPM(i);
@@ -275,7 +277,7 @@ class Tempo {
this.BPMs[i] = parseFloat(this.BPMs[i]) + Math.round(0.1 * this.BPMs[i]);
if (this.BPMs[i] > 1000) {
- logo.errorMsg(_("The beats per minute must be below 1000."));
+ this.activity.errorMsg(_("The beats per minute must be below 1000."));
this.BPMs[i] = 1000;
}
@@ -291,7 +293,7 @@ class Tempo {
slowDown(i) {
this.BPMs[i] = parseFloat(this.BPMs[i]) - Math.round(0.1 * this.BPMs[i]);
if (this.BPMs[i] < 30) {
- logo.errorMsg(_("The beats per minute must be above 30"));
+ this.activity.errorMsg(_("The beats per minute must be above 30"));
this.BPMs[i] = 30;
}
@@ -323,7 +325,7 @@ class Tempo {
// Are we done yet?
if (d.getTime() > this._widgetNextTimes[i]) {
// Play a tone.
- logo.synth.trigger(0, ["C2"], 0.0625, Tempo.TEMPOSYNTH, null, null, false);
+ this.activity.logo.synth.trigger(0, ["C2"], 0.0625, Tempo.TEMPOSYNTH, null, null, false);
this._widgetNextTimes[i] += this._intervals[i];
// Ensure we are at the edge.
@@ -401,8 +403,8 @@ class Tempo {
[4, ["number", { value: 4 }], 0, 0, [2]],
[5, ["vspace", {}], 0, 0, [0, null]]
];
- logo.blocks.loadNewBlocks(newStack);
- logo.textMsg(_("New action block generated!"));
+ this.activity.blocks.loadNewBlocks(newStack);
+ this.activity.textMsg(_("New action block generated!"));
}, 200 * i);
}
diff --git a/js/widgets/timbre.js b/js/widgets/timbre.js
index af00740ca4..1c04309094 100644
--- a/js/widgets/timbre.js
+++ b/js/widgets/timbre.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-20 Walter Bender
+// Copyright (c) 2017-21 Walter Bender
// Copyright (c) 2017 Tayba Wasim
// Copyright (c) 2017 Prachi Agrawal
//
@@ -12,15 +12,16 @@
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
/*
- global logo, blocks, DEFAULTOSCILLATORTYPE, platformColor, rationalToFraction, last, saveLocally,
- Singer, instrumentsEffects, instrumentsFilters, _, docById, DEFAULTFILTERTYPE, docByName,
- OSCTYPES, FILTERTYPES, oneHundredToFraction
+ global
+
+ DEFAULTOSCILLATORTYPE, platformColor, rationalToFraction, last,
+ Singer, instrumentsEffects:writeable, instrumentsFilters:writeable,
+ _, docById, DEFAULTFILTERTYPE, docByName, OSCTYPES, FILTERTYPES,
+ oneHundredToFraction
*/
/*
Global locations
- js/activity.js
- logo, blocks, savelocally
js/utils/musicutils.js
DEFAULTOSCILLATORTYPE, DEFAULTFILTERTYPE, OSCTYPES, FILTERTYPES
js/utils/platformstyle.js
@@ -177,66 +178,78 @@ class TimbreWidget {
if (this.isActive["envelope"] === true && this.env[i] != null) {
for (let j = 0; j < 4; j++) {
- updateParams[j] = blocks.blockList[this.env[i]].connections[j + 1];
+ updateParams[j] = this.activity.blocks.blockList[this.env[i]].connections[j + 1];
}
}
if (this.isActive["filter"] === true && this.fil[i] != null) {
for (let j = 0; j < 3; j++) {
- updateParams[j] = blocks.blockList[this.fil[i]].connections[j + 1];
+ updateParams[j] = this.activity.blocks.blockList[this.fil[i]].connections[j + 1];
}
}
if (this.isActive["oscillator"] === true && this.osc[i] != null) {
for (let j = 0; j < 2; j++) {
- updateParams[j] = blocks.blockList[this.osc[i]].connections[j + 1];
+ updateParams[j] = this.activity.blocks.blockList[this.osc[i]].connections[j + 1];
}
}
if (this.isActive["amsynth"] === true && this.AMSynthesizer[i] != null) {
- updateParams[0] = blocks.blockList[this.AMSynthesizer[i]].connections[1];
+ updateParams[0] = this.activity.blocks.blockList[this.AMSynthesizer[i]].connections[1];
}
if (this.isActive["fmsynth"] === true && this.FMSynthesizer[i] != null) {
- updateParams[0] = blocks.blockList[this.FMSynthesizer[i]].connections[1];
+ updateParams[0] = this.activity.blocks.blockList[this.FMSynthesizer[i]].connections[1];
}
if (this.isActive["noisesynth"] === true && this.NoiseSynthesizer[i] != null) {
- updateParams[0] = blocks.blockList[this.NoiseSynthesizer[i]].connections[1];
+ updateParams[0] = this.activity.blocks.blockList[
+ this.NoiseSynthesizer[i]
+ ].connections[1];
}
if (this.isActive["duosynth"] === true && this.duoSynthesizer[i] != null) {
for (let j = 0; j < 2; j++) {
- updateParams[j] = blocks.blockList[this.duoSynthesizer[i]].connections[j + 1];
+ updateParams[j] = this.activity.blocks.blockList[
+ this.duoSynthesizer[i]
+ ].connections[j + 1];
}
}
if (this.isActive["tremolo"] === true && this.tremoloEffect[i] != null) {
for (let j = 0; j < 2; j++) {
- updateParams[j] = blocks.blockList[this.tremoloEffect[i]].connections[j + 1];
+ updateParams[j] = this.activity.blocks.blockList[this.tremoloEffect[i]].connections[
+ j + 1
+ ];
}
}
if (this.isActive["vibrato"] === true && this.vibratoEffect[i] != null) {
- updateParams[0] = blocks.blockList[this.vibratoEffect[i]].connections[1];
+ updateParams[0] = this.activity.blocks.blockList[this.vibratoEffect[i]].connections[1];
// The rate arg of the vibrato block must be in the form: a / b
- const divBlock = blocks.blockList[this.vibratoEffect[i]].connections[2];
+ const divBlock = this.activity.blocks.blockList[this.vibratoEffect[i]].connections[2];
if (
- blocks.blockList[divBlock].name === "divide" &&
- blocks.blockList[divBlock].connections[1] != null &&
- blocks.blockList[blocks.blockList[divBlock].connections[1]].name === "number" &&
- blocks.blockList[divBlock].connections[2] != null &&
- blocks.blockList[blocks.blockList[divBlock].connections[2]].name === "number"
+ this.activity.blocks.blockList[divBlock].name === "divide" &&
+ this.activity.blocks.blockList[divBlock].connections[1] != null &&
+ this.activity.blocks.blockList[
+ this.activity.blocks.blockList[divBlock].connections[1]
+ ].name === "number" &&
+ this.activity.blocks.blockList[divBlock].connections[2] != null &&
+ this.activity.blocks.blockList[
+ this.activity.blocks.blockList[divBlock].connections[2]
+ ].name === "number"
) {
- const numBlock = blocks.blockList[divBlock].connections[1];
- const denomBlock = blocks.blockList[divBlock].connections[2];
+ const numBlock = this.activity.blocks.blockList[divBlock].connections[1];
+ const denomBlock = this.activity.blocks.blockList[divBlock].connections[2];
updateParams[1] = denomBlock;
updateParams[2] = numBlock;
} else {
// Convert to a / b format
- const obj = rationalToFraction(logo.parseArg(logo, 0, divBlock, null, null));
- const n = blocks.blockList.length;
- blocks.loadNewBlocks([
+ const obj = rationalToFraction(
+ this.activity.logo.parseArg(this.activity.logo, 0, divBlock, null, null)
+ );
+ const n = this.activity.blocks.blockList.length;
+ this.activity.blocks.loadNewBlocks([
[0, ["divide", {}], 0, 0, [null, 1, 2]],
[1, ["number", { value: obj[0] }], 0, 0, [0]],
[2, ["number", { value: obj[1] }], 0, 0, [0]]
@@ -246,12 +259,12 @@ class TimbreWidget {
updateParams[2] = n + 1; // Numerator block
const __blockRefresher = () => {
- blocks.blockList[last(this.vibratoEffect)].connections[2] = n;
- blocks.blockList[n].connections[0] = last(this.vibratoEffect);
- blocks.blockList[divBlock].connections[0] = null;
- blocks.clampBlocksToCheck.push([n, 0]);
- blocks.clampBlocksToCheck.push([this.blockNo, 0]);
- blocks.adjustDocks(this.blockNo, true);
+ this.activity.blocks.blockList[last(this.vibratoEffect)].connections[2] = n;
+ this.activity.blocks.blockList[n].connections[0] = last(this.vibratoEffect);
+ this.activity.blocks.blockList[divBlock].connections[0] = null;
+ this.activity.blocks.clampBlocksToCheck.push([n, 0]);
+ this.activity.blocks.clampBlocksToCheck.push([this.blockNo, 0]);
+ this.activity.blocks.adjustDocks(this.blockNo, true);
};
setTimeout(__blockRefresher(), 250);
@@ -260,31 +273,37 @@ class TimbreWidget {
if (this.isActive["chorus"] === true && this.chorusEffect[i] != null) {
for (let j = 0; j < 3; j++) {
- updateParams[j] = blocks.blockList[this.chorusEffect[i]].connections[j + 1];
+ updateParams[j] = this.activity.blocks.blockList[this.chorusEffect[i]].connections[
+ j + 1
+ ];
}
}
if (this.isActive["phaser"] === true && this.phaserEffect[i] != null) {
for (let j = 0; j < 3; j++) {
- updateParams[j] = blocks.blockList[this.phaserEffect[i]].connections[j + 1];
+ updateParams[j] = this.activity.blocks.blockList[this.phaserEffect[i]].connections[
+ j + 1
+ ];
}
}
if (this.isActive["distortion"] === true && this.distortionEffect[i] != null) {
- updateParams[0] = blocks.blockList[this.distortionEffect[i]].connections[1];
+ updateParams[0] = this.activity.blocks.blockList[
+ this.distortionEffect[i]
+ ].connections[1];
}
if (updateParams[0] != null) {
if (typeof value === "string") {
- blocks.blockList[updateParams[k]].value = value;
+ this.activity.blocks.blockList[updateParams[k]].value = value;
} else {
- blocks.blockList[updateParams[k]].value = parseFloat(value);
+ this.activity.blocks.blockList[updateParams[k]].value = parseFloat(value);
}
- blocks.blockList[updateParams[k]].text.text = value.toString();
- blocks.blockList[updateParams[k]].updateCache();
- logo.refreshCanvas();
- saveLocally();
+ this.activity.blocks.blockList[updateParams[k]].text.text = value.toString();
+ this.activity.blocks.blockList[updateParams[k]].updateCache();
+ this.activity.refreshCanvas();
+ this.activity.saveLocally();
}
}
@@ -295,7 +314,7 @@ class TimbreWidget {
* @returns {void}
*/
_playNote(note, duration) {
- logo.synth.setMasterVolume(last(Singer.masterVolume));
+ this.activity.logo.synth.setMasterVolume(last(Singer.masterVolume));
const timbreEffects = instrumentsEffects[0][this.instrumentName];
const paramsEffects = {
@@ -349,7 +368,7 @@ class TimbreWidget {
}
if (this.instrumentName in instrumentsFilters[0]) {
- logo.synth.trigger(
+ this.activity.logo.synth.trigger(
0,
note,
Singer.defaultBPMFactor * duration,
@@ -358,7 +377,7 @@ class TimbreWidget {
instrumentsFilters[0][this.instrumentName]
);
} else {
- logo.synth.trigger(
+ this.activity.logo.synth.trigger(
0,
note,
Singer.defaultBPMFactor * duration,
@@ -376,7 +395,7 @@ class TimbreWidget {
_play() {
this._playing = !this._playing;
- logo.resetSynth(0);
+ this.activity.logo.resetSynth(0);
const cell = this.playButton;
if (this._playing) {
@@ -393,8 +412,8 @@ class TimbreWidget {
TimbreWidget.ICONSIZE +
'" vertical-align="middle" align-content="center"> ';
} else {
- logo.synth.setMasterVolume(0);
- logo.synth.stop();
+ this.activity.logo.synth.setMasterVolume(0);
+ this.activity.logo.synth.stop();
cell.innerHTML =
'
1) {
@@ -511,7 +535,12 @@ class TimbreWidget {
docById("myspanS0").textContent = this.FMSynthParams[0];
this.fmSynthParamvals["modulationIndex"] = parseFloat(this.FMSynthParams[0]);
this._update(blockValue, this.FMSynthParams[0], 0);
- logo.synth.createSynth(0, this.instrumentName, "fmsynth", this.fmSynthParamvals);
+ this.activity.logo.synth.createSynth(
+ 0,
+ this.instrumentName,
+ "fmsynth",
+ this.fmSynthParamvals
+ );
} else if (this.isActive["noisesynth"] === true) {
docById("synthButtonCell").style.backgroundColor = platformColor.selectorBackground;
if (this.NoiseSynthesizer.length > 1) {
@@ -522,7 +551,12 @@ class TimbreWidget {
docById("myspanS0").textContent = this.NoiseSynthParams[0];
this.noiseSynthParamvals["noise.type"] = this.NoiseSynthParams[0];
this._update(blockValue, this.NoiseSynthParams[0], 0);
- logo.synth.createSynth(0, this.instrumentName, "noisesynth", this.noiseSynthParamvals);
+ this.activity.logo.synth.createSynth(
+ 0,
+ this.instrumentName,
+ "noisesynth",
+ this.noiseSynthParamvals
+ );
} else if (this.isActive["duosynth"] === true) {
docById("synthButtonCell").style.backgroundColor = platformColor.selectorBackground;
if (this.duoSynthesizer.length > 1) {
@@ -537,7 +571,12 @@ class TimbreWidget {
docById("myspanS1").textContent = this.duoSynthParams[1];
this.duoSynthParamVals["vibratoAmount"] = parseFloat(this.duoSynthParams[1]);
this._update(blockValue, this.duoSynthParams[1], 1);
- logo.synth.createSynth(0, this.instrumentName, "duosynth", this.duoSynthParamVals);
+ this.activity.logo.synth.createSynth(
+ 0,
+ this.instrumentName,
+ "duosynth",
+ this.duoSynthParamVals
+ );
} else if (this.isActive["oscillator"]) {
docById("oscillatorButtonCell").style.backgroundColor =
platformColor.selectorBackground;
@@ -552,7 +591,12 @@ class TimbreWidget {
this._update(blockValue, "6", 1);
this.synthVals["oscillator"]["type"] = "sine6";
this.synthVals["oscillator"]["source"] = DEFAULTOSCILLATORTYPE;
- logo.synth.createSynth(0, this.instrumentName, this.oscParams[0], this.synthVals);
+ this.activity.logo.synth.createSynth(
+ 0,
+ this.instrumentName,
+ this.oscParams[0],
+ this.synthVals
+ );
} else if (this.isActive["filter"]) {
for (let i = 0; i < this.fil.length; i++) {
docById("filterButtonCell").style.backgroundColor =
@@ -661,7 +705,8 @@ class TimbreWidget {
* Initialises the timbre widget.
* @returns {void}
*/
- init() {
+ init(activity) {
+ this.activity = activity;
this._delta = 0;
this._playing = false;
@@ -680,7 +725,7 @@ class TimbreWidget {
widgetWindow.getWidgetBody().style.overflowY = "auto";
widgetWindow.onclose = () => {
- logo.hideMsgs();
+ this.activity.hideMsgs();
widgetWindow.destroy();
};
@@ -723,7 +768,7 @@ class TimbreWidget {
if (this.osc.length === 0) {
this._synth();
} else {
- logo.errorMsg(_("Unable to use synth due to existing oscillator"));
+ this.activity.errorMsg(_("Unable to use synth due to existing oscillator"));
}
};
@@ -744,17 +789,17 @@ class TimbreWidget {
this.isActive["oscillator"] = true;
if (this.osc.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo].connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
const OSCILLATOROBJ = [
[0, ["oscillator", {}], 0, 0, [null, 2, 1, null]],
[1, ["number", { value: 6 }], 0, 0, [0]],
[2, ["oscillatortype", { value: DEFAULTOSCILLATORTYPE }], 0, 0, [0]]
];
- blocks.loadNewBlocks(OSCILLATOROBJ);
+ this.activity.blocks.loadNewBlocks(OSCILLATOROBJ);
- const n = blocks.blockList.length - 3;
+ const n = this.activity.blocks.blockList.length - 3;
this.osc.push(n);
this.oscParams.push(DEFAULTOSCILLATORTYPE);
this.oscParams.push(6);
@@ -793,8 +838,8 @@ class TimbreWidget {
this.isActive["envelope"] = true;
if (this.env.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo].connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
const ENVOBJ = [
[0, ["envelope", {}], 0, 0, [null, 1, 2, 3, 4, null]],
@@ -803,9 +848,9 @@ class TimbreWidget {
[3, ["number", { value: 60 }], 0, 0, [0]],
[4, ["number", { value: 1 }], 0, 0, [0]]
];
- blocks.loadNewBlocks(ENVOBJ);
+ this.activity.blocks.loadNewBlocks(ENVOBJ);
- const n = blocks.blockList.length - 5;
+ const n = this.activity.blocks.blockList.length - 5;
this.env.push(n);
this.ENVs.push(1);
this.ENVs.push(50);
@@ -855,8 +900,8 @@ class TimbreWidget {
this.isActive["filter"] = true;
if (this.fil.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo].connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
const FILTEROBJ = [
[0, ["filter", {}], 0, 0, [null, 3, 1, 2, null]],
@@ -864,9 +909,9 @@ class TimbreWidget {
[2, ["number", { value: 392 }], 0, 0, [0]],
[3, ["filtertype", { value: DEFAULTFILTERTYPE }], 0, 0, [0]]
];
- blocks.loadNewBlocks(FILTEROBJ);
+ this.activity.blocks.loadNewBlocks(FILTEROBJ);
- const n = blocks.blockList.length - 4;
+ const n = this.activity.blocks.blockList.length - 4;
this.fil.push(n);
this.filterParams.push(DEFAULTFILTERTYPE);
this.filterParams.push(-12);
@@ -910,7 +955,7 @@ class TimbreWidget {
// docById('timbreButtonsDiv').style.visibility = 'hidden';
// docById('this.timbreTableDiv').style.visibility = 'hidden';
// docById('timbreName').classList.remove('hasKeyboard');
- // logo.hideMsgs();
+ // this.activity.logo.hideMsgs();
// };
_unhighlightButtons = () => {
@@ -922,7 +967,7 @@ class TimbreWidget {
filterButtonCell.style.backgroundColor = platformColor.selectorBackground;
};
- logo.textMsg(_("Click on buttons to open the timbre design tools."));
+ this.activity.textMsg(_("Click on buttons to open the timbre design tools."));
widgetWindow.sendToCenter();
}
@@ -935,19 +980,19 @@ class TimbreWidget {
*/
clampConnection(n, clamp, topOfClamp) {
// Connect the clamp to the Widget block.
- blocks.blockList[this.blockNo].connections[2] = n;
- blocks.blockList[n].connections[0] = this.blockNo;
+ this.activity.blocks.blockList[this.blockNo].connections[2] = n;
+ this.activity.blocks.blockList[n].connections[0] = this.blockNo;
// If there were blocks in the Widget, move them inside the clamp.
if (topOfClamp != null) {
- blocks.blockList[n].connections[clamp] = topOfClamp;
- blocks.blockList[topOfClamp].connections[0] = n;
+ this.activity.blocks.blockList[n].connections[clamp] = topOfClamp;
+ this.activity.blocks.blockList[topOfClamp].connections[0] = n;
}
// Adjust the clamp sizes and positions.
- blocks.clampBlocksToCheck.push([n, 0]);
- blocks.clampBlocksToCheck.push([this.blockNo, 0]);
- blocks.adjustDocks(this.blockNo, true);
+ this.activity.blocks.clampBlocksToCheck.push([n, 0]);
+ this.activity.blocks.clampBlocksToCheck.push([this.blockNo, 0]);
+ this.activity.blocks.adjustDocks(this.blockNo, true);
}
/**
@@ -960,19 +1005,19 @@ class TimbreWidget {
*/
clampConnectionVspace(n, vspace, topOfClamp) {
// Connect the clamp to the Widget block.
- blocks.blockList[this.blockNo].connections[2] = n;
- blocks.blockList[n].connections[0] = this.blockNo;
+ this.activity.blocks.blockList[this.blockNo].connections[2] = n;
+ this.activity.blocks.blockList[n].connections[0] = this.blockNo;
// If there were blocks in the Widget, move them inside the clamp.
if (topOfClamp != null) {
- blocks.blockList[vspace].connections[1] = topOfClamp;
- blocks.blockList[topOfClamp].connections[0] = vspace;
+ this.activity.blocks.blockList[vspace].connections[1] = topOfClamp;
+ this.activity.blocks.blockList[topOfClamp].connections[0] = vspace;
}
// Adjust the clamp sizes and positions.
- blocks.clampBlocksToCheck.push([n, 0]);
- blocks.clampBlocksToCheck.push([this.blockNo, 0]);
- blocks.adjustDocks(this.blockNo, true);
+ this.activity.blocks.clampBlocksToCheck.push([n, 0]);
+ this.activity.blocks.clampBlocksToCheck.push([this.blockNo, 0]);
+ this.activity.blocks.adjustDocks(this.blockNo, true);
}
/**
@@ -1010,17 +1055,19 @@ class TimbreWidget {
*/
_blockReplace(oldblk, newblk) {
// Find the connections from the old block
- const c0 = blocks.blockList[oldblk].connections[0];
- const c1 = last(blocks.blockList[oldblk].connections);
+ const c0 = this.activity.blocks.blockList[oldblk].connections[0];
+ const c1 = last(this.activity.blocks.blockList[oldblk].connections);
// Connect the new block
- blocks.blockList[newblk].connections[0] = c0;
- blocks.blockList[newblk].connections[blocks.blockList[newblk].connections.length - 1] = c1;
+ this.activity.blocks.blockList[newblk].connections[0] = c0;
+ this.activity.blocks.blockList[newblk].connections[
+ this.activity.blocks.blockList[newblk].connections.length - 1
+ ] = c1;
if (c0 != null) {
- for (let i = 0; i < blocks.blockList[c0].connections.length; i++) {
- if (blocks.blockList[c0].connections[i] === oldblk) {
- blocks.blockList[c0].connections[i] = newblk;
+ for (let i = 0; i < this.activity.blocks.blockList[c0].connections.length; i++) {
+ if (this.activity.blocks.blockList[c0].connections[i] === oldblk) {
+ this.activity.blocks.blockList[c0].connections[i] = newblk;
break;
}
}
@@ -1028,36 +1075,36 @@ class TimbreWidget {
// Look for a containing clamp, which may need to be resized.
let blockAbove = c0;
while (blockAbove != this.blockNo) {
- if (blocks.blockList[blockAbove].isClampBlock()) {
- blocks.clampBlocksToCheck.push([blockAbove, 0]);
+ if (this.activity.blocks.blockList[blockAbove].isClampBlock()) {
+ this.activity.blocks.clampBlocksToCheck.push([blockAbove, 0]);
}
- blockAbove = blocks.blockList[blockAbove].connections[0];
+ blockAbove = this.activity.blocks.blockList[blockAbove].connections[0];
}
- blocks.clampBlocksToCheck.push([this.blockNo, 0]);
+ this.activity.blocks.clampBlocksToCheck.push([this.blockNo, 0]);
}
if (c1 != null) {
- for (let i = 0; i < blocks.blockList[c1].connections.length; i++) {
- if (blocks.blockList[c1].connections[i] === oldblk) {
- blocks.blockList[c1].connections[i] = newblk;
+ for (let i = 0; i < this.activity.blocks.blockList[c1].connections.length; i++) {
+ if (this.activity.blocks.blockList[c1].connections[i] === oldblk) {
+ this.activity.blocks.blockList[c1].connections[i] = newblk;
break;
}
}
}
// Refresh the dock positions
- blocks.adjustDocks(c0, true);
+ this.activity.blocks.adjustDocks(c0, true);
// Send the old block to the trash
- blocks.blockList[oldblk].connections[0] = null;
- blocks.blockList[oldblk].connections[
- blocks.blockList[oldblk].connections.length - 1
+ this.activity.blocks.blockList[oldblk].connections[0] = null;
+ this.activity.blocks.blockList[oldblk].connections[
+ this.activity.blocks.blockList[oldblk].connections.length - 1
] = null;
- blocks.sendStackToTrash(blocks.blockList[oldblk]);
+ this.activity.blocks.sendStackToTrash(this.activity.blocks.blockList[oldblk]);
- logo.refreshCanvas();
+ this.activity.refreshCanvas();
}
/**
@@ -1068,37 +1115,41 @@ class TimbreWidget {
* @returns {void}
*/
blockConnection(len, bottomOfClamp) {
- const n = blocks.blockList.length - len;
+ const n = this.activity.blocks.blockList.length - len;
if (bottomOfClamp == null) {
- blocks.blockList[this.blockNo].connections[2] = n;
- blocks.blockList[n].connections[0] = this.blockNo;
+ this.activity.blocks.blockList[this.blockNo].connections[2] = n;
+ this.activity.blocks.blockList[n].connections[0] = this.blockNo;
} else {
- let c = blocks.blockList[bottomOfClamp].connections.length - 1;
+ let c = this.activity.blocks.blockList[bottomOfClamp].connections.length - 1;
// Check for nested clamps.
// A hidden block is attached to the bottom of each clamp.
// But don't go inside a note block.
while (
- blocks.blockList[bottomOfClamp].name === "hidden" &&
- blocks.blockList[blocks.blockList[bottomOfClamp].connections[0]].name !== "newnote"
+ this.activity.blocks.blockList[bottomOfClamp].name === "hidden" &&
+ this.activity.blocks.blockList[
+ this.activity.blocks.blockList[bottomOfClamp].connections[0]
+ ].name !== "newnote"
) {
- const cblk = blocks.blockList[bottomOfClamp].connections[0];
- c = blocks.blockList[cblk].connections.length - 2;
- blocks.clampBlocksToCheck.push([cblk, 0]);
- if (blocks.blockList[cblk].connections[c] == null) {
+ const cblk = this.activity.blocks.blockList[bottomOfClamp].connections[0];
+ c = this.activity.blocks.blockList[cblk].connections.length - 2;
+ this.activity.blocks.clampBlocksToCheck.push([cblk, 0]);
+ if (this.activity.blocks.blockList[cblk].connections[c] == null) {
bottomOfClamp = cblk;
} else {
// Find bottom of stack
- bottomOfClamp = blocks.findBottomBlock(blocks.blockList[cblk].connections[c]);
- c = blocks.blockList[bottomOfClamp].connections.length - 1;
+ bottomOfClamp = this.activity.blocks.findBottomBlock(
+ this.activity.blocks.blockList[cblk].connections[c]
+ );
+ c = this.activity.blocks.blockList[bottomOfClamp].connections.length - 1;
}
}
- blocks.blockList[bottomOfClamp].connections[c] = n;
- blocks.blockList[n].connections[0] = bottomOfClamp;
+ this.activity.blocks.blockList[bottomOfClamp].connections[c] = n;
+ this.activity.blocks.blockList[n].connections[0] = bottomOfClamp;
}
- blocks.clampBlocksToCheck.push([this.blockNo, 0]);
- blocks.adjustDocks(this.blockNo, true);
+ this.activity.blocks.clampBlocksToCheck.push([this.blockNo, 0]);
+ this.activity.blocks.adjustDocks(this.blockNo, true);
}
/**
@@ -1164,22 +1215,23 @@ class TimbreWidget {
this.isActive["duosynth"] = false;
if (this.AMSynthesizer.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
const AMSYNTHOBJ = [
[0, ["amsynth", {}], 0, 0, [null, 1, null]],
[1, ["number", { value: 1 }], 0, 0, [0]]
];
- blocks.loadNewBlocks(AMSYNTHOBJ);
+ this.activity.blocks.loadNewBlocks(AMSYNTHOBJ);
- const n = blocks.blockList.length - 2;
+ const n = this.activity.blocks.blockList.length - 2;
this.AMSynthesizer.push(n);
this.AMSynthParams.push(1);
this._changeBlock(last(this.AMSynthesizer), synthChosen, bottomOfClamp);
this.amSynthParamvals["harmonicity"] = parseFloat(this.AMSynthParams[0]);
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"amsynth",
@@ -1213,7 +1265,7 @@ class TimbreWidget {
this.amSynthParamvals["harmonicity"] = parseFloat(elem.value);
docById("myspanS0").textContent = elem.value;
this._update(blockValue, elem.value, 0);
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"amsynth",
@@ -1227,16 +1279,17 @@ class TimbreWidget {
this.isActive["duosynth"] = false;
if (this.FMSynthesizer.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
const FMSYNTHOBJ = [
[0, ["fmsynth", {}], 0, 0, [null, 1, null]],
[1, ["number", { value: 10 }], 0, 0, [0]]
];
- blocks.loadNewBlocks(FMSYNTHOBJ);
+ this.activity.blocks.loadNewBlocks(FMSYNTHOBJ);
- const n = blocks.blockList.length - 2;
+ const n = this.activity.blocks.blockList.length - 2;
this.FMSynthesizer.push(n);
this.FMSynthParams.push(10);
@@ -1244,7 +1297,7 @@ class TimbreWidget {
this.fmSynthParamvals["modulationIndex"] = parseFloat(
this.FMSynthParams[0]
);
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"fmsynth",
@@ -1278,7 +1331,7 @@ class TimbreWidget {
docById("myspanS0").textContent = elem.value;
this.fmSynthParamvals["modulationIndex"] = parseFloat(elem.value);
this._update(blockValue, elem.value, 0);
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"fmsynth",
@@ -1293,22 +1346,23 @@ class TimbreWidget {
this.isActive["duosynth"] = false;
if (this.NoiseSynthesizer.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
const NOISESYNTHOBJ = [
[0, ["noisesynth", {}], 0, 0, [null, 1, null]],
[1, ["number", { value: 10 }], 0, 0, [0]]
];
- blocks.loadNewBlocks(NOISESYNTHOBJ);
+ this.activity.blocks.loadNewBlocks(NOISESYNTHOBJ);
- const n = blocks.blockList.length - 2;
+ const n = this.activity.blocks.blockList.length - 2;
this.NoiseSynthesizer.push(n);
this.NoiseSynthParams.push("white");
this._changeBlock(last(this.NoiseSynthesizer), synthChosen, bottomOfClamp);
this.noiseSynthParamvals["noise.type"] = this.NoiseSynthParams[0];
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"noisesynth",
@@ -1342,7 +1396,7 @@ class TimbreWidget {
docById("myspanS0").textContent = elem.value;
this.noiseSynthParamvals["noise.type"] = parseFloat(elem.value);
this._update(blockValue, elem.value, 0);
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"noisesynth",
@@ -1356,17 +1410,18 @@ class TimbreWidget {
this.isActive["duosynth"] = true;
if (this.duoSynthesizer.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
const DUOSYNTHOBJ = [
[0, ["duosynth", {}], 0, 0, [null, 1, 2, null]],
[1, ["number", { value: 10 }], 0, 0, [0]],
[2, ["number", { value: 6 }], 0, 0, [0]]
];
- blocks.loadNewBlocks(DUOSYNTHOBJ);
+ this.activity.blocks.loadNewBlocks(DUOSYNTHOBJ);
- const n = blocks.blockList.length - 3;
+ const n = this.activity.blocks.blockList.length - 3;
this.duoSynthesizer.push(n);
this.duoSynthParams.push(10);
this.duoSynthParams.push(6);
@@ -1376,7 +1431,7 @@ class TimbreWidget {
this.duoSynthParamVals["vibratoAmount"] = parseFloat(
this.duoSynthParams[1]
);
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"duosynth",
@@ -1427,7 +1482,7 @@ class TimbreWidget {
docById("myspanS" + m).textContent = elem.value;
this._update(blockValue, elem.value, Number(m));
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
"duosynth",
@@ -1531,7 +1586,12 @@ class TimbreWidget {
this.synthVals["oscillator"]["type"] = elem.value + this.oscParams[1].toString();
this.synthVals["oscillator"]["source"] = elem.value;
this._update(blockValue, elem.value, 0);
- logo.synth.createSynth(0, this.instrumentName, this.oscParams[0], this.synthVals);
+ this.activity.logo.synth.createSynth(
+ 0,
+ this.instrumentName,
+ this.oscParams[0],
+ this.synthVals
+ );
this._playNote("G4", 1 / 8);
});
@@ -1543,7 +1603,12 @@ class TimbreWidget {
docById("myRangeO0").value = parseFloat(elem.value);
docById("myspanO0").textContent = elem.value;
this._update(blockValue, elem.value, 1);
- logo.synth.createSynth(0, this.instrumentName, this.oscParams[0], this.synthVals);
+ this.activity.logo.synth.createSynth(
+ 0,
+ this.instrumentName,
+ this.oscParams[0],
+ this.synthVals
+ );
this._playNote("G4", 1 / 8);
});
@@ -1554,7 +1619,12 @@ class TimbreWidget {
this.synthVals["oscillator"]["source"] = this.oscParams[0];
if (newOscillator) {
- logo.synth.createSynth(0, this.instrumentName, this.oscParams[0], this.synthVals);
+ this.activity.logo.synth.createSynth(
+ 0,
+ this.instrumentName,
+ this.oscParams[0],
+ this.synthVals
+ );
}
}
@@ -1625,7 +1695,7 @@ class TimbreWidget {
docById("myspan" + m).textContent = elem.value;
this.synthVals["envelope"][this.adsrMap[m]] = parseFloat(elem.value) / 100;
this._update(blockValue, parseFloat(elem.value), m);
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
this.synthVals["oscillator"]["source"],
@@ -1636,7 +1706,7 @@ class TimbreWidget {
}
if (newEnvelope) {
- logo.synth.createSynth(
+ this.activity.logo.synth.createSynth(
0,
this.instrumentName,
this.synthVals["oscillator"]["source"],
@@ -1819,7 +1889,7 @@ class TimbreWidget {
(el) => el.filterType === elem.value
);
if (error.length > 1) {
- logo.errorMsg(_("Filter already present."));
+ this.activity.errorMsg(_("Filter already present."));
}
this._playNote("G4", 1 / 8);
};
@@ -1909,11 +1979,11 @@ class TimbreWidget {
*/
_addFilter() {
const env = docById("timbreTable");
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
- const bottomOfClamp = blocks.findBottomBlock(topOfClamp);
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo].connections[2];
+ const bottomOfClamp = this.activity.blocks.findBottomBlock(topOfClamp);
// The block we'll be adding will be at the end of the list.
- this.fil.push(blocks.blockList.length);
+ this.fil.push(this.activity.blocks.blockList.length);
const selectedFilters = instrumentsFilters[0][this.instrumentName].slice();
const filterType = FILTERTYPES.slice().filter((filter) => {
@@ -1936,7 +2006,7 @@ class TimbreWidget {
// Don't create the new blocks until we know what filter to use.
const len = this.filterParams.length;
- blocks.loadNewBlocks([
+ this.activity.blocks.loadNewBlocks([
[0, ["filter", {}], 0, 0, [null, 3, 1, 2, null]],
[1, ["number", { value: this.filterParams[len - 2] }], 0, 0, [0]],
[2, ["number", { value: this.filterParams[len - 1] }], 0, 0, [0]],
@@ -2052,16 +2122,17 @@ class TimbreWidget {
if (this.tremoloEffect.length === 0) {
// This is the first block in the child stack
// of the Timbre clamp.
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
- const n = blocks.blockList.length;
+ const n = this.activity.blocks.blockList.length;
const TREMOLOOBJ = [
[0, ["tremolo", {}], 0, 0, [null, 1, 2, null, 3]],
[1, ["number", { value: 10 }], 0, 0, [0]],
[2, ["number", { value: 50 }], 0, 0, [0]],
[3, "hidden", 0, 0, [0, null]]
];
- blocks.loadNewBlocks(TREMOLOOBJ);
+ this.activity.blocks.loadNewBlocks(TREMOLOOBJ);
this.tremoloEffect.push(n);
this.tremoloParams.push(10);
@@ -2130,9 +2201,10 @@ class TimbreWidget {
docById("myspanFx1").textContent = obj[0] + "/" + obj[1]; // this.vibratoParams[1];
} else {
// If necessary, add a vibrato block.
- const topOfTimbreClamp = blocks.blockList[this.blockNo].connections[2];
+ const topOfTimbreClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
- const vibratoBlock = blocks.blockList.length;
+ const vibratoBlock = this.activity.blocks.blockList.length;
const VIBRATOOBJ = [
[0, ["vibrato", {}], 0, 0, [null, 1, 3, 2, 6]],
[1, ["number", { value: 5 }], 0, 0, [0]],
@@ -2142,7 +2214,7 @@ class TimbreWidget {
[5, ["number", { value: 16 }], 0, 0, [3]],
[6, ["hidden", {}], 0, 0, [0, null]]
];
- blocks.loadNewBlocks(VIBRATOOBJ);
+ this.activity.blocks.loadNewBlocks(VIBRATOOBJ);
this.vibratoEffect.push(vibratoBlock);
this.vibratoParams.push(5);
@@ -2235,9 +2307,10 @@ class TimbreWidget {
}
if (this.chorusEffect.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
- const n = blocks.blockList.length;
+ const n = this.activity.blocks.blockList.length;
const CHORUSOBJ = [
[0, ["chorus", {}], 0, 0, [null, 1, 2, 3, null, 4]],
[1, ["number", { value: 2 }], 0, 0, [0]],
@@ -2245,7 +2318,7 @@ class TimbreWidget {
[3, ["number", { value: 70 }], 0, 0, [0]],
[4, "hidden", 0, 0, [0, null]]
];
- blocks.loadNewBlocks(CHORUSOBJ);
+ this.activity.blocks.loadNewBlocks(CHORUSOBJ);
this.chorusEffect.push(n);
this.chorusParams.push(2);
@@ -2329,9 +2402,10 @@ class TimbreWidget {
}
if (this.phaserEffect.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
- const n = blocks.blockList.length;
+ const n = this.activity.blocks.blockList.length;
const PHASEROBJ = [
[0, ["phaser", {}], 0, 0, [null, 1, 2, 3, null, 4]],
[1, ["number", { value: 5 }], 0, 0, [0]],
@@ -2339,7 +2413,7 @@ class TimbreWidget {
[3, ["number", { value: 350 }], 0, 0, [0]],
[4, "hidden", 0, 0, [0, null]]
];
- blocks.loadNewBlocks(PHASEROBJ);
+ this.activity.blocks.loadNewBlocks(PHASEROBJ);
this.phaserEffect.push(n);
this.phaserParams.push(5);
@@ -2407,15 +2481,16 @@ class TimbreWidget {
}
if (this.distortionEffect.length === 0) {
- const topOfClamp = blocks.blockList[this.blockNo].connections[2];
+ const topOfClamp = this.activity.blocks.blockList[this.blockNo]
+ .connections[2];
- const n = blocks.blockList.length;
+ const n = this.activity.blocks.blockList.length;
const DISTORTIONOBJ = [
[0, ["dis", {}], 0, 0, [null, 1, null, 2]],
[1, ["number", { value: 40 }], 0, 0, [0]],
[2, "hidden", 0, 0, [0, null]]
];
- blocks.loadNewBlocks(DISTORTIONOBJ);
+ this.activity.blocks.loadNewBlocks(DISTORTIONOBJ);
this.distortionEffect.push(n);
this.distortionParams.push(40);
diff --git a/js/widgets/widgetWindows.js b/js/widgets/widgetWindows.js
index 6cce4c4e4f..f39e672b0f 100644
--- a/js/widgets/widgetWindows.js
+++ b/js/widgets/widgetWindows.js
@@ -9,12 +9,12 @@
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
-/*global _, docById*/
+/* global _, docById */
/*
Globals location
- js/utils/utils.js
-_, docById
+ _, docById
*/
window.widgetWindows = { openWindows: {}, _posCache: {} };
@@ -91,7 +91,7 @@ class WidgetWindow {
// not a relative in either direciton.
if (this._fullscreenEnabled) {
- this._drag.ondblclick = () => {
+ this._drag.ondblclick = (e) => {
this._maximize();
this.takeFocus();
this.onmaximize();
diff --git a/plugins/README.md b/plugins/README.md
old mode 100755
new mode 100644
diff --git a/plugins/accelerometer.json b/plugins/accelerometer.json
old mode 100755
new mode 100644
index 62b3b4a8b4..fb24a43f0d
--- a/plugins/accelerometer.json
+++ b/plugins/accelerometer.json
@@ -1,13 +1,13 @@
{
- "BLOCKPLUGINS": {
- "accelerometerz": "var accelerometerZBlk = new ProtoBlock('accelerometerz');accelerometerZBlk.palette = palettes.dict['sensors'];blocks.protoBlockDict['accelerometerz'] = accelerometerZBlk;accelerometerZBlk.staticLabels.push(_('motion z'));accelerometerZBlk.adjustWidthToLabel();accelerometerZBlk.parameterBlock();",
- "accelerometery": "var accelerometerYBlk = new ProtoBlock('accelerometery');accelerometerYBlk.palette = palettes.dict['sensors'];blocks.protoBlockDict['accelerometery'] = accelerometerYBlk;accelerometerYBlk.staticLabels.push(_('motion y'));accelerometerYBlk.adjustWidthToLabel();accelerometerYBlk.parameterBlock();",
- "accelerometerx": "var accelerometerXBlk = new ProtoBlock('accelerometerx');accelerometerXBlk.palette = palettes.dict['sensors'];blocks.protoBlockDict['accelerometerx'] = accelerometerXBlk;accelerometerXBlk.staticLabels.push(_('motion x'));accelerometerXBlk.adjustWidthToLabel();accelerometerXBlk.parameterBlock();"
- },
- "GLOBALS": "accelerometer = {'x': null, 'y': null, 'z': null};function saveAccelerometerData(event) { accelerometer['x'] = event.accelerationIncludingGravity.x; accelerometer['y'] = event.accelerationIncludingGravity.y; accelerometer['z'] = event.accelerationIncludingGravity.z;};if (window.DeviceMotionEvent) { window.addEventListener(\"devicemotion\", saveAccelerometerData, false);}else{ console.log(\"DeviceMotionEvent is not supported (no accelerometer)\");}",
+ "GLOBALS": "globalActivity.logo.pluginVars['accelerometer'] = {'x': null, 'y': null, 'z': null};const saveAccelerometerData = function (event) { globalActivity.logo.pluginVars['accelerometer']['x'] = event.accelerationIncludingGravity.x; globalActivity.logo.pluginVars['accelerometer']['y'] = event.accelerationIncludingGravity.y; globalActivity.logo.pluginVars['accelerometer']['z'] = event.accelerationIncludingGravity.z;};if (window.DeviceMotionEvent) { window.addEventListener('devicemotion', saveAccelerometerData, false);}else { globalActivity.errorMsg('DeviceMotionEvent is not supported (no accelerometer)');}",
"ARGPLUGINS": {
- "accelerometerz": "var block = logo.blocks.blockList[blk];block.value = accelerometer['z'];",
- "accelerometery": "var block = logo.blocks.blockList[blk];block.value = accelerometer['y'];",
- "accelerometerx": "var block = logo.blocks.blockList[blk];block.value = accelerometer['x'];"
+ "accelerometerx": "const accelBlock = globalActivity.blocks.blockList[blk];accelBlock.value = globalActivity.logo.pluginVars['accelerometer']['x'];",
+ "accelerometery": "const accelBlock = globalActivity.blocks.blockList[blk];accelBlock.value = globalActivity.logo.pluginVars['accelerometer']['y'];",
+ "accelerometerz": "const accelBlock = globalActivity.blocks.blockList[blk];accelBlock.value = globalActivity.logo.pluginVars['accelerometer']['z'];"
+ },
+ "BLOCKPLUGINS": {
+ "accelerometerx": "const accelerometerXBlk = new ProtoBlock('accelerometerx');accelerometerXBlk.palette = globalActivity.palettes.dict['sensors'];globalActivity.blocks.protoBlockDict['accelerometerx'] = accelerometerXBlk;accelerometerXBlk.staticLabels.push(_('motion x'));accelerometerXBlk.adjustWidthToLabel();accelerometerXBlk.parameterBlock();",
+ "accelerometery": "const accelerometerYBlk = new ProtoBlock('accelerometery');accelerometerYBlk.palette = globalActivity.palettes.dict['sensors'];globalActivity.blocks.protoBlockDict['accelerometery'] = accelerometerYBlk;accelerometerYBlk.staticLabels.push(_('motion y'));accelerometerYBlk.adjustWidthToLabel();accelerometerYBlk.parameterBlock();",
+ "accelerometerz": "const accelerometerZBlk = new ProtoBlock('accelerometerz');accelerometerZBlk.palette = globalActivity.palettes.dict['sensors'];globalActivity.blocks.protoBlockDict['accelerometerz'] = accelerometerZBlk;accelerometerZBlk.staticLabels.push(_('motion z'));accelerometerZBlk.adjustWidthToLabel();accelerometerZBlk.parameterBlock();"
}
-}
+}
\ No newline at end of file
diff --git a/plugins/accelerometer.rtp b/plugins/accelerometer.rtp
old mode 100755
new mode 100644
index 3662a0e712..7da52d137c
--- a/plugins/accelerometer.rtp
+++ b/plugins/accelerometer.rtp
@@ -16,51 +16,51 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
.
//* globals *//
-var accelerometer = {'x': null, 'y': null, 'z': null};
-function saveAccelerometerData(event) {
- accelerometer['x'] = event.accelerationIncludingGravity.x;
- accelerometer['y'] = event.accelerationIncludingGravity.y;
- accelerometer['z'] = event.accelerationIncludingGravity.z;
+globalActivity.logo.pluginVars['accelerometer'] = {'x': null, 'y': null, 'z': null};
+const saveAccelerometerData = function (event) {
+ globalActivity.logo.pluginVars['accelerometer']['x'] = event.accelerationIncludingGravity.x;
+ globalActivity.logo.pluginVars['accelerometer']['y'] = event.accelerationIncludingGravity.y;
+ globalActivity.logo.pluginVars['accelerometer']['z'] = event.accelerationIncludingGravity.z;
};
if (window.DeviceMotionEvent) {
- window.addEventListener("devicemotion", saveAccelerometerData, false);
+ window.addEventListener('devicemotion', saveAccelerometerData, false);
}
-else{
- console.log("DeviceMotionEvent is not supported (no accelerometer)");
+else {
+ globalActivity.errorMsg('DeviceMotionEvent is not supported (no accelerometer)');
}
+//* arg-globals *//
+const accelBlock = globalActivity.blocks.blockList[blk];
+
//* arg:accelerometerx *//
-var block = logo.blocks.blockList[blk];
-block.value = accelerometer['x'];
+accelBlock.value = globalActivity.logo.pluginVars['accelerometer']['x'];
//* arg:accelerometery *//
-var block = logo.blocks.blockList[blk];
-block.value = accelerometer['y'];
+accelBlock.value = globalActivity.logo.pluginVars['accelerometer']['y'];
//* arg:accelerometerz *//
-var block = logo.blocks.blockList[blk];
-block.value = accelerometer['z'];
+accelBlock.value = globalActivity.logo.pluginVars['accelerometer']['z'];
//* block:accelerometerx *//
-var accelerometerXBlk = new ProtoBlock('accelerometerx');
-accelerometerXBlk.palette = palettes.dict['sensors'];
-blocks.protoBlockDict['accelerometerx'] = accelerometerXBlk;
+const accelerometerXBlk = new ProtoBlock('accelerometerx');
+accelerometerXBlk.palette = globalActivity.palettes.dict['sensors'];
+globalActivity.blocks.protoBlockDict['accelerometerx'] = accelerometerXBlk;
accelerometerXBlk.staticLabels.push(_('motion x'));
accelerometerXBlk.adjustWidthToLabel();
accelerometerXBlk.parameterBlock();
//* block:accelerometery *//
-var accelerometerYBlk = new ProtoBlock('accelerometery');
-accelerometerYBlk.palette = palettes.dict['sensors'];
-blocks.protoBlockDict['accelerometery'] = accelerometerYBlk;
+const accelerometerYBlk = new ProtoBlock('accelerometery');
+accelerometerYBlk.palette = globalActivity.palettes.dict['sensors'];
+globalActivity.blocks.protoBlockDict['accelerometery'] = accelerometerYBlk;
accelerometerYBlk.staticLabels.push(_('motion y'));
accelerometerYBlk.adjustWidthToLabel();
accelerometerYBlk.parameterBlock();
//* block:accelerometerz *//
-var accelerometerZBlk = new ProtoBlock('accelerometerz');
-accelerometerZBlk.palette = palettes.dict['sensors'];
-blocks.protoBlockDict['accelerometerz'] = accelerometerZBlk;
+const accelerometerZBlk = new ProtoBlock('accelerometerz');
+accelerometerZBlk.palette = globalActivity.palettes.dict['sensors'];
+globalActivity.blocks.protoBlockDict['accelerometerz'] = accelerometerZBlk;
accelerometerZBlk.staticLabels.push(_('motion z'));
accelerometerZBlk.adjustWidthToLabel();
accelerometerZBlk.parameterBlock();
diff --git a/plugins/bitcoin.json b/plugins/bitcoin.json
deleted file mode 100755
index f47925722e..0000000000
--- a/plugins/bitcoin.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "HIGHLIGHTSTROKECOLORS": {
- "mashape": "#000000"
- },
- "ARGPLUGINS": {
- "bitcoinrate": "var block = logo.blocks.blockList[blk];var conns = block.connections;var from = logo.parseArg(logo, turtle, conns[1]);var amount = logo.parseArg(logo, turtle, conns[2]);var apiURL = 'https://community-bitcointy.p.mashape.com/convert/' + amount + '/' + from;if (block.cacheFor === apiURL && block.cache !== undefined) { var response = block.cache;} else { try { var request = new XMLHttpRequest(); request.open('GET', apiURL, false); request.setRequestHeader('X-Mashape-Authorization', bitcoinMashapeKey); request.send(null); var response = request.responseText; block.cacheFor = apiURL; block.cache = response; } catch (e) { logo.errorMsg('Could not connect to Currency API', blk); }}console.log(response);obj = JSON.parse(response);block.value = obj['value'] / 100;"
- },
- "GLOBALS": "bitcoinMashapeKey = 'PCwj8N1ftxmsh4WCJmQoJqiNhRCbp1DTsnTjsnkmyDCNwB94sm';",
- "PALETTEHIGHLIGHTCOLORS": {
- "mashape": "#ffb1b3"
- },
- "PALETTEPLUGINS": {
- "mashape": "
"
- },
- "BLOCKPLUGINS": {
- "bitcoinrate": "var bitcoinRate = new ProtoBlock('bitcoinrate');bitcoinRate.palette = palettes.dict['mashape'];blocks.protoBlockDict['bitcoinrate'] = bitcoinRate;bitcoinRate.staticLabels.push(_('bitcoin'), _('from'), _('value'));bitcoinRate.adjustWidthToLabel();bitcoinRate.twoArgMathBlock();bitcoinRate.dockTypes[1] = 'anyin';bitcoinRate.dockTypes[2] = 'numberin';bitcoinRate.defaults.push('USD', 100);"
- },
- "PALETTEFILLCOLORS": {
- "mashape": "#ff0066"
- },
- "PALETTESTROKECOLORS": {
- "mashape": "#ef003e"
- }
-}
diff --git a/plugins/bitcoin.rtp b/plugins/bitcoin.rtp
deleted file mode 100755
index c2f827c010..0000000000
--- a/plugins/bitcoin.rtp
+++ /dev/null
@@ -1,72 +0,0 @@
-//* comment *//
-
-Copyright (C) 2015 Walter Bender
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
.
-
-//* globals *//
-
-var bitcoinMashapeKey = 'PCwj8N1ftxmsh4WCJmQoJqiNhRCbp1DTsnTjsnkmyDCNwB94sm';
-
-//* block:bitcoinrate *//
-
-var bitcoinRate = new ProtoBlock('bitcoinrate');
-bitcoinRate.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['bitcoinrate'] = bitcoinRate;
-bitcoinRate.staticLabels.push(_('bitcoin'), _('from'), _('value'));
-bitcoinRate.adjustWidthToLabel();
-bitcoinRate.twoArgMathBlock();
-bitcoinRate.dockTypes[1] = 'anyin';
-bitcoinRate.dockTypes[2] = 'numberin';
-bitcoinRate.defaults.push('USD', 100);
-
-//* arg:bitcoinrate *//
-
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-
-var from = logo.parseArg(logo, turtle, conns[1]);
-var amount = logo.parseArg(logo, turtle, conns[2]);
-
-var apiURL = 'https://community-bitcointy.p.mashape.com/convert/' + amount + '/' + from;
-
-if (block.cacheFor === apiURL && block.cache !== undefined) {
- var response = block.cache;
-} else {
- try {
- var request = new XMLHttpRequest();
- request.open('GET', apiURL, false);
- request.setRequestHeader('X-Mashape-Authorization', bitcoinMashapeKey);
- request.send(null);
-
- var response = request.responseText;
- block.cacheFor = apiURL;
- block.cache = response;
- } catch (e) {
- logo.errorMsg('Could not connect to Currency API', blk);
- }
-}
-
-console.log(response);
-obj = JSON.parse(response);
-block.value = obj['value'] / 100;
-
-//* palette-icon:mashape *//
-
-
-
-//* palette-fill:mashape *// #ff0066
-//* palette-stroke:mashape *// #ef003e
-//* palette-highlight:mashape *// #ffb1b3
-//* palette-stroke-highlight:mashape *// #000000
diff --git a/plugins/dictionary.json b/plugins/dictionary.json
deleted file mode 100755
index 64c821db02..0000000000
--- a/plugins/dictionary.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "HIGHLIGHTSTROKECOLORS": {
- "mashape": "#000000"
- },
- "ARGPLUGINS": {
- "dictionary": "var block = logo.blocks.blockList[blk];var conns = block.connections;var word = (logo.parseArg(logo, turtle, conns[1])).toLowerCase();var apiURL = \"https://montanaflynn-dictionary.p.mashape.com/define?word=\" + word;var request = new XMLHttpRequest();request.open('GET', apiURL, false);request.setRequestHeader('X-Mashape-Authorization', dictionaryMashapeKey);request.send(null);var response = request.responseText;var data = JSON.parse(response);if ('definitions' in data) { try { block.value = data['definitions'][0]['text']; } catch (e) { block.value = null; }}"
- },
- "GLOBALS": "dictionaryMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';",
- "PALETTEHIGHLIGHTCOLORS": {
- "mashape": "#ffb1b3"
- },
- "PALETTEPLUGINS": {
- "mashape": "
"
- },
- "BLOCKPLUGINS": {
- "dictionary": "var dictionaryBlk = new ProtoBlock('dictionary');dictionaryBlk.palette = palettes.dict['mashape'];blocks.protoBlockDict['dictionary'] = dictionaryBlk;dictionaryBlk.staticLabels.push(_('define'));dictionaryBlk.adjustWidthToLabel();dictionaryBlk.oneArgMathBlock();dictionaryBlk.dockTypes[1] = 'anyin';dictionaryBlk.defaults.push('turtle');"
- },
- "PALETTEFILLCOLORS": {
- "mashape": "#ff0066"
- },
- "PALETTESTROKECOLORS": {
- "mashape": "#ef003e"
- }
-}
diff --git a/plugins/dictionary.rtp b/plugins/dictionary.rtp
deleted file mode 100755
index fc28760484..0000000000
--- a/plugins/dictionary.rtp
+++ /dev/null
@@ -1,58 +0,0 @@
-//* comment *//
-
-Copyright (C) 2015 Daksh Shah
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
.
-
-//* globals *//
-var dictionaryMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';
-
-//* block:dictionary *//
-var dictionaryBlk = new ProtoBlock('dictionary');
-dictionaryBlk.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['dictionary'] = dictionaryBlk;
-dictionaryBlk.staticLabels.push(_('define'));
-dictionaryBlk.adjustWidthToLabel();
-dictionaryBlk.oneArgMathBlock();
-dictionaryBlk.dockTypes[1] = 'anyin';
-dictionaryBlk.defaults.push('turtle');
-
-//* arg:dictionary *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var word = (logo.parseArg(logo, turtle, conns[1])).toLowerCase();
-var apiURL = "https://montanaflynn-dictionary.p.mashape.com/define?word=" + word;
-var request = new XMLHttpRequest();
-request.open('GET', apiURL, false);
-request.setRequestHeader('X-Mashape-Authorization', dictionaryMashapeKey);
-request.send(null);
-var response = request.responseText;
-var data = JSON.parse(response);
-if ('definitions' in data) {
- try {
- block.value = data['definitions'][0]['text'];
- }
- catch (e) {
- block.value = null;
- }
-}
-
-//* palette-icon:mashape *//
-
-
-//* palette-fill:mashape *// #ff0066
-//* palette-stroke:mashape *// #ef003e
-//* palette-highlight:mashape *// #ffb1b3
-//* palette-stroke-highlight:mashape *// #000000
-
diff --git a/plugins/facebook.json b/plugins/facebook.json
old mode 100755
new mode 100644
index ee4c2659fa..822fc4e009
--- a/plugins/facebook.json
+++ b/plugins/facebook.json
@@ -1,23 +1,23 @@
{
- "HIGHLIGHTSTROKECOLORS": {
- "facebook": "#5f7cb6"
- },
"FLOWPLUGINS": {
"publish": "if (args.length == 1) { doPublish(args[0]);};"
- },
- "PALETTEHIGHLIGHTCOLORS": {
- "facebook": "#86a0d0"
- },
- "PALETTEPLUGINS": {
- "facebook": "\t]>
"
- },
+ },
"BLOCKPLUGINS": {
"publish": "var pubBlock = new ProtoBlock('publish');pubBlock.palette = palettes.dict['facebook'];blocks.protoBlockDict['publish'] = pubBlock;pubBlock.staticLabels.push(_('publish'));pubBlock.adjustWidthToLabel();pubBlock.oneArgBlock();pubBlock.defaults.push(_('comment'));pubBlock.dockTypes[1] = 'textin';"
- },
+ },
+ "PALETTEPLUGINS": {
+ "facebook": "\t]>
"
+ },
"PALETTEFILLCOLORS": {
"facebook": "#7893c6"
- },
+ },
"PALETTESTROKECOLORS": {
"facebook": "#3a62a5"
+ },
+ "PALETTEHIGHLIGHTCOLORS": {
+ "facebook": "#86a0d0"
+ },
+ "HIGHLIGHTSTROKECOLORS": {
+ "facebook": "#5f7cb6"
}
-}
+}
\ No newline at end of file
diff --git a/plugins/facebook.rtp b/plugins/facebook.rtp
old mode 100755
new mode 100644
diff --git a/plugins/finance.json b/plugins/finance.json
deleted file mode 100755
index 2e2c0a49f6..0000000000
--- a/plugins/finance.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "HIGHLIGHTSTROKECOLORS": {
- "mashape": "#000000"
- },
- "ARGPLUGINS": {
- "stockprice": "var block = logo.blocks.blockList[blk];var conns = block.connections;var stock = logo.parseArg(logo, turtle, conns[1]);var apiURL = 'https://cors-anywhere.herokuapp.com/dev.markitondemand.com/Api/v2/Quote/json?symbol=' + stock;if (block.cacheFor === apiURL && block.cache !== undefined) { var response = block.cache;} else { try { var request = new XMLHttpRequest(); request.open('GET', apiURL, false); request.send(null); var response = request.responseText; block.cacheFor = apiURL; block.cache = response; } catch (e) { logo.errorMsg('Could not connect to Markit On Demand API', blk); }}j = JSON.parse(response);if (j.Status !== 'SUCCESS') { if (j.Message.indexOf('No symbol matches') !== -1) { logo.errorMsg('No stock symbol %s found. Try another, eg. GOOG, AAPL'.replace('%s', stock), blk); } else { logo.errorMsg(j.Message, blk); }} else { block.value = j.LastPrice;}",
- "currencyrate": "var block = logo.blocks.blockList[blk];var conns = block.connections;var from = logo.parseArg(logo, turtle, conns[1]);var to = logo.parseArg(logo, turtle, conns[2]);var apiURL = 'https://currency-exchange.p.mashape.com/exchange?from=' + from + '&q=1.0&to=' + to;if (block.cacheFor === apiURL && block.cache !== undefined) { var response = block.cache;} else { try { var request = new XMLHttpRequest(); request.open('GET', apiURL, false); request.setRequestHeader('X-Mashape-Authorization', financeMashapeKey); request.send(null); var response = request.responseText; block.cacheFor = apiURL; block.cache = response; } catch (e) { logo.errorMsg('Could not connect to Currency API', blk); }}block.value = parseFloat(response);"
- },
- "GLOBALS": "financeMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';",
- "PALETTEHIGHLIGHTCOLORS": {
- "mashape": "#ffb1b3"
- },
- "PALETTEPLUGINS": {
- "mashape": "
"
- },
- "BLOCKPLUGINS": {
- "stockprice": "var stockprice = new ProtoBlock('stockprice');stockprice.palette = palettes.dict['mashape'];blocks.protoBlockDict['stockprice'] = stockprice;stockprice.staticLabels.push(_('stock price'));stockprice.adjustWidthToLabel();stockprice.oneArgMathBlock();stockprice.dockTypes[1] = 'anyin';stockprice.defaults.push('GOOG');",
- "currencyrate": "var currencyRate = new ProtoBlock('currencyrate');currencyRate.palette = palettes.dict['mashape'];blocks.protoBlockDict['currencyrate'] = currencyRate;currencyRate.extraWidth = 20;currencyRate.staticLabels.push(_('currency'), _('from'), _('to'));currencyRate.adjustWidthToLabel();currencyRate.twoArgMathBlock();currencyRate.dockTypes[1] = 'anyin';currencyRate.dockTypes[2] = 'anyin';currencyRate.defaults.push('AUD', 'USD');"
- },
- "PALETTEFILLCOLORS": {
- "mashape": "#ff0066"
- },
- "PALETTESTROKECOLORS": {
- "mashape": "#ef003e"
- }
-}
diff --git a/plugins/finance.rtp b/plugins/finance.rtp
deleted file mode 100755
index fd5297cbca..0000000000
--- a/plugins/finance.rtp
+++ /dev/null
@@ -1,118 +0,0 @@
-//* comment *//
-
-Copyright (C) 2015 Sam Parkinson
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
.
-
-//* globals *//
-
-var financeMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';
-
-//* block:currencyrate *//
-
-var currencyRate = new ProtoBlock('currencyrate');
-currencyRate.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['currencyrate'] = currencyRate;
-currencyRate.extraWidth = 20;
-currencyRate.staticLabels.push(_('currency'), _('from'), _('to'));
-currencyRate.adjustWidthToLabel();
-currencyRate.twoArgMathBlock();
-currencyRate.dockTypes[1] = 'anyin';
-currencyRate.dockTypes[2] = 'anyin';
-currencyRate.defaults.push('AUD', 'USD');
-
-
-//* arg:currencyrate *//
-
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-
-var from = logo.parseArg(logo, turtle, conns[1]);
-var to = logo.parseArg(logo, turtle, conns[2]);
-var apiURL = 'https://currency-exchange.p.mashape.com/exchange?from=' + from + '&q=1.0&to=' + to;
-
-if (block.cacheFor === apiURL && block.cache !== undefined) {
- var response = block.cache;
-} else {
- try {
- var request = new XMLHttpRequest();
- request.open('GET', apiURL, false);
- request.setRequestHeader('X-Mashape-Authorization', financeMashapeKey);
- request.send(null);
-
- var response = request.responseText;
- block.cacheFor = apiURL;
- block.cache = response;
- } catch (e) {
- logo.errorMsg('Could not connect to Currency API', blk);
- }
-}
-
-block.value = parseFloat(response);
-
-//* block:stockprice *//
-
-var stockprice = new ProtoBlock('stockprice');
-stockprice.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['stockprice'] = stockprice;
-stockprice.staticLabels.push(_('stock price'));
-stockprice.adjustWidthToLabel();
-stockprice.oneArgMathBlock();
-stockprice.dockTypes[1] = 'anyin';
-stockprice.defaults.push('GOOG');
-
-//* arg:stockprice *//
-
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-
-var stock = logo.parseArg(logo, turtle, conns[1]);
-var apiURL = 'https://cors-anywhere.herokuapp.com/dev.markitondemand.com/Api/v2/Quote/json?symbol=' + stock;
-
-if (block.cacheFor === apiURL && block.cache !== undefined) {
- var response = block.cache;
-} else {
- try {
- var request = new XMLHttpRequest();
- request.open('GET', apiURL, false);
- request.send(null);
-
- var response = request.responseText;
- block.cacheFor = apiURL;
- block.cache = response;
- } catch (e) {
- logo.errorMsg('Could not connect to Markit On Demand API', blk);
- }
-}
-
-j = JSON.parse(response);
-if (j.Status !== 'SUCCESS') {
- if (j.Message.indexOf('No symbol matches') !== -1) {
- logo.errorMsg('No stock symbol %s found. Try another, eg. GOOG, AAPL'.replace('%s', stock), blk);
- } else {
- logo.errorMsg(j.Message, blk);
- }
-} else {
- block.value = j.LastPrice;
-}
-
-//* palette-icon:mashape *//
-
-
-
-//* palette-fill:mashape *// #ff0066
-//* palette-stroke:mashape *// #ef003e
-//* palette-highlight:mashape *// #ffb1b3
-//* palette-stroke-highlight:mashape *// #000000
-
diff --git a/plugins/gmap.json b/plugins/gmap.json
deleted file mode 100755
index a21e49d3cf..0000000000
--- a/plugins/gmap.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "HIGHLIGHTSTROKECOLORS": {
- "GMAP": "#002659"
- },
- "ARGPLUGINS": {
- "coord": "var block = logo.blocks.blockList[blk];var conns = block.connections;var latitude = logo.parseArg(logo, turtle, conns[1]);var longitude = logo.parseArg(logo, turtle, conns[2]);latitude = eval(latitude);longitude = eval(longitude);if(!latitude || !longitude) { latitude = 42.357279; longitude = -71.065740;}gmapURL = 'http://maps.googleapis.com/maps/api/staticmap?center=' + latitude + ',' + longitude; block.value = gmapURL;",
- "cityToLat": "var block = logo.blocks.blockList[blk];var conns = block.connections;var city = logo.parseArg(logo, turtle, conns[1]);if (city == cityName) { block.value = cityLatitude;} else { var apiURL = 'https://devru-latitude-longitude-find-v1.p.mashape.com/latlon.php?location=' + city; var request = new XMLHttpRequest(); request.open('GET', apiURL, false); request.setRequestHeader('X-Mashape-Authorization', mashapeKey); request.send(null); var response = request.responseText; var data = JSON.parse(response); var latitude = 0; if(data['Results'].length > 0) { data = data['Results'][0]['ll']; var parts = data.split(' '); try { cityLatitude = Number(parts[0]); cityLongitude = Number(parts[1]); var latitude = cityLatitude; cityName = city; } catch (e) { logo.errorMsg(_('Coordinate data not available.'), blk); } } else { logo.errorMsg(_('Coordinate data not available.'), blk); } block.value = latitude;}",
- "zoom": "var block = logo.blocks.blockList[blk];var conns = block.connections;var zoomFactor = logo.parseArg(logo, turtle, conns[1]);block.value = zoomFactor;",
- "cityToLong": "var block = logo.blocks.blockList[blk];var conns = block.connections;var city = logo.parseArg(logo, turtle, conns[1]);if (city == cityName) { block.value = cityLongitude;} else { var apiURL = 'https://devru-latitude-longitude-find-v1.p.mashape.com/latlon.php?location=' + city; var request = new XMLHttpRequest(); request.open('GET', apiURL, false); request.setRequestHeader('X-Mashape-Authorization', mashapeKey); request.send(null); var response = request.responseText; var data = JSON.parse(response); var longitude = 0; if (data['Results'].length > 0) { data = data['Results'][0]['ll']; var parts = data.split(' '); try { cityLatitude = Number(parts[0]); cityLongitude = Number(parts[1]); var longitude = cityLongitude; cityName = city; } catch (e) { logo.errorMsg(_('Coordinate data not available.'), blk); } } else { logo.errorMsg(_('Coordinate data not available.'), blk); } block.value = longitude;}",
- "gmap": "var block = logo.blocks.blockList[blk];var conns = block.connections;var url = logo.parseArg(logo, turtle, conns[1]);var zoom_factor = logo.parseArg(logo, turtle, conns[2]);if(!url) { url = 'http://maps.googleapis.com/maps/api/staticmap?center=42.357279,-71.065740';}if(!zoom_factor) { zoom_factor = 10;}if(zoom_factor == 0) { zoom_factor = 0;}gmapURL = url + '&size=800x800&zoom=' + zoom_factor +'&sensor=false';block.value = gmapURL;"
- },
- "GLOBALS": "mashapeKey = 'JidA8phgY8mshJ8MiEUeHTdwFjjtp1wq209jsncYthfRDMQNW6';cityName = '';cityLatitude = 0;cityLongitude = 0;",
- "PALETTEHIGHLIGHTCOLORS": {
- "GMAP": "#00c5ff"
- },
- "PALETTEPLUGINS": {
- "GMAP": "
"
- },
- "BLOCKPLUGINS": {
- "coord": "var coordBlk = new ProtoBlock('coord');coordBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['coord'] = coordBlk;coordBlk.staticLabels.push(_('coordinates'),_('latitude'),_('longitude'));coordBlk.adjustWidthToLabel();coordBlk.twoArgMathBlock();coordBlk.dockTypes[1] = 'anyin';coordBlk.dockTypes[2] = 'anyin';coordBlk.defaults.push(42.357279,-71.065740);",
- "cityToLat": "var cityToLatBlk = new ProtoBlock('cityToLat');cityToLatBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['cityToLat'] = cityToLatBlk;cityToLatBlk.staticLabels.push(_('city latitude'));cityToLatBlk.adjustWidthToLabel();cityToLatBlk.oneArgMathBlock();cityToLatBlk.dockTypes[1] = 'anyin';cityToLatBlk.defaults.push(\"Boston\");",
- "zoom": "var zoomBlk = new ProtoBlock('zoom');zoomBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['zoom'] = zoomBlk;zoomBlk.staticLabels.push(_('zoom'));zoomBlk.adjustWidthToLabel();zoomBlk.oneArgMathBlock();zoomBlk.dockTypes[1] = 'anyin';zoomBlk.defaults.push(10);",
- "cityToLong": "var cityToLongBlk = new ProtoBlock('cityToLong');cityToLongBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['cityToLong'] = cityToLongBlk;cityToLongBlk.staticLabels.push(_('city longitude'));cityToLongBlk.adjustWidthToLabel();cityToLongBlk.oneArgMathBlock();cityToLongBlk.dockTypes[1] = 'anyin';cityToLongBlk.defaults.push(\"Boston\");",
- "gmap": "var gmapBlk = new ProtoBlock('gmap');gmapBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['gmap'] = gmapBlk;gmapBlk.staticLabels.push(_('Google map'),_('coordinates'),_('zoom factor'));gmapBlk.adjustWidthToLabel();gmapBlk.twoArgMathBlock();"
- },
- "PALETTEFILLCOLORS": {
- "GMAP": "#00abff"
- },
- "PALETTESTROKECOLORS": {
- "GMAP": "#005aaa"
- }
-}
diff --git a/plugins/gmap.rtp b/plugins/gmap.rtp
deleted file mode 100755
index 7fc35c26cf..0000000000
--- a/plugins/gmap.rtp
+++ /dev/null
@@ -1,202 +0,0 @@
-//* comment *//
-
-Copyright (C) 2015 Yash Khandelwal
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
.
-
-NOTE: Default local is downtown Boston.
-
-//* globals *//
-var gmapMashapeKey = 'JidA8phgY8mshJ8MiEUeHTdwFjjtp1wq209jsncYthfRDMQNW6';
-var cityName = '';
-var cityLatitude = 0;
-var cityLongitude = 0;
-
-//* block:cityToLat *//
-var cityToLatBlk = new ProtoBlock('cityToLat');
-cityToLatBlk.palette = palettes.dict['GMAP'];
-blocks.protoBlockDict['cityToLat'] = cityToLatBlk;
-cityToLatBlk.staticLabels.push(_('city latitude'));
-cityToLatBlk.adjustWidthToLabel();
-cityToLatBlk.oneArgMathBlock();
-cityToLatBlk.dockTypes[1] = 'anyin';
-cityToLatBlk.defaults.push("Boston");
-
-//* block:cityToLong *//
-var cityToLongBlk = new ProtoBlock('cityToLong');
-cityToLongBlk.palette = palettes.dict['GMAP'];
-blocks.protoBlockDict['cityToLong'] = cityToLongBlk;
-cityToLongBlk.staticLabels.push(_('city longitude'));
-cityToLongBlk.adjustWidthToLabel();
-cityToLongBlk.oneArgMathBlock();
-cityToLongBlk.dockTypes[1] = 'anyin';
-cityToLongBlk.defaults.push("Boston");
-
-//* arg:cityToLong *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var city = logo.parseArg(logo, turtle, conns[1]);
-
-if (city == cityName) {
- block.value = cityLongitude;
-} else {
- var apiURL = 'https://devru-latitude-longitude-find-v1.p.mashape.com/latlon.php?location=' + city;
- var request = new XMLHttpRequest();
- request.open('GET', apiURL, false);
- request.setRequestHeader('X-Mashape-Authorization', gmapMashapeKey);
- request.send(null);
- var response = request.responseText;
- var data = JSON.parse(response);
- var longitude = 0;
- if (data['Results'].length > 0) {
- data = data['Results'][0]['ll'];
- var parts = data.split(' ');
- try {
- cityLatitude = Number(parts[0]);
- cityLongitude = Number(parts[1]);
- var longitude = cityLongitude;
- cityName = city;
- } catch (e) {
- logo.errorMsg(_('Coordinate data not available.'), blk);
- }
- } else {
- logo.errorMsg(_('Coordinate data not available.'), blk);
- }
- block.value = longitude;
-}
-
-//* arg:cityToLat *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var city = logo.parseArg(logo, turtle, conns[1]);
-
-if (city == cityName) {
- block.value = cityLatitude;
-} else {
- var apiURL = 'https://devru-latitude-longitude-find-v1.p.mashape.com/latlon.php?location=' + city;
- var request = new XMLHttpRequest();
- request.open('GET', apiURL, false);
- request.setRequestHeader('X-Mashape-Authorization', gmapMashapeKey);
- request.send(null);
- var response = request.responseText;
- var data = JSON.parse(response);
- var latitude = 0;
- if(data['Results'].length > 0) {
- data = data['Results'][0]['ll'];
- var parts = data.split(' ');
- try {
- cityLatitude = Number(parts[0]);
- cityLongitude = Number(parts[1]);
- var latitude = cityLatitude;
- cityName = city;
- } catch (e) {
- logo.errorMsg(_('Coordinate data not available.'), blk);
- }
- } else {
- logo.errorMsg(_('Coordinate data not available.'), blk);
- }
- block.value = latitude;
-}
-
-//* block:gmap *//
-var gmapBlk = new ProtoBlock('gmap');
-gmapBlk.palette = palettes.dict['GMAP'];
-blocks.protoBlockDict['gmap'] = gmapBlk;
-gmapBlk.staticLabels.push(_('Google map'),_('coordinates'),_('zoom factor'));
-gmapBlk.adjustWidthToLabel();
-gmapBlk.twoArgMathBlock();
-
-//* arg:gmap *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var url = logo.parseArg(logo, turtle, conns[1]);
-var zoom_factor = logo.parseArg(logo, turtle, conns[2]);
-if(!url) {
- url = 'http://maps.googleapis.com/maps/api/staticmap?center=42.357279,-71.065740';
-}
-
-if(!zoom_factor) {
- zoom_factor = 10;
-}
-
-if(zoom_factor == 0) {
- zoom_factor = 0;
-}
-
-gmapURL = url + '&size=800x800&zoom=' + zoom_factor +'&sensor=false';
-block.value = gmapURL;
-
-//* block:zoom *//
-var zoomBlk = new ProtoBlock('zoom');
-zoomBlk.palette = palettes.dict['GMAP'];
-blocks.protoBlockDict['zoom'] = zoomBlk;
-zoomBlk.staticLabels.push(_('zoom'));
-zoomBlk.adjustWidthToLabel();
-zoomBlk.oneArgMathBlock();
-zoomBlk.dockTypes[1] = 'anyin';
-zoomBlk.defaults.push(10);
-
-//* arg:zoom *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var zoomFactor = logo.parseArg(logo, turtle, conns[1]);
-block.value = zoomFactor;
-
-//* block:coord *//
-var coordBlk = new ProtoBlock('coord');
-coordBlk.palette = palettes.dict['GMAP'];
-blocks.protoBlockDict['coord'] = coordBlk;
-coordBlk.staticLabels.push(_('coordinates'),_('latitude'),_('longitude'));
-coordBlk.adjustWidthToLabel();
-coordBlk.twoArgMathBlock();
-coordBlk.dockTypes[1] = 'anyin';
-coordBlk.dockTypes[2] = 'anyin';
-coordBlk.defaults.push(42.357279,-71.065740);
-
-//* arg:coord *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var latitude = logo.parseArg(logo, turtle, conns[1]);
-var longitude = logo.parseArg(logo, turtle, conns[2]);
-
-latitude = eval(latitude);
-longitude = eval(longitude);
-
-if(!latitude || !longitude) {
- latitude = 42.357279;
- longitude = -71.065740;
-}
-gmapURL = 'http://maps.googleapis.com/maps/api/staticmap?center=' + latitude + ',' + longitude;
-
-block.value = gmapURL;
-
-//* palette-icon:GMAP *//
-
-
-
-
-
-
-
-//* palette-fill:GMAP *// #00abff
-//* palette-stroke:GMAP *// #005aaa
-//* palette-highlight:GMAP *// #00c5ff
-//* palette-stroke-highlight:GMAP *// #002659
diff --git a/plugins/heap.json b/plugins/heap.json
deleted file mode 100755
index 625a123f4d..0000000000
--- a/plugins/heap.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "BLOCKPLUGINS": {
- "heapEmpty": "var heapEmpty = new ProtoBlock('heapEmpty');heapEmpty.palette = palettes.dict['extras'];blocks.protoBlockDict['heapEmpty'] = heapEmpty;heapEmpty.staticLabels.push(_('heap empty?'));heapEmpty.adjustWidthToLabel();heapEmpty.booleanZeroArgBlock();",
- "showHeap": "var showHeap = new ProtoBlock('showHeap');showHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['showHeap'] = showHeap;showHeap.staticLabels.push(_('show heap'));showHeap.adjustWidthToLabel();showHeap.zeroArgBlock();",
- "pop": "var popBlk = new ProtoBlock('pop');popBlk.palette = palettes.dict['extras'];blocks.protoBlockDict['pop'] = popBlk;popBlk.staticLabels.push(_('pop'));popBlk.adjustWidthToLabel();popBlk.parameterBlock();",
- "emptyHeap": "var emptyHeap = new ProtoBlock('emptyHeap');emptyHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['emptyHeap'] = emptyHeap;emptyHeap.staticLabels.push(_('empty heap'));emptyHeap.adjustWidthToLabel();emptyHeap.zeroArgBlock();",
- "saveHeap": "var saveHeap = new ProtoBlock('saveHeap');saveHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['saveHeap'] = saveHeap;saveHeap.staticLabels.push(_('save heap'));saveHeap.adjustWidthToLabel();saveHeap.oneArgBlock();saveHeap.defaults.push('heap.json');saveHeap.dockTypes[1] = 'textin';",
- "loadHeap": "var loadHeap = new ProtoBlock('loadHeap');loadHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['loadHeap'] = loadHeap;loadHeap.staticLabels.push(_('load heap'));loadHeap.adjustWidthToLabel();loadHeap.oneArgBlock();loadHeap.dockTypes[1] = 'filein';loadHeap.defaults = [[null, null]];",
- "push": "var pushBlk = new ProtoBlock('push');pushBlk.palette = palettes.dict['extras'];blocks.protoBlockDict['push'] = pushBlk;pushBlk.staticLabels.push(_('push'));pushBlk.adjustWidthToLabel();pushBlk.oneArgBlock();pushBlk.dockTypes[1] = 'anyin';"
- },
- "GLOBALS": "turtleHeaps = {};",
- "ARGPLUGINS": {
- "heapEmpty": "var block = logo.blocks.blockList[blk];if (turtle in turtleHeaps) { block.value = (turtleHeaps[turtle].length == 0);} else { block.value = true;}",
- "pop": "var block = logo.blocks.blockList[blk];if (turtle in turtleHeaps && turtleHeaps[turtle].length > 0) { block.value = turtleHeaps[turtle].pop();} else { logo.errorMsg(_('empty heap')); block.value = null;}"
- },
- "FLOWPLUGINS": {
- "emptyHeap": "turtleHeaps[turtle] = [];",
- "showHeap": "var block = logo.blocks.blockList[blk];logo.textMsg(JSON.stringify(turtleHeaps[turtle]));",
- "push": "var block = logo.blocks.blockList[blk];var conns = block.connections;var arg = logo.parseArg(logo, turtle, conns[1]);if (!(turtle in turtleHeaps)) { turtleHeaps[turtle] = [];}turtleHeaps[turtle].push(arg);",
- "loadHeap": "var block = logo.blocks.blockList[blk];var conns = block.connections;var arg = logo.parseArg(logo, turtle, conns[1]);if (turtle in turtleHeaps) { var oldHeap = turtleHeaps[turtle];} else { var oldHeap = [];}if (blocks.blockList[conns[1]].name == 'loadFile') { if (!arg) { logo.errorMsg(_('You need to select a file.')); } else { if (arg.length != 2) { logo.errorMsg(_('You need to select a file.')); } else { try { turtleHeaps[turtle] = JSON.parse(arg[1]); if (!Array.isArray(turtleHeaps[turtle])) { throw 'is not array'; } } catch (e) { turtleHeaps[turtle] = oldHeap; logo.errorMsg(_('The file you selected does not contain a valid heap.')); } } }}else { logo.errorMsg(_('The loadHeap block needs a loadFile block.'))};",
- "saveHeap": "function downloadFile(filename, mimetype, content) { var download = document.createElement('a'); download.setAttribute('href', 'data:' + mimetype + ';charset=utf-8,' + content); download.setAttribute('download', filename); document.body.appendChild(download); download.click(); document.body.removeChild(download);};var block = logo.blocks.blockList[blk];var conns = block.connections;var arg = logo.parseArg(logo, turtle, conns[1]);if (arg && turtle in turtleHeaps) { downloadFile(arg, 'text/json', JSON.stringify(turtleHeaps[turtle]));};"
- }
-}
diff --git a/plugins/heap.rtp b/plugins/heap.rtp
deleted file mode 100755
index c576420f8b..0000000000
--- a/plugins/heap.rtp
+++ /dev/null
@@ -1,164 +0,0 @@
-//* comment *//
-
-Copyright (C) 2015 Ignacio Rodríguez
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
.
-
-//* globals *//
-turtleHeaps = {};
-
-//* flow:showHeap *//
-var block = logo.blocks.blockList[blk];
-logo.textMsg(JSON.stringify(turtleHeaps[turtle]));
-
-//* flow:emptyHeap *//
-turtleHeaps[turtle] = [];
-
-//* flow:push *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var arg = logo.parseArg(logo, turtle, conns[1]);
-if (!(turtle in turtleHeaps)) {
- turtleHeaps[turtle] = [];
-}
-turtleHeaps[turtle].push(arg);
-
-//* arg:pop *//
-var block = logo.blocks.blockList[blk];
-if (turtle in turtleHeaps && turtleHeaps[turtle].length > 0) {
- block.value = turtleHeaps[turtle].pop();
-} else {
- logo.errorMsg(_('empty heap'));
- block.value = null;
-}
-
-//* arg:heapEmpty *//
-var block = logo.blocks.blockList[blk];
-if (turtle in turtleHeaps) {
- block.value = (turtleHeaps[turtle].length == 0);
-} else {
- block.value = true;
-}
-
-//* flow:saveHeap *//
-function downloadFile(filename, mimetype, content) {
- var download = document.createElement('a');
- download.setAttribute('href', 'data:' + mimetype + ';charset=utf-8,' + content);
- download.setAttribute('download', filename);
- document.body.appendChild(download);
- download.click();
- document.body.removeChild(download);
-};
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var arg = logo.parseArg(logo, turtle, conns[1]);
-if (arg && turtle in turtleHeaps) {
- downloadFile(arg, 'text/json', JSON.stringify(turtleHeaps[turtle]));
-};
-
-//* flow:loadHeap *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-var arg = logo.parseArg(logo, turtle, conns[1]);
-if (turtle in turtleHeaps) {
- var oldHeap = turtleHeaps[turtle];
-} else {
- var oldHeap = [];
-}
-if (blocks.blockList[conns[1]].name == 'loadFile') {
- if (!arg) {
- logo.errorMsg(_('You need to select a file.'));
- }
- else {
- if (arg.length != 2) {
- logo.errorMsg(_('You need to select a file.'));
- }
- else {
- try {
- turtleHeaps[turtle] = JSON.parse(arg[1]);
- if (!Array.isArray(turtleHeaps[turtle])) {
- throw 'is not array';
- }
- }
- catch (e) {
- turtleHeaps[turtle] = oldHeap;
- logo.errorMsg(_('The file you selected does not contain a valid heap.'));
- }
- }
- }
-}
-else {
- logo.errorMsg(_('The loadHeap block needs a loadFile block.'))
-};
-
-//* block:push *//
-var pushBlk = new ProtoBlock('push');
-pushBlk.palette = palettes.dict['extras'];
-blocks.protoBlockDict['push'] = pushBlk;
-pushBlk.staticLabels.push(_('push'));
-pushBlk.adjustWidthToLabel();
-pushBlk.oneArgBlock();
-pushBlk.dockTypes[1] = 'anyin';
-
-//* block:pop *//
-var popBlk = new ProtoBlock('pop');
-popBlk.palette = palettes.dict['extras'];
-blocks.protoBlockDict['pop'] = popBlk;
-popBlk.staticLabels.push(_('pop'));
-popBlk.adjustWidthToLabel();
-popBlk.parameterBlock();
-
-//* block:showHeap *//
-var showHeap = new ProtoBlock('showHeap');
-showHeap.palette = palettes.dict['extras'];
-blocks.protoBlockDict['showHeap'] = showHeap;
-showHeap.staticLabels.push(_('show heap'));
-showHeap.adjustWidthToLabel();
-showHeap.zeroArgBlock();
-
-//* block:heapEmpty *//
-var heapEmpty = new ProtoBlock('heapEmpty');
-heapEmpty.palette = palettes.dict['extras'];
-blocks.protoBlockDict['heapEmpty'] = heapEmpty;
-heapEmpty.staticLabels.push(_('heap empty?'));
-heapEmpty.adjustWidthToLabel();
-heapEmpty.booleanZeroArgBlock();
-
-//* block:emptyHeap *//
-var emptyHeap = new ProtoBlock('emptyHeap');
-emptyHeap.palette = palettes.dict['extras'];
-blocks.protoBlockDict['emptyHeap'] = emptyHeap;
-emptyHeap.staticLabels.push(_('empty heap'));
-emptyHeap.adjustWidthToLabel();
-emptyHeap.zeroArgBlock();
-
-//* block:saveHeap *//
-var saveHeap = new ProtoBlock('saveHeap');
-saveHeap.palette = palettes.dict['extras'];
-blocks.protoBlockDict['saveHeap'] = saveHeap;
-saveHeap.staticLabels.push(_('save heap'));
-saveHeap.adjustWidthToLabel();
-saveHeap.oneArgBlock();
-saveHeap.defaults.push('heap.json');
-saveHeap.dockTypes[1] = 'textin';
-
-//* block:loadHeap *//
-var loadHeap = new ProtoBlock('loadHeap');
-loadHeap.palette = palettes.dict['extras'];
-blocks.protoBlockDict['loadHeap'] = loadHeap;
-loadHeap.staticLabels.push(_('load heap'));
-loadHeap.adjustWidthToLabel();
-loadHeap.oneArgBlock();
-loadHeap.dockTypes[1] = 'filein';
-loadHeap.defaults = [[null, null]];
diff --git a/plugins/logic.json b/plugins/logic.json
deleted file mode 100755
index 6625f4e4c5..0000000000
--- a/plugins/logic.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "HIGHLIGHTSTROKECOLORS": {
- "logic": "#000000"
- },
- "ARGPLUGINS": {
- "mynot": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = ~ logo.parseArg(logo, turtle, conns[1]);",
- "myor": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.parseArg(logo, turtle, conns[1]) | logo.parseArg(logo, turtle, conns[2]);",
- "myxor": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.parseArg(logo, turtle, conns[1]) >> logo.parseArg(logo, turtle, conns[2]);",
- "mysr": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.parseArg(logo, turtle, conns[1]) >> logo.parseArg(logo, turtle, conns[2]);",
- "mysl": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.parseArg(logo, turtle, conns[1]) << logo.parseArg(logo, turtle, conns[2]);",
- "myand": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.parseArg(logo, turtle, conns[1]) & logo.parseArg(logo, turtle, conns[2]);"
- },
- "PALETTEHIGHLIGHTCOLORS": {
- "logic": "#FF9FFF"
- },
- "PALETTEPLUGINS": {
- "logic": "
0 1 1 0 "
- },
- "BLOCKPLUGINS": {
- "mynot": "var LogicTwoArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.twoArgMathBlock(); block.defaults.push(1); block.defaults.push(1);};var LogicArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(0);};LogicArgBlock('mynot', 'NOT');",
- "myor": "var LogicTwoArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.twoArgMathBlock(); block.defaults.push(1); block.defaults.push(1);};var LogicArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(0);};LogicTwoArgBlock('myor', 'OR');",
- "myxor": "var LogicTwoArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.twoArgMathBlock(); block.defaults.push(1); block.defaults.push(1);};var LogicArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(0);};LogicTwoArgBlock('myxor', 'XOR');",
- "mysr": "var LogicTwoArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.twoArgMathBlock(); block.defaults.push(1); block.defaults.push(1);};var LogicArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(0);};LogicTwoArgBlock('mysr', '>>');",
- "mysl": "var LogicTwoArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.twoArgMathBlock(); block.defaults.push(1); block.defaults.push(1);};var LogicArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(0);};LogicTwoArgBlock('mysl', '<<');",
- "myand": "var LogicTwoArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.twoArgMathBlock(); block.defaults.push(1); block.defaults.push(1);};var LogicArgBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['logic']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(0);};LogicTwoArgBlock('myand', 'AND');"
- },
- "PALETTEFILLCOLORS": {
- "logic": "#ff00ff"
- },
- "PALETTESTROKECOLORS": {
- "logic": "#C700D3"
- }
-}
diff --git a/plugins/logic.rtp b/plugins/logic.rtp
deleted file mode 100755
index 7177f4ed68..0000000000
--- a/plugins/logic.rtp
+++ /dev/null
@@ -1,73 +0,0 @@
-//* comment *//
-
-Copyright (C) 2015 Ignacio Rodríguez
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
.
-
-This plugin provides logical bit operations in Turtle Art,
-such as AND, OR, XOR, NOT, logical shift left, logical shift right.
-
-
-//* arg-globals *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-
-//* block-globals *//
-var LogicTwoArgBlock = function (name, label) {
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['logic'];
- blocks.protoBlockDict[name] = block;
- block.staticLabels.push(label);
- block.adjustWidthToLabel();
- block.twoArgMathBlock();
- block.defaults.push(1);
- block.defaults.push(1);
-};
-
-var LogicArgBlock = function (name, label) {
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['logic'];
- blocks.protoBlockDict[name] = block;
- block.staticLabels.push(label);
- block.adjustWidthToLabel();
- block.oneArgMathBlock();
- block.defaults.push(0);
-};
-
-//* block:myxor *// LogicTwoArgBlock('myxor', 'XOR');
-//* arg:myxor *// block.value = logo.parseArg(logo, turtle, conns[1]) >> logo.parseArg(logo, turtle, conns[2]);
-
-//* block:myand *// LogicTwoArgBlock('myand', 'AND');
-//* arg:myand *// block.value = logo.parseArg(logo, turtle, conns[1]) & logo.parseArg(logo, turtle, conns[2]);
-
-//* block:myor *// LogicTwoArgBlock('myor', 'OR');
-//* arg:myor *// block.value = logo.parseArg(logo, turtle, conns[1]) | logo.parseArg(logo, turtle, conns[2]);
-
-//* block:mysl *// LogicTwoArgBlock('mysl', '<<');
-//* arg:mysl *// block.value = logo.parseArg(logo, turtle, conns[1]) << logo.parseArg(logo, turtle, conns[2]);
-
-//* block:mysr *// LogicTwoArgBlock('mysr', '>>');
-//* arg:mysr *// block.value = logo.parseArg(logo, turtle, conns[1]) >> logo.parseArg(logo, turtle, conns[2]);
-
-//* block:mynot *// LogicArgBlock('mynot', 'NOT');
-//* arg:mynot *// block.value = ~ logo.parseArg(logo, turtle, conns[1]);
-
-//* palette-icon:logic *//
-
0 1 1 0
-
-//* palette-fill:logic *// #ff00ff
-//* palette-stroke:logic *// #C700D3
-//* palette-highlight:logic *// #FF9FFF
-//* palette-stroke-highlight:logic *// #000000
-
diff --git a/plugins/maths.json b/plugins/maths.json
old mode 100755
new mode 100644
index bcb413b645..0561ebace0
--- a/plugins/maths.json
+++ b/plugins/maths.json
@@ -1,48 +1,47 @@
{
- "HIGHLIGHTSTROKECOLORS": {
- "maths": "#FFCDDF"
- },
+ "BLOCKPLUGINS": {
+ "power": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleTwoArgBlock('power', [_('power'), _('base'), _('exp')], [10, 2]);",
+ "sin": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('sin', 'sin', '3.14159');",
+ "cos": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('cos', 'cos', '3.14159');",
+ "tan": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('tan', 'tan', '3.14159');",
+ "asin": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('asin', 'asin', 0);",
+ "acos": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('acos', 'acos', 0);",
+ "atan": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('atan', 'atan', 1);",
+ "floor": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('floor', _('floor'), 0.5);",
+ "ceiling": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('ceiling', _('ceiling'), 0.5);",
+ "degrees": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('degrees', _('to degrees'), 3.14159);",
+ "radians": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('radians', _('to radians'), 180);",
+ "pi": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};staticBlock('pi', '\u03c0');",
+ "e": "const simpleOneArgBlock = function (name, label, defaultValue) { if (label === undefined) { var label = name; } const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); if (defaultValue === undefined) { block.defaults.push(1.0); } else { block.defaults.push(defaultValue); }};const simpleTwoArgBlock = function (name, labels, defaultValues) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; for (let i = 0; i < labels.length; i++) { block.staticLabels.push(labels[i]); } block.adjustWidthToLabel(); block.twoArgMathBlock(); for (let i = 0; i < defaultValues.length; i++) { block.defaults.push(defaultValues[i]); }};const staticBlock = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['maths']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};staticBlock('e', 'e');"
+ },
"ARGPLUGINS": {
- "asin": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.asin(logo.parseArg(logo, turtle, conns[1]));",
- "cos": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.cos(logo.parseArg(logo, turtle, conns[1]));",
- "e": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.E;",
- "power": "var block = logo.blocks.blockList[blk];var conns = block.connections;var base = logo.parseArg(logo, turtle, conns[1]);var exp = logo.parseArg(logo, turtle, conns[2]);block.value = Math.pow(base, exp);",
- "atan": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.atan(logo.parseArg(logo, turtle, conns[1]));",
- "floor": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.floor(logo.parseArg(logo, turtle, conns[1]));",
- "ceiling": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.ceil(logo.parseArg(logo, turtle, conns[1]));",
- "radians": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.parseArg(logo, turtle, conns[1]) * (Math.PI/180);",
- "degrees": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.parseArg(logo, turtle, conns[1]) * (180/Math.PI);",
- "acos": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.acos(logo.parseArg(logo, turtle, conns[1]));",
- "pi": "var block = logo.blocks.blockList[blk];var conns = block.connecti
-ons;block.value = Math.PI;",
- "sin": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.sin(logo.parseArg(logo, turtle, conns[1]));",
- "tan": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = Math.tan(logo.parseArg(logo, turtle, conns[1]));"
- },
- "PALETTEHIGHLIGHTCOLORS": {
- "maths": "#FF5293"
- },
+ "power": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;var base = logo.parseArg(logo, turtle, conns[1]);var exp = logo.parseArg(logo, turtle, conns[2]);mathBlock.value = Math.pow(base, exp);",
+ "sin": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.sin(logo.parseArg(logo, turtle, conns[1]));",
+ "cos": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.cos(logo.parseArg(logo, turtle, conns[1]));",
+ "tan": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.tan(logo.parseArg(logo, turtle, conns[1]));",
+ "asin": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.asin(logo.parseArg(logo, turtle, conns[1]));",
+ "acos": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.acos(logo.parseArg(logo, turtle, conns[1]));",
+ "atan": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.atan(logo.parseArg(logo, turtle, conns[1]));",
+ "floor": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.floor(logo.parseArg(logo, turtle, conns[1]));",
+ "ceiling": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.ceil(logo.parseArg(logo, turtle, conns[1]));",
+ "degrees": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = logo.parseArg(logo, turtle, conns[1]) * (180/Math.PI);",
+ "radians": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = logo.parseArg(logo, turtle, conns[1]) * (Math.PI/180);",
+ "pi": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.PI;",
+ "e": "const mathBlock = globalActivity.logo.blockList[blk];const conns = mathBlock.connections;mathBlock.value = Math.E;"
+ },
"PALETTEPLUGINS": {
- "maths": "
image/svg+xml "
- },
- "BLOCKPLUGINS": {
- "asin": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('asin');",
- "cos": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('cos');",
- "e": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};staticBlock('e', 'e');",
- "atan": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('atan');",
- "power": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var block = new ProtoBlock('power');block.palette = palettes.dict['maths'];blocks.protoBlockDict['power'] = block;block.staticLabels.push(_('power'), _('base'), _('exp'));block.twoArgMathBlock();block.defaults.push(10, 2);",
- "floor": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock(_('floor'));",
- "ceiling": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock(_('ceiling'));",
- "sin": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('sin');",
- "degrees": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock(_('degrees'), _('to degrees'));",
- "tan": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('tan');",
- "pi": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};staticBlock('pi', '\u03c0');",
- "acos": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock('acos');",
- "radians": "var simpleOneArgBlock = function (name, label) { if (label === undefined) { var label = name; } var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.defaults.push(1);};var staticBlock = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['maths']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};simpleOneArgBlock(_('radians'), _('to radians'));"
- },
+ "maths": "
image/svg+xml "
+ },
"PALETTEFILLCOLORS": {
"maths": "#FF6EA1"
- },
+ },
"PALETTESTROKECOLORS": {
"maths": "#FF2C76"
+ },
+ "PALETTEHIGHLIGHTCOLORS": {
+ "maths": "#FF5293"
+ },
+ "HIGHLIGHTSTROKECOLORS": {
+ "maths": "#FFCDDF"
}
-}
+}
\ No newline at end of file
diff --git a/plugins/maths.rtp b/plugins/maths.rtp
old mode 100755
new mode 100644
index 1aa2d7de61..2e8ce371a0
--- a/plugins/maths.rtp
+++ b/plugins/maths.rtp
@@ -16,70 +16,114 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
.
//* arg-globals *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
+const mathBlock = globalActivity.logo.blockList[blk];
+const conns = mathBlock.connections;
//* block-globals *//
-var simpleOneArgBlock = function (name, label) {
+const simpleOneArgBlock = function (name, label, defaultValue) {
if (label === undefined) { var label = name; }
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['maths'];
- blocks.protoBlockDict[name] = block;
+ const block = new ProtoBlock(name);
+ block.palette = globalActivity.palettes.dict['maths'];
+ globalActivity.blocks.protoBlockDict[name] = block;
block.staticLabels.push(label);
block.adjustWidthToLabel();
block.oneArgMathBlock();
- block.defaults.push(1);
+ if (defaultValue === undefined) {
+ block.defaults.push(1.0);
+ } else {
+ block.defaults.push(defaultValue);
+ }
};
-var staticBlock = function (name, label) {
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['maths'];
- blocks.protoBlockDict[name] = block;
+const simpleTwoArgBlock = function (name, labels, defaultValues) {
+ const block = new ProtoBlock(name);
+ block.palette = globalActivity.palettes.dict['maths'];
+ globalActivity.blocks.protoBlockDict[name] = block;
+ for (let i = 0; i < labels.length; i++) {
+ block.staticLabels.push(labels[i]);
+ }
+ block.adjustWidthToLabel();
+ block.twoArgMathBlock();
+ for (let i = 0; i < defaultValues.length; i++) {
+ block.defaults.push(defaultValues[i]);
+ }
+};
+
+const staticBlock = function (name, label) {
+ const block = new ProtoBlock(name);
+ block.palette = globalActivity.palettes.dict['maths'];
+ globalActivity.blocks.protoBlockDict[name] = block;
block.staticLabels.push(label);
block.adjustWidthToLabel();
block.parameterBlock();
};
//* block:power *//
-var block = new ProtoBlock('power');
-block.palette = palettes.dict['maths'];
-blocks.protoBlockDict['power'] = block;
-block.staticLabels.push(_('power'), _('base'), _('exp'));
-block.twoArgMathBlock();
-block.defaults.push(10, 2);
+simpleTwoArgBlock('power', [_('power'), _('base'), _('exp')], [10, 2]);
//* arg:power *//
var base = logo.parseArg(logo, turtle, conns[1]);
var exp = logo.parseArg(logo, turtle, conns[2]);
-block.value = Math.pow(base, exp);
-
-//* block:sin *// simpleOneArgBlock('sin');
-//* arg:sin *// block.value = Math.sin(logo.parseArg(logo, turtle, conns[1]));
-//* block:cos *// simpleOneArgBlock('cos');
-//* arg:cos *// block.value = Math.cos(logo.parseArg(logo, turtle, conns[1]));
-//* block:tan *// simpleOneArgBlock('tan');
-//* arg:tan *// block.value = Math.tan(logo.parseArg(logo, turtle, conns[1]));
-
-//* block:asin *// simpleOneArgBlock('asin');
-//* arg:asin *// block.value = Math.asin(logo.parseArg(logo, turtle, conns[1]));
-//* block:acos *// simpleOneArgBlock('acos');
-//* arg:acos *// block.value = Math.acos(logo.parseArg(logo, turtle, conns[1]));
-//* block:atan *// simpleOneArgBlock('atan');
-//* arg:atan *// block.value = Math.atan(logo.parseArg(logo, turtle, conns[1]));
-
-//* block:floor *// simpleOneArgBlock(_('floor'));
-//* arg:floor *// block.value = Math.floor(logo.parseArg(logo, turtle, conns[1]));
-//* block:ceiling *// simpleOneArgBlock(_('ceiling'));
-//* arg:ceiling *// block.value = Math.ceil(logo.parseArg(logo, turtle, conns[1]));
-
-//* block:degrees *// simpleOneArgBlock(_('degrees'), _('to degrees'));
-//* arg:degrees *// block.value = logo.parseArg(logo, turtle, conns[1]) * (180/Math.PI);
-//* block:radians *// simpleOneArgBlock(_('radians'), _('to radians'));
-//* arg:radians *// block.value = logo.parseArg(logo, turtle, conns[1]) * (Math.PI/180);
-
-//* block:pi *// staticBlock('pi', 'π');
-//* arg:pi *// block.value = Math.PI;
-//* block:e *// staticBlock('e', 'e');
-//* arg:e *// block.value = Math.E;
+mathBlock.value = Math.pow(base, exp);
+
+//* block:sin *//
+simpleOneArgBlock('sin', 'sin', '3.14159');
+//* arg:sin *//
+mathBlock.value = Math.sin(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:cos *//
+simpleOneArgBlock('cos', 'cos', '3.14159');
+//* arg:cos *//
+mathBlock.value = Math.cos(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:tan *//
+simpleOneArgBlock('tan', 'tan', '3.14159');
+//* arg:tan *//
+mathBlock.value = Math.tan(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:asin *//
+simpleOneArgBlock('asin', 'asin', 0);
+//* arg:asin *//
+mathBlock.value = Math.asin(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:acos *//
+simpleOneArgBlock('acos', 'acos', 0);
+//* arg:acos *//
+mathBlock.value = Math.acos(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:atan *//
+simpleOneArgBlock('atan', 'atan', 1);
+//* arg:atan *//
+mathBlock.value = Math.atan(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:floor *//
+simpleOneArgBlock('floor', _('floor'), 0.5);
+//* arg:floor *//
+mathBlock.value = Math.floor(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:ceiling *//
+simpleOneArgBlock('ceiling', _('ceiling'), 0.5);
+//* arg:ceiling *//
+mathBlock.value = Math.ceil(logo.parseArg(logo, turtle, conns[1]));
+
+//* block:degrees *//
+simpleOneArgBlock('degrees', _('to degrees'), 3.14159);
+//* arg:degrees *//
+mathBlock.value = logo.parseArg(logo, turtle, conns[1]) * (180/Math.PI);
+
+//* block:radians *//
+simpleOneArgBlock('radians', _('to radians'), 180);
+//* arg:radians *//
+mathBlock.value = logo.parseArg(logo, turtle, conns[1]) * (Math.PI/180);
+
+//* block:pi *//
+staticBlock('pi', 'π');
+//* arg:pi *//
+mathBlock.value = Math.PI;
+
+//* block:e *//
+staticBlock('e', 'e');
+//* arg:e *//
+mathBlock.value = Math.E;
//* palette-icon:maths *//
@@ -108,8 +152,12 @@ block.value = Math.pow(base, exp);
id="path7"
style="fill:none;stroke:#FF6EA1;stroke-width:1.51425433" />
-//* palette-fill:maths *// #FF6EA1
-//* palette-stroke:maths *// #FF2C76
-//* palette-highlight:maths *// #FF5293
-//* palette-stroke-highlight:maths *// #FFCDDF
+//* palette-fill:maths *//
+#FF6EA1
+//* palette-stroke:maths *//
+#FF2C76
+//* palette-highlight:maths *//
+#FF5293
+//* palette-stroke-highlight:maths *//
+#FFCDDF
diff --git a/plugins/nutrition.json b/plugins/nutrition.json
old mode 100755
new mode 100644
index 9f10e202d4..c4a69dc72f
--- a/plugins/nutrition.json
+++ b/plugins/nutrition.json
@@ -1,119 +1,119 @@
{
- "HIGHLIGHTSTROKECOLORS": {
- "food": "#000000",
- "eatme": "#000000"
- },
- "ARGPLUGINS": {
- "fiber": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = nutritionFiber;",
- "get_fiber": "var block = logo.blocks.blockList[blk];var conns = block.connections;var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];block.value = blockFoodData[3];",
- "get_fat": "var block = logo.blocks.blockList[blk];var conns = block.connections;var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];block.value = blockFoodData[4];",
- "carbohydrates": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = nutritionCarbohydrate;",
- "calories": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = nutritionCalories;",
- "fat": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = nutritionFat;",
- "get_carbohydrates": "var block = logo.blocks.blockList[blk];var conns = block.connections;var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];block.value = blockFoodData[2];",
- "get_calories": "var block = logo.blocks.blockList[blk];var conns = block.connections;var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];block.value = blockFoodData[0];",
- "get_name": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = logo.blocks.blockList[conns[1]].name;",
- "protein": "var block = logo.blocks.blockList[blk];var conns = block.connections;block.value = nutritionProtein;",
- "get_protein": "var block = logo.blocks.blockList[blk];var conns = block.connections;var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];block.value = blockFoodData[1];"
- },
+ "GLOBALS": "globalActivity.logo.pluginVars['nutrition'] = { 'calories': 0, 'protein': 0, 'carbohydrate': 0, 'fiber': 0, 'fat': 0, 'foodData': { 'apple': [72, 0, 19, 3, 0], \t'banana': [105, 1, 27, 3, 0], 'orange': [62, 1, 15, 3, 0], 'bread': [69, 4, 12, 2, 1], 'corn': [96, 3, 21, 3, 1], 'potato': [159, 4, 36, 4, 0], 'sweetpotato': [169, 1, 22, 1, 8], 'tomato': [150, 4, 25, 3, 5], 'broccoli': [94, 4, 11, 5, 5], 'riceandbeans': [411, 14, 60, 8, 13], 'tamale': [126, 6, 11, 1, 6], 'cheese': [114, 7, 0, 0, 9], 'chicken': [152, 15, 0, 0, 10], 'fish': [58, 6, 0, 0, 3], 'beef': [285, 46, 0, 0, 10], 'cake': [387, 4, 69, 2, 13], 'cookie': [68, 1, 8, 0, 4], 'water': [0, 0, 0, 0, 0] }};",
+ "BLOCKPLUGINS": {
+ "get_calories": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};get_eatme('get_calories', _('get calories'));",
+ "get_protein": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};get_eatme('get_protein', _('get protein'));",
+ "get_carbohydrates": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};get_eatme('get_carbohydrates', _('get carbs'));",
+ "get_fiber": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};get_eatme('get_fiber', _('get fiber'));",
+ "get_fat": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};get_eatme('get_fat', _('get fat'));",
+ "get_name": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};get_eatme('get_name', _('get name'));",
+ "calories": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};show_value('calories', _('calories'));",
+ "protein": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};show_value('protein', _('protein'));",
+ "carbohydrates": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};show_value('carbohydrates', _('carbs'));",
+ "fiber": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};show_value('fiber', _('fiber'));",
+ "fat": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};show_value('fat', _('fat'));",
+ "eat": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};eat('eat', _('eat'));",
+ "digest": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};action('digest', _('digest meal'), 20);",
+ "apple": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('apple', _('apple'));",
+ "banana": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('banana', _('banana'));",
+ "orange": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('orange', _('orange'));",
+ "bread": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('bread', _('wheat bread'));",
+ "corn": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('corn', _('corn'));",
+ "potato": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('potato', _('potato'));",
+ "sweetpotato": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('sweetpotato', _('sweet potato'));",
+ "tomato": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('tomato', _('tomato'));",
+ "broccoli": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('broccoli', _('broccoli'));",
+ "riceandbeans": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('riceandbeans', _('rice and beans'));",
+ "tamale": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('tamale', _('tamale'));",
+ "cheese": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('cheese', _('cheese'));",
+ "chicken": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('chicken', _('chicken'));",
+ "fish": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('fish', _('fish'));",
+ "beef": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('beef', _('beef'));",
+ "cake": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('cake', _('cake'));",
+ "cookie": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('cookie', _('cookie'));",
+ "water": "const get_eatme = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};const show_value = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};const eat = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};const action = function (name, label) { const block = new ProtoBlock(name); block.palette = globalActivity.palettes.dict['eatme']; globalActivity.blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};const food_block = function (blkname, name) { const block = new ProtoBlock(blkname); block.palette = globalActivity.palettes.dict['food']; globalActivity.blocks.protoBlockDict[blkname] = block; block.image = globalActivity.pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock();};food_block('water', _('water'));"
+ },
"PARAMETERPLUGINS": {
- "protein": "value = nutritionProtein;",
- "fiber": "value = nutritionFiber;",
- "carbohydrates": "value = nutritionCarbohydrates;",
- "fat": "value = nutritionFat;",
- "calories )": "value = nutritionCalories;"
- },
- "GLOBALS": "nutritionCalories = 0;nutritionProtein = 0;nutritionCarbohydrate = 0;nutritionFiber = 0;nutritionFat = 0;nutritionFoodData = { 'apple': [72, 0, 19, 3, 0], 'banana': [105, 1, 27, 3, 0], 'orange': [62, 1, 15, 3, 0], 'bread': [69, 4, 12, 2, 1], 'corn': [96, 3, 21, 3, 1], 'potato': [159, 4, 36, 4, 0], 'sweetpotato': [169, 1, 22, 1, 8], 'tomato': [150, 4, 25, 3, 5], 'broccoli': [94, 4, 11, 5, 5], 'riceandbeans': [411, 14, 60, 8, 13], 'tamale': [126, 6, 11, 1, 6], 'cheese': [114, 7, 0, 0, 9], 'chicken': [152, 15, 0, 0, 10], 'fish': [58, 6, 0, 0, 3], 'beef': [285, 46, 0, 0, 10], 'cake': [387, 4, 69, 2, 13], 'cookie': [68, 1, 8, 0, 4], 'water': [0, 0, 0, 0, 0]};",
- "PALETTEHIGHLIGHTCOLORS": {
- "food": "#FFFFFF",
- "eatme": "#FFFFFF"
- },
+ "calories )": "value = globalActivity.logo.pluginVars['nutrition']['calories'];",
+ "protein": "value = globalActivity.logo.pluginVars['nutrition']['protein'];",
+ "carbohydrates": "value = globalActivity.logo.pluginVars['nutrition']['carbohydrates'];",
+ "fiber": "value = globalActivity.logo.pluginVars['nutrition']['fiber'];",
+ "fat": "value = globalActivity.logo.pluginVars['nutrition']['fat'];"
+ },
"FLOWPLUGINS": {
- "tomato": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "tamale": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "beef": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "apple": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "fish": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "potato": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "corn": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "eat": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};console.log();var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];nutritionCalories += blockFoodData[0];nutritionProtein += blockFoodData[1];nutritionCarbohydrate += blockFoodData[2];nutritionFiber += blockFoodData[3];nutritionFat += blockFoodData[4];",
- "broccoli": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "water": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "cake": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "cookie": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "sweetpotato": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "riceandbeans": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "orange": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "chicken": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "cheese": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "banana": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);",
- "digest": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};nutritionCalories = 0;nutritionProtein = 0;nutritionCarbohydrate = 0;nutritionFiber = 0;nutritionFat = 0;",
- "bread": "var block = logo.blocks.blockList[blk];var conns = block.connections;function showMsg(data) { logo.textMsg(JSON.stringify(data));};block.value = nutritionFoodData[block.name];showMsg(block.value);"
- },
+ "apple": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "banana": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "orange": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "bread": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "corn": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "potato": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "sweetpotato": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "tomato": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "broccoli": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "riceandbeans": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "tamale": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "cheese": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "chicken": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "fish": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "beef": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "cake": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "cookie": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "water": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];showMsg(nutritionBlock.value);",
+ "eat": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];globalActivity.logo.pluginVars['nutrition']['calories'] += blockFoodData[0];globalActivity.logo.pluginVars['nutrition']['protein'] += blockFoodData[1];globalActivity.logo.pluginVars['nutrition']['carbohydrate'] += blockFoodData[2];globalActivity.logo.pluginVars['nutrition']['fiber'] += blockFoodData[3];globalActivity.logo.pluginVars['nutrition']['fat'] += blockFoodData[4];",
+ "digest": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const showMsg = function (data) { globalActivity.textMsg(JSON.stringify(data));};globalActivity.logo.pluginVars['nutrition']['calories'] = 0;globalActivity.logo.pluginVars['nutrition']['protein'] = 0;globalActivity.logo.pluginVars['nutrition']['carbohydrate'] = 0;globalActivity.logo.pluginVars['nutrition']['fiber'] = 0;globalActivity.logo.pluginVars['nutrition']['fat'] = 0;"
+ },
+ "ARGPLUGINS": {
+ "fiber": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['fiber'];",
+ "calories": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['calories'];",
+ "protein": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['protein'];",
+ "carbohydrates": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['carbohydrate'];",
+ "fat": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['fat'];",
+ "get_calories": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];nutritionBlock.value = blockFoodData[0];",
+ "get_protein": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];nutritionBlock.value = blockFoodData[1];",
+ "get_carbohydrates": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];nutritionBlock.value = blockFoodData[2];",
+ "get_fiber": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];nutritionBlock.value = blockFoodData[3];",
+ "get_fat": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];nutritionBlock.value = blockFoodData[4];",
+ "get_name": "const nutritionBlock = globalActivity.blocks.blockList[blk];const conns = nutritionBlock.connections;nutritionBlock.value = globalActivity.blocks.blockList[conns[1]].name;"
+ },
"PALETTEPLUGINS": {
- "food": "
",
- "eatme": "
"
- },
- "IMAGES": {
- "tomato": "data:image/svg+xml;utf8,
",
- "cheese": "data:image/svg+xml;utf8,
",
- "tamale": "data:image/svg+xml;utf8,
",
- "apple": "data:image/svg+xml;utf8,
",
- "beef": "data:image/svg+xml;utf8,
",
- "potato": "data:image/svg+xml;utf8,
",
- "corn": "data:image/svg+xml;utf8,
",
- "banana": "data:image/svg+xml;utf8,
",
- "water": "data:image/svg+xml;utf8,
",
- "cake": "data:image/svg+xml;utf8,
",
- "fish": "data:image/svg+xml;utf8,
",
- "cookie": "data:image/svg+xml;utf8,
",
- "sweetpotato": "data:image/svg+xml;utf8,
",
- "riceandbeans": "data:image/svg+xml;utf8,
",
- "orange": "data:image/svg+xml;utf8,
",
- "chicken": "data:image/svg+xml;utf8,
",
- "egg": "data:image/svg+xml;utf8,
",
- "broccoli": "data:image/svg+xml;utf8,
",
- "bread": "data:image/svg+xml;utf8,
"
- },
- "BLOCKPLUGINS": {
- "cheese": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('cheese', _('cheese'));",
- "apple": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('apple', _('apple'));",
- "get_fat": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};get_eatme('get_fat', _('get fat'));",
- "fish": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('fish', _('fish'));",
- "get_calories": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};get_eatme('get_calories', _('get calories'));",
- "protein": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};show_value('protein', _('protein'));",
- "chicken": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('chicken', _('chicken'));",
- "digest": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};action('digest', _('digest meal'), 20);",
- "get_fiber": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};get_eatme('get_fiber', _('get fiber'));",
- "carbohydrates": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};show_value('carbohydrates', _('carbs'));",
- "eat": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};eat('eat', _('eat'));",
- "riceandbeans": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('riceandbeans', _('rice and beans'));",
- "orange": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('orange', _('orange'));",
- "banana": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('banana', _('banana'));",
- "tamale": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('tamale', _('tamale'));",
- "fiber": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};show_value('fiber', _('fiber'));",
- "corn": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('corn', _('corn'));",
- "fat": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};show_value('fat', _('fat'));",
- "get_carbohydrates": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};get_eatme('get_carbohydrates', _('get carbs'));",
- "water": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('water', _('water'));",
- "cookie": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('cookie', _('cookie'));",
- "sweetpotato": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('sweetpotato', _('sweet potato'));",
- "broccoli": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('broccoli', _('broccoli'));",
- "bread": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('bread', _('wheat bread'));",
- "tomato": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('tomato', _('tomato'));",
- "beef": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('beef', _('beef'));",
- "potato": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('potato', _('potato'));",
- "calories": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};show_value('calories', _('calories'));",
- "get_name": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};get_eatme('get_name', _('get name'));",
- "cake": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};food_block('cake', _('cake'));",
- "get_protein": "var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain';};var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock();};var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain';};var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock();};var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block;};get_eatme('get_protein', _('get protein'));"
- },
+ "food": "
",
+ "eatme": "
"
+ },
"PALETTEFILLCOLORS": {
- "food": "#D5D5D5",
+ "food": "#D5D5D5",
"eatme": "#D5D5D5"
- },
+ },
"PALETTESTROKECOLORS": {
- "food": "#A0A0A0",
+ "food": "#A0A0A0",
"eatme": "#A0A0A0"
+ },
+ "PALETTEHIGHLIGHTCOLORS": {
+ "food": "#E0E0E0",
+ "eatme": "#E0E0E0"
+ },
+ "HIGHLIGHTSTROKECOLORS": {
+ "food": "#808080",
+ "eatme": "#808080"
+ },
+ "IMAGES": {
+ "egg": "
",
+ "orange": "
",
+ "tomato": "
",
+ "sweetpotato": "
",
+ "broccoli": "
",
+ "apple": "
",
+ "cookie": "
",
+ "corn": "
",
+ "water": "
",
+ "beef": "
",
+ "cake": "
",
+ "potato": "
",
+ "fish": "
",
+ "bread": "
",
+ "banana": "
",
+ "cheese": "
",
+ "chicken": "
",
+ "tamale": "
",
+ "riceandbeans": "
"
}
-}
+}
\ No newline at end of file
diff --git a/plugins/nutrition.rtp b/plugins/nutrition.rtp
old mode 100755
new mode 100644
index c26645c7ee..e299808ad7
--- a/plugins/nutrition.rtp
+++ b/plugins/nutrition.rtp
@@ -15,89 +15,89 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
.
-TODO: description
-
//* globals *//
-var nutritionCalories = 0;
-var nutritionProtein = 0;
-var nutritionCarbohydrate = 0;
-var nutritionFiber = 0;
-var nutritionFat = 0;
-var nutritionFoodData = {
- 'apple': [72, 0, 19, 3, 0],
- 'banana': [105, 1, 27, 3, 0],
- 'orange': [62, 1, 15, 3, 0],
- 'bread': [69, 4, 12, 2, 1],
- 'corn': [96, 3, 21, 3, 1],
- 'potato': [159, 4, 36, 4, 0],
- 'sweetpotato': [169, 1, 22, 1, 8],
- 'tomato': [150, 4, 25, 3, 5],
- 'broccoli': [94, 4, 11, 5, 5],
- 'riceandbeans': [411, 14, 60, 8, 13],
- 'tamale': [126, 6, 11, 1, 6],
- 'cheese': [114, 7, 0, 0, 9],
- 'chicken': [152, 15, 0, 0, 10],
- 'fish': [58, 6, 0, 0, 3],
- 'beef': [285, 46, 0, 0, 10],
- 'cake': [387, 4, 69, 2, 13],
- 'cookie': [68, 1, 8, 0, 4],
- 'water': [0, 0, 0, 0, 0]
+globalActivity.logo.pluginVars['nutrition'] = {
+ 'calories': 0,
+ 'protein': 0,
+ 'carbohydrate': 0,
+ 'fiber': 0,
+ 'fat': 0,
+ 'foodData': {
+ 'apple': [72, 0, 19, 3, 0],
+ 'banana': [105, 1, 27, 3, 0],
+ 'orange': [62, 1, 15, 3, 0],
+ 'bread': [69, 4, 12, 2, 1],
+ 'corn': [96, 3, 21, 3, 1],
+ 'potato': [159, 4, 36, 4, 0],
+ 'sweetpotato': [169, 1, 22, 1, 8],
+ 'tomato': [150, 4, 25, 3, 5],
+ 'broccoli': [94, 4, 11, 5, 5],
+ 'riceandbeans': [411, 14, 60, 8, 13],
+ 'tamale': [126, 6, 11, 1, 6],
+ 'cheese': [114, 7, 0, 0, 9],
+ 'chicken': [152, 15, 0, 0, 10],
+ 'fish': [58, 6, 0, 0, 3],
+ 'beef': [285, 46, 0, 0, 10],
+ 'cake': [387, 4, 69, 2, 13],
+ 'cookie': [68, 1, 8, 0, 4],
+ 'water': [0, 0, 0, 0, 0]
+ }
};
//* flow-globals *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
-function showMsg(data) {
- logo.textMsg(JSON.stringify(data));
+const nutritionBlock = globalActivity.blocks.blockList[blk];
+const conns = nutritionBlock.connections;
+const showMsg = function (data) {
+ globalActivity.textMsg(JSON.stringify(data));
};
//* arg-globals *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
+const nutritionBlock = globalActivity.blocks.blockList[blk];
+const conns = nutritionBlock.connections;
//* block-globals *//
-var get_eatme = function (name, label) {
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['eatme'];
- blocks.protoBlockDict[name] = block;
+const get_eatme = function (name, label) {
+ const block = new ProtoBlock(name);
+ block.palette = globalActivity.palettes.dict['eatme'];
+ globalActivity.blocks.protoBlockDict[name] = block;
block.staticLabels.push(label);
block.adjustWidthToLabel();
block.oneArgMathBlock();
block.dockTypes[1] = 'mediain';
};
-var show_value = function (name, label) {
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['eatme'];
- blocks.protoBlockDict[name] = block;
+const show_value = function (name, label) {
+ const block = new ProtoBlock(name);
+ block.palette = globalActivity.palettes.dict['eatme'];
+ globalActivity.blocks.protoBlockDict[name] = block;
block.staticLabels.push(label);
block.adjustWidthToLabel();
block.parameterBlock();
};
-var eat = function (name, label) {
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['eatme'];
- blocks.protoBlockDict[name] = block;
+const eat = function (name, label) {
+ const block = new ProtoBlock(name);
+ block.palette = globalActivity.palettes.dict['eatme'];
+ globalActivity.blocks.protoBlockDict[name] = block;
block.staticLabels.push(label);
block.adjustWidthToLabel();
block.oneArgBlock();
block.dockTypes[1] = 'mediain';
};
-var action = function (name, label) {
- var block = new ProtoBlock(name);
- block.palette = palettes.dict['eatme'];
- blocks.protoBlockDict[name] = block;
+const action = function (name, label) {
+ const block = new ProtoBlock(name);
+ block.palette = globalActivity.palettes.dict['eatme'];
+ globalActivity.blocks.protoBlockDict[name] = block;
block.staticLabels.push(label);
block.adjustWidthToLabel();
block.zeroArgBlock();
};
-var food_block = function (blkname, name) {
- var block = new ProtoBlock(blkname);
- block.palette = palettes.dict['food'];
- block.image = pluginsImages[blkname];
+const food_block = function (blkname, name) {
+ const block = new ProtoBlock(blkname);
+ block.palette = globalActivity.palettes.dict['food'];
+ globalActivity.blocks.protoBlockDict[blkname] = block;
+ block.image = globalActivity.pluginsImages[blkname];
block.staticLabels.push(name);
block.adjustWidthToLabel();
block.mediaBlock();
- blocks.protoBlockDict[blkname] = block;
};
//* block:get_calories *//
@@ -122,31 +122,31 @@ get_eatme('get_name', _('get name'));
show_value('calories', _('calories'));
//* parameter:calories )*//
-value = nutritionCalories;
+value = globalActivity.logo.pluginVars['nutrition']['calories'];
//* block:protein *//
show_value('protein', _('protein'));
//* parameter:protein *//
-value = nutritionProtein;
+value = globalActivity.logo.pluginVars['nutrition']['protein'];
//* block:carbohydrates *//
show_value('carbohydrates', _('carbs'));
//* parameter:carbohydrates *//
-value = nutritionCarbohydrates;
+value = globalActivity.logo.pluginVars['nutrition']['carbohydrates'];
//* block:fiber *//
show_value('fiber', _('fiber'));
//* parameter:fiber *//
-value = nutritionFiber;
+value = globalActivity.logo.pluginVars['nutrition']['fiber'];
//* block:fat *//
show_value('fat', _('fat'));
//* parameter:fat *//
-value = nutritionFat;
+value = globalActivity.logo.pluginVars['nutrition']['fat'];
//* block:eat *//
eat('eat', _('eat'));
@@ -209,217 +209,199 @@ food_block('cookie', _('cookie'));
food_block('water', _('water'));
//* flow:apple *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:banana *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:orange *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:bread *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:corn *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:potato *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:sweetpotato *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:tomato *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:broccoli *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:riceandbeans *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:tamale *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:cheese *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:chicken *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:fish *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:beef *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:cake *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:cookie *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:water *//
-block.value = nutritionFoodData[block.name];
-showMsg(block.value);
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['foodData'][block.name];
+showMsg(nutritionBlock.value);
//* flow:eat *//
-console.log();
-var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];
-nutritionCalories += blockFoodData[0];
-nutritionProtein += blockFoodData[1];
-nutritionCarbohydrate += blockFoodData[2];
-nutritionFiber += blockFoodData[3];
-nutritionFat += blockFoodData[4];
+const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];
+globalActivity.logo.pluginVars['nutrition']['calories'] += blockFoodData[0];
+globalActivity.logo.pluginVars['nutrition']['protein'] += blockFoodData[1];
+globalActivity.logo.pluginVars['nutrition']['carbohydrate'] += blockFoodData[2];
+globalActivity.logo.pluginVars['nutrition']['fiber'] += blockFoodData[3];
+globalActivity.logo.pluginVars['nutrition']['fat'] += blockFoodData[4];
//* flow:digest *//
-nutritionCalories = 0;
-nutritionProtein = 0;
-nutritionCarbohydrate = 0;
-nutritionFiber = 0;
-nutritionFat = 0;
+globalActivity.logo.pluginVars['nutrition']['calories'] = 0;
+globalActivity.logo.pluginVars['nutrition']['protein'] = 0;
+globalActivity.logo.pluginVars['nutrition']['carbohydrate'] = 0;
+globalActivity.logo.pluginVars['nutrition']['fiber'] = 0;
+globalActivity.logo.pluginVars['nutrition']['fat'] = 0;
//* arg:fiber *//
-block.value = nutritionFiber;
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['fiber'];
//* arg:calories *//
-block.value = nutritionCalories;
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['calories'];
//* arg:protein *//
-block.value = nutritionProtein;
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['protein'];
//* arg:carbohydrates *//
-block.value = nutritionCarbohydrate;
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['carbohydrate'];
//* arg:fat *//
-block.value = nutritionFat;
+nutritionBlock.value = globalActivity.logo.pluginVars['nutrition']['fat'];
//* arg:get_calories *//
-var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];
-block.value = blockFoodData[0];
+const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];
+nutritionBlock.value = blockFoodData[0];
//* arg:get_protein *//
-var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];
-block.value = blockFoodData[1];
+const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];
+nutritionBlock.value = blockFoodData[1];
//* arg:get_carbohydrates *//
-var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];
-block.value = blockFoodData[2];
+const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];
+nutritionBlock.value = blockFoodData[2];
//* arg:get_fiber *//
-var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];
-block.value = blockFoodData[3];
+const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];
+nutritionBlock.value = blockFoodData[3];
//* arg:get_fat *//
-var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name];
-block.value = blockFoodData[4];
+const blockFoodData = globalActivity.logo.pluginVars['nutrition']['foodData'][globalActivity.blocks.blockList[conns[1]].name];
+nutritionBlock.value = blockFoodData[4];
//* arg:get_name *//
-block.value = logo.blocks.blockList[conns[1]].name;
+nutritionBlock.value = globalActivity.blocks.blockList[conns[1]].name;
//* palette-icon:food *//
-
+
+
//* palette-fill:food *// #D5D5D5
//* palette-stroke:food *// #A0A0A0
-//* palette-highlight:food *// #FFFFFF
-//* palette-stroke-highlight:food *// #000000
-
+//* palette-highlight:food *// #E0E0E0
+//* palette-stroke-highlight:food *// #808080
//* palette-icon:eatme *//
-
+
+
//* palette-fill:eatme *// #D5D5D5
//* palette-stroke:eatme *// #A0A0A0
-//* palette-highlight:eatme *// #FFFFFF
-//* palette-stroke-highlight:eatme *// #000000
+//* palette-highlight:eatme *// #E0E0E0
+//* palette-stroke-highlight:eatme *// #808080
//* image:egg *//
-
-
+
//* image:orange *//
-
-
+
//* image:tomato *//
-
-
+
//* image:sweetpotato *//
-
-
+
//* image:broccoli *//
-
-
+
//* image:apple *//
-
-
+
//* image:cookie *//
-
-
+
//* image:corn *//
-
-
+
//* image:water *//
-
-
+
//* image:beef *//
-
-
+
//* image:cake *//
-
-
+
//* image:potato *//
-
-
+
//* image:fish *//
-
-
+
//* image:bread *//
-
-
+
//* image:banana *//
-
-
+
//* image:cheese *//
-
-
+
//* image:chicken *//
-
-
+
//* image:tamale *//
-
-
+
//* image:riceandbeans *//
-
+
diff --git a/pluginify.py b/plugins/pluginify.py
similarity index 98%
rename from pluginify.py
rename to plugins/pluginify.py
index 02684bdb6f..b6ddbf29a9 100755
--- a/pluginify.py
+++ b/plugins/pluginify.py
@@ -171,7 +171,8 @@ def pluginify(data):
if type_ == 'image':
# TODO: Detect if its png
- IMAGES[name] = 'data:image/svg+xml;utf8,' + value
+ # Assume for now it is SVG.
+ IMAGES[name] = value # 'data:image/svg+xml;utf8,' + value
if IMAGES:
outp['IMAGES'] = IMAGES
diff --git a/plugins/rodi.json b/plugins/rodi.json
old mode 100755
new mode 100644
index 3c9bea9f86..d8be0d18ae
--- a/plugins/rodi.json
+++ b/plugins/rodi.json
@@ -1,54 +1,54 @@
{
- "HIGHLIGHTSTROKECOLORS": {
- "rodi": "#000000"
- },
- "ARGPLUGINS": {
- "rodisenseleft": "var block = logo.blocks.blockList[blk];block.value = doRodiGetSensor(logo, blk, 0);",
- "rodisee": "var block = logo.blocks.blockList[blk];block.value = doRodiGetDistance(logo, blk);",
- "rodisenselight": "var block = logo.blocks.blockList[blk];block.value = doRodiGetLightSensor(blk);var apiUrl = RODI_BASE_URL + '/7/';doAsyncCall(logo, blk, apiUrl);",
- "rodisenseright": "var block = logo.blocks.blockList[blk];block.value = doRodiGetSensor(logo, blk, 1);",
- "rodimovestatus": "var block = logo.blocks.blockList[blk];block.value = doRodiGetMoveStatus(logo, blk);"
- },
- "GLOBALS": "RODI_BASE_URL = 'http://192.168.4.1:1234';rodiSensorsCache = null;rodiSensorsValidFor = 100;rodiSensorsCacheExpires = 0;rodiLightSensorCache = null;rodiLightSensorValidFor = 100;rodiLightSensorCacheExpires = 0;rodiMoveStatus = _('stop');rodiDistanceCache = null;rodiDistanceValidFor = 100;rodiDistanceCacheExpires = 0;doRodiGetDistance = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { if (Date.now() > rodiDistanceCacheExpires) { apiUrl = RODI_BASE_URL + '/5/'; distance = doSyncCall(logo, blk, apiUrl); if (distance != null) { rodiDistanceCacheExpires = Date.now() + rodiDistanceValidFor; rodiDistanceCache = distance; return distance; } else { return 100; } } else { return rodiDistanceCache; } }};doRodiGetMoveStatus = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { return rodiMoveStatus; }};doRodiMove = function (logo, blk, left, right) { apiUrl = RODI_BASE_URL + '/3/' + left + '/' + right + '/'; if (left === right) { if (left < 0) { rodiMoveStatus = _('back'); } else if (left > 0) { rodiMoveStatus = _('forward'); } else { rodiMoveStatus = _('stop'); } } else { if (left > right) { rodiMoveStatus = _('right'); } else { rodiMoveStatus = _('left'); } } doAsyncCall(logo, blk, apiUrl)};doRodiGetSensor = function (logo, blk, index) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { if (Date.now() > rodiSensorsCacheExpires) { apiUrl = RODI_BASE_URL + '/2/'; sensors = doSyncCall(logo, blk, apiUrl); if (sensors != null) { rodiSensorsCacheExpires = Date.now() + rodiSensorsValidFor; rodiSensorsCache = sensors; return sensors[index]; } else { return -1; } } else { return rodiSensorsCache[index]; } }};doRodiGetLightSensor = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { if (Date.now() > rodiLightSensorCacheExpires) { apiUrl = RODI_BASE_URL + '/7/'; sensor = doSyncCall(logo, apiUrl); if (sensor != null) { rodiLightSensorCacheExpires = Date.now() + rodiLightSensorValidFor; rodiLightSensorCache = sensor; return sensor; } else { return -1; } } else { return rodiLightSensorCache; } }};doAsyncCall = function (logo, blk, url){ console.log(url); try { request = new XMLHttpRequest(); request.open('GET', url, true); request.send(null); } catch (e) { if (logo != null) { logo.errorMsg(e, blk); } console.log(e); }};doSyncCall = function (logo, blk, url) { console.log(url); request = new XMLHttpRequest(); try { request.open('GET', url, false); request.send(null); return JSON.parse(request.responseText); } catch (e) { if (logo != null) { logo.errorMsg(e, blk); } console.log(e); return null; }};function doRodiStop(){ doRodiMove(null, null, 0, 0);};blocks.logo.stage.addEventListener('__STOP__', doRodiStop, false);",
- "PALETTEHIGHLIGHTCOLORS": {
- "rodi": "#ced8f8"
- },
+ "GLOBALS": "globalActivity.logo.pluginVars['rodi'] = { 'RODI_BASE_URL': 'http://192.168.4.1:1234', 'sensorsCache': null, 'sensorsValidFor': 100, 'sensorsCacheExpires': 0, 'lightSensorCache': null, 'lightSensorValidFor': 100, 'lightSensorCacheExpires': 0, 'moveStatus': _('stop'), 'distanceCache': null, 'distanceValidFor': 100, 'distanceCacheExpires': 0};globalActivity.logo.pluginVars['rodi']['doRodiGetDistance'] = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]); } else { if (Date.now() > logo.pluginVars['rodi']['distanceCacheExpires']) { const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/5/'; const distance = logo.pluginVars['rodi']['doSyncCall'](logo, blk, apiUrl); if (distance !== null) { logo.pluginVars['rodi']['distanceCacheExpires'] = Date.now() + logo.pluginVars['rodi']['distanceValidFor']; logo.pluginVars['rodi']['distanceCache'] = distance; return distance; } else { return 100; } } else { return logo.pluginVars['rodi']['distanceCache']; } }};globalActivity.logo.pluginVars['rodi']['doRodiGetMoveStatus'] = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]); } else { return logo.pluginVars['rodi']['moveStatus']; }};globalActivity.logo.pluginVars['rodi']['doRodiMove'] = function (logo, blk, left, right) { const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/3/' + left + '/' + right + '/'; if (left === right) { if (left < 0) { logo.pluginVars['rodi']['moveStatus'] = _('back'); } else if (left > 0) { logo.pluginVars['rodi']['moveStatus'] = _('forward'); } else { logo.pluginVars['rodi']['moveStatus'] = _('stop'); } } else { if (left > right) { logo.pluginVars['rodi']['moveStatus'] = _('right'); } else { logo.pluginVars['rodi']['moveStatus'] = _('left'); } } logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl)};globalActivity.logo.pluginVars['rodi']['doRodiGetSensor'] = function (logo, blk, index) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]); } else { if (Date.now() > logo.pluginVars['rodi']['sensorsCacheExpires']) { const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/2/'; const sensors = logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl); if (sensors != null) { logo.pluginVars['rodi']['sensorsCacheExpires'] = Date.now() + logo.pluginVars['rodi']['sensorsValidFor']; logo.pluginVars['rodi']['sensorsCache'] = sensors; return sensors[index]; } else { return -1; } } else { return logo.pluginVars['rodi']['sensorsCache'][index]; } }};globalActivity.logo.pluginVars['rodi']['doRodiGetLightSensor'] = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]); } else { if (Date.now() > logo.pluginVars['rodi']['lightSensorCacheExpires']) { const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/7/'; const sensor = logo.pluginVars['rodi']['doSyncCall'](logo, apiUrl); if (sensor != null) { logo.pluginVars['rodi']['lightSensorCacheExpires'] = Date.now() + logo.pluginVars['rodi']['lightSensorValidFor']; logo.pluginVars['rodi']['lightSensorCache'] = sensor; return sensor; } else { return -1; } } else { return logo.pluginVars['rodi']['lightSensorCache']; } }};globalActivity.logo.pluginVars['rodi']['doAsyncCall'] = function (logo, blk, url) { globalActivity.textMsg(url); try { const request = new XMLHttpRequest(); request.open('GET', url, true); request.send(null); } catch (e) { if (logo !== null) { activity.errorMsg(e, blk); } activity.errorMsg(e); }};globalActivity.logo.pluginVars['rodi']['doSyncCall'] = function (logo, blk, url) { globalActivity.textMsg(url); const request = new XMLHttpRequest(); try { request.open('GET', url, false); request.send(null); return JSON.parse(request.responseText); } catch (e) { if (logo != null) { globalActivity.errorMsg(e, blk); } globalActivity.errorMsg(e); return null; }};globalActivity.logo.pluginVars['rodi']['doRodiStop'] = function () { globalActivity.logo.pluginVars['rodi']['doRodiMove'](null, null, 0, 0);};globalActivity.stage.addEventListener('__STOP__', globalActivity.logo.pluginVars['rodi']['doRodiStop'], false);",
+ "BLOCKPLUGINS": {
+ "rodiblink": "const rodiBlink = new ProtoBlock('rodiblink');rodiBlink.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodiblink'] = rodiBlink;rodiBlink.staticLabels.push(_('blink'));rodiBlink.adjustWidthToLabel();rodiBlink.oneArgBlock();rodiBlink.defaults.push(1000);",
+ "rodising": "const rodiSing = new ProtoBlock('rodising');rodiSing.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodising'] = rodiSing;rodiSing.staticLabels.push(_('play'));rodiSing.staticLabels.push(_('note'));rodiSing.staticLabels.push(_('duration'));rodiSing.adjustWidthToLabel();rodiSing.twoArgBlock();rodiSing.dockTypes[1] = 'numberin';rodiSing.dockTypes[2] = 'numberin';rodiSing.defaults.push(31);rodiSing.defaults.push(250);",
+ "rodipixel": "const rodiPixel = new ProtoBlock('rodipixel');rodiPixel.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodipixel'] = rodiPixel;rodiPixel.staticLabels.push(_('pixel color'));rodiPixel.staticLabels.push(_('red'));rodiPixel.staticLabels.push(_('green'));rodiPixel.staticLabels.push(_('blue'));rodiPixel.adjustWidthToLabel();rodiPixel.threeArgBlock();rodiPixel.dockTypes[1] = 'numberin';rodiPixel.dockTypes[2] = 'numberin';rodiPixel.dockTypes[3] = 'numberin';rodiPixel.defaults.push(0);rodiPixel.defaults.push(0);rodiPixel.defaults.push(0);",
+ "rodiled": "const rodiLed = new ProtoBlock('rodiled');rodiLed.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodiled'] = rodiLed;rodiLed.staticLabels.push(_('led'));rodiLed.adjustWidthToLabel();rodiLed.oneArgBlock();rodiLed.defaults.push(1);",
+ "rodisenselight": "var rodiSenseLight = new ProtoBlock('rodisenselight');rodiSenseLight.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodisenselight'] = rodiSenseLight;rodiSenseLight.staticLabels.push(_('light intensity'));rodiSenseLight.adjustWidthToLabel();rodiSenseLight.parameterBlock();",
+ "rodisenseleft": "const rodiSenseLeft = new ProtoBlock('rodisenseleft');rodiSenseLeft.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodisenseleft'] = rodiSenseLeft;rodiSenseLeft.staticLabels.push(_('infrared light (left)'));rodiSenseLeft.adjustWidthToLabel();rodiSenseLeft.parameterBlock();",
+ "rodisenseright": "const rodiSenseRight = new ProtoBlock('rodisenseright');rodiSenseRight.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodisenseright'] = rodiSenseRight;rodiSenseRight.staticLabels.push(_('infrared light (right)'));rodiSenseRight.adjustWidthToLabel();rodiSenseRight.parameterBlock();",
+ "rodisee": "const rodiSee = new ProtoBlock('rodisee');rodiSee.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodisee'] = rodiSee;rodiSee.staticLabels.push(_('distance'));rodiSee.adjustWidthToLabel();rodiSee.parameterBlock();",
+ "rodimovestatus": "const rodiMoveStatus = new ProtoBlock('rodimovestatus');rodiMoveStatus.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodimovestatus'] = rodiMoveStatus;rodiMoveStatus.staticLabels.push(_('status'));rodiMoveStatus.adjustWidthToLabel();rodiMoveStatus.parameterBlock();",
+ "rodimove": "const rodiMove = new ProtoBlock('rodimove');rodiMove.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodimove'] = rodiMove;rodiMove.staticLabels.push(_('move'));rodiMove.staticLabels.push(_('left'));rodiMove.staticLabels.push(_('right'));rodiMove.adjustWidthToLabel();rodiMove.twoArgBlock();rodiMove.dockTypes[1] = 'numberin';rodiMove.dockTypes[2] = 'numberin';rodiMove.defaults.push(100);rodiMove.defaults.push(100);",
+ "rodileft": "const rodiLeft = new ProtoBlock('rodileft');rodiLeft.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodileft'] = rodiLeft;rodiLeft.staticLabels.push(_('left'));rodiLeft.adjustWidthToLabel();rodiLeft.zeroArgBlock();",
+ "rodiright": "const rodiRight = new ProtoBlock('rodiright');rodiRight.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodiright'] = rodiRight;rodiRight.staticLabels.push(_('right'));rodiRight.adjustWidthToLabel();rodiRight.zeroArgBlock();",
+ "rodiback": "const rodiBack = new ProtoBlock('rodiback');rodiBack.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodiback'] = rodiBack;rodiBack.staticLabels.push(_('back'));rodiBack.adjustWidthToLabel();rodiBack.zeroArgBlock();",
+ "rodiforward": "const rodiForward = new ProtoBlock('rodiforward');rodiForward.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodiforward'] = rodiForward;rodiForward.staticLabels.push(_('forward'));rodiForward.adjustWidthToLabel();rodiForward.zeroArgBlock();",
+ "rodistop": "const rodiStop = new ProtoBlock('rodistop');rodiStop.palette = globalActivity.palettes.dict['rodi'];globalActivity.blocks.protoBlockDict['rodistop'] = rodiStop;rodiStop.staticLabels.push(_('stop'));rodiStop.adjustWidthToLabel();rodiStop.zeroArgBlock();"
+ },
"FLOWPLUGINS": {
- "rodiforward": "doRodiMove(logo, blk, 100, 100);",
- "rodistop": "doRodiMove(logo, blk, 0, 0);",
- "rodiback": "doRodiMove(logo, blk, -100, -100);",
- "rodileft": "doRodiMove(logo, blk, -100, 100);",
- "rodiright": "doRodiMove(logo, blk, 100, -100);",
- "rodiled": "var block = logo.blocks.blockList[blk];var conns = block.connections;var state = logo.parseArg(logo, turtle, conns[1]);var apiUrl = RODI_BASE_URL + '/8/' + state + '/';doAsyncCall(logo, blk, apiUrl);",
- "rodising": "var block = logo.blocks.blockList[blk];var conns = block.connections;var note = logo.parseArg(logo, turtle, conns[1]);var duration = logo.parseArg(logo, turtle, conns[2]);var apiUrl = RODI_BASE_URL + '/4/' + note + '/' + duration + '/';doAsyncCall(logo, blk, apiUrl);",
- "rodimove": "var block = logo.blocks.blockList[blk];var conns = block.connections;var left = logo.parseArg(logo, turtle, conns[1]);var right = logo.parseArg(logo, turtle, conns[2]);doRodiMove(logo, blk, left, right);",
- "rodipixel": "var block = logo.blocks.blockList[blk];var conns = block.connections;var red = logo.parseArg(logo, turtle, conns[1]);var green = logo.parseArg(logo, turtle, conns[2]);var blue = logo.parseArg(logo, turtle, conns[3]);var apiUrl = RODI_BASE_URL + '/6/' + red + '/' + green + '/' + blue + '/';doAsyncCall(logo, blk, apiUrl);",
- "rodiblink": "var block = logo.blocks.blockList[blk];var conns = block.connections;var rate = logo.parseArg(logo, turtle, conns[1]);var apiUrl = RODI_BASE_URL + '/1/' + rate + '/';doAsyncCall(logo, blk, apiUrl);"
- },
+ "rodiblink": "const rodiBlock = globalActivity.blocks.blockList[blk];const conns = rodiBlock.connections;const rate = logo.parseArg(logo, turtle, conns[1]);const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/1/' + rate + '/';logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);",
+ "rodising": "const rodiBlock = globalActivity.blocks.blockList[blk];const conns = rodiBlock.connections;const note = logo.parseArg(logo, turtle, conns[1]);const duration = logo.parseArg(logo, turtle, conns[2]);const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/4/' + note + '/' + duration + '/';logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);",
+ "rodipixel": "const rodiBlock = globalActivity.blocks.blockList[blk];const conns = rodiBlock.connections;const red = logo.parseArg(logo, turtle, conns[1]);const green = logo.parseArg(logo, turtle, conns[2]);const blue = logo.parseArg(logo, turtle, conns[3]);const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/6/' + red + '/' + green + '/' + blue + '/';logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);",
+ "rodiled": "const rodiBlock = globalActivity.blocks.blockList[blk];const conns = rodiBlock.connections;const state = logo.parseArg(logo, turtle, conns[1]);const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/8/' + state + '/';logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);",
+ "rodimove": "const rodiBlock = globalActivity.blocks.blockList[blk];const conns = rodiBlock.connections;const left = logo.parseArg(logo, turtle, conns[1]);const right = logo.parseArg(logo, turtle, conns[2]);logo.pluginVars['rodi']['doRodiMove'](logo, blk, left, right);",
+ "rodileft": "logo.pluginVars['rodi']['doRodiMove'](logo, blk, -100, 100);",
+ "rodiright": "logo.pluginVars['rodi']['doRodiMove'](logo, blk, 100, -100);",
+ "rodiback": "logo.pluginVars['rodi']['doRodiMove'](logo, blk, -100, -100);",
+ "rodiforward": "logo.pluginVars['rodi']['doRodiMove'](logo, blk, 100, 100);",
+ "rodistop": "logo.pluginVars['rodi']['doRodiMove'](logo, blk, 0, 0);"
+ },
+ "ARGPLUGINS": {
+ "rodisenselight": "const rodiBlock = globalActivity.blocks.blockList[blk];rodiBlock.value = logo.pluginVars['rodi']['doRodiGetLightSensor'](blk);const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/7/';logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);",
+ "rodisenseleft": "const rodiblock = globalActivity.blocks.blockList[blk];rodiBlock.value = logo.pluginVars['rodi']['doRodiGetSensor'](logo, blk, 0);",
+ "rodisenseright": "const rodiBlock = globalActivity.blocks.blockList[blk];rodiBlock.value = logo.pluginVars['rodi']['doRodiGetSensor'](logo, blk, 1);",
+ "rodisee": "const rodiBlock = globalActivity.blocks.blockList[blk];rodiBlock.value = logo.pluginVars['rodi']['doRodiGetDistance'](logo, blk);",
+ "rodimovestatus": "const rodiBlock = globalActivity.blocks.blockList[blk];rodiBlock.value = logo.pluginVars['rodi']['doRodiGetMoveStatus'](logo, blk);"
+ },
"PALETTEPLUGINS": {
- "rodi": "
"
- },
- "BLOCKPLUGINS": {
- "rodising": "var rodiSing = new ProtoBlock('rodising');rodiSing.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodising'] = rodiSing;rodiSing.staticLabels.push(_('play'));rodiSing.staticLabels.push(_('note'));rodiSing.staticLabels.push(_('duration'));rodiSing.adjustWidthToLabel();rodiSing.twoArgBlock();rodiSing.dockTypes[1] = 'numberin';rodiSing.dockTypes[2] = 'numberin';rodiSing.defaults.push(31);rodiSing.defaults.push(250);",
- "rodipixel": "var rodiPixel = new ProtoBlock('rodipixel');rodiPixel.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodipixel'] = rodiPixel;rodiPixel.staticLabels.push(_('pixel color'));rodiPixel.staticLabels.push(_('red'));rodiPixel.staticLabels.push(_('green'));rodiPixel.staticLabels.push(_('blue'));rodiPixel.adjustWidthToLabel();rodiPixel.threeArgBlock();rodiPixel.dockTypes[1] = 'numberin';rodiPixel.dockTypes[2] = 'numberin';rodiPixel.dockTypes[3] = 'numberin';rodiPixel.defaults.push(0);rodiPixel.defaults.push(0);rodiPixel.defaults.push(0);",
- "rodiled": "var rodiLed = new ProtoBlock('rodiled');rodiLed.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiled'] = rodiLed;rodiLed.staticLabels.push(_('led'));rodiLed.adjustWidthToLabel();rodiLed.oneArgBlock();rodiLed.defaults.push(1);",
- "rodiblink": "var rodiBlink = new ProtoBlock('rodiblink');rodiBlink.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiblink'] = rodiBlink;rodiBlink.staticLabels.push(_('blink'));rodiBlink.adjustWidthToLabel();rodiBlink.oneArgBlock();rodiBlink.defaults.push(1000);",
- "rodisenseright": "var rodiSenseRight = new ProtoBlock('rodisenseright');rodiSenseRight.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisenseright'] = rodiSenseRight;rodiSenseRight.staticLabels.push(_('infrared light (right)'));rodiSenseRight.adjustWidthToLabel();rodiSenseRight.parameterBlock();",
- "rodisenseleft": "var rodiSenseLeft = new ProtoBlock('rodisenseleft');rodiSenseLeft.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisenseleft'] = rodiSenseLeft;rodiSenseLeft.staticLabels.push(_('infrared light (left)'));rodiSenseLeft.adjustWidthToLabel();rodiSenseLeft.parameterBlock();",
- "rodisenselight": "var rodiSenseLight = new ProtoBlock('rodisenselight');rodiSenseLight.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisenselight'] = rodiSenseLight;rodiSenseLight.staticLabels.push(_('light intensity'));rodiSenseLight.adjustWidthToLabel();rodiSenseLight.parameterBlock();",
- "rodisee": "var rodiSee = new ProtoBlock('rodisee');rodiSee.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisee'] = rodiSee;rodiSee.staticLabels.push(_('distance'));rodiSee.adjustWidthToLabel();rodiSee.parameterBlock();",
- "rodimovestatus": "var rodiMoveStatus = new ProtoBlock('rodimovestatus');rodiMoveStatus.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodimovestatus'] = rodiMoveStatus;rodiMoveStatus.staticLabels.push(_('status'));rodiMoveStatus.adjustWidthToLabel();rodiMoveStatus.parameterBlock();",
- "rodimove": "var rodiMove = new ProtoBlock('rodimove');rodiMove.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodimove'] = rodiMove;rodiMove.staticLabels.push(_('move'));rodiMove.staticLabels.push(_('left'));rodiMove.staticLabels.push(_('right'));rodiMove.adjustWidthToLabel();rodiMove.twoArgBlock();rodiMove.dockTypes[1] = 'numberin';rodiMove.dockTypes[2] = 'numberin';rodiMove.defaults.push(100);rodiMove.defaults.push(100);",
- "rodiright": "var rodiRight = new ProtoBlock('rodiright');rodiRight.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiright'] = rodiRight;rodiRight.staticLabels.push(_('right'));rodiRight.adjustWidthToLabel();rodiRight.zeroArgBlock();",
- "rodileft": "var rodiLeft = new ProtoBlock('rodileft');rodiLeft.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodileft'] = rodiLeft;rodiLeft.staticLabels.push(_('left'));rodiLeft.adjustWidthToLabel();rodiLeft.zeroArgBlock();",
- "rodiback": "var rodiBack = new ProtoBlock('rodiback');rodiBack.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiback'] = rodiBack;rodiBack.staticLabels.push(_('back'));rodiBack.adjustWidthToLabel();rodiBack.zeroArgBlock();",
- "rodiforward": "var rodiForward = new ProtoBlock('rodiforward');rodiForward.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiforward'] = rodiForward;rodiForward.staticLabels.push(_('forward'));rodiForward.adjustWidthToLabel();rodiForward.zeroArgBlock();",
- "rodistop": "var rodiStop = new ProtoBlock('rodistop');rodiStop.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodistop'] = rodiStop;rodiStop.staticLabels.push(_('stop'));rodiStop.adjustWidthToLabel();rodiStop.zeroArgBlock();"
- },
+ "rodi": "
"
+ },
"PALETTEFILLCOLORS": {
"rodi": "#6a8df6"
- },
+ },
"PALETTESTROKECOLORS": {
"rodi": "#5a7de6"
+ },
+ "PALETTEHIGHLIGHTCOLORS": {
+ "rodi": "#ced8f8"
+ },
+ "HIGHLIGHTSTROKECOLORS": {
+ "rodi": "#5a7de6"
}
-}
+}
\ No newline at end of file
diff --git a/plugins/rodi.rtp b/plugins/rodi.rtp
old mode 100755
new mode 100644
index d241675d2e..bb09df0b56
--- a/plugins/rodi.rtp
+++ b/plugins/rodi.rtp
@@ -1,6 +1,6 @@
//* comment *//
-Copyright (C) 2015, 2016 Walter Bender
+Copyright (C) 2015-16, 2021 Walter Bender
Copyright (C) 2015 Martin Abente Lahaye
This program is free software: you can redistribute it and/or modify
@@ -18,161 +18,157 @@ along with this program. If not, see
.
//* globals *//
-var RODI_BASE_URL = 'http://192.168.4.1:1234';
-
-var rodiSensorsCache = null;
-var rodiSensorsValidFor = 100;
-var rodiSensorsCacheExpires = 0;
-
-var rodiLightSensorCache = null;
-var rodiLightSensorValidFor = 100;
-var rodiLightSensorCacheExpires = 0;
-
-var rodiMoveStatus = _('stop');
-
-var rodiDistanceCache = null;
-var rodiDistanceValidFor = 100;
-var rodiDistanceCacheExpires = 0;
+globalActivity.logo.pluginVars['rodi'] = {
+ 'RODI_BASE_URL': 'http://192.168.4.1:1234',
+ 'sensorsCache': null,
+ 'sensorsValidFor': 100,
+ 'sensorsCacheExpires': 0,
+ 'lightSensorCache': null,
+ 'lightSensorValidFor': 100,
+ 'lightSensorCacheExpires': 0,
+ 'moveStatus': _('stop'),
+ 'distanceCache': null,
+ 'distanceValidFor': 100,
+ 'distanceCacheExpires': 0
+};
-var doRodiGetDistance = function (logo, blk) {
+globalActivity.logo.pluginVars['rodi']['doRodiGetDistance'] = function (logo, blk) {
if (logo.inStatusMatrix) {
- logo.statusFields.push([blk, logo.blocks.blockList[blk].name]);
+ logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]);
} else {
- if (Date.now() > rodiDistanceCacheExpires) {
+ if (Date.now() > logo.pluginVars['rodi']['distanceCacheExpires']) {
- var apiUrl = RODI_BASE_URL + '/5/';
- var distance = doSyncCall(logo, blk, apiUrl);
+ const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/5/';
+ const distance = logo.pluginVars['rodi']['doSyncCall'](logo, blk, apiUrl);
- if (distance != null) {
- rodiDistanceCacheExpires = Date.now() + rodiDistanceValidFor;
- rodiDistanceCache = distance;
+ if (distance !== null) {
+ logo.pluginVars['rodi']['distanceCacheExpires'] = Date.now() + logo.pluginVars['rodi']['distanceValidFor'];
+ logo.pluginVars['rodi']['distanceCache'] = distance;
return distance;
} else {
return 100;
}
} else {
- return rodiDistanceCache;
+ return logo.pluginVars['rodi']['distanceCache'];
}
}
};
-var doRodiGetMoveStatus = function (logo, blk) {
+globalActivity.logo.pluginVars['rodi']['doRodiGetMoveStatus'] = function (logo, blk) {
if (logo.inStatusMatrix) {
- logo.statusFields.push([blk, logo.blocks.blockList[blk].name]);
+ logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]);
} else {
- return rodiMoveStatus;
+ return logo.pluginVars['rodi']['moveStatus'];
}
};
-var doRodiMove = function (logo, blk, left, right) {
- var apiUrl = RODI_BASE_URL + '/3/' + left + '/' + right + '/';
+globalActivity.logo.pluginVars['rodi']['doRodiMove'] = function (logo, blk, left, right) {
+ const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/3/' + left + '/' + right + '/';
if (left === right) {
if (left < 0) {
- rodiMoveStatus = _('back');
+ logo.pluginVars['rodi']['moveStatus'] = _('back');
} else if (left > 0) {
- rodiMoveStatus = _('forward');
+ logo.pluginVars['rodi']['moveStatus'] = _('forward');
} else {
- rodiMoveStatus = _('stop');
+ logo.pluginVars['rodi']['moveStatus'] = _('stop');
}
} else {
if (left > right) {
- rodiMoveStatus = _('right');
+ logo.pluginVars['rodi']['moveStatus'] = _('right');
} else {
- rodiMoveStatus = _('left');
+ logo.pluginVars['rodi']['moveStatus'] = _('left');
}
}
- doAsyncCall(logo, blk, apiUrl)
+ logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl)
};
-var doRodiGetSensor = function (logo, blk, index) {
+globalActivity.logo.pluginVars['rodi']['doRodiGetSensor'] = function (logo, blk, index) {
if (logo.inStatusMatrix) {
- logo.statusFields.push([blk, logo.blocks.blockList[blk].name]);
+ logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]);
} else {
- if (Date.now() > rodiSensorsCacheExpires) {
-
- var apiUrl = RODI_BASE_URL + '/2/';
- var sensors = doSyncCall(logo, blk, apiUrl);
+ if (Date.now() > logo.pluginVars['rodi']['sensorsCacheExpires']) {
+ const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/2/';
+ const sensors = logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);
if (sensors != null) {
- rodiSensorsCacheExpires = Date.now() + rodiSensorsValidFor;
- rodiSensorsCache = sensors;
+ logo.pluginVars['rodi']['sensorsCacheExpires'] = Date.now() + logo.pluginVars['rodi']['sensorsValidFor'];
+ logo.pluginVars['rodi']['sensorsCache'] = sensors;
return sensors[index];
} else {
return -1;
}
} else {
- return rodiSensorsCache[index];
+ return logo.pluginVars['rodi']['sensorsCache'][index];
}
}
};
-var doRodiGetLightSensor = function (logo, blk) {
+globalActivity.logo.pluginVars['rodi']['doRodiGetLightSensor'] = function (logo, blk) {
if (logo.inStatusMatrix) {
- logo.statusFields.push([blk, logo.blocks.blockList[blk].name]);
+ logo.statusFields.push([blk, globalActivity.blocks.blockList[blk].name]);
} else {
- if (Date.now() > rodiLightSensorCacheExpires) {
-
- var apiUrl = RODI_BASE_URL + '/7/';
- var sensor = doSyncCall(logo, apiUrl);
+ if (Date.now() > logo.pluginVars['rodi']['lightSensorCacheExpires']) {
+ const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/7/';
+ const sensor = logo.pluginVars['rodi']['doSyncCall'](logo, apiUrl);
if (sensor != null) {
- rodiLightSensorCacheExpires = Date.now() + rodiLightSensorValidFor;
- rodiLightSensorCache = sensor;
+ logo.pluginVars['rodi']['lightSensorCacheExpires'] = Date.now() + logo.pluginVars['rodi']['lightSensorValidFor'];
+ logo.pluginVars['rodi']['lightSensorCache'] = sensor;
return sensor;
} else {
return -1;
}
} else {
- return rodiLightSensorCache;
+ return logo.pluginVars['rodi']['lightSensorCache'];
}
}
};
-var doAsyncCall = function (logo, blk, url){
- console.log(url);
+globalActivity.logo.pluginVars['rodi']['doAsyncCall'] = function (logo, blk, url) {
+ globalActivity.textMsg(url);
try {
- var request = new XMLHttpRequest();
+ const request = new XMLHttpRequest();
request.open('GET', url, true);
request.send(null);
} catch (e) {
- if (logo != null) {
- logo.errorMsg(e, blk);
+ if (logo !== null) {
+ activity.errorMsg(e, blk);
}
- console.log(e);
+ activity.errorMsg(e);
}
};
-var doSyncCall = function (logo, blk, url) {
- console.log(url);
+globalActivity.logo.pluginVars['rodi']['doSyncCall'] = function (logo, blk, url) {
+ globalActivity.textMsg(url);
- var request = new XMLHttpRequest();
+ const request = new XMLHttpRequest();
try {
request.open('GET', url, false);
request.send(null);
return JSON.parse(request.responseText);
} catch (e) {
if (logo != null) {
- logo.errorMsg(e, blk);
+ globalActivity.errorMsg(e, blk);
}
- console.log(e);
+ globalActivity.errorMsg(e);
return null;
}
};
-function doRodiStop(){
- doRodiMove(null, null, 0, 0);
+globalActivity.logo.pluginVars['rodi']['doRodiStop'] = function () {
+ globalActivity.logo.pluginVars['rodi']['doRodiMove'](null, null, 0, 0);
};
-blocks.logo.stage.addEventListener('__STOP__', doRodiStop, false);
+globalActivity.stage.addEventListener('__STOP__', globalActivity.logo.pluginVars['rodi']['doRodiStop'], false);
//* block:rodiblink *//
-var rodiBlink = new ProtoBlock('rodiblink');
-rodiBlink.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodiblink'] = rodiBlink;
+const rodiBlink = new ProtoBlock('rodiblink');
+rodiBlink.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodiblink'] = rodiBlink;
rodiBlink.staticLabels.push(_('blink'));
rodiBlink.adjustWidthToLabel();
rodiBlink.oneArgBlock();
@@ -180,18 +176,18 @@ rodiBlink.defaults.push(1000);
//* flow:rodiblink *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
+const rodiBlock = globalActivity.blocks.blockList[blk];
+const conns = rodiBlock.connections;
-var rate = logo.parseArg(logo, turtle, conns[1]);
-var apiUrl = RODI_BASE_URL + '/1/' + rate + '/';
-doAsyncCall(logo, blk, apiUrl);
+const rate = logo.parseArg(logo, turtle, conns[1]);
+const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/1/' + rate + '/';
+logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);
//* block:rodising *//
-var rodiSing = new ProtoBlock('rodising');
-rodiSing.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodising'] = rodiSing;
+const rodiSing = new ProtoBlock('rodising');
+rodiSing.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodising'] = rodiSing;
rodiSing.staticLabels.push(_('play'));
rodiSing.staticLabels.push(_('note'));
rodiSing.staticLabels.push(_('duration'));
@@ -204,19 +200,19 @@ rodiSing.defaults.push(250);
//* flow:rodising *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
+const rodiBlock = globalActivity.blocks.blockList[blk];
+const conns = rodiBlock.connections;
-var note = logo.parseArg(logo, turtle, conns[1]);
-var duration = logo.parseArg(logo, turtle, conns[2]);
-var apiUrl = RODI_BASE_URL + '/4/' + note + '/' + duration + '/';
-doAsyncCall(logo, blk, apiUrl);
+const note = logo.parseArg(logo, turtle, conns[1]);
+const duration = logo.parseArg(logo, turtle, conns[2]);
+const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/4/' + note + '/' + duration + '/';
+logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);
//* block:rodipixel *//
-var rodiPixel = new ProtoBlock('rodipixel');
-rodiPixel.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodipixel'] = rodiPixel;
+const rodiPixel = new ProtoBlock('rodipixel');
+rodiPixel.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodipixel'] = rodiPixel;
rodiPixel.staticLabels.push(_('pixel color'));
rodiPixel.staticLabels.push(_('red'));
rodiPixel.staticLabels.push(_('green'));
@@ -232,21 +228,21 @@ rodiPixel.defaults.push(0);
//* flow:rodipixel *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
+const rodiBlock = globalActivity.blocks.blockList[blk];
+const conns = rodiBlock.connections;
-var red = logo.parseArg(logo, turtle, conns[1]);
-var green = logo.parseArg(logo, turtle, conns[2]);
-var blue = logo.parseArg(logo, turtle, conns[3]);
+const red = logo.parseArg(logo, turtle, conns[1]);
+const green = logo.parseArg(logo, turtle, conns[2]);
+const blue = logo.parseArg(logo, turtle, conns[3]);
-var apiUrl = RODI_BASE_URL + '/6/' + red + '/' + green + '/' + blue + '/';
-doAsyncCall(logo, blk, apiUrl);
+const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/6/' + red + '/' + green + '/' + blue + '/';
+logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);
//* block:rodiled *//
-var rodiLed = new ProtoBlock('rodiled');
-rodiLed.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodiled'] = rodiLed;
+const rodiLed = new ProtoBlock('rodiled');
+rodiLed.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodiled'] = rodiLed;
rodiLed.staticLabels.push(_('led'));
rodiLed.adjustWidthToLabel();
rodiLed.oneArgBlock();
@@ -254,91 +250,91 @@ rodiLed.defaults.push(1);
//* flow:rodiled *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
+const rodiBlock = globalActivity.blocks.blockList[blk];
+const conns = rodiBlock.connections;
-var state = logo.parseArg(logo, turtle, conns[1]);
-var apiUrl = RODI_BASE_URL + '/8/' + state + '/';
-doAsyncCall(logo, blk, apiUrl);
+const state = logo.parseArg(logo, turtle, conns[1]);
+const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/8/' + state + '/';
+logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);
//* block:rodisenselight *//
var rodiSenseLight = new ProtoBlock('rodisenselight');
-rodiSenseLight.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodisenselight'] = rodiSenseLight;
+rodiSenseLight.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodisenselight'] = rodiSenseLight;
rodiSenseLight.staticLabels.push(_('light intensity'));
rodiSenseLight.adjustWidthToLabel();
rodiSenseLight.parameterBlock();
//* arg:rodisenselight *//
-var block = logo.blocks.blockList[blk];
-block.value = doRodiGetLightSensor(blk);
+const rodiBlock = globalActivity.blocks.blockList[blk];
+rodiBlock.value = logo.pluginVars['rodi']['doRodiGetLightSensor'](blk);
-var apiUrl = RODI_BASE_URL + '/7/';
-doAsyncCall(logo, blk, apiUrl);
+const apiUrl = logo.pluginVars['rodi']['RODI_BASE_URL'] + '/7/';
+logo.pluginVars['rodi']['doAsyncCall'](logo, blk, apiUrl);
//* block:rodisenseleft *//
-var rodiSenseLeft = new ProtoBlock('rodisenseleft');
-rodiSenseLeft.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodisenseleft'] = rodiSenseLeft;
+const rodiSenseLeft = new ProtoBlock('rodisenseleft');
+rodiSenseLeft.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodisenseleft'] = rodiSenseLeft;
rodiSenseLeft.staticLabels.push(_('infrared light (left)'));
rodiSenseLeft.adjustWidthToLabel();
rodiSenseLeft.parameterBlock();
//* arg:rodisenseleft *//
-var block = logo.blocks.blockList[blk];
-block.value = doRodiGetSensor(logo, blk, 0);
+const rodiblock = globalActivity.blocks.blockList[blk];
+rodiBlock.value = logo.pluginVars['rodi']['doRodiGetSensor'](logo, blk, 0);
//* block:rodisenseright *//
-var rodiSenseRight = new ProtoBlock('rodisenseright');
-rodiSenseRight.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodisenseright'] = rodiSenseRight;
+const rodiSenseRight = new ProtoBlock('rodisenseright');
+rodiSenseRight.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodisenseright'] = rodiSenseRight;
rodiSenseRight.staticLabels.push(_('infrared light (right)'));
rodiSenseRight.adjustWidthToLabel();
rodiSenseRight.parameterBlock();
//* arg:rodisenseright *//
-var block = logo.blocks.blockList[blk];
-block.value = doRodiGetSensor(logo, blk, 1);
+const rodiBlock = globalActivity.blocks.blockList[blk];
+rodiBlock.value = logo.pluginVars['rodi']['doRodiGetSensor'](logo, blk, 1);
//* block:rodisee *//
-var rodiSee = new ProtoBlock('rodisee');
-rodiSee.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodisee'] = rodiSee;
+const rodiSee = new ProtoBlock('rodisee');
+rodiSee.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodisee'] = rodiSee;
rodiSee.staticLabels.push(_('distance'));
rodiSee.adjustWidthToLabel();
rodiSee.parameterBlock();
//* arg:rodisee *//
-var block = logo.blocks.blockList[blk];
-block.value = doRodiGetDistance(logo, blk);
+const rodiBlock = globalActivity.blocks.blockList[blk];
+rodiBlock.value = logo.pluginVars['rodi']['doRodiGetDistance'](logo, blk);
//* block:rodimovestatus *//
-var rodiMoveStatus = new ProtoBlock('rodimovestatus');
-rodiMoveStatus.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodimovestatus'] = rodiMoveStatus;
+const rodiMoveStatus = new ProtoBlock('rodimovestatus');
+rodiMoveStatus.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodimovestatus'] = rodiMoveStatus;
rodiMoveStatus.staticLabels.push(_('status'));
rodiMoveStatus.adjustWidthToLabel();
rodiMoveStatus.parameterBlock();
//* arg:rodimovestatus *//
-var block = logo.blocks.blockList[blk];
-block.value = doRodiGetMoveStatus(logo, blk);
+const rodiBlock = globalActivity.blocks.blockList[blk];
+rodiBlock.value = logo.pluginVars['rodi']['doRodiGetMoveStatus'](logo, blk);
//* block:rodimove *//
-var rodiMove = new ProtoBlock('rodimove');
-rodiMove.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodimove'] = rodiMove;
+const rodiMove = new ProtoBlock('rodimove');
+rodiMove.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodimove'] = rodiMove;
rodiMove.staticLabels.push(_('move'));
rodiMove.staticLabels.push(_('left'));
rodiMove.staticLabels.push(_('right'));
@@ -351,82 +347,82 @@ rodiMove.defaults.push(100);
//* flow:rodimove *//
-var block = logo.blocks.blockList[blk];
-var conns = block.connections;
+const rodiBlock = globalActivity.blocks.blockList[blk];
+const conns = rodiBlock.connections;
-var left = logo.parseArg(logo, turtle, conns[1]);
-var right = logo.parseArg(logo, turtle, conns[2]);
-doRodiMove(logo, blk, left, right);
+const left = logo.parseArg(logo, turtle, conns[1]);
+const right = logo.parseArg(logo, turtle, conns[2]);
+logo.pluginVars['rodi']['doRodiMove'](logo, blk, left, right);
//* block:rodileft *//
-var rodiLeft = new ProtoBlock('rodileft');
-rodiLeft.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodileft'] = rodiLeft;
+const rodiLeft = new ProtoBlock('rodileft');
+rodiLeft.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodileft'] = rodiLeft;
rodiLeft.staticLabels.push(_('left'));
rodiLeft.adjustWidthToLabel();
rodiLeft.zeroArgBlock();
//* flow:rodileft *//
-doRodiMove(logo, blk, -100, 100);
+logo.pluginVars['rodi']['doRodiMove'](logo, blk, -100, 100);
//* block:rodiright *//
-var rodiRight = new ProtoBlock('rodiright');
-rodiRight.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodiright'] = rodiRight;
+const rodiRight = new ProtoBlock('rodiright');
+rodiRight.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodiright'] = rodiRight;
rodiRight.staticLabels.push(_('right'));
rodiRight.adjustWidthToLabel();
rodiRight.zeroArgBlock();
//* flow:rodiright *//
-doRodiMove(logo, blk, 100, -100);
+logo.pluginVars['rodi']['doRodiMove'](logo, blk, 100, -100);
//* block:rodiback *//
-var rodiBack = new ProtoBlock('rodiback');
-rodiBack.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodiback'] = rodiBack;
+const rodiBack = new ProtoBlock('rodiback');
+rodiBack.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodiback'] = rodiBack;
rodiBack.staticLabels.push(_('back'));
rodiBack.adjustWidthToLabel();
rodiBack.zeroArgBlock();
//* flow:rodiback *//
-doRodiMove(logo, blk, -100, -100);
+logo.pluginVars['rodi']['doRodiMove'](logo, blk, -100, -100);
//* block:rodiforward *//
-var rodiForward = new ProtoBlock('rodiforward');
-rodiForward.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodiforward'] = rodiForward;
+const rodiForward = new ProtoBlock('rodiforward');
+rodiForward.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodiforward'] = rodiForward;
rodiForward.staticLabels.push(_('forward'));
rodiForward.adjustWidthToLabel();
rodiForward.zeroArgBlock();
//* flow:rodiforward *//
-doRodiMove(logo, blk, 100, 100);
+logo.pluginVars['rodi']['doRodiMove'](logo, blk, 100, 100);
//* block:rodistop *//
-var rodiStop = new ProtoBlock('rodistop');
-rodiStop.palette = palettes.dict['rodi'];
-blocks.protoBlockDict['rodistop'] = rodiStop;
+const rodiStop = new ProtoBlock('rodistop');
+rodiStop.palette = globalActivity.palettes.dict['rodi'];
+globalActivity.blocks.protoBlockDict['rodistop'] = rodiStop;
rodiStop.staticLabels.push(_('stop'));
rodiStop.adjustWidthToLabel();
rodiStop.zeroArgBlock();
//* flow:rodistop *//
-doRodiMove(logo, blk, 0, 0);
+logo.pluginVars['rodi']['doRodiMove'](logo, blk, 0, 0);
//* palette-icon:rodi *//
-
+
//* palette-fill:rodi *// #6a8df6
//* palette-stroke:rodi *// #5a7de6
//* palette-highlight:rodi *// #ced8f8
-//* palette-stroke-highlight:rodi *// #000000
+//* palette-stroke-highlight:rodi *// #5a7de6
diff --git a/plugins/translate.json b/plugins/translate.json
deleted file mode 100755
index 4ede40fd84..0000000000
--- a/plugins/translate.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "HIGHLIGHTSTROKECOLORS": {
- "mashape": "#000000"
- },
- "ARGPLUGINS": {
- "translate": "var apiURL = 'https://community-onehourtranslation.p.mashape.com/mt/';var key = 'TranslatedText';var text = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[1]);var targetLang = 'Spanish';var args = 'translate/text?public_key=' + translatePublicKey + '&secret_key=' + translateSecretKey + '&source_content=' + text + '&source_language=' + fromLang + '&target_language=' + toLang;var request = new XMLHttpRequest();request.open('GET', apiURL + args, false);request.setRequestHeader('X-Mashape-Authorization', translateMashapeKey);request.send(null);var value = JSON.parse(request.responseText)['results'][key];if (!value) { logo.errorMsg('Problem with the language setting.', blk); value = '';}logo.blocks.blockList[blk].value = value;",
- "detectlang": "var apiURL = 'https://community-onehourtranslation.p.mashape.com/mt/';var key = 'language';var text = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[1]);var args = 'detect/text?public_key=' + translatePublicKey + '&secret_key=' + translateSecretKey + '&source_content=' + text;var request = new XMLHttpRequest();request.open('GET', apiURL + args, false);request.setRequestHeader('X-Mashape-Authorization', translateMashapeKey);request.send(null);var value = JSON.parse(request.responseText)['results'][key];if (!value) { logo.errorMsg('Problem with the language setting.', blk); value = '';}logo.blocks.blockList[blk].value = value;"
- },
- "GLOBALS": "translateMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';translatePublicKey = 'nGhwbdV7TrtzC9qLp3DZ';translateSecretKey = '3b68e1d00446eed728cdda66280a8312';",
- "PALETTEHIGHLIGHTCOLORS": {
- "mashape": "#ffb1b3"
- },
- "FLOWPLUGINS": {
- "setlang": "fromLang = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[1]);toLang = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[2]);"
- },
- "PALETTEPLUGINS": {
- "mashape": "
"
- },
- "BLOCKPLUGINS": {
- "setlang": "var setLangBlock = new ProtoBlock('setlang');setLangBlock.palette = palettes.dict['mashape'];blocks.protoBlockDict['setlang'] = setLangBlock;setLangBlock.staticLabels.push(_('set lang'), _('source'), _('target'));setLangBlock.adjustWidthToLabel();setLangBlock.twoArgBlock();setLangBlock.dockTypes[1] = 'anyin';setLangBlock.dockTypes[2] = 'anyin';setLangBlock.defaults.push('English', 'Spanish');",
- "translate": "var translateBlock = new ProtoBlock('translate');translateBlock.palette = palettes.dict['mashape'];blocks.protoBlockDict['translate'] = translateBlock;translateBlock.staticLabels.push(_('translate'));translateBlock.adjustWidthToLabel();translateBlock.oneArgMathBlock();translateBlock.dockTypes[0] = 'textout';translateBlock.dockTypes[1] = 'textin';translateBlock.defaults.push(_('hello'));",
- "detectlang": "var detectLangBlock = new ProtoBlock('detectlang');detectLangBlock.palette = palettes.dict['mashape'];blocks.protoBlockDict['detectlang'] = detectLangBlock;detectLangBlock.staticLabels.push(_('detect lang'));detectLangBlock.adjustWidthToLabel();detectLangBlock.oneArgMathBlock();detectLangBlock.dockTypes[0] = 'textout';detectLangBlock.dockTypes[1] = 'anyin';detectLangBlock.defaults.push(_('hello'));"
- },
- "PALETTEFILLCOLORS": {
- "mashape": "#ff0066"
- },
- "PALETTESTROKECOLORS": {
- "mashape": "#ef003e"
- }
-}
diff --git a/plugins/translate.rtp b/plugins/translate.rtp
deleted file mode 100755
index 3139aebc9f..0000000000
--- a/plugins/translate.rtp
+++ /dev/null
@@ -1,109 +0,0 @@
-//* comment *//
-
-// Copyright (c) 2015 Walter Bender, Ignacio Rodriguez, Sam Parkinson
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; if not, write to the Free Software
-// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
-
-// Plugins are a dictionary of json-encoded components: a flow-block
-// dictionary, an arg-block dictionary, a block dictionary, and a
-// palette dictionary. The flow-block dictionary is a set of commands
-// that are evaluated when a flow block is run; the arg-block
-// dictionary is a set of commands that are evaluated when an arg
-// block is run; the block dictionary defines the new blocks in the
-// plugin; and the palette dictionary defines icons (svg) associated
-// with the palettes populated by the blocks found in the plugin.
-
-// The Mashape plugin provides blocks that use the mashape.com APIs.
-// Included here are blocks to translate strings and to poll
-// international weather forecasts.
-
-//* globals *//
-var translateMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';
-var translatePublicKey = 'nGhwbdV7TrtzC9qLp3DZ';
-var translateSecretKey = '3b68e1d00446eed728cdda66280a8312';
-
-//* flow:setlang *//
-fromLang = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[1]);
-toLang = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[2]);
-
-//* arg:translate *//
-var apiURL = 'https://community-onehourtranslation.p.mashape.com/mt/';
-var key = 'TranslatedText';
-var text = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[1]);
-var targetLang = 'Spanish';
-var args = 'translate/text?public_key=' + translatePublicKey + '&secret_key=' + translateSecretKey + '&source_content=' + text + '&source_language=' + fromLang + '&target_language=' + toLang;
-var request = new XMLHttpRequest();
-request.open('GET', apiURL + args, false);
-request.setRequestHeader('X-Mashape-Authorization', translateMashapeKey);
-request.send(null);
-var value = JSON.parse(request.responseText)['results'][key];
-if (!value) {
- logo.errorMsg('Problem with the language setting.', blk);
- value = '';
-}
-logo.blocks.blockList[blk].value = value;
-
-//* arg:detectlang *//
-var apiURL = 'https://community-onehourtranslation.p.mashape.com/mt/';
-var key = 'language';
-var text = logo.parseArg(logo, turtle, logo.blocks.blockList[blk].connections[1]);
-var args = 'detect/text?public_key=' + translatePublicKey + '&secret_key=' + translateSecretKey + '&source_content=' + text;
-var request = new XMLHttpRequest();
-request.open('GET', apiURL + args, false);
-request.setRequestHeader('X-Mashape-Authorization', translateMashapeKey);
-request.send(null);
-var value = JSON.parse(request.responseText)['results'][key];
-if (!value) {
- logo.errorMsg('Problem with the language setting.', blk);
- value = '';
-}
-logo.blocks.blockList[blk].value = value;
-
-//* block:translate *//
-var translateBlock = new ProtoBlock('translate');
-translateBlock.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['translate'] = translateBlock;
-translateBlock.staticLabels.push(_('translate'));
-translateBlock.adjustWidthToLabel();
-translateBlock.oneArgMathBlock();
-translateBlock.dockTypes[0] = 'textout';
-translateBlock.dockTypes[1] = 'textin';
-translateBlock.defaults.push(_('hello'));
-
-//* block:detectlang *//
-var detectLangBlock = new ProtoBlock('detectlang');
-detectLangBlock.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['detectlang'] = detectLangBlock;
-detectLangBlock.staticLabels.push(_('detect lang'));
-detectLangBlock.adjustWidthToLabel();
-detectLangBlock.oneArgMathBlock();
-detectLangBlock.dockTypes[0] = 'textout';
-detectLangBlock.dockTypes[1] = 'anyin';
-detectLangBlock.defaults.push(_('hello'));
-
-//* block:setlang *//
-var setLangBlock = new ProtoBlock('setlang');
-setLangBlock.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['setlang'] = setLangBlock;
-setLangBlock.staticLabels.push(_('set lang'), _('source'), _('target'));
-setLangBlock.adjustWidthToLabel();
-setLangBlock.twoArgBlock();
-setLangBlock.dockTypes[1] = 'anyin';
-setLangBlock.dockTypes[2] = 'anyin';
-setLangBlock.defaults.push('English', 'Spanish');
-
-//* palette-icon:mashape *//
-
-
-//* palette-fill:mashape *// #ff0066
-//* palette-stroke:mashape *// #ef003e
-//* palette-highlight:mashape *// #ffb1b3
-//* palette-stroke-highlight:mashape *// #000000
-
diff --git a/plugins/turtle.json b/plugins/turtle.json
deleted file mode 100755
index f388c9222b..0000000000
--- a/plugins/turtle.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "BLOCKPLUGINS": {
- "xturtle": "var getxTurtleBlock = new ProtoBlock('xturtle');getxTurtleBlock.palette = palettes.dict['extras'];blocks.protoBlockDict['xturtle'] = getxTurtleBlock;getxTurtleBlock.staticLabels.push(_('turtle x'));getxTurtleBlock.adjustWidthToLabel();getxTurtleBlock.oneArgBlock();getxTurtleBlock.dockTypes[1] = 'anyin';getxTurtleBlock.defaults.push('0');",
- "yturtle": "var getyTurtleBlock = new ProtoBlock('yturtle');getyTurtleBlock.palette = palettes.dict['extras'];blocks.protoBlockDict['yturtle'] = getyTurtleBlock;getyTurtleBlock.staticLabels.push(_('turtle y'));getyTurtleBlock.adjustWidthToLabel();getyTurtleBlock.oneArgBlock();getyTurtleBlock.dockTypes[1] = 'anyin';getyTurtleBlock.defaults.push('0');",
- "stopTurtle": "var stopTurtleBlock = new ProtoBlock('stopTurtle');stopTurtleBlock.palette = palettes.dict['extras'];blocks.protoBlockDict['stopTurtle'] = stopTurtleBlock;stopTurtleBlock.staticLabels.push(_('stop turtle'));stopTurtleBlock.adjustWidthToLabel();stopTurtleBlock.oneArgBlock();stopTurtleBlock.dockTypes[1] = 'anyin';stopTurtleBlock.defaults.push('0');",
- "setturtlename": "var setTurtleName = new ProtoBlock('setturtlename');setTurtleName.palette = palettes.dict['extras'];blocks.protoBlockDict['setturtlename'] = setTurtleName;setTurtleName.staticLabels.push(_('turtle name'));setTurtleName.staticLabels.push(_('source'));setTurtleName.staticLabels.push(_('target'));setTurtleName.adjustWidthToLabel();setTurtleName.twoArgBlock();setTurtleName.dockTypes[1] = 'anyin';setTurtleName.dockTypes[2] = 'anyin';setTurtleName.defaults.push('0');setTurtleName.defaults.push('Yertle');",
- "startTurtle": "var startTurtleBlock = new ProtoBlock('startTurtle');startTurtleBlock.palette = palettes.dict['extras'];blocks.protoBlockDict['startTurtle'] = startTurtleBlock;startTurtleBlock.staticLabels.push(_('start turtle'));startTurtleBlock.adjustWidthToLabel();startTurtleBlock.oneArgBlock();startTurtleBlock.dockTypes[1] = 'anyin';startTurtleBlock.defaults.push('0');"
- },
- "GLOBALS": "",
- "FLOWPLUGINS": {
- "setturtlename": "var cblk = logo.blocks.blockList[blk].connections[1];var sourceName = args[0];var targetName = args[1];var thisTurtle = null;var foundTurtle = false;for (var i = 0; i < turtles.turtleList.length; i++) { thisTurtle = turtles.turtleList[i]; if (sourceName == thisTurtle.name) { thisTurtle.name = targetName; foundTurtle = true; break; }}if (!foundTurtle) { logo.errorMsg('Could not find turtle ' + sourceName, blk);}"
- }
-}
diff --git a/plugins/turtle.rtp b/plugins/turtle.rtp
deleted file mode 100755
index ca8d7ed4ac..0000000000
--- a/plugins/turtle.rtp
+++ /dev/null
@@ -1,90 +0,0 @@
-//* comment *//
-
-Copyright (C) 2015 Ignacio Rodríguez
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
.
-
-//* globals *//
-
-//* flow:setturtlename *//
-var cblk = logo.blocks.blockList[blk].connections[1];
-var sourceName = args[0];
-var targetName = args[1];
-var thisTurtle = null;
-var foundTurtle = false;
-for (var i = 0; i < turtles.turtleList.length; i++) {
- thisTurtle = turtles.turtleList[i];
- if (sourceName == thisTurtle.name) {
- thisTurtle.name = targetName;
- foundTurtle = true;
- break;
- }
-}
-if (!foundTurtle) {
- logo.errorMsg('Could not find turtle ' + sourceName, blk);
-}
-
-//* block:xturtle *//
-var getxTurtleBlock = new ProtoBlock('xturtle');
-getxTurtleBlock.palette = palettes.dict['extras'];
-blocks.protoBlockDict['xturtle'] = getxTurtleBlock;
-getxTurtleBlock.staticLabels.push(_('turtle x'));
-getxTurtleBlock.adjustWidthToLabel();
-getxTurtleBlock.oneArgBlock();
-getxTurtleBlock.dockTypes[1] = 'anyin';
-getxTurtleBlock.defaults.push('0');
-
-//* block:yturtle *//
-var getyTurtleBlock = new ProtoBlock('yturtle');
-getyTurtleBlock.palette = palettes.dict['extras'];
-blocks.protoBlockDict['yturtle'] = getyTurtleBlock;
-getyTurtleBlock.staticLabels.push(_('turtle y'));
-getyTurtleBlock.adjustWidthToLabel();
-getyTurtleBlock.oneArgBlock();
-getyTurtleBlock.dockTypes[1] = 'anyin';
-getyTurtleBlock.defaults.push('0');
-
-//* block:startTurtle *//
-var startTurtleBlock = new ProtoBlock('startTurtle');
-startTurtleBlock.palette = palettes.dict['extras'];
-blocks.protoBlockDict['startTurtle'] = startTurtleBlock;
-startTurtleBlock.staticLabels.push(_('start turtle'));
-startTurtleBlock.adjustWidthToLabel();
-startTurtleBlock.oneArgBlock();
-startTurtleBlock.dockTypes[1] = 'anyin';
-startTurtleBlock.defaults.push('0');
-
-//* block:stopTurtle *//
-var stopTurtleBlock = new ProtoBlock('stopTurtle');
-stopTurtleBlock.palette = palettes.dict['extras'];
-blocks.protoBlockDict['stopTurtle'] = stopTurtleBlock;
-stopTurtleBlock.staticLabels.push(_('stop turtle'));
-stopTurtleBlock.adjustWidthToLabel();
-stopTurtleBlock.oneArgBlock();
-stopTurtleBlock.dockTypes[1] = 'anyin';
-stopTurtleBlock.defaults.push('0');
-
-//* block:setturtlename *//
-var setTurtleName = new ProtoBlock('setturtlename');
-setTurtleName.palette = palettes.dict['extras'];
-blocks.protoBlockDict['setturtlename'] = setTurtleName;
-setTurtleName.staticLabels.push(_('turtle name'));
-setTurtleName.staticLabels.push(_('source'));
-setTurtleName.staticLabels.push(_('target'));
-setTurtleName.adjustWidthToLabel();
-setTurtleName.twoArgBlock();
-setTurtleName.dockTypes[1] = 'anyin';
-setTurtleName.dockTypes[2] = 'anyin';
-setTurtleName.defaults.push('0');
-setTurtleName.defaults.push('Yertle');
diff --git a/plugins/weather.json b/plugins/weather.json
old mode 100755
new mode 100644
index 2248468ff3..462c27cbb2
--- a/plugins/weather.json
+++ b/plugins/weather.json
@@ -1,28 +1,28 @@
{
- "HIGHLIGHTSTROKECOLORS": {
- "mashape": "#000000"
- },
+ "GLOBALS": "",
"ARGPLUGINS": {
- "weatherincity": "var block = logo.blocks.blockList[blk];var apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';var conns = block.connections;var city = logo.parseArg(logo, turtle, conns[1]);var daysAhead = parseInt(logo.parseArg(logo, turtle, conns[2]));if (daysAhead < -1 || daysAhead > 5) { logo.errorMsg('Days ahead must be in the range of -1 to 5.', blk); daysAhead = 0;}if (block.cacheCity === city && block.cache !== undefined) { var response = block.cache;} else { var request = new XMLHttpRequest(); request.open('GET', apiURL + city, false); request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey); request.send(null); var response = request.responseText; block.cacheCity = city; block.cache = response;}var forecast = JSON.parse(response);block.value = forecast[daysAhead + 1]['condition'];",
- "weatherincitylow": "var block = logo.blocks.blockList[blk];var apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';var conns = block.connections;var city = logo.parseArg(logo, turtle, conns[1]);var daysAhead = parseInt(logo.parseArg(logo, turtle, conns[2]));if (daysAhead < -1 || daysAhead > 5) { logo.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk); daysAhead = 0;}if (block.cacheCity === city && block.cache !== undefined) { var response = block.cache;} else { var request = new XMLHttpRequest(); request.open('GET', apiURL + city, false); request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey); request.send(null); var response = request.responseText; block.cacheCity = city; block.cache = response;}var forecast = JSON.parse(response);block.value = parseInt(forecast[daysAhead + 1]['low_celsius']);",
- "weatherincityhigh": "var block = logo.blocks.blockList[blk];var apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';var conns = block.connections;var city = logo.parseArg(logo, turtle, conns[1]);var daysAhead = parseInt(logo.parseArg(logo, turtle, conns[2]));if (daysAhead < -1 || daysAhead > 5) { logo.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk); daysAhead = 0;}if (block.cacheCity === city && block.cache !== undefined) { var response = block.cache;} else { var request = new XMLHttpRequest(); request.open('GET', apiURL + city, false); request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey); request.send(null); var response = request.responseText; block.cacheCity = city; block.cache = response;}var forecast = JSON.parse(response);block.value = parseInt(forecast[daysAhead + 1]['high_celsius']);"
- },
- "GLOBALS": "weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';",
- "PALETTEHIGHLIGHTCOLORS": {
- "mashape": "#ffb1b3"
- },
- "PALETTEPLUGINS": {
- "mashape": "
"
- },
+ "weatherincity": "const weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';const weatherBlock = globalActivity.blocks.blockList[blk];const apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';const conns = weatherBlock.connections;const city = globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[1]);const daysAhead = parseInt(globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[2]));if (daysAhead < -1 || daysAhead > 5) { globalActivity.errorMsg('Days ahead must be in the range of -1 to 5.', blk); daysAhead = 0;}if (weatherBlock.cacheCity === city && weatherBlock.cache !== undefined) { weatherBlock.value = weatherBlock.cache;} else { try { const request = new XMLHttpRequest(); request.open('GET', apiURL + city, false); request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey); request.send(null); const response = request.responseText; weatherBlock.cacheCity = city; const forecast = JSON.parse(response); weatherBlock.cache = forecast[daysAhead + 1]['condition']; } catch { weatherBlock.cache = \"It's always sunny in Philadelphia.\" } weatherBlock.value = weatherBlock.cache;}",
+ "weatherincityhigh": "const weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';const weatherBlock = globalActivity.blocks.blockList[blk];const apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';const conns = weatherBlock.connections;const city = globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[1]);const daysAhead = parseInt(globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[2]));if (daysAhead < -1 || daysAhead > 5) { globalActivity.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk); daysAhead = 0;}if (weatherBlock.cacheCity === city && weatherBlock.cache !== undefined) { weatherBlock.value = weatherBlock.cache;} else { try { const request = new XMLHttpRequest(); request.open('GET', apiURL + city, false); request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey); request.send(null); const response = request.responseText; weatherBlock.cacheCity = city; const forecast = JSON.parse(response); weatherBlock.cache = parseInt(forecast[daysAhead + 1]['high_celsius']); } catch { weatherBlock.cache = \"It's always sunny in Philadelphia.\" } weatherBlock.value = weatherBlock.cache;}",
+ "weatherincitylow": "const weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';const weatherBlock = globalActivity.blocks.blockList[blk];const apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';const conns = weatherBlock.connections;const city = globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[1]);const daysAhead = parseInt(globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[2]));if (daysAhead < -1 || daysAhead > 5) { globalActivity.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk); daysAhead = 0;}if (weatherBlock.cacheCity === city && weatherBlock.cache !== undefined) { weatherBlock.value = weatherBlock.cache;} else { try { const request = new XMLHttpRequest(); request.open('GET', apiURL + city, false); request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey); request.send(null); const response = request.responseText; weatherBlock.cacheCity = city; const forecast = JSON.parse(response); weatherBlock.cache = parseInt(forecast[daysAhead + 1]['low_celsius']); } catch { weatherBlock.cache = \"It's always sunny in Philadelphia.\" } weatherBlock.value = weatherBlock.cache;}"
+ },
"BLOCKPLUGINS": {
- "weatherincity": "var weatherBlock = new ProtoBlock('weatherincity');weatherBlock.palette = palettes.dict['mashape'];blocks.protoBlockDict['weatherincity'] = weatherBlock;weatherBlock.staticLabels.push(_('forecast'));weatherBlock.staticLabels.push(_('city'));weatherBlock.staticLabels.push(_('day'));weatherBlock.adjustWidthToLabel();weatherBlock.twoArgMathBlock();weatherBlock.dockTypes[0] = 'textout';weatherBlock.dockTypes[1] = 'anyin';weatherBlock.defaults.push('Canberra');weatherBlock.defaults.push(1);",
- "weatherincitylow": "var weatherLowBlock = new ProtoBlock('weatherincitylow');weatherLowBlock.palette = palettes.dict['mashape'];blocks.protoBlockDict['weatherincitylow'] = weatherLowBlock;weatherLowBlock.staticLabels.push(_('low'));weatherLowBlock.staticLabels.push(_('city'));weatherLowBlock.staticLabels.push(_('day'));weatherLowBlock.adjustWidthToLabel();weatherLowBlock.twoArgMathBlock();weatherLowBlock.dockTypes[1] = 'anyin';weatherLowBlock.defaults.push('Canberra');weatherLowBlock.defaults.push(1);",
- "weatherincityhigh": "var weatherHighBlock = new ProtoBlock('weatherincityhigh');weatherHighBlock.palette = palettes.dict['mashape'];blocks.protoBlockDict['weatherincityhigh'] = weatherHighBlock;weatherHighBlock.staticLabels.push(_('high'));weatherHighBlock.staticLabels.push(_('city'));weatherHighBlock.staticLabels.push(_('day'));weatherHighBlock.adjustWidthToLabel();weatherHighBlock.twoArgMathBlock();weatherHighBlock.dockTypes[1] = 'anyin';weatherHighBlock.defaults.push('Canberra');weatherHighBlock.defaults.push(1);"
- },
+ "weatherincity": "const weatherBlock = new ProtoBlock('weatherincity');weatherBlock.palette = globalActivity.palettes.dict['mashape'];globalActivity.blocks.protoBlockDict['weatherincity'] = weatherBlock;weatherBlock.staticLabels.push(_('forecast'));weatherBlock.staticLabels.push(_('city'));weatherBlock.staticLabels.push(_('day'));weatherBlock.adjustWidthToLabel();weatherBlock.twoArgMathBlock();weatherBlock.dockTypes[0] = 'textout';weatherBlock.dockTypes[1] = 'anyin';weatherBlock.defaults.push('Canberra');weatherBlock.defaults.push(1);",
+ "weatherincityhigh": "const weatherHighBlock = new ProtoBlock('weatherincityhigh');weatherHighBlock.palette = globalActivity.palettes.dict['mashape'];globalActivity.blocks.protoBlockDict['weatherincityhigh'] = weatherHighBlock;weatherHighBlock.staticLabels.push(_('high'));weatherHighBlock.staticLabels.push(_('city'));weatherHighBlock.staticLabels.push(_('day'));weatherHighBlock.adjustWidthToLabel();weatherHighBlock.twoArgMathBlock();weatherHighBlock.dockTypes[1] = 'anyin';weatherHighBlock.defaults.push('Canberra');weatherHighBlock.defaults.push(1);",
+ "weatherincitylow": "const weatherLowBlock = new ProtoBlock('weatherincitylow');weatherLowBlock.palette = globalActivity.palettes.dict['mashape'];globalActivity.blocks.protoBlockDict['weatherincitylow'] = weatherLowBlock;weatherLowBlock.staticLabels.push(_('low'));weatherLowBlock.staticLabels.push(_('city'));weatherLowBlock.staticLabels.push(_('day'));weatherLowBlock.adjustWidthToLabel();weatherLowBlock.twoArgMathBlock();weatherLowBlock.dockTypes[1] = 'anyin';weatherLowBlock.defaults.push('Canberra');weatherLowBlock.defaults.push(1);"
+ },
+ "PALETTEPLUGINS": {
+ "mashape": "
"
+ },
"PALETTEFILLCOLORS": {
"mashape": "#ff0066"
- },
+ },
"PALETTESTROKECOLORS": {
"mashape": "#ef003e"
+ },
+ "PALETTEHIGHLIGHTCOLORS": {
+ "mashape": "#ffb1b3"
+ },
+ "HIGHLIGHTSTROKECOLORS": {
+ "mashape": "#ef003e"
}
-}
+}
\ No newline at end of file
diff --git a/plugins/weather.rtp b/plugins/weather.rtp
old mode 100755
new mode 100644
index b9f845a9ae..cbd53f654d
--- a/plugins/weather.rtp
+++ b/plugins/weather.rtp
@@ -1,5 +1,8 @@
//* comment *//
+// This plugin will no longer run because Mashape as been deprecated
+// and replaced by a RapidAPI, which is a paywall.
+
// Copyright (c) 2015 Walter Bender, Sam Parkinson
//
// This program is free software; you can redistribute it and/or modify
@@ -26,84 +29,96 @@
//* globals *//
-var weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';
-
//* arg:weatherincity *//
-var block = logo.blocks.blockList[blk];
-var apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';
-var conns = block.connections;
-var city = logo.parseArg(logo, turtle, conns[1]);
-var daysAhead = parseInt(logo.parseArg(logo, turtle, conns[2]));
+const weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';const weatherBlock = globalActivity.blocks.blockList[blk];
+const apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';
+const conns = weatherBlock.connections;
+const city = globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[1]);
+const daysAhead = parseInt(globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[2]));
if (daysAhead < -1 || daysAhead > 5) {
- logo.errorMsg('Days ahead must be in the range of -1 to 5.', blk);
+ globalActivity.errorMsg('Days ahead must be in the range of -1 to 5.', blk);
daysAhead = 0;
}
-if (block.cacheCity === city && block.cache !== undefined) {
- var response = block.cache;
+if (weatherBlock.cacheCity === city && weatherBlock.cache !== undefined) {
+ weatherBlock.value = weatherBlock.cache;
} else {
- var request = new XMLHttpRequest();
- request.open('GET', apiURL + city, false);
- request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey);
- request.send(null);
- var response = request.responseText;
- block.cacheCity = city;
- block.cache = response;
+ try {
+ const request = new XMLHttpRequest();
+ request.open('GET', apiURL + city, false);
+ request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey);
+ request.send(null);
+ const response = request.responseText;
+ weatherBlock.cacheCity = city;
+ const forecast = JSON.parse(response);
+ weatherBlock.cache = forecast[daysAhead + 1]['condition'];
+ } catch {
+ weatherBlock.cache = "It's always sunny in Philadelphia."
+ }
+ weatherBlock.value = weatherBlock.cache;
}
-var forecast = JSON.parse(response);
-block.value = forecast[daysAhead + 1]['condition'];
//* arg:weatherincityhigh *//
-var block = logo.blocks.blockList[blk];
-var apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';
-var conns = block.connections;
-var city = logo.parseArg(logo, turtle, conns[1]);
-var daysAhead = parseInt(logo.parseArg(logo, turtle, conns[2]));
+const weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';
+const weatherBlock = globalActivity.blocks.blockList[blk];
+const apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';
+const conns = weatherBlock.connections;
+const city = globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[1]);
+const daysAhead = parseInt(globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[2]));
if (daysAhead < -1 || daysAhead > 5) {
- logo.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk);
+ globalActivity.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk);
daysAhead = 0;
}
-if (block.cacheCity === city && block.cache !== undefined) {
- var response = block.cache;
+if (weatherBlock.cacheCity === city && weatherBlock.cache !== undefined) {
+ weatherBlock.value = weatherBlock.cache;
} else {
- var request = new XMLHttpRequest();
- request.open('GET', apiURL + city, false);
- request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey);
- request.send(null);
- var response = request.responseText;
- block.cacheCity = city;
- block.cache = response;
+ try {
+ const request = new XMLHttpRequest();
+ request.open('GET', apiURL + city, false);
+ request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey);
+ request.send(null);
+ const response = request.responseText;
+ weatherBlock.cacheCity = city;
+ const forecast = JSON.parse(response);
+ weatherBlock.cache = parseInt(forecast[daysAhead + 1]['high_celsius']);
+ } catch {
+ weatherBlock.cache = "It's always sunny in Philadelphia."
+ }
+ weatherBlock.value = weatherBlock.cache;
}
-var forecast = JSON.parse(response);
-block.value = parseInt(forecast[daysAhead + 1]['high_celsius']);
//* arg:weatherincitylow *//
-var block = logo.blocks.blockList[blk];
-var apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';
-var conns = block.connections;
-var city = logo.parseArg(logo, turtle, conns[1]);
-var daysAhead = parseInt(logo.parseArg(logo, turtle, conns[2]));
+const weatherMashapeKey = '3Rfxc7fwp2mshJxgtDxKSueYna8Ap1qZfAcjsn2hjpuWPuBCrI';
+const weatherBlock = globalActivity.blocks.blockList[blk];
+const apiURL = 'https://george-vustrey-weather.p.mashape.com/api.php?location=';
+const conns = weatherBlock.connections;
+const city = globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[1]);
+const daysAhead = parseInt(globalActivity.logo.parseArg(globalActivity.logo, turtle, conns[2]));
if (daysAhead < -1 || daysAhead > 5) {
- logo.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk);
+ globalActivity.errorMsg(_('Days ahead must be in the range of -1 to 5.'), blk);
daysAhead = 0;
}
-if (block.cacheCity === city && block.cache !== undefined) {
- var response = block.cache;
+if (weatherBlock.cacheCity === city && weatherBlock.cache !== undefined) {
+ weatherBlock.value = weatherBlock.cache;
} else {
- var request = new XMLHttpRequest();
- request.open('GET', apiURL + city, false);
- request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey);
- request.send(null);
- var response = request.responseText;
- block.cacheCity = city;
- block.cache = response;
+ try {
+ const request = new XMLHttpRequest();
+ request.open('GET', apiURL + city, false);
+ request.setRequestHeader('X-Mashape-Authorization', weatherMashapeKey);
+ request.send(null);
+ const response = request.responseText;
+ weatherBlock.cacheCity = city;
+ const forecast = JSON.parse(response);
+ weatherBlock.cache = parseInt(forecast[daysAhead + 1]['low_celsius']);
+ } catch {
+ weatherBlock.cache = "It's always sunny in Philadelphia."
+ }
+ weatherBlock.value = weatherBlock.cache;
}
-var forecast = JSON.parse(response);
-block.value = parseInt(forecast[daysAhead + 1]['low_celsius']);
//* block:weatherincity *//
-var weatherBlock = new ProtoBlock('weatherincity');
-weatherBlock.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['weatherincity'] = weatherBlock;
+const weatherBlock = new ProtoBlock('weatherincity');
+weatherBlock.palette = globalActivity.palettes.dict['mashape'];
+globalActivity.blocks.protoBlockDict['weatherincity'] = weatherBlock;
weatherBlock.staticLabels.push(_('forecast'));
weatherBlock.staticLabels.push(_('city'));
weatherBlock.staticLabels.push(_('day'));
@@ -115,9 +130,9 @@ weatherBlock.defaults.push('Canberra');
weatherBlock.defaults.push(1);
//* block:weatherincityhigh *//
-var weatherHighBlock = new ProtoBlock('weatherincityhigh');
-weatherHighBlock.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['weatherincityhigh'] = weatherHighBlock;
+const weatherHighBlock = new ProtoBlock('weatherincityhigh');
+weatherHighBlock.palette = globalActivity.palettes.dict['mashape'];
+globalActivity.blocks.protoBlockDict['weatherincityhigh'] = weatherHighBlock;
weatherHighBlock.staticLabels.push(_('high'));
weatherHighBlock.staticLabels.push(_('city'));
weatherHighBlock.staticLabels.push(_('day'));
@@ -128,9 +143,9 @@ weatherHighBlock.defaults.push('Canberra');
weatherHighBlock.defaults.push(1);
//* block:weatherincitylow *//
-var weatherLowBlock = new ProtoBlock('weatherincitylow');
-weatherLowBlock.palette = palettes.dict['mashape'];
-blocks.protoBlockDict['weatherincitylow'] = weatherLowBlock;
+const weatherLowBlock = new ProtoBlock('weatherincitylow');
+weatherLowBlock.palette = globalActivity.palettes.dict['mashape'];
+globalActivity.blocks.protoBlockDict['weatherincitylow'] = weatherLowBlock;
weatherLowBlock.staticLabels.push(_('low'));
weatherLowBlock.staticLabels.push(_('city'));
weatherLowBlock.staticLabels.push(_('day'));
@@ -141,9 +156,9 @@ weatherLowBlock.defaults.push('Canberra');
weatherLowBlock.defaults.push(1);
//* palette-icon:mashape *//
-
+
//* palette-fill:mashape *// #ff0066
//* palette-stroke:mashape *// #ef003e
//* palette-highlight:mashape *// #ffb1b3
-//* palette-stroke-highlight:mashape *// #000000
+//* palette-stroke-highlight:mashape *// #ef003e