diff --git a/js/widgets/sampler.js b/js/widgets/sampler.js index e1a75740b2..11ef1dcb07 100644 --- a/js/widgets/sampler.js +++ b/js/widgets/sampler.js @@ -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; @@ -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"; @@ -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"), ""); @@ -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 ); @@ -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; } } }; @@ -2336,7 +2326,6 @@ function SampleWidget() { instruments[0][instrumentName].playbackRate.value = playbackRate; } else { // If the instrument doesn't exist yet, we'll apply the adjustment when playing - console.log("Instrument not found, will apply cent adjustment during playback"); } } diff --git a/sw.js b/sw.js index be8abca044..cd4aaf6827 100644 --- a/sw.js +++ b/sw.js @@ -1,7 +1,6 @@ /* global - offlineFallbackPage */ // This is the "Offline page" service worker @@ -11,6 +10,7 @@ const precacheFiles = [ /* Add an array of files to precache for your app */ "./index.html" ]; +const offlineFallbackPage = "./index.html"; self.addEventListener("install", function (event) { // eslint-disable-next-line no-console