This commit is contained in:
mtgmonkey 2025-04-24 22:32:10 -04:00
commit f4e4e2eae1
30 changed files with 11452 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

Binary file not shown.

33
frontend/elm.json Normal file
View file

@ -0,0 +1,33 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/json": "1.1.3",
"elm/url": "1.0.0",
"lobanov/elm-localstorage": "1.0.1",
"rtfeldman/elm-css": "18.0.0"
},
"indirect": {
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/http": "2.0.0",
"elm/random": "1.0.0",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.3",
"lobanov/elm-taskport": "2.0.1",
"robinheghan/murmur3": "1.0.0",
"rtfeldman/elm-hex": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}

81
frontend/index.def.html Normal file
View file

@ -0,0 +1,81 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf8">
<title>Main</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #000000;
}
</style>
<script src="main.js"></script>
</head>
<body>
<script>
var app;
// call main with data from ./init.json and initialisation function
callWithServerData('./init.json', main, init)
// FUNCTIONS
// takes pertinent data and returns an app
// serverData : Object
// cookies : Object
function init(serverData, cookies) {
const flags = {...serverData, ...cookies};
app = Elm.Main.init({
flags: flags
});
app.ports.setStorage.subscribe(setStorage);
app.ports.refresh.subscribe(main);
}
// main 'loop'
// serverData : Object
// init : Function
function main(serverData, init) {
const cookies = localStorage.getItem('cookies') ? JSON.parse(localStorage.getItem('cookies')) : "";
init(serverData, cookies);
// XXX send test server data to getTestFromServer
// callWithServerData('./test.json', app.ports.getTestFromServer.send);
}
// passes the content of json at path to the function toCall
// path : String
// toCall : Function
function callWithServerData(path, toCall, ...args) {
fetch(path)
.then(response => response.json())
.then(data => {
if (toCall === main) {
toCall(data, args[0]);
} else {
toCall(data, args);
}
})
.catch(err => {
console.error('Err ', err.message);
const data = "";
if (toCall === main) {
toCall(data, args[0]);
} else {
toCall(data, args);
}
});
}
// sets localStorage cookies to passed cookies value
// cookies : Object
function setStorage(cookies) {
localStorage.setItem('cookies', JSON.stringify(cookies));
}
</script>
</body>
</html>

9
frontend/shell.nix Normal file
View file

@ -0,0 +1,9 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
nativeBuildInputs = [
pkgs.elmPackages.elm
pkgs.elmPackages.elm-format
pkgs.uglify-js
pkgs.ungoogled-chromium
];
}

1165
frontend/src/Main.elm Normal file

File diff suppressed because it is too large Load diff