Skip to content

Commit 209a58e

Browse files
authored
refactor: replace var with let/const in widgets and toolbar files (#5051)
1 parent 31c4325 commit 209a58e

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

js/toolbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ class Toolbar {
827827
const menuIcon = docById("menu");
828828
const auxToolbar = docById("aux-toolbar");
829829
menuIcon.onclick = () => {
830-
var searchBar = docById("search");
830+
const searchBar = docById("search");
831831
searchBar.classList.toggle("open");
832832
if (auxToolbar.style.display == "" || auxToolbar.style.display == "none") {
833833
onclick(this.activity, false);

js/widgets/aiwidget.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ function AIWidget() {
782782
widgetWindow.show();
783783

784784
// For the button callbacks
785-
var that = this;
785+
const that = this;
786786

787787
widgetWindow.onclose = () => {
788788
if (this.drawVisualIDs) {
@@ -873,10 +873,10 @@ function AIWidget() {
873873
* @returns {void}
874874
*/
875875
this._playABCSong = function () {
876-
var abc = abcNotationSong;
877-
var stopAudioButton = document.querySelector(".stop-audio");
876+
const abc = abcNotationSong;
877+
const stopAudioButton = document.querySelector(".stop-audio");
878878

879-
var visualObj = ABCJS.renderAbc("*", abc, {
879+
const visualObj = ABCJS.renderAbc("*", abc, {
880880
responsive: "resize"
881881
})[0];
882882

@@ -890,7 +890,7 @@ function AIWidget() {
890890
window.webkitAudioContext ||
891891
navigator.mozAudioContext ||
892892
navigator.msAudioContext;
893-
var audioContext = new window.AudioContext();
893+
const audioContext = new window.AudioContext();
894894
audioContext.resume().then(function () {
895895
// In theory the AC shouldn't start suspended because it is being initialized in a click handler, but iOS seems to anyway.
896896

@@ -917,13 +917,13 @@ function AIWidget() {
917917
.catch(function (error) {
918918
if (error.status === "NotSupported") {
919919
stopAudioButton.setAttribute("style", "display:none;");
920-
var audioError = document.querySelector(".audio-error");
920+
const audioError = document.querySelector(".audio-error");
921921
audioError.setAttribute("style", "");
922922
} else console.warn("synth error", error);
923923
});
924924
});
925925
} else {
926-
var audioError = document.querySelector(".audio-error");
926+
const audioError = document.querySelector(".audio-error");
927927
audioError.setAttribute("style", "");
928928
}
929929
};

js/widgets/phrasemaker.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,68 +275,68 @@ class PhraseMaker {
275275
* Width of the screen.
276276
* @type {number}
277277
*/
278-
var screenWidth = window.innerWidth;
278+
const screenWidth = window.innerWidth;
279279

280280
/**
281281
* Height of the screen.
282282
* @type {number}
283283
*/
284-
var screenHeight = window.innerHeight;
284+
const screenHeight = window.innerHeight;
285285

286286
/**
287287
* Container element for floating windows.
288288
* @type {HTMLElement}
289289
*/
290-
var floatingWindowsDiv = document.getElementById("floatingWindows");
290+
const floatingWindowsDiv = document.getElementById("floatingWindows");
291291

292292
/**
293293
* Collection of window frame elements.
294294
* @type {NodeListOf<Element>}
295295
*/
296-
var windowFrameElements = floatingWindowsDiv.querySelectorAll(".windowFrame");
296+
const windowFrameElements = floatingWindowsDiv.querySelectorAll(".windowFrame");
297297

298-
for (var i = 0; i < windowFrameElements.length; i++) {
298+
for (let i = 0; i < windowFrameElements.length; i++) {
299299
/**
300300
* Current window frame element.
301301
* @type {Element}
302302
*/
303-
var windowFrame = windowFrameElements[i];
303+
const windowFrame = windowFrameElements[i];
304304

305305
/**
306306
* Widget body element within the window frame.
307307
* @type {Element}
308308
*/
309-
var wfWinBody = windowFrame.querySelector(".wfWinBody");
309+
const wfWinBody = windowFrame.querySelector(".wfWinBody");
310310

311311
/**
312312
* Widget element within the window frame.
313313
* @type {Element}
314314
*/
315-
var wfbWidget = windowFrame.querySelector(".wfbWidget");
315+
const wfbWidget = windowFrame.querySelector(".wfbWidget");
316316

317317
/**
318318
* Total width of the window frame.
319319
* @type {number}
320320
*/
321-
var totalWidth = parseFloat(window.getComputedStyle(windowFrame).width);
321+
const totalWidth = parseFloat(window.getComputedStyle(windowFrame).width);
322322

323323
/**
324324
* Total height of the window frame.
325325
* @type {number}
326326
*/
327-
var totalHeight = parseFloat(window.getComputedStyle(windowFrame).height);
327+
const totalHeight = parseFloat(window.getComputedStyle(windowFrame).height);
328328

329329
/**
330330
* Maximum allowed width for the window frame.
331331
* @type {number}
332332
*/
333-
var maxWidth = screenWidth * 0.8;
333+
const maxWidth = screenWidth * 0.8;
334334

335335
/**
336336
* Maximum allowed height for the window frame.
337337
* @type {number}
338338
*/
339-
var maxHeight = screenHeight * 0.8;
339+
const maxHeight = screenHeight * 0.8;
340340

341341
if (totalWidth > screenWidth || totalHeight > screenHeight) {
342342
windowFrame.style.height = Math.min(totalHeight, maxHeight) + "px";

js/widgets/sampler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ function SampleWidget() {
305305
* @returns {void}
306306
*/
307307
this.__save = function () {
308-
var that = this;
308+
const that = this;
309309
setTimeout(function () {
310310
that._addSample();
311311

312312
// Include the cent adjustment value in the sample block
313313
const centAdjustment = that.centAdjustmentValue || 0;
314314

315-
var newStack = [
315+
const newStack = [
316316
[0, "settimbre", 100, 100, [null, 1, null, 5]],
317317
[
318318
1,

0 commit comments

Comments
 (0)