Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -7958,7 +7958,9 @@ class Activity {
},
() => {
alert(
"Something went wrong reading JSON-encoded project data."
_(
"Something went wrong reading JSON-encoded project data."
)
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion js/blocks/ProgramBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ function setupProgramBlocks(activity) {
win.focus();
} else {
// Browser has blocked it.
alert("Please allow popups for this site");
alert(_("Please allow popups for this site"));
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion js/blocks/__tests__/GraphicsBlocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ describe("GraphicsBlocks", () => {
};

activity = {
blocks: {},
blocks: {
blockList: {}
},
errorMsg: jest.fn(),
turtles: {
companionTurtle: jest.fn(() => 0),
Expand Down
10 changes: 7 additions & 3 deletions js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ requirejs(["i18next", "i18nextHttpBackend"], function (i18next, i18nextHttpBacke
console.error(
"FATAL: createjs (EaselJS/TweenJS) not found. Cannot proceed."
);
alert("Failed to load EaselJS. Please refresh the page.");
const t_ = typeof _ === "function" ? _ : s => s;
alert(t_("Failed to load EaselJS. Please refresh the page."));
return;
}

Expand All @@ -333,15 +334,18 @@ requirejs(["i18next", "i18nextHttpBackend"], function (i18next, i18nextHttpBacke
},
function (err) {
console.error("Failed to load activity/activity:", err);
alert("Failed to load Music Blocks. Please refresh the page.");
const t_ = typeof _ === "function" ? _ : s => s;
alert(t_("Failed to load Music Blocks. Please refresh the page."));
}
);
}, 100); // Small delay to allow globals to be set
},
function (err) {
console.error("Core bootstrap failed:", err);
const t_ = typeof _ === "function" ? _ : s => s;
alert(
"Failed to initialize Music Blocks core. Please refresh the page.\n\nError: " +
t_("Failed to initialize Music Blocks core. Please refresh the page.") +
"\n\nError: " +
(err.message || err)
);
}
Expand Down
7 changes: 5 additions & 2 deletions js/utils/synthutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ function Synth() {
if (fileName) {
download(url, fileName + (platform.FF ? ".wav" : ".ogg"));
} else {
alert("Download cancelled.");
alert(_("Download cancelled."));
}
};
// this.recorder.start();
Expand Down Expand Up @@ -1992,7 +1992,10 @@ function Synth() {
if (Tone.context.state !== "running" && !window.hasShownAudioWarning) {
window.hasShownAudioWarning = true;
alert(
"⚠️ Sound is disabled!\n\nPlease check your browser settings (Site Settings > Sound) to allow audio for Music Blocks."
"⚠️ " +
_(
"Sound is disabled! Please check your browser settings (Site Settings > Sound) to allow audio for Music Blocks."
)
);
}
}, 2000);
Expand Down
78 changes: 34 additions & 44 deletions js/widgets/sampler.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ function SampleWidget() {
this.activity.blocks.blockList[mainSampleBlock].text.text
) {
// Append cent adjustment to the block text if possible
const currentText = this.activity.blocks.blockList[mainSampleBlock].text
.text;
const currentText =
this.activity.blocks.blockList[mainSampleBlock].text.text;
if (!currentText.includes("¢")) {
this.activity.blocks.blockList[mainSampleBlock].text.text +=
" " + centText;
Expand Down Expand Up @@ -522,29 +522,25 @@ function SampleWidget() {
}
};

widgetWindow.addButton(
"load-media.svg",
ICONSIZE,
_("Upload sample"),
""
).onclick = function () {
stopTuner();
const fileChooser = docById("myOpenAll");
widgetWindow.addButton("load-media.svg", ICONSIZE, _("Upload sample"), "").onclick =
function () {
stopTuner();
const fileChooser = docById("myOpenAll");

// eslint-disable-next-line no-unused-vars
const __readerAction = function (event) {
window.scroll(0, 0);
const sampleFile = fileChooser.files[0];
that.handleFiles(sampleFile);
fileChooser.removeEventListener("change", __readerAction);
};

// eslint-disable-next-line no-unused-vars
const __readerAction = function (event) {
fileChooser.addEventListener("change", __readerAction, false);
fileChooser.focus();
fileChooser.click();
window.scroll(0, 0);
const sampleFile = fileChooser.files[0];
that.handleFiles(sampleFile);
fileChooser.removeEventListener("change", __readerAction);
};

fileChooser.addEventListener("change", __readerAction, false);
fileChooser.focus();
fileChooser.click();
window.scroll(0, 0);
};

// Create a container for the pitch button and frequency display
this.pitchBtnContainer = document.createElement("div");
this.pitchBtnContainer.className = "wfbtItem";
Expand Down Expand Up @@ -576,22 +572,18 @@ function SampleWidget() {
};

this._save_lock = false;
widgetWindow.addButton(
"export-chunk.svg",
ICONSIZE,
_("Save sample"),
""
).onclick = function () {
stopTuner();
// Debounce button
if (!that._get_save_lock()) {
that._save_lock = true;
that._saveSample();
setTimeout(function () {
that._save_lock = false;
}, 1000);
}
};
widgetWindow.addButton("export-chunk.svg", ICONSIZE, _("Save sample"), "").onclick =
function () {
stopTuner();
// Debounce button
if (!that._get_save_lock()) {
that._save_lock = true;
that._saveSample();
setTimeout(function () {
that._save_lock = false;
}, 1000);
}
};

this._recordBtn = widgetWindow.addButton("mic.svg", ICONSIZE, _("Toggle Mic"), "");

Expand Down Expand Up @@ -1783,9 +1775,8 @@ function SampleWidget() {

const __selectionChanged = () => {
const label = this._pitchWheel.navItems[this._pitchWheel.selectedNavItemIndex].title;
const attr = this._accidentalsWheel.navItems[
this._accidentalsWheel.selectedNavItemIndex
].title;
const attr =
this._accidentalsWheel.navItems[this._accidentalsWheel.selectedNavItemIndex].title;
const octave = Number(
this._octavesWheel.navItems[this._octavesWheel.selectedNavItemIndex].title
);
Expand Down Expand Up @@ -2047,9 +2038,8 @@ function SampleWidget() {
const playbackRate = TunerUtils.calculatePlaybackRate(0, this.centsValue);
// Apply the playback rate to the sample
if (instruments[0]["customsample_" + this.originalSampleName]) {
instruments[0][
"customsample_" + this.originalSampleName
].playbackRate.value = playbackRate;
instruments[0]["customsample_" + this.originalSampleName].playbackRate.value =
playbackRate;
}
}
};
Expand Down Expand Up @@ -2247,7 +2237,7 @@ function SampleWidget() {
this.pitchDetectionAnimationId = requestAnimationFrame(updatePitch);
} catch (err) {
console.error(`${err.name}: ${err.message}`);
alert("Microphone access failed: " + err.message);
alert(_("Microphone access failed: ") + err.message);
// Clean up any partially initialized resources
this.stopPitchDetection();
}
Expand Down
Loading