Compare commits

..

No commits in common. "a61f5f5e5bf1a3730b8279a3b0dc217bdcf1c686" and "15c4ae9bad74d467825ab413d0cfc3e1fcdac323" have entirely different histories.

10 changed files with 2 additions and 5409 deletions

View File

@ -34,14 +34,13 @@
pkgs.libadwaita
pkgs.librsvg
pkgs.nodejs
pkgs.nodePackages.eslint
pkgs.nodePackages.typescript
pkgs.nodePackages.typescript-language-server
pkgs.openssl
pkgs.pipewire
pkgs.pkg-config
pkgs.rustup
pkgs.sqlite
pkgs.cargo-nextest
pkgs.wasm-pack
pkgs.sqlx-cli
pkgs.udev
pkgs.wasm-pack

View File

@ -1,10 +0,0 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['plugin:@typescript-eslint/recommended', 'eslint:recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
}

View File

@ -1,5 +0,0 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

5210
otg/pwa/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +0,0 @@
{
"name": "otg-pwa",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc",
"lint": "eslint ./src/**/.ts",
"test": "jest",
"test:watch": "jest --watch"
},
"author": "Savanni D'Gerinel <savanni@luminescent-dreams.com>",
"license": "GPL-3.0-or-later",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"http-server": "^14.1.1",
"jest": "^29.7.0",
"ts-jest": "^29.1.3"
}
}

View File

@ -1,37 +0,0 @@
import { c_to_k, f_to_k, k_to_c, k_to_f } from './conversions';
describe('temperature conversions', () => {
it('should convert celsius to kelvin', () => {
expect(c_to_k(0)).toBe(273.15);
expect(c_to_k(100)).toBe(373.15);
});
it('should convert fahrenheit to kelvin', () => {
expect(f_to_k(32)).toBe(273.15);
expect(f_to_k(212)).toBe(373.15);
});
it('should convert kelvin to celsius', () => {
expect(k_to_c(273.15)).toBe(0);
expect(k_to_c(373.15)).toBe(100);
});
it('should convert kelvin to fahrenheit', () => {
expect(k_to_f(273.15)).toBe(32);
expect(k_to_f(373.15)).toBe(212);
});
});
/*
import { getMessage } from './index'
describe('getMessage()', () => {
it('should return the correct message when called', () => {
expect(getMessage()).toBe('Hello, world')
})
it('should be super smart', () => {
expect(true).toBe(true)
})
})
*/

View File

@ -1,6 +0,0 @@
export const c_to_k = (value: number) => value + 273.15;
export const f_to_k = (value: number) => ((value - 32) * 5 / 9) + 273.15;
export const k_to_c = (value: number) => value - 273.15;
export const k_to_f = (value: number) => (value - 273.15) * 9 / 5 + 32;

View File

@ -1,18 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>On The Grid</title>
<style>
:body {
font-family: "sans-serif";
}
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="./index.js"></script>
</body>
</html>

View File

@ -1,83 +0,0 @@
import { c_to_k, f_to_k, k_to_c, k_to_f } from './conversions';
interface TemperatureChanged {
source: string,
value: number,
}
class TemperatureField extends HTMLElement {
static observedAttributes = ['value'];
value = 0;
inputElement: HTMLInputElement;
shadow: ShadowRoot;
constructor() {
super();
this.inputElement = document.createElement('input');
this.inputElement.type = "text";
this.shadow = this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
this.inputElement.onchange = ev => {
if (ev.target instanceof HTMLInputElement) {
let value = parseFloat(ev.target.value);
if (this.id == "f") {
const event = new CustomEvent('temperature-changed', { detail: { source: this.id, value: f_to_k(value) } });
this.dispatchEvent(event);
} else if (this.id == "c") {
const event = new CustomEvent('temperature-changed', { detail: { source: this.id, value: c_to_k(value) } });
this.dispatchEvent(event);
} else if (this.id == "k") {
const event = new CustomEvent('temperature-changed', { detail: { source: this.id, value } });
this.dispatchEvent(event);
}
}
}
}
render() {
this.shadow.appendChild(this.inputElement);
}
setTemperature(v: number) {
console.log("set the temperature on ", this.id, "to ", v);
}
}
class App {
temperatureK = 0;
updateTemperature(value: number) {
const f = document.getElementById("f");
if (f instanceof TemperatureField) {
f.setTemperature(value);
}
const c = document.getElementById("c");
if (c instanceof TemperatureField) {
c.setTemperature(value);
}
const k = document.getElementById("k");
if (k instanceof TemperatureField) {
k.setTemperature(value);
}
}
}
window.customElements.define('temperature-field', TemperatureField);
const app = new App();
document.getElementById("f")?.addEventListener('temperature-changed', ev => {
if (ev instanceof CustomEvent) { app.updateTemperature(ev.detail.value) }
});
document.getElementById("c")?.addEventListener('temperature-changed', ev => {
if (ev instanceof CustomEvent) { app.updateTemperature(ev.detail.value) }
});
document.getElementById("k")?.addEventListener('temperature-changed', ev => {
if (ev instanceof CustomEvent) { app.updateTemperature(ev.detail.value) }
});

View File

@ -1,13 +0,0 @@
{
"compilerOptions": {
"strict": true,
"target": "ESNext",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}