diff --git a/index.js b/index.js index dada225..f020928 100644 --- a/index.js +++ b/index.js @@ -8,10 +8,11 @@ bpm.addEventListener("change", (e) => { const newChannel = document.getElementById("new-channel"); const insert = document.getElementById("insert"); insert.addEventListener("click", (e) => { - const newSequence = newChannel.querySelector("input[type=text]").value; + input = newChannel.querySelector("input[type=text]"); + const newSequence = input.value; if (newSequence) { createChannel(rebuildArray(newSequence)); - newChannel.value = ""; + input.value = ""; } }); @@ -24,8 +25,6 @@ document.getElementById("start")?.addEventListener("click", async () => { newChannel.classList.remove("hidden"); createChannel(["C4", null, null, "F4", null, null, null]); - createChannel([["C3", ["F3", "G3", "A#3"]], "C3", ["D#3", "D3"], "F3"]); - createChannel(["C3", ["G3", ["F3", "A#3"]], "C3", ["D#3", "D3"], "F3"]); createChannel(["C3", "F3"]); }); @@ -84,7 +83,11 @@ let createChannel = function (sequence) { function simplifyArray(literal) { // Sorry for this - return literal.replaceAll('"', "").replaceAll("'", "").replaceAll(",", ", "); + return literal + .replaceAll('"', "") + .replaceAll("'", "") + .replaceAll(",", ", ") + .replaceAll("null", "-"); } function rebuildArray(literal) { @@ -100,6 +103,7 @@ function rebuildArray(literal) { let array = JSON.parse(rebuild); try { getAllIndexes(array, "null").forEach((index) => (array[index] = null)); + getAllIndexes(array, "-").forEach((index) => (array[index] = null)); } catch (e) { console.log(e); }