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
###

22
.vscode/launch.json vendored
View File

@ -4,8 +4,28 @@
{
"type": "node",
"request": "launch",
"name": "Launch Current Opened File",
"name": "node Launch Current Opened 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": [
"gitea",
"Immich",
"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

@ -6,15 +6,16 @@
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="slideshow/css/index.css">
<title>www</title>
</head>
<body>
<div id="deviceReady">
<p><a href='slideshow/index.html?b=2024-11-23-22-25'>Slideshow</a></p>
<p><a href='slideshow/index.html?a=last&b=2024-11-23-22-25'>Slideshow (Last)</a></p>
<p><a href='slideshow/index.html?a=time&b=2024-11-23-22-25'>Slideshow (Time)</a></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?nocache=2025-08-02-11-33'>Slideshow</a></h1></p>
<p><h1><a href='slideshow/index.html?a=last&nocache=2025-08-02-11-33'>Slideshow (Last)</a></h1></p>
<p><h1><a href='slideshow/index.html?a=time&nocache=2025-08-02-11-33'>Slideshow (Time)</a></h1></p>
<p><h1><a href='slideshow/index.html?a=last-list&nocache=2025-08-02-11-33'>Slideshow (Last-List)</a></h1></p>
</div>
</body>

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": {
"prettier.check": "prettier . --check",
"prettier.write": "prettier . --write",
"garbage-collect": "git gc",
"kanbn.board": "kanbn board",
"kanbn.board.json": "kanbn board -j > .kanbn/board.json",
"garbage-collect": "git gc"
"prettier.check": "prettier . --check",
"prettier.write": "prettier . --write"
},
"devDependencies": {
"prettier": "^3.0.0"
}
"type": "module"
}

View File

@ -21,7 +21,7 @@
<script src="scripts/jquery-1.9.1.min.js"></script>
<script src="scripts/bootstrap.min.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>
</html>

View File

@ -1,17 +1,10 @@
{
"DataDirectory": "random-results",
"ImageInterval": 15123,
"ImageIntervalX": 9123,
"ImageIntervalXX": 21234,
"ImageInterval": 15123,
"JsonInterval": 59000,
"ImageZero": "images/1x1_00000000.png",
"DataDirectoryX": "../.random",
"DataDirectoryXX": "../Images-c9dbce3b-Results/F)Random/c9dbce3b/[]",
"DataDirectory": "random-results",
"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/"
"JsonInterval": 59000,
"ListLength": 15,
"UserId": "93f51ef4-f1f8-48af-ab00-e00436d790ef"
}

View File

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

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
}
}