Skip to content

Commit

Permalink
Merge pull request #22 from Asc91/main
Browse files Browse the repository at this point in the history
Fix issue #15
  • Loading branch information
lorforlinux authored May 21, 2024
2 parents ae26e41 + 81bb18e commit 0ea6aab
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function saveSettings() {
document.getElementById("saveChanges").addEventListener("click", saveSettings);
window.addEventListener("load", function () {
// Check if the browser is compatible with the Web Serial API
if ((!navigator.serial)) {
if (!navigator.serial) {
// Display the compatibility message
document.getElementById("compatibilityMessage").style.display = "block";
// Hide the navbar
Expand Down Expand Up @@ -173,11 +173,15 @@ let isRecording = false;
// Function to start streaming
function startStreaming() {
isStreaming = true;
document.getElementById("startButton").textContent = "Stop";
document.getElementById("recordButton").disabled = false;
}

// Function to stop streaming
function stopStreaming() {
isStreaming = false;
document.getElementById("startButton").textContent = "Start";
document.getElementById("recordButton").disabled = true;
}

async function connectToDevice() {
Expand Down Expand Up @@ -278,25 +282,29 @@ document.getElementById("connectButton").addEventListener("click", async () => {
document.getElementById("startButton").addEventListener("click", () => {
if (!isStreaming) {
startStreaming();
document.getElementById("startButton").textContent = "Stop";
document.getElementById("recordButton").disabled = false;
} else {
stopStreaming();
document.getElementById("startButton").textContent = "Start";
document.getElementById("recordButton").disabled = true;
isRecording = false;
}
});
document.getElementById("recordButton").addEventListener("click", () => {
isRecording = !isRecording;
document.getElementById("recordButton").textContent = isRecording
? "Pause"
: "Record";
document.getElementById("saveButton").disabled = isRecording;
if (!isRecording) {
isRecording = true;
document.getElementById("recordButton").textContent = "Pause";
document.getElementById("startButton").disabled = true;
document.getElementById("saveButton").disabled = true;
} else if (isRecording) {
isRecording = false;
document.getElementById("recordButton").textContent = "Record";
document.getElementById("startButton").disabled = false;
document.getElementById("saveButton").disabled = false;
}
});

document.getElementById("saveButton").addEventListener("click", async () => {
startButton.disabled = true;
stopStreaming();
await save_csv();
startButton.disabled = false;
});

// Download CSV file return db;
Expand Down

0 comments on commit 0ea6aab

Please sign in to comment.