Skip to content

Commit 754b429

Browse files
committed
Minor code simplification
1 parent 70cd037 commit 754b429

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ bicial-*.json
2525
# IDE settings
2626
.vscode
2727
.vscode-test
28+
29+
# OS junk
30+
.DS_Store
31+
Thumbs.db

main.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,8 @@
528528
const checked = selected.has(i) ? "checked" : "";
529529
html += `<td><input type="checkbox" class="row-check" data-i="${i}" ${checked}></td>`;
530530
// per-row volume adjustments
531-
const adjLeft = adjL[i];
532-
const adjRight = adjR[i];
533-
html += `<td><input type="range" class="adj" min="-50" max="50" step="1" value="${adjLeft}" data-ear="L" data-i="${i}"></td>`;
534-
html += `<td><input type="range" class="adj" min="-50" max="50" step="1" value="${adjRight}" data-ear="R" data-i="${i}"></td>`;
531+
html += `<td><input type="range" class="adj" min="-50" max="50" step="1" value="${adjL[i]}" data-ear="L" data-i="${i}"></td>`;
532+
html += `<td><input type="range" class="adj" min="-50" max="50" step="1" value="${adjR[i]}" data-ear="R" data-i="${i}"></td>`;
535533
html += "</tr>";
536534
}
537535
// bottom batch row
@@ -630,19 +628,10 @@
630628
);
631629
sl.value = v;
632630
const c = Number(localStorage.getItem(KEYS.electrodeCount) || "12");
633-
const cir = (localStorage.getItem(KEYS.ciSide) || "R") === "R";
634-
const adjLeft = getAdj(c, "L");
635-
const adjRight = getAdj(c, "R");
636-
if (ear === "L") {
637-
(cir ? adjLeft : adjRight)[i] = v;
638-
} else {
639-
(cir ? adjRight : adjLeft)[i] = v;
640-
}
641-
setAdj(c, "L", adjLeft);
642-
setAdj(c, "R", adjRight);
643-
// live-update gain if L+R is active for this row (map displayed ear to actual channel)
644-
const actualEar = cir ? ear : ear === "L" ? "R" : "L";
645-
updateLiveGainFor(i, actualEar);
631+
const adjArr = getAdj(c, ear);
632+
adjArr[i] = v;
633+
setAdj(c, ear, adjArr);
634+
updateLiveGainFor(i, ear);
646635
});
647636
});
648637
container.querySelectorAll(".row-check").forEach((cb) => {
@@ -1410,6 +1399,7 @@
14101399
k === KEYS.volumeR ||
14111400
k === KEYS.beepDuration ||
14121401
k === KEYS.beepReps ||
1402+
k === KEYS.semiKeyLabel ||
14131403
k.startsWith(KEYS.fLPrefix) ||
14141404
k.startsWith(KEYS.fRPrefix) ||
14151405
k.startsWith(KEYS.adjLPrefix) ||
@@ -1429,9 +1419,8 @@
14291419
// Clear only our app keys from localStorage
14301420
const keys = keysForAllCounts();
14311421
keys.forEach((k) => localStorage.removeItem(k));
1432-
// Re-init UI controls with defaults and re-render
1433-
initControls();
1434-
showToast('All settings have been reset');
1422+
// Reload to avoid duplicate listeners and fully re-init
1423+
location.reload();
14351424
}
14361425

14371426
function resetAlignments() {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"url": "https://github.com/cito/bicial/issues"
2727
},
2828
"scripts": {
29-
"start": "open index.html || xdg-open index.html || start index.html",
30-
"serve": "npx http-server -p 8000 -o || python -m http.server 8000 || php -S localhost:8000"
29+
"start": "xdg-open index.html || open index.html || start index.html",
30+
"serve": "npx http-server -p 8000 -o || python3 -m http.server 8000 || python -m http.server 8000 || php -S localhost:8000 -t ."
3131
},
3232
"files": [
3333
"index.html",

0 commit comments

Comments
 (0)