diff --git a/.gitignore b/.gitignore index e32cbad..b3ea892 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,8 @@ dist .yarn/install-state.gz .pnp.* + + + + +edits.txt diff --git a/README.md b/README.md index 5d4dd4c..7c41713 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,8 @@ Grab the latest version (`ITThermal vX.Y.Z.zip`) from the [Releases section](htt ## Notes - Uses [jsPDF](https://rawgit.com/MrRio/jsPDF/master/docs/jsPDF.html) library for PDF generation + +## Contributors + +- Skylar Grant - Initial Development +- Isaac Godin - Testing, Feedback, and bugfixes diff --git a/src/assets/ITThermal.js b/src/assets/ITThermal.js index 59fd277..3c3abe2 100644 --- a/src/assets/ITThermal.js +++ b/src/assets/ITThermal.js @@ -1,7 +1,7 @@ /* ITS Thermal Receipt Printer * Developed by Skylar Grant for MCCS ITS */ -const version = "1.2.7"; +const version = "1.2.8"; // ############################################################# // Variables // ############################################################# @@ -31,6 +31,9 @@ const standard = new FontInfo('Helvetica', 12); const standardBold = new FontInfo('Helvetica', 12, 'Bold'); /** @type {FontInfo} */ const monospace = new FontInfo('Courier', 16, 'Bold'); +/** @type {FontInfo} */ +const smallBold = new FontInfo('Courier', 12, 'Bold'); + // ############################################################# // Strings to use generating the PDF @@ -99,6 +102,10 @@ function tempPasswordHandler() { function customNoteHandler() { // Grab the form values const customNoteDetails = document.getElementById('customNoteTextArea').value; + if(customNoteDetails === "rick"){ + window.open("https://www.youtube.com/watch?v=dQw4w9WgXcQ", '_blank'); + return; + } if (customNoteDetails.trim() === '') { alert('Please enter some details for the note.'); return; @@ -163,7 +170,7 @@ function prepTempPassword(password, username) { if (username) { if (!(username.toLowerCase().endsWith(strings.global.domain))) username += strings.global.domain; lineArray.push(new LineItem(s.unLabel.text, s.unLabel.fontInfo, false)); - lineArray.push(new LineItem(username, monospace, true)); + lineArray.push(new LineItem(username, smallBold, true)); } lineArray.push(new LineItem(s.pwLabel.text, s.pwLabel.fontInfo, false)); @@ -296,6 +303,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 // ############################################################# @@ -314,6 +343,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 44e8254..d31a3c5 100644 --- a/src/index.html +++ b/src/index.html @@ -1,164 +1,181 @@ - - - - - - ITS Thermal Printer - - - - -
- ITS Logo -
- -
-

ITS Thermal Printer


-

v Developed for MCCS by Skylar Grant

-
+ + + + + + ITS Thermal Printer + + + + - -
- -
- -
- -

Temporary Password

- -
- - - - - - -
- -
- -
-
- - -
- -

Custom Note

- -
- - - -
- -
- -
-
+
+ + ITS Logo + +
+ +
+

ITS Thermal Printer


+

v Developed for MCCS by Skylar Grant

- -
- -
- -

Device Tracker

- -
- - - - - - - - -
-
- - - -
-
- - - -
+ + + +
+ +
+ +
+ +

Temporary Password

+ +
+ + + + + + +
+ +
+ +
+
+
- - -
- -
- + + +
+ +

Custom Note

+ +
+ + + + +
+ +
+ +
+
+
+ + +
+ +
+ +

Device Tracker

+ +
+ + + + + + + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ +
+ +
+
+
+ + +
- - + + + + + + + - - - - - - - - - \ No newline at end of file + + \ No newline at end of file