Skip to content

Commit f92d05f

Browse files
committed
Improve comments and panel switching code
1 parent 297c8fa commit f92d05f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

js/layout.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ function isSerialVisible() {
2727
}
2828

2929
function setupPanelFocusHandlers() {
30-
console.log("Setting up panel focus handlers");
30+
// Removing existing handlers to avoid duplicates
3131
serialPage.removeEventListener('click', handleActivePanel);
32-
serialPage.addEventListener('click', handleActivePanel);
3332
editorPage.removeEventListener('click', handleActivePanel);
33+
34+
// Adding new handlers
35+
serialPage.addEventListener('click', handleActivePanel);
3436
editorPage.addEventListener('click', handleActivePanel);
3537
}
3638

@@ -40,26 +42,21 @@ function handleActivePanel(event) {
4042
}
4143

4244
function setActivePanel(panel) {
45+
editorPage.classList.remove('focused-panel');
46+
serialPage.classList.remove('focused-panel');
47+
4348
if (panel === serialPage && isSerialVisible()) {
4449
// Serial panel requested and visible
4550
serialPage.classList.add('focused-panel');
46-
editorPage.classList.remove('focused-panel');
47-
console.log("Serial panel focused");
4851
} else if (panel === editorPage && isEditorVisible()) {
4952
// Editor panel requested and visible
5053
editorPage.classList.add('focused-panel');
51-
serialPage.classList.remove('focused-panel');
52-
console.log("Editor panel focused");
5354
} else {
5455
// Requested panel is not visible, set other panel as focused
5556
if (isEditorVisible()) {
5657
editorPage.classList.add('focused-panel');
57-
serialPage.classList.remove('focused-panel');
58-
console.log("Editor panel focused (default)");
5958
} else {
6059
serialPage.classList.add('focused-panel');
61-
editorPage.classList.remove('focused-panel');
62-
console.log("Serial panel focused (default)");
6360
}
6461
}
6562
}

0 commit comments

Comments
 (0)