Skip to content

Commit

Permalink
Merge pull request #216 from OpenGammaProject/dev
Browse files Browse the repository at this point in the history
Version 2024-01-17
  • Loading branch information
NuclearPhoenixx authored Jan 17, 2024
2 parents aa5aa89 + 68538f4 commit 43c8152
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 70 deletions.
48 changes: 37 additions & 11 deletions assets/js/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/main.js.map

Large diffs are not rendered by default.

88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@types/w3c-web-serial": "^1.0.6",
"@types/w3c-web-usb": "^1.0.10",
"@types/wicg-file-system-access": "^2023.10.4",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"eslint": "^8.56.0",
"typescript": "^5.3.3"
}
Expand Down
2 changes: 1 addition & 1 deletion service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
https://nuclearphoenix.xyz
*/
const APP_VERSION = '2024-01-10';
const APP_VERSION = '2024-01-17';
const CACHE_NAME = 'gamma-static'; // A random name for the cache

const OFFLINE_RESOURCES = ['/',
Expand Down
55 changes: 44 additions & 11 deletions source/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const isoList: IsotopeList = {};
let checkNearIso = false;
let maxDist = 100; // Max energy distance to highlight

const APP_VERSION = '2024-01-10';
const APP_VERSION = '2024-01-17';
const localStorageAvailable = 'localStorage' in self; // Test for localStorage, for old browsers
const wakeLockAvailable = 'wakeLock' in navigator; // Test for Screen Wake Lock API
const notificationsAvailable = 'Notification' in window; // Test for Notifications API
Expand Down Expand Up @@ -989,6 +989,9 @@ function toggleSma(value: boolean, thisValue: HTMLInputElement | null = null ):
}


document.getElementById('sma-val')!.onkeydown = event => {
if (event.key === 'Enter') document.getElementById('sma')?.click(); // ENTER key
};
document.getElementById('sma-val')!.oninput = event => changeSma(<HTMLInputElement>event.target);

function changeSma(input: HTMLInputElement): void {
Expand Down Expand Up @@ -2250,16 +2253,6 @@ function loadJSON(name: string): any {


function bindInputs(): void {
const nonSettingsEnterPressElements = {
'sma-val': 'sma',
'ser-command': 'send-command'
}
for (const [inputId, buttonId] of Object.entries(nonSettingsEnterPressElements)) {
document.getElementById(inputId)!.onkeydown = event => {
if (event.key === 'Enter') document.getElementById(buttonId)?.click(); // ENTER key
};
}

// Bind settings button onclick events and enter press, format: {settingsValueElement: settingsName}
const settingsEnterPressElements = {
'iso-hover-prox': 'maxIsoDist',
Expand Down Expand Up @@ -2892,6 +2885,38 @@ async function readSerial(): Promise<void> {
}


document.getElementById('ser-command')!.onkeydown = (event) => {
if (event.key === 'Enter') document.getElementById('send-command')?.click(); // ENTER key

if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
event.preventDefault();
handleArrowKey(event.key);
}
//event.preventDefault();
}


const consoleHistory = {
history: <string[]>[],
currentIndex: -1
}

function handleArrowKey(key: string): void {
const element = <HTMLInputElement>document.getElementById('ser-command');
if (key === 'ArrowUp' && consoleHistory.currentIndex < consoleHistory.history.length - 1) {
consoleHistory.currentIndex++;
} else if (key === 'ArrowDown' && consoleHistory.currentIndex > -1) {
consoleHistory.currentIndex--;
}

if (consoleHistory.currentIndex >= 0 && consoleHistory.currentIndex < consoleHistory.history.length) {
element.value = consoleHistory.history[consoleHistory.currentIndex];
} else {
element.value = '';
}
}


document.getElementById('send-command')!.onclick = () => sendSerial();

async function sendSerial(): Promise<void> {
Expand All @@ -2904,6 +2929,14 @@ async function sendSerial(): Promise<void> {
return;
}

// Add message to console history
const inputValue = element.value.trim();

if (inputValue.length) {
consoleHistory.history.unshift(inputValue);
consoleHistory.currentIndex = -1;
}

element.value = '';
}

Expand Down

0 comments on commit 43c8152

Please sign in to comment.