Last List

Bun Init
This commit is contained in:
2025-08-02 12:28:07 -07:00
parent 1033df0303
commit 0c4afa55d8
11 changed files with 303 additions and 157 deletions

24
.vscode/dashkiosk.http vendored Normal file
View File

@ -0,0 +1,24 @@
@UniformResourceLocator = https://dashkiosk.phares.duckdns.org
@Display = 5NRH58
###
GET {{UniformResourceLocator}}/api/display HTTP/1.1
Accept: application/json
###
GET {{UniformResourceLocator}}/api/group HTTP/1.1
Accept: application/json
###
PUT {{UniformResourceLocator}}/api/display/5NRH58/group/1 HTTP/1.1
Accept: application/json
###
PUT {{UniformResourceLocator}}/api/display/5NRH58/group/2 HTTP/1.1
Accept: application/json
###

40
.vscode/launch.json vendored
View File

@ -1,11 +1,31 @@
{ {
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Launch Current Opened File", "name": "node Launch Current Opened File",
"program": "${file}" "program": "${file}"
} },
] {
} "type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "launch",
"name": "Debug File",
"program": "${file}",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"watchMode": false
},
{
"type": "bun",
"internalConsoleOptions": "neverOpen",
"request": "launch",
"name": "Run File",
"program": "${file}",
"cwd": "${workspaceFolder}",
"noDebug": true,
"watchMode": false
}
]
}

View File

@ -1,5 +1,6 @@
{ {
"cSpell.words": [ "cSpell.words": [
"gitea",
"Immich", "Immich",
"onlinepngtools" "onlinepngtools"
], ],

31
bun.lock Normal file
View File

@ -0,0 +1,31 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"devDependencies": {
"@types/bun": "latest",
"prettier": "^3.0.0",
},
"peerDependencies": {
"typescript": "^5",
},
},
},
"packages": {
"@types/bun": ["@types/bun@1.2.19", "", { "dependencies": { "bun-types": "1.2.19" } }, "sha512-d9ZCmrH3CJ2uYKXQIUuZ/pUnTqIvLDS0SK7pFmbx8ma+ziH/FRMoAq5bYpRG7y+w1gl+HgyNZbtqgMq4W4e2Lg=="],
"@types/node": ["@types/node@24.1.0", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w=="],
"@types/react": ["@types/react@19.1.9", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-WmdoynAX8Stew/36uTSVMcLJJ1KRh6L3IZRx1PZ7qJtBqT3dYTgyDTx8H1qoRghErydW7xw9mSJ3wS//tCRpFA=="],
"bun-types": ["bun-types@1.2.19", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-uAOTaZSPuYsWIXRpj7o56Let0g/wjihKCkeRqUBhlLVM/Bt+Fj9xTo+LhC1OV1XDaGkz4hNC80et5xgy+9KTHQ=="],
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
"prettier": ["prettier@3.0.1", "", { "bin": "bin/prettier.cjs" }, "sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ=="],
"typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="],
"undici-types": ["undici-types@7.8.0", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
}
}

View File

@ -2,20 +2,21 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="msapplication-tap-highlight" content="no"> <meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" <meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>www</title> <link rel="stylesheet" type="text/css" href="slideshow/css/index.css">
<title>www</title>
</head> </head>
<body> <body>
<div id="deviceReady"> <div id="deviceReady">
<p><a href='slideshow/index.html?b=2024-11-23-22-25'>Slideshow</a></p> <p><h1><a href='slideshow/index.html?nocache=2025-08-02-11-33'>Slideshow</a></h1></p>
<p><a href='slideshow/index.html?a=last&b=2024-11-23-22-25'>Slideshow (Last)</a></p> <p><h1><a href='slideshow/index.html?a=last&nocache=2025-08-02-11-33'>Slideshow (Last)</a></h1></p>
<p><a href='slideshow/index.html?a=time&b=2024-11-23-22-25'>Slideshow (Time)</a></p> <p><h1><a href='slideshow/index.html?a=time&nocache=2025-08-02-11-33'>Slideshow (Time)</a></h1></p>
<p><a href='slideshow/index.html?a=noSleep&b=2024-11-23-22-25'>Slideshow (No Sleep)</a></p> <p><h1><a href='slideshow/index.html?a=last-list&nocache=2025-08-02-11-33'>Slideshow (Last-List)</a></h1></p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,12 +1,20 @@
{ {
"devDependencies": {
"@types/bun": "latest",
"prettier": "^3.0.0"
},
"module": "index.ts",
"name": "www",
"peerDependencies": {
"typescript": "^5"
},
"private": true,
"scripts": { "scripts": {
"prettier.check": "prettier . --check", "garbage-collect": "git gc",
"prettier.write": "prettier . --write",
"kanbn.board": "kanbn board", "kanbn.board": "kanbn board",
"kanbn.board.json": "kanbn board -j > .kanbn/board.json", "kanbn.board.json": "kanbn board -j > .kanbn/board.json",
"garbage-collect": "git gc" "prettier.check": "prettier . --check",
"prettier.write": "prettier . --write"
}, },
"devDependencies": { "type": "module"
"prettier": "^3.0.0"
}
} }

View File

@ -2,26 +2,26 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="msapplication-tap-highlight" content="no"> <meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" <meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" href="css/bootstrap.min.css" media="screen"> <link rel="stylesheet" href="css/bootstrap.min.css" media="screen">
<link rel="stylesheet" href="css/bootswatch/slate/bootstrap.min.css"> <link rel="stylesheet" href="css/bootswatch/slate/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/index.css"> <link rel="stylesheet" type="text/css" href="css/index.css">
<title>Slideshow</title> <title>Slideshow</title>
</head> </head>
<body> <body>
<div id="deviceReady"> <div id="deviceReady">
<div class="opaque"></div> <div class="opaque"></div>
<div class=""></div> <div class=""></div>
<div class=""></div> <div class=""></div>
</div> </div>
<script src="scripts/jquery-1.9.1.min.js"></script> <script src="scripts/jquery-1.9.1.min.js"></script>
<script src="scripts/bootstrap.min.js"></script> <script src="scripts/bootstrap.min.js"></script>
<script src="scripts/jquery.bgswitcher.js"></script> <script src="scripts/jquery.bgswitcher.js"></script>
<script type="text/javascript" src="scripts/index.js?nocache=2024-11-23-22-25"></script> <script type="text/javascript" src="scripts/index.js?nocache=2025-08-02-11-33"></script>
</body> </body>
</html> </html>

View File

@ -1,17 +1,10 @@
{ {
"DataDirectory": "random-results",
"ImageInterval": 15123,
"ImageIntervalX": 9123, "ImageIntervalX": 9123,
"ImageIntervalXX": 21234, "ImageIntervalXX": 21234,
"ImageInterval": 15123,
"JsonInterval": 59000,
"ImageZero": "images/1x1_00000000.png", "ImageZero": "images/1x1_00000000.png",
"DataDirectoryX": "../.random", "JsonInterval": 59000,
"DataDirectoryXX": "../Images-c9dbce3b-Results/F)Random/c9dbce3b/[]", "ListLength": 15,
"DataDirectory": "random-results", "UserId": "93f51ef4-f1f8-48af-ab00-e00436d790ef"
"ImmichUrlX": "http://192.168.11.2:3001/api/assets/",
"ImmichUrlXX": "https://immich.phares.duckdns.org/api/assets/",
"RandomPathsUrlX": "http://192.168.11.2:5009/api/v1/assets/5f0b1052-466d-44de-a554-226d7256850d/random-paths/",
"RandomPathsUrlXX": "https://immichtoslideshow.phares.duckdns.org/api/v1/assets/5f0b1052-466d-44de-a554-226d7256850d/random-paths/",
"RootX": "../.original",
"RootXX": "../Images-c9dbce3b-Results/thumbs",
"Root": "5f0b1052-466d-44de-a554-226d7256850d/"
} }

View File

@ -1,50 +1,51 @@
(function () { (function () {
"use strict"; 'use strict';
var _Root; var _UserId;
var _RootAlt;
var _ImageZero; var _ImageZero;
var _ListLength;
var _DataDirectory; var _DataDirectory;
var _RandomPathsUrl; var _UniformResourceLocator;
var _Pause = 0; var _Pause = 0;
var _Images = []; var _Images = [];
var _JsonInterval;
var _ImageInterval;
var _ImageIndex = 0; var _ImageIndex = 0;
var _OpaqueIndex = 0; var _OpaqueIndex = 0;
var _DeviceReadyDiv = $('#deviceReady div'); var _hasLast = false;
var _hasList = false;
var time = document.createElement('time'); var _hasTime = false;
time.setAttribute('style', 'position: fixed;'); var _TickLoadList = null;
var _DeviceReadyDiv = typeof document == 'undefined' ? undefined : $('#deviceReady div');
var _TimeElement = typeof document == 'undefined' ? undefined : document.createElement('time');
function loadData() { function loadData() {
var currentDate = new Date(); const currentDate = new Date();
var mm = (new Date().getMonth() + 1).toString().padStart(2, '0'); const dd = currentDate.getDate().toString().padStart(2, '0');
var dd = currentDate.getDate().toString().padStart(2, '0'); const mm = (new Date().getMonth() + 1).toString().padStart(2, '0');
if (window.location.href.indexOf('time') > 0) { const url = _UniformResourceLocator + '/slideshow/' + _DataDirectory + '/' + mm + '-' + dd + '.json?nocache=2025-08-02-11-33';
time.innerText = mm + '-' + dd + '.json';
}
var url = _DataDirectory + '/' + mm + '-' + dd + '.json?nocache=2024-11-23-22-25';
console.log(url); console.log(url);
$.getJSON(url, function (data) { fetch(url, { nocache: new Date().getTime() })
console.log('success', data.length); .then((res) => res.text())
_Images = []; .then((text) => {
$.each(data, function (_, value) { console.log(url + ' downloaded successfully');
// _Images.push(value.replaceAll("\\", "/")); const data = JSON.parse(text);
_Images.push(value); console.log('success', data.length);
}); _Images = [];
}) for (let i = 0; i < data.length; i++) {
.done(function () { console.log('second success'); }) _Images.push(_UniformResourceLocator + '/slideshow/' + _UserId + data[i]);
.fail(function (er) { console.log('error', er); }) }
.always(function () { console.log('complete'); }); })
.catch((e) => console.error(e));
if (_TimeElement != undefined && _hasTime) {
_TimeElement.innerText = _UniformResourceLocator + ' ' + mm + '-' + dd + '.json';
}
} }
function onTickJSON() { function onTickJSON() {
var currentDate = new Date(); const currentDate = new Date();
var currentHours = currentDate.getHours(); const currentHours = currentDate.getHours();
if (currentHours === 0) { if (currentHours === 0) {
var currentMinutes = currentDate.getMinutes(); const currentMinutes = currentDate.getMinutes();
if (currentMinutes === 0) { if (currentMinutes === 0) {
loadData(); loadData();
} }
@ -52,18 +53,14 @@
} }
function GetBackgroundImage() { function GetBackgroundImage() {
var result = "background-image: url('" + _Root + _Images[_ImageIndex] + '?index=' + _ImageIndex + "'), url('"; let result = "background-image: url('" + _Images[_ImageIndex] + '?index=' + _ImageIndex + "'), url('" + _ImageZero + "');";
if (_RootAlt !== null) {
result = result + _RootAlt + _Images[_ImageIndex] + '?index=' + _ImageIndex + "'), url('";
}
result = result + _ImageZero + "');";
return result; return result;
} }
function onTickImage() { function onTickImage() {
if (_Images.length > 0 && _Pause === 0) { if (_Images.length > 0 && _Pause === 0) {
var currentDate = new Date(); const currentDate = new Date();
var currentHours = currentDate.getHours(); const currentHours = currentDate.getHours();
if (currentHours >= 23 || currentHours <= 6) { if (currentHours >= 23 || currentHours <= 6) {
_DeviceReadyDiv.attr('style', 'background-color: #191717;'); _DeviceReadyDiv.attr('style', 'background-color: #191717;');
} }
@ -73,7 +70,7 @@
if (_ImageIndex >= _Images.length) { if (_ImageIndex >= _Images.length) {
_ImageIndex = 0; _ImageIndex = 0;
} }
var loadIndex; let loadIndex;
switch (_OpaqueIndex) { switch (_OpaqueIndex) {
case 0: case 0:
loadIndex = 2; loadIndex = 2;
@ -89,13 +86,13 @@
break; break;
default: default:
} }
var backgroundImage = GetBackgroundImage(); const backgroundImage = GetBackgroundImage();
_DeviceReadyDiv.eq(loadIndex).attr('style', backgroundImage); _DeviceReadyDiv.eq(loadIndex).attr('style', backgroundImage);
_DeviceReadyDiv.eq(_OpaqueIndex).addClass('opaque'); _DeviceReadyDiv.eq(_OpaqueIndex).addClass('opaque');
if (window.location.href.indexOf('time') > 0) { if (_TimeElement != undefined && _hasTime) {
var mm = (new Date().getMonth() + 1).toString().padStart(2, '0'); const mm = (new Date().getMonth() + 1).toString().padStart(2, '0');
var dd = currentDate.getDate().toString().padStart(2, '0'); const dd = currentDate.getDate().toString().padStart(2, '0');
time.innerText = mm + '-' + dd + '.json' + ' ' + _Images[_ImageIndex]; _TimeElement.innerText = _UniformResourceLocator + ' ' + mm + '-' + dd + '.json' + ' ' + _Images[_ImageIndex];
} }
} }
} }
@ -103,7 +100,7 @@
function pause() { function pause() {
_Pause = 1; _Pause = 1;
$('#deviceReady').innerHTML = '<div></div>'; _DeviceReadyDiv.innerHTML = '<div></div>';
} }
function goBack() { function goBack() {
@ -114,7 +111,7 @@
if (_ImageIndex === 0) { if (_ImageIndex === 0) {
_ImageIndex = _Images.length - 1; _ImageIndex = _Images.length - 1;
} }
var backgroundImage = GetBackgroundImage(); const backgroundImage = GetBackgroundImage();
_DeviceReadyDiv.attr('style', backgroundImage); _DeviceReadyDiv.attr('style', backgroundImage);
} }
@ -126,12 +123,12 @@
if (_ImageIndex >= _Images.length) { if (_ImageIndex >= _Images.length) {
_ImageIndex = 0; _ImageIndex = 0;
} }
var backgroundImage = GetBackgroundImage(); const backgroundImage = GetBackgroundImage();
_DeviceReadyDiv.attr('style', backgroundImage); _DeviceReadyDiv.attr('style', backgroundImage);
} }
function getInput(e) { function getInput(e) {
var which = e.which; const which = e.which;
switch (which) { switch (which) {
case 13: //Okay case 13: //Okay
if (_Pause === 0) { if (_Pause === 0) {
@ -139,7 +136,7 @@
} }
else { else {
_Pause = 0; _Pause = 0;
$('#deviceReady').innerHTML = '<div class="opaque"></div><div></div><div></div>'; _DeviceReadyDiv.innerHTML = '<div class="opaque"></div><div></div><div></div>';
} }
break; break;
case 37: //Left case 37: //Left
@ -164,59 +161,102 @@
} }
} }
if (window.location.href.indexOf('time') > 0) { function getUniformResourceLocator() {
document.body.appendChild(time); let result;
if (typeof window == 'undefined') {
result = 'https://slideshow.phares.duckdns.org';
}
else {
result = window.location.protocol + '//' + window.location.host;
}
return result;
} }
if (window.location.href.indexOf('last') > 0) { function loadPage() {
var url = '../log-nginx/access.log?nocache=2024-11-23-22-25'; const uniformResourceLocator = getUniformResourceLocator();
$.get(url, function (data) { _hasLast = typeof window == 'undefined' ? false : window.location.href.indexOf('last') > 0;
var arrayOfUrl = []; _hasList = typeof window == 'undefined' ? false : window.location.href.indexOf('list') > 0;
var arrayOfIndex = []; _hasTime = typeof window == 'undefined' ? false : window.location.href.indexOf('time') > 0;
var arrayOfLines = data.match(/[^\r\n]+/g); const url = uniformResourceLocator + '/slideshow/index.json?nocache=2025-08-02-11-33';
for (var i = arrayOfLines.length - 1; i >= 0; i--) {
arrayOfUrl = arrayOfLines[i].split('?index=');
if (arrayOfUrl.length !== 2)
continue;
arrayOfIndex = arrayOfUrl[1].split(' ');
if (arrayOfIndex.length < 2)
continue;
var index = parseInt(arrayOfIndex[0]);
console.log('index', index);
_ImageIndex = index;
break;
}
})
.fail(function (err) {
console.error(err);
});
}
$(document).ready(function () {
console.log('onDeviceReady');
document.addEventListener('keyup', getInput, false);
var url = '../slideshow/index.json?nocache=2024-11-23-22-25';
console.log(url); console.log(url);
var _ = $.getJSON(url, function (data) { fetch(url, { nocache: new Date().getTime() })
console.log(url + ' downloaded successfully'); .then((res) => res.text())
_RootAlt = null; .then((text) => {
_Root = data.Root; console.log(url + ' downloaded successfully');
_ImageZero = data.ImageZero; const data = JSON.parse(text);
_JsonInterval = data.JsonInterval; _UserId = data.UserId;
_ImageInterval = data.ImageInterval; _ListLength = data.ListLength;
_DataDirectory = data.DataDirectory; _DataDirectory = data.DataDirectory;
console.log(url + ' used successfully'); _UniformResourceLocator = uniformResourceLocator;
}) _ImageZero = uniformResourceLocator + '/slideshow/' + data.ImageZero;
.done(function () { console.log(url + ' used successfully');
if (_TimeElement != undefined && _hasTime) {
_TimeElement.setAttribute('style', 'position: fixed;');
document.body.appendChild(_TimeElement);
}
if (_hasLast) {
loadLog();
}
loadData(); loadData();
_ = setInterval(onTickJSON, _JsonInterval); if (!_hasList && _DeviceReadyDiv != undefined) {
_ = setInterval(onTickImage, _ImageInterval); setInterval(onTickJSON, data.JsonInterval);
setInterval(onTickImage, data.ImageInterval);
}
if (_hasList && _hasLast) {
_TickLoadList = setInterval(onTickLoadList, 500);
}
}) })
.fail(function (er) { console.log('error', er); }) .catch((e) => console.error(e));
.always(function () { console.log('complete'); }); }
});
function onTickLoadList() {
if (_ImageIndex > 0 && _Images.length > 0) {
clearInterval(_TickLoadList);
let innerHTML = '';
for (let i = 0; i < _ListLength; i++) {
innerHTML += '<p><a href="' + _Images[_ImageIndex] + '"><img style="max-width: 330px" src="' + _Images[_ImageIndex] + '" title="' + _ImageIndex + '" alt="' + _Images[_ImageIndex] + '"></a></p>\n';
_ImageIndex -= 1;
if (_ImageIndex < 0) {
_ImageIndex = _Images.length - 1;
}
}
document.getElementById('deviceReady').innerHTML = innerHTML;
}
}
function loadLog() {
const url = _UniformResourceLocator + '/log-nginx/access.log?nocache=2025-08-02-11-33';
fetch(url, { nocache: new Date().getTime() })
.then((res) => res.text())
.then((text) => {
console.log(url + ' downloaded successfully');
let arrayOfUrl = [];
let arrayOfIndex = [];
const arrayOfLines = text.match(/[^\r\n]+/g);
for (let i = arrayOfLines.length - 1; i >= 0; i--) {
arrayOfUrl = arrayOfLines[i].split('?index=');
if (arrayOfUrl.length !== 2)
continue;
arrayOfIndex = arrayOfUrl[1].split(' ');
if (arrayOfIndex.length < 2)
continue;
let index = parseInt(arrayOfIndex[0]);
console.log('index', index);
_ImageIndex = index;
break;
}
})
.catch((e) => console.error(e));
}
if (typeof document == 'undefined') {
loadPage();
} else {
$(document).ready(function () {
console.log('onDeviceReady');
document.addEventListener('keyup', getInput, false);
loadPage();
});
}
})(); })();

28
tsconfig.json Normal file
View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
// Environment setup & latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}