From 82c1aeb9ec1a219c1ec289b1215c36d6527df198 Mon Sep 17 00:00:00 2001 From: Isaac Godin Date: Fri, 9 Jan 2026 13:21:39 -0500 Subject: [PATCH] Added a password gen feature and updated the ui a bit --- src/assets/ITThermal.js | 30 ++++++++++++++++++++++++++++++ src/index.html | 37 ++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/assets/ITThermal.js b/src/assets/ITThermal.js index eb3c2f8..fb6a923 100644 --- a/src/assets/ITThermal.js +++ b/src/assets/ITThermal.js @@ -299,6 +299,28 @@ function printPdf() { }, 100); } +async function generatePassword(length = 12) { + const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-=[]{}|;:,.<>?"; + let password = ""; + + for (let i = 0; i < length; i++) { + const randomIndex = Math.floor(Math.random() * characters.length); + password += characters[randomIndex]; + } + + const textareaElement = document.getElementById("tempPwPassword"); + textareaElement.value = password; + + try { + await navigator.clipboard.writeText(password); + console.log('text copied'); + } catch (err) { + console.error('Failed: ', err); + } +} + + + // ############################################################# // Event Listeners // ############################################################# @@ -317,6 +339,14 @@ document.getElementById('customNoteBtn').addEventListener('click', () => { alert(`An error occurred while generating the PDF: ${error.message}`); } }); +document.getElementById('genPassword').addEventListener('click', () => { + try { + generatePassword(); + } catch (error) { + alert(`An error occurred while generating the PDF: ${error.message}`); + } +}); + document.getElementById('deviceTrackerBtn').addEventListener('click', () => { try { deviceTrackerHandler(); diff --git a/src/index.html b/src/index.html index 5fca5ad..d31a3c5 100644 --- a/src/index.html +++ b/src/index.html @@ -35,11 +35,11 @@ + class="dark:border-gray-700 dark:bg-gray-700 dark:text-white mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> + class="dark:border-gray-700 dark:bg-gray-700 dark:text-white mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@@ -50,6 +50,14 @@ Generate Receipt
+
+ +
@@ -62,7 +70,7 @@ + class="dark:border-gray-700 dark:bg-gray-700 dark:text-white mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@@ -87,11 +95,11 @@ + class="dark:border-gray-700 dark:bg-gray-700 dark:text-white mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"> + class="dark:border-gray-700 dark:bg-gray-700 dark:text-white mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@@ -99,41 +107,41 @@
+ class="dark:border-gray-700 dark:bg-gray-700 dark:text-white mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@@ -167,4 +175,7 @@ - \ No newline at end of file + + + + \ No newline at end of file