From c7c28d65e42e67c97f5c01e0d85a01b78d99fc3b Mon Sep 17 00:00:00 2001 From: Drew Bednar <drew@androiddrew.com> Date: Wed, 7 Aug 2024 20:41:36 -0400 Subject: [PATCH] Trash old code --- basic/index.html | 16 ---------- basic/main.py | 8 ----- basic/script.js | 37 ---------------------- basic/script_v1.js | 35 --------------------- basic/style.css | 22 ------------- old/v1/old/index.html | 72 ------------------------------------------- old/v1/old/style.css | 0 7 files changed, 190 deletions(-) delete mode 100644 basic/index.html delete mode 100644 basic/main.py delete mode 100644 basic/script.js delete mode 100644 basic/script_v1.js delete mode 100644 basic/style.css delete mode 100644 old/v1/old/index.html delete mode 100644 old/v1/old/style.css diff --git a/basic/index.html b/basic/index.html deleted file mode 100644 index a9e9d07..0000000 --- a/basic/index.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Web Serial API Example</title> - <link rel="stylesheet" href="styles.css"> -</head> -<body> - <h1>Web Serial Connect</h1> - <button id="connect">Connect to Serial Device</button> - <pre id="output"></pre> - - <script src="script.js"></script> -</body> -</html> diff --git a/basic/main.py b/basic/main.py deleted file mode 100644 index d6e115e..0000000 --- a/basic/main.py +++ /dev/null @@ -1,8 +0,0 @@ -import time - -i = 0 - -while True: - print("Iteration: {}".format(i)) - i+=1 - time.sleep(1) \ No newline at end of file diff --git a/basic/script.js b/basic/script.js deleted file mode 100644 index 437d472..0000000 --- a/basic/script.js +++ /dev/null @@ -1,37 +0,0 @@ -document.getElementById('connect').addEventListener('click', async () => { - // Feature detection - if ('serial' in navigator) { - try { - // Request a port and open a connection - const port = await navigator.serial.requestPort(); - await port.open({ baudRate: 115200 }); - - // Create a text decoder to decode the bytes from the serial device - const decoder = new TextDecoderStream(); - const inputDone = port.readable.pipeTo(decoder.writable); - const inputStream = decoder.readable; - - // Read data from the serial device - const reader = inputStream.getReader(); - const outputElement = document.getElementById('output'); - outputElement.textContent = ''; - - while (true) { - const { value, done } = await reader.read(); - if (done) { - // Allow the serial port to be closed later. - reader.releaseLock(); - break; - } - // Print the output to the webpage - outputElement.textContent += value; - // Scroll to the bottom as new data comes in - outputElement.scrollTop = outputElement.scrollHeight; - } - } catch (error) { - console.error('There was an error:', error); - } - } else { - console.log('Web Serial API not supported in this browser.'); - } -}); diff --git a/basic/script_v1.js b/basic/script_v1.js deleted file mode 100644 index e6dbcb5..0000000 --- a/basic/script_v1.js +++ /dev/null @@ -1,35 +0,0 @@ -document.getElementById('connect').addEventListener('click', async () => { - // Feature detection - if ('serial' in navigator) { - try { - // Request a port and open a connection - const port = await navigator.serial.requestPort(); - await port.open({ baudRate: 115200 }); - - // Create a text decoder to decode the bytes from the serial device - const decoder = new TextDecoderStream(); - const inputDone = port.readable.pipeTo(decoder.writable); - const inputStream = decoder.readable; - - // Read data from the serial device - const reader = inputStream.getReader(); - const outputElement = document.getElementById('output'); - outputElement.textContent = ''; - - while (true) { - const { value, done } = await reader.read(); - if (done) { - // Allow the serial port to be closed later. - reader.releaseLock(); - break; - } - // Print the output to the webpage - outputElement.textContent += value; - } - } catch (error) { - console.error('There was an error:', error); - } - } else { - console.log('Web Serial API not supported in this browser.'); - } -}); diff --git a/basic/style.css b/basic/style.css deleted file mode 100644 index e27818c..0000000 --- a/basic/style.css +++ /dev/null @@ -1,22 +0,0 @@ -body { - margin: 0; - font-family: Arial, sans-serif; -} - -button { - margin: 20px; -} - -#output { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 33vh; /* Top third of the screen */ - background-color: #333; /* Slightly darker background */ - color: #fff; - overflow-y: scroll; - padding: 10px; - box-sizing: border-box; - border-bottom: 1px solid #555; -} diff --git a/old/v1/old/index.html b/old/v1/old/index.html deleted file mode 100644 index c532597..0000000 --- a/old/v1/old/index.html +++ /dev/null @@ -1,72 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Scrollable Element with Autoscroll</title> - <style> - body, html { - height: 100%; - margin: 0; - padding: 0; - } - #container { - display: flex; - flex-direction: column; - height: 100%; - } - #top-half { - flex: 1; - padding: 20px; - } - #scrollable-element { - flex: 1; - overflow-y: auto; - border: 1px solid #ccc; - padding: 10px; - background-color: #e2e8f0; - } - </style> -</head> -<body> - <div id="container"> - <div id="top-half"> - <h1>Scrollable Element Demo</h1> - <label> - <input type="checkbox" id="autoscroll-checkbox" checked> Autoscroll - </label> - </div> - <div id="scrollable-element"></div> - </div> - - <script> - const scrollableElement = document.getElementById('scrollable-element'); - const autoscrollCheckbox = document.getElementById('autoscroll-checkbox'); - let autoscroll = true; - - autoscrollCheckbox.addEventListener('change', (e) => { - autoscroll = e.target.checked; - if (autoscroll) { - scrollToBottom(); - } - }); - - function addText() { - const newText = document.createElement('p'); - newText.textContent = `New text added at ${new Date().toLocaleTimeString()}`; - scrollableElement.appendChild(newText); - - if (autoscroll) { - scrollToBottom(); - } - } - - function scrollToBottom() { - scrollableElement.scrollTop = scrollableElement.scrollHeight; - } - - // Simulate adding text every 2 seconds - setInterval(addText, 2000); - </script> -</body> -</html> \ No newline at end of file diff --git a/old/v1/old/style.css b/old/v1/old/style.css deleted file mode 100644 index e69de29..0000000