Compare commits

..
2 Commits
Author SHA1 Message Date
mangavalkandClaude Opus 5.5 9f960fae17 Retry NTP sooner after a failed attempt
The first NTP attempt after boot usually fails and the retry waited a
flat 5 minutes, so the clock showed 00:00 (1970) for 5 minutes after
every restart or OTA update. Retries now back off 15 s, 30 s, 1 min ...
up to 5 min. Measured after an OTA update: time set at 30 s uptime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:08:29 +01:00
mangavalkandClaude Opus 5.5 b40b5f680c Replace the web UI with a single-file page
The upstream jQuery page (147 KB, 3-column grid, slider values hidden,
help behind label clicks, no save feedback) is replaced by
firmware/uniclock/web/index.html: one file, no jQuery, gzipped by
web/gzip_web.py to data/index.html.gz (12 KB) before every build.

- Tabs Home / Tubes / Light / Network / System, rows with label, help
  line and control; sliders always show their value
- "Saved" / "Not saved" after each change, reverted on failure; offline
  indicator with automatic retry (the old poll stopped after one error)
- WiFi and MQTT settings only save with a Save button, then offer a
  restart; password fields are write-only
- Controls for hardware this clock lacks (alarm, radar, sensors) hidden
- Runs on sample data when opened from disk

Firmware: one serveStatic route (gzip, no-cache + ETag) replaces the
per-file routes; /getConfiguration no longer returns passwords and adds
ip, hasAlarm, hasRadar and the real cathProtMin; /getCurrentInfos adds
currentSec and mqtt state and sends "lux" instead of "lx" when there is
no sensor; /cathodeProtect and /firmwareupdate now answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:06:35 +01:00
14 changed files with 735 additions and 1664 deletions

No files matched your search

+12 -3
View File
@@ -105,6 +105,15 @@ GPIO0 to GND, tap RST to GND, then release GPIO0.
SignalRGB LED 0 = left tube, `tubePixels` {0,1,2,3} is right. Settings `wledEnable` / SignalRGB LED 0 = left tube, `tubePixels` {0,1,2,3} is right. Settings `wledEnable` /
`wledDarkWithTubes` / `wledUseBrightness` live in `prmExt`, stored in EEPROM after `prm` with `wledDarkWithTubes` / `wledUseBrightness` live in `prmExt`, stored in EEPROM after `prm` with
their own magic value: never add fields to `prm` (a `MAGIC_VALUE` bump factory-resets the their own magic value: never add fields to `prm` (a `MAGIC_VALUE` bump factory-resets the
clock, WiFi included). HA switch "SignalRGB". `page.js`/`site.css` were cached by browsers for a clock, WiFi included). HA switch "SignalRGB".
year; now sent with `no-cache`. 7. Done (2026-10-29, on the clock): new web UI. Source `firmware/uniclock/web/index.html`
7. Open: the user can create `secrets.h` (gitignored, never read it) for OTA and web passwords. (one file, no jQuery, controls generated from the `PAGES` table), gzipped by `web/gzip_web.py`
to `data/index.html.gz` (12 KB, was 147 KB), served by one `serveStatic` with `no-cache`.
Opened from disk it runs on sample data; check it with headless Edge (`msedge --headless=new
--screenshot`). `/getConfiguration` no longer returns passwords (`*PswSet` flags instead);
new fields `ip`, `hasAlarm`, `hasRadar`, real `cathProtMin`; `/getCurrentInfos` has
`currentSec` and `mqtt` (0 off / 1 not connected / 2 connected). Network settings save with a
Save button and offer a restart.
NTP: the first attempt after boot usually fails; retries now back off 15 s, 30 s ... 5 min
(was a flat 5 min, so the clock showed 00:00 for 5 minutes after every restart).
8. Open: the user can create `secrets.h` (gitignored, never read it) for OTA and web passwords.
+1 -1
View File
@@ -74,7 +74,7 @@ Optional passwords for the web page and OTA updates go in
## SignalRGB ## SignalRGB
Turn on **SignalRGB (WLED)** on the RGB page of the web UI (or the SignalRGB switch in Home Turn on **SignalRGB control** on the Light page of the web UI (or the SignalRGB switch in Home
Assistant). The clock then answers like a WLED device with one LED per tube, LED 0 = left tube: Assistant). The clock then answers like a WLED device with one LED per tube, LED 0 = left tube:
mDNS `_wled._tcp`, `/json/info` and `/json/state` without a password, and colour frames over UDP mDNS `_wled._tcp`, `/json/info` and `/json/state` without a password, and colour frames over UDP
(WLED realtime on port 21324, DDP on 4048). SignalRGB should find it by itself; if not, add it by (WLED realtime on port 21324, DDP on 4048). SignalRGB should find it by itself; if not, add it by
@@ -269,8 +269,7 @@ extern char tubeDriver[]; //human-readable driver name string, shown on the web
char webName[] = WEBNAME; char webName[] = WEBNAME;
AsyncWebServer server(80); AsyncWebServer server(80);
#define CACHE_MAX_AGE "max-age=31536000" //maximum is: 31536000 #define CACHE_REVALIDATE "no-cache" //the web UI changes with uploadfs: don't let browsers keep an old copy
#define CACHE_REVALIDATE "no-cache" //page.js and site.css change with web UI updates (uploadfs): don't let browsers keep an old copy
#ifdef USE_WIFIMANAGER #ifdef USE_WIFIMANAGER
#include <ESPAsyncWiFiManager.h> #include <ESPAsyncWiFiManager.h>
@@ -879,21 +878,24 @@ void startWifiMode() {
// Primary time source (see calcTime()/docs/DEVELOPER_GUIDE.md 4.4): refreshes the system clock from // Primary time source (see calcTime()/docs/DEVELOPER_GUIDE.md 4.4): refreshes the system clock from
// NTP over WiFi, at most once every TIMESERVER_REFRESH (2h) - or every 5 minutes if the previous // NTP over WiFi, at most once every TIMESERVER_REFRESH (2h) - or, after a failed attempt, again after
// attempt failed (lastTimeFailure backoff), retrying the NTP request itself up to 5 times per call. // 15 s, 30 s, 1 min ... up to 5 min (retryDelay), retrying the NTP request itself up to 5 times per call.
// On success, rebuilds myTZ from the current prm.utc_offset/prm.enableDST (so a live timezone/DST // On success, rebuilds myTZ from the current prm.utc_offset/prm.enableDST (so a live timezone/DST
// change from the web UI takes effect on the very next scheduled refresh) and calls setTime() with // change from the web UI takes effect on the very next scheduled refresh) and calls setTime() with
// the timezone-adjusted local time. Returns true only if this call actually refreshed the clock - // the timezone-adjusted local time. Returns true only if this call actually refreshed the clock -
// callers (calcTime()) use that to decide whether the RTC also needs updating this cycle. // callers (calcTime()) use that to decide whether the RTC also needs updating this cycle.
boolean updateTimefromTimeserver() { //true, if successful boolean updateTimefromTimeserver() { //true, if successful
static unsigned long lastTimeFailure = 0; static unsigned long lastTimeFailure = 0;
static unsigned long retryDelay = 15000; //after a failure: 15 s, then doubled each time, at most 5 min
boolean res = false; boolean res = false;
int count = 1; int count = 1;
if (((millis()-lastTimeUpdate)<TIMESERVER_REFRESH) && (lastTimeUpdate!=0)) if (((millis()-lastTimeUpdate)<TIMESERVER_REFRESH) && (lastTimeUpdate!=0))
return(res); return(res);
if ((lastTimeFailure>0) && ((millis()-lastTimeFailure)<300000)) return(res); //wait for 5min to retry, if no success // FIXED: was a flat 5 min, and the first attempt right after boot usually fails, so the clock showed
// 00:00 (1970) for 5 minutes after every restart or OTA update.
if ((lastTimeFailure>0) && ((millis()-lastTimeFailure)<retryDelay)) return(res);
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
while (true) { while (true) {
@@ -912,12 +914,15 @@ boolean updateTimefromTimeserver() { //true, if successful
DPRINT(" time:"); DPRINT(hour()); DPRINT(":"); DPRINT(minute()); DPRINT(":"); DPRINTLN(second()); DPRINT(" time:"); DPRINT(hour()); DPRINT(":"); DPRINT(minute()); DPRINT(":"); DPRINTLN(second());
DPRINTLN("Clock refreshed from timeserver."); DPRINTLN("Clock refreshed from timeserver.");
lastTimeFailure = 0; lastTimeFailure = 0;
retryDelay = 15000;
} }
count ++; count ++;
if (res) break; //success!!! if (res) break; //success!!!
Fdelay(1000); Fdelay(1000);
if (count > 5) { //failure, but stop trying if (count > 5) { //failure, but stop trying
if (lastTimeFailure > 0) retryDelay = min(retryDelay * 2, 300000ul);
lastTimeFailure = millis(); lastTimeFailure = millis();
DPRINT("Timeserver failed, next try in "); DPRINT(retryDelay / 1000); DPRINTLN(" s");
break; break;
} }
} //end while } //end while
@@ -1140,14 +1145,13 @@ void doCathodeProtect() {
cathodeProtRunning = false; cathodeProtRunning = false;
} }
// Sets up the ESPAsyncWebServer instance (port 80) that backs the web admin UI: static file routes // Sets up the ESPAsyncWebServer instance (port 80) that backs the web admin UI: a static route serves
// serve the SPA's HTML/CSS/JS straight out of SPIFFS (uploaded separately via the IDE's filesystem // the single-file page out of SPIFFS (uploadfs from the data/ folder), plus a handful of action routes
// uploader from the repo's data/ folder - see file header), plus a handful of action routes
// (/reset, /factoryreset, /firmwareupdate, /cathodeProtect) and the JSON/form REST-ish API // (/reset, /factoryreset, /firmwareupdate, /cathodeProtect) and the JSON/form REST-ish API
// (handleConfigChanged/handleSendConfig/handleSendCurrentInfos/handleSendClockDetails, defined below). // (handleConfigChanged/handleSendConfig/handleSendCurrentInfos/handleSendClockDetails, defined below).
// Optional password for the web UI (WEB_PASSWORD, and WEB_USER, default "admin", in secrets.h). // Optional password for the web UI (WEB_PASSWORD, and WEB_USER, default "admin", in secrets.h).
// Everything except /generate_204 (captive-portal check) and /getCurrentInfos (time and sensor // Everything except /generate_204 (captive-portal check) and /getCurrentInfos (time and sensor
// values only) needs it; /getConfiguration returns the stored WiFi and MQTT passwords. // values only) needs it. /getConfiguration no longer sends the stored passwords (only whether one is set).
#ifdef WEB_PASSWORD #ifdef WEB_PASSWORD
#ifndef WEB_USER #ifndef WEB_USER
#define WEB_USER "admin" #define WEB_USER "admin"
@@ -1160,71 +1164,6 @@ void doCathodeProtect() {
void startServer() { void startServer() {
DPRINTLN("Starting Async Webserver..."); DPRINTLN("Starting Async Webserver...");
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
DPRINTLN("Webserver: / -> index.html");
if(SPIFFS.exists("/index.html")) {
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/index.html", "text/html");
request->send(response);
}
else {
request->send( 204, "text/html", "File Not Found" );
DPRINTLN("/index.html not found");
}
}) WEB_AUTH;
server.on("/jquery_351.js", HTTP_GET, [](AsyncWebServerRequest * request) {
DPRINTLN("Webserver: /jquery_351.js");
if (SPIFFS.exists("/jquery_351.js")) {
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/jquery_351.js", "text/js");
response->addHeader("Cache-Control", CACHE_MAX_AGE);
request->send(response);
}
else {
request->send( 204, "text/html", "File Not Found" );
DPRINTLN("/jquery_351.js not found");
}
}) WEB_AUTH;
server.on("/jquery_360.js", HTTP_GET, [](AsyncWebServerRequest * request) {
DPRINTLN("Webserver: /jquery_360.js");
if (SPIFFS.exists("/jquery_360.js")) {
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/jquery_360.js", "text/js");
response->addHeader("Cache-Control", CACHE_MAX_AGE);
request->send(response);
}
else {
request->send( 204, "text/html", "File Not Found" );
DPRINTLN("/jquery_360.js not found");
}
}) WEB_AUTH;
server.on("/page.js", HTTP_GET, [](AsyncWebServerRequest * request) {
DPRINTLN("Webserver: /page.js");
if (SPIFFS.exists("/page.js")) {
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/page.js", "text/js");
response->addHeader("Cache-Control", CACHE_REVALIDATE);
request->send(response);
}
else {
request->send( 204, "text/html", "File Not Found" );
DPRINTLN("/page.js not found");
}
}) WEB_AUTH;
server.on("/favicon.ico", HTTP_GET, [](AsyncWebServerRequest * request) {
DPRINTLN("Webserver: /favicon.ico");
if (SPIFFS.exists("/favicon.ico")){
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/favicon.ico", "image/png");
response->addHeader("Cache-Control", CACHE_MAX_AGE);
request->send(response);
}
else {
request->send( 204, "text/html", "File Not Found" );
DPRINTLN("/favicon.ico not found");
}
}) WEB_AUTH;
server.on("/generate_204", HTTP_GET, [](AsyncWebServerRequest * request) { server.on("/generate_204", HTTP_GET, [](AsyncWebServerRequest * request) {
DPRINTLN("Webserver: /generate_204"); DPRINTLN("Webserver: /generate_204");
AsyncWebServerResponse *response = request->beginResponse(302); // AsyncWebServerResponse *response = request->beginResponse(302); //
@@ -1243,19 +1182,6 @@ void startServer() {
*/ */
}); });
//____________________________________________________________________________
server.on("/site.css", HTTP_GET, [](AsyncWebServerRequest * request) {
DPRINTLN("Webserver: /site.css");
if (SPIFFS.exists("/site.css")) {
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/site.css", "text/css");
response->addHeader("Cache-Control", CACHE_REVALIDATE);
request->send(response);
}
else {
request->send( 204, "text/html", "File Not Found" );
DPRINTLN("/site.css not found");
}
}) WEB_AUTH;
//____________________________________________________________________________ //____________________________________________________________________________
server.on("/reset", HTTP_POST, [] (AsyncWebServerRequest *request) { server.on("/reset", HTTP_POST, [] (AsyncWebServerRequest *request) {
DPRINTLN("/reset:"); DPRINTLN("/reset:");
@@ -1277,10 +1203,12 @@ void startServer() {
//____________________________________________________________________________ //____________________________________________________________________________
server.on("/firmwareupdate", HTTP_POST, [](AsyncWebServerRequest * request) { server.on("/firmwareupdate", HTTP_POST, [](AsyncWebServerRequest * request) {
makeFirmwareUpdate = true; makeFirmwareUpdate = true;
request->send(200, "text/plain", "OK"); //FIXED: no answer was sent, so the browser waited until it timed out
}) WEB_AUTH; }) WEB_AUTH;
//____________________________________________________________________________ //____________________________________________________________________________
server.on("/cathodeProtect", HTTP_POST, [](AsyncWebServerRequest * request) { server.on("/cathodeProtect", HTTP_POST, [](AsyncWebServerRequest * request) {
makeCathodeProtect = true; makeCathodeProtect = true;
request->send(200, "text/plain", "OK");
}) WEB_AUTH; }) WEB_AUTH;
@@ -1289,6 +1217,10 @@ void startServer() {
server.on("/getCurrentInfos", HTTP_GET, handleSendCurrentInfos); server.on("/getCurrentInfos", HTTP_GET, handleSendCurrentInfos);
server.on("/getClockDetails", HTTP_GET, handleSendClockDetails) WEB_AUTH; server.on("/getClockDetails", HTTP_GET, handleSendClockDetails) WEB_AUTH;
wledRoutes(); //WLED JSON API for SignalRGB, without password (wled.ino) wledRoutes(); //WLED JSON API for SignalRGB, without password (wled.ino)
// The web UI (data/: index.html.gz, built from web/index.html, and favicon.ico). Registered last: it
// matches every GET path, and the routes above must win. A missing file falls through to handleNotFound.
// For "/" it sends index.html.gz with Content-Encoding: gzip; no-cache + ETag makes reloads a cheap 304.
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.html").setCacheControl(CACHE_REVALIDATE) WEB_AUTH;
server.onNotFound(handleNotFound); server.onNotFound(handleNotFound);
server.begin(); server.begin();
@@ -1632,6 +1564,13 @@ void handleSendConfig(AsyncWebServerRequest *request) {
doc["tubeDriver"] = tubeDriver; doc["tubeDriver"] = tubeDriver;
doc["maxDigits"] = maxDigits; //number of digits (tubes) doc["maxDigits"] = maxDigits; //number of digits (tubes)
doc["maxBrightness"] = MAXBRIGHTNESS; //Maximum tube brightness usually 10, sometimes 12 doc["maxBrightness"] = MAXBRIGHTNESS; //Maximum tube brightness usually 10, sometimes 12
doc["ip"] = ip.toString();
doc["hasAlarm"] = (ALARMSPEAKER_PIN >= 0); //the web page hides the alarm and presence settings without the hardware
#if (RADAR_PIN >= 0) || defined(USE_MASTER_RADAR)
doc["hasRadar"] = true;
#else
doc["hasRadar"] = false;
#endif
//Actual time and environment data //Actual time and environment data
sprintf(buf, "%4d.%02d.%02d", year(), month(), day()); sprintf(buf, "%4d.%02d.%02d", year(), month(), day());
@@ -1717,15 +1656,20 @@ if (useTemp > 1)
#endif #endif
doc["wifiMode"] = prm.wifiMode; doc["wifiMode"] = prm.wifiMode;
doc["wifiSsid"] = prm.wifiSsid; doc["wifiSsid"] = prm.wifiSsid;
doc["wifiPsw"] = prm.wifiPsw; // Passwords are write-only: the page gets "" plus whether one is stored, and only sends a field the
// user typed in (so "" here never overwrites a stored password).
doc["wifiPsw"] = "";
doc["wifiPswSet"] = prm.wifiPsw[0] != 0;
doc["ApSsid"] = prm.ApSsid; doc["ApSsid"] = prm.ApSsid;
doc["ApPsw"] = prm.ApPsw; doc["ApPsw"] = "";
doc["ApPswSet"] = prm.ApPsw[0] != 0;
doc["NtpServer"] = prm.NtpServer; doc["NtpServer"] = prm.NtpServer;
doc["firmware"] = prm.firmwareServer; doc["firmware"] = prm.firmwareServer;
doc["mqttBrokerAddr"] = prm.mqttBrokerAddr; doc["mqttBrokerAddr"] = prm.mqttBrokerAddr;
doc["mqttBrokerUser"] = prm.mqttBrokerUser; doc["mqttBrokerUser"] = prm.mqttBrokerUser;
doc["mqttBrokerPsw"] = prm.mqttBrokerPsw; doc["mqttBrokerPsw"] = "";
doc["mqttBrokerPswSet"] = prm.mqttBrokerPsw[0] != 0;
doc["mqttEnable"] = prm.mqttEnable; doc["mqttEnable"] = prm.mqttEnable;
#if defined(USE_MQTT) #if defined(USE_MQTT)
doc["mqttBrokerRefresh"] = prm.mqttBrokerRefresh; doc["mqttBrokerRefresh"] = prm.mqttBrokerRefresh;
@@ -1756,9 +1700,10 @@ if (useTemp > 1)
doc["corrT1"] = prm.corrT1; doc["corrT1"] = prm.corrT1;
doc["corrH0"] = prm.corrH0; doc["corrH0"] = prm.corrH0;
doc["corrH1"] = prm.corrH1; doc["corrH1"] = prm.corrH1;
doc["cathProtMin"] = 3; //default value for cathProtMin slider doc["cathProtMin"] = cathProtMin; //FIXED: was always 3, whatever was set (not stored in EEPROM: 5 after a restart)
String json; String json;
serializeJson(doc, json); serializeJson(doc, json);
if (doc.overflowed()) DPRINTLN("handleSendConfig: JSON document too small, fields missing!");
request->send(200, "application/json", json); request->send(200, "application/json", json);
} }
@@ -1792,7 +1737,7 @@ void handleSendClockDetails(AsyncWebServerRequest *request) {
// ("temperature1"/"humidity1") and legacy ("temperature"/"humidity") key names for backwards // ("temperature1"/"humidity1") and legacy ("temperature"/"humidity") key names for backwards
// compatibility with older versions of the web front-end. // compatibility with older versions of the web front-end.
void handleSendCurrentInfos(AsyncWebServerRequest *request) { void handleSendCurrentInfos(AsyncWebServerRequest *request) {
StaticJsonDocument<400> doc; StaticJsonDocument<512> doc; //400 was tight with "stalls", "mqtt" and "currentSec"
//StaticJsonDocument<512> doc; //StaticJsonDocument<512> doc;
char buf[20]; //conversion buffer char buf[20]; //conversion buffer
@@ -1802,6 +1747,7 @@ void handleSendCurrentInfos(AsyncWebServerRequest *request) {
doc["currentDate"] = buf; doc["currentDate"] = buf;
sprintf(buf, "%02d:%02d", hour(), minute()); sprintf(buf, "%02d:%02d", hour(), minute());
doc["currentTime"] = buf; doc["currentTime"] = buf;
doc["currentSec"] = second(); //the web page runs its clock from this between polls
//DPRINT("useTemp:"); DPRINT(useTemp); DPRINT("useHumid:"); DPRINT(useHumid); //DPRINT("useTemp:"); DPRINT(useTemp); DPRINT("useHumid:"); DPRINT(useHumid);
if (useTemp > 0) { if (useTemp > 0) {
doc["temperature1"] = temperature[0] + prm.corrT0; doc["temperature1"] = temperature[0] + prm.corrT0;
@@ -1837,8 +1783,11 @@ if (useTemp > 1)
doc["lux"] = lx; doc["lux"] = lx;
} }
else else
doc["lx"] = 255; doc["lux"] = 255; //FIXED: was "lx"
doc["rssi"] = WiFi.RSSI(); doc["rssi"] = WiFi.RSSI();
#ifdef USE_MQTT
doc["mqtt"] = !prm.mqttEnable ? 0 : mqttIsConnected() ? 2 : 1; //0 = off, 1 = not connected, 2 = connected
#endif
doc["uptime"] = millis() / 1000; doc["uptime"] = millis() / 1000;
doc["heap"] = ESP.getFreeHeap(); doc["heap"] = ESP.getFreeHeap();
#ifdef USE_WLED_REALTIME #ifdef USE_WLED_REALTIME
@@ -1,454 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Uniclock 3.0</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="site.css">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" sizes="16x16">
<script src="jquery_360.js"></script>
<script src="page.js"></script>
</head>
<body>
<div id="info-popup">
<div id="popup-box" class="max-width">
<div id="popup-close-btn">X</div>
<h2>Random Input</h2>
<div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
<div id="menu-holder">
<div class="floating-menu">
<div class="max-width">
<table id="menu">
<tr></tr>
</table>
</div>
</div>
</div>
<div class="content max-width">
<div class="form">
<div page="main">
<div class="header">
<br>
<div class="control-holder">
<label for="version">Version</label>
<span id="versionHeader" class="info medium" pagemenu="settings"></span>
</div>
<div class="control-holder">
<label>Current Time</label>
<span id="currentTime" class="info medium"></span>
</div>
<div class="control-holder temperature-holder">
<label>Temperature</label>
<span id="temperature" class="info medium"></span>
</div>
<div class="control-holder temperature-holder2">
<label>Temperature-2</label>
<span id="temperature2" class="info medium"></span>
</div>
<div class="control-holder humidity-holder">
<label>Humidity</label>
<span id="humidity" class="info medium"></span>
</div>
<div class="control-holder humidity-holder2">
<label>Humidity-2</label>
<span id="humidity2" class="info medium"></span>
</div>
<div class="control-holder pressure-holder">
<label>Pressure</label>
<span id="pressure" class="info medium"></span>
</div>
<div class="control-holder lux-holder">
<label>Illuminance</label>
<span id="lux" class="info medium"></span>
</div>
<div class="control-holder">
<label>WiFi RSSI dB</label>
<span id="rssi" class="info medium"></span>
</div>
</div>
<div class="control-holder">
<label>Alarm</label>
<input id="alarmEnable" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="alarmEnable">off</span>
<span class="switcher non-selectable" for="alarmEnable"></span>
<span class="switcher-text right non-selectable" for="alarmEnable">on</span>
</div>
<div class="control-holder">
<label for="alarmTime">Alarm Time</label>
<div class="multiple-input">
<select id="alarmTimeHours" class="number-select two-digit" min="0" max="23"></select>
<span>:</span>
<select id="alarmTimeMinutes" class="number-select two-digit" min="0" max="59" step="1"></select>
</div>
</div>
<div class="control-holder">
<label for="alarmPeriod">Alarm End (sec)</label>
<input type="range" min="1" max="240" class="slider" id="alarmPeriod">
</div>
<div class="control-holder radar-holder">
<label>Radar</label>
<input id="enableRadar" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="enableRadar">off</span>
<span class="switcher non-selectable" for="enableRadar"></span>
<span class="switcher-text right non-selectable" for="enableRadar">on</span>
</div>
<div class="control-holder radar-holder">
<label>Radar Timeout (min)</label>
<input type="range" min="1" max="60" class="slider" id="radarTimeout">
</div>
<div class="control-holder lux-holder">
<label>AutoDimmer</label>
<input id="enableAutoDim" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="enableAutoDim">off</span>
<span class="switcher non-selectable" for="enableAutoDim"></span>
<span class="switcher-text right non-selectable" for="enableAutoDim">on</span>
</div>
</div>
<!-- display settings -->
<div page="display" class="tube-holder">
<br>
<div class="control-holder">
<label>Manual Override</label>
<input id="manualOverride" type="checkbox" class="switch two-side">
<span class="switcher-text left non-selectable" for="manualOverride">DAY</span>
<span class="switcher non-selectable" for="manualOverride"></span>
<span class="switcher-text right non-selectable" for="manualOverride">NIGHT</span>
</div>
<div class="control-holder wordclock-holder">
<label>Display Mode</label>
<input id="set12_24" type="checkbox" class="switch two-side">
<span class="switcher-text left non-selectable" for="set12_24">12h</span>
<span class="switcher non-selectable" for="set12_24"></span>
<span class="switcher-text right non-selectable" for="set12_24">24h</span>
</div>
<div class="control-holder wordclock-holder">
<label>Zero Handling</label>
<input id="showZero" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="showZero">Hide</span>
<span class="switcher non-selectable" for="showZero"></span>
<span class="switcher-text right non-selectable" for="showZero">Show</span>
</div>
<div class="control-holder wordclock-holder">
<label>Blinking Dots</label>
<input id="enableBlink" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="enableBlink">off</span>
<span class="switcher non-selectable" for="enableBlink"></span>
<span class="switcher-text right non-selectable" for="enableBlink">on</span>
</div>
<div class="control-holder wordclock-holder">
<label>Double Blink</label>
<input id="enableDoubleBlink" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="enableDoubleBlink">off</span>
<span class="switcher non-selectable" for="enableDoubleBlink"></span>
<span class="switcher-text right non-selectable" for="enableDoubleBlink">on</span>
</div>
<div class="control-holder">
<label>Time Zone</label>
<select id="utc_offset" class="number-select" min="-12" max="12" prefix="(UTC " suffix=":00)"></select>
</div>
<div class="control-holder">
<label title="Daylight saving time">DST</label>
<input id="enableDST" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="enableDST">off</span>
<span class="switcher non-selectable" for="enableDST"></span>
<span class="switcher-text right non-selectable" for="enableDST">on</span>
</div>
<div class="control-holder">
<label for="animMode">Animation Mode</label>
<!-- <select id="animMode" class="number-select" min="0" max="6" step="1" prefix="Animation_" suffix=""></select> -->
<select id="animMode">
<option value="0">Off</option>
<option value="1">1 Count Up</option>
<option value="2">2 Count Down</option>
<option value="3">3 Shift Right</option>
<option value="4">4 Shift Left</option>
<option value="5">5 Transition</option>
<option value="6">Random 1-5</option>
<option value="7">Random 1-4</option>
</select>
</div>
<div class="control-holder wordclock-holder">
<label for="interval">Cathode Protect</label>
<input type="range" min="0" max="60" class="slider" id="interval">
</div>
<div class="control-holder">
<label>Auto Day/Night</label>
<input id="enableAutoShutoff" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="enableAutoShutoff">off</span>
<span class="switcher non-selectable" for="enableAutoShutoff"></span>
<span class="switcher-text right non-selectable" for="enableAutoShutoff">on</span>
</div>
<div class="control-holder">
<label>Day Brightness</label>
<input type="range" min="1" class="slider" id="dayBright">
</div>
<div class="control-holder">
<label>Night Brightness</label>
<input type="range" min="0" class="slider" id="nightBright">
</div>
<div class="control-holder">
<label>Day</label>
<div class="multiple-input">
<select id="dayTimeHours" class="number-select two-digit" min="0" max="23"></select>
<span>:</span>
<select id="dayTimeMinutes" class="number-select two-digit" min="0" max="59" step="5"></select>
</div>
</div>
<div class="control-holder">
<label>Night</label>
<div class="multiple-input">
<select id="nightTimeHours" class="number-select two-digit" min="0" max="23"></select>
<span>:</span>
<select id="nightTimeMinutes" class="number-select two-digit" min="0" max="59" step="5"></select>
</div>
</div>
<div class="control-holder wordclock-holder">
<label>Display Time/Date</label>
<input id="enableTimeDisplay" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="enableTimeDisplay">off</span>
<span class="switcher non-selectable" for="enableTimeDisplay"></span>
<span class="switcher-text right non-selectable" for="enableTimeDisplay">on</span>
</div>
<div class="control-holder">
<label for="dateMode">Date Format</label>
<select id="dateMode">
<option value="0">dd/mm/yyyy</option>
<option value="1">mm/dd/yyyy</option>
<option value="2">yyyy/mm/dd</option>
</select>
</div>
<div class="control-holder wordclock-holder">
<label>Date Repeat (min)</label>
<input type="range" min="0" max="10" class="slider" id="dateRepeatMin">
</div>
<div class="control-holder temperature-holder">
<label>Temp/H. Repeat (min)</label>
<input type="range" min="0" max="10" class="slider" id="tempRepeatMin">
</div>
<div class="control-holder temperature-holder">
<label>Temperature Format</label>
<input id="tempCF" type="checkbox" class="switch two-side">
<span class="switcher-text left non-selectable" for="tempCF">C</span>
<span class="switcher non-selectable" for="tempCF"></span>
<span class="switcher-text right non-selectable" for="tempCF">F</span>
</div>
<div class="control-holder wordclock-holder">
<label>Date seconds</label>
<div class="multiple-input">
<select id="dateStart" class="number-select two-digit" min="0" max="59"></select>
<span>-</span>
<select id="dateEnd" class="number-select two-digit" min="0" max="59" step="1"></select>
</div>
</div>
<div class="control-holder temperature-holder">
<label>Temperature seconds</label>
<div class="multiple-input">
<select id="tempStart" class="number-select two-digit" min="0" max="59"></select>
<span>-</span>
<select id="tempEnd" class="number-select two-digit" min="0" max="59" step="1"></select>
</div>
</div>
<div class="control-holder humidity-holder">
<label>Humidity seconds</label>
<div class="multiple-input">
<select id="humidStart" class="number-select two-digit" min="0" max="59"></select>
<span>-</span>
<select id="humidEnd" class="number-select two-digit" min="0" max="59" step="1"></select>
</div>
</div>
</div>
<!-- RGB settings -->
<div page="rgb" class="tube-holder">
<br>
<div class="control-holder rgb-holder">
<label for="rgbEffect">RGB Effect</label>
<select id="rgbEffect">
<option value="0">OFF</option>
<option value="1">Fixed Color</option>
<option value="2">Rainbow Flow</option>
<option value="3">Rainbow Stepper</option>
<option value="4">Color Dimmer</option>
<option value="5">Color Changer</option>
<option value="6">Color FlowChanger</option>
<option value="7">Color FlowChanger Random-1</option>
<option value="8">Color FlowChanger Random-2</option>
<option value="9">Color FlowChanger Random-3</option>
<option value="10">Knight Rider's KITT</option>
</select>
</div>
<div class="control-holder rgb-holder">
<label>RGB Brightness</label>
<input type="range" min="8" max="255" class="slider" id="rgbBrightness">
</div>
<div class="control-holder">
<label>Fixed Color</label>
<div id="color-select-holder">
<div>
<input type="range" min="1" max="255" class="slider" id="rgbFixColor">
</div>
<div>
<div id="selectedColor"></div>
</div>
</div>
</div>
<div class="control-holder rgb-holder">
<label>Direction</label>
<input id="rgbDir" type="checkbox" class="switch two-side">
<span class="switcher-text left non-selectable" for="rgbDir">left</span>
<span class="switcher non-selectable" for="rgbDir"></span>
<span class="switcher-text right non-selectable" for="rgbDir">right</span>
</div>
<div class="control-holder">
<label for="rgbSpeed">Animation Speed</label>
<input type="range" min="1" max="255" class="slider" id="rgbSpeed">
</div>
<div class="control-holder wled-holder">
<label>SignalRGB (WLED)</label>
<input id="wledEnable" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="wledEnable">off</span>
<span class="switcher non-selectable" for="wledEnable"></span>
<span class="switcher-text right non-selectable" for="wledEnable">on</span>
</div>
<div class="control-holder wled-holder">
<label>SignalRGB off with tubes</label>
<input id="wledDarkWithTubes" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="wledDarkWithTubes">off</span>
<span class="switcher non-selectable" for="wledDarkWithTubes"></span>
<span class="switcher-text right non-selectable" for="wledDarkWithTubes">on</span>
</div>
<div class="control-holder wled-holder">
<label>SignalRGB uses RGB Brightness</label>
<input id="wledUseBrightness" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="wledUseBrightness">off</span>
<span class="switcher non-selectable" for="wledUseBrightness"></span>
<span class="switcher-text right non-selectable" for="wledUseBrightness">on</span>
</div>
<div class="control-holder wled-holder">
<label>SignalRGB active</label>
<span id="wledLive" class="info medium"></span>
</div>
</div>
<!-- WiFi settings -->
<div page=wifi>
<br>
<div class="control-holder">
<label>WiFi SSID</label>
<input type="text" id="wifiSsid">
</div>
<div class="control-holder">
<label>WiFi Password</label>
<input type="text" id="wifiPsw">
</div>
<div class="control-holder">
<label>AP SSID</label>
<input type="text" id="ApSsid">
</div>
<div class="control-holder">
<label>AP Password</label>
<input type="text" id="ApPsw">
</div>
<div class="control-holder">
<label>WiFi Mode</label>
<input id="wifiMode" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="wifiMode">AP</span>
<span class="switcher non-selectable" for="wifiMode"></span>
<span class="switcher-text right non-selectable" for="wifiMode">Client</span>
</div>
<div class="control-holder">
<label>Ntp Server</label>
<input type="text" id="NtpServer">
</div>
<div class="control-holder mqtt-holder">
<label>MQTT Enable</label>
<input id="mqttEnable" type="checkbox" class="switch">
<span class="switcher-text left non-selectable" for="mqttEnable">off</span>
<span class="switcher non-selectable" for="mqttEnable"></span>
<span class="switcher-text right non-selectable" for="mqttEnable">on</span>
</div>
<div class="control-holder mqtt-holder">
<label>MQTT Address</label>
<input type="text" id="mqttBrokerAddr">
</div>
<div class="control-holder mqtt-holder">
<label>MQTT User</label>
<input type="text" id="mqttBrokerUser">
</div>
<div class="control-holder mqtt-holder">
<label>MQTT Password</label>
<input type="text" id="mqttBrokerPsw">
</div>
<div class="control-holder mqtt-holder">
<label>MQTT Refresh (sec)</label>
<input type="range" min="10" max="100" class="slider" id="mqttBrokerRefresh">
</div>
</div>
<div page="settings" hidden="true">
<br><br>
<!-- Sensor corrections -->
<div class="control-holder temperature-holder">
<label>Temperature#1</label>
<input type="range" min="-5" max="5" step="0.1" class="slider" id="corrT0">
</div>
<div class="control-holder temperature-holder2">
<label>Temperature#2</label>
<input type="range" min="-5" max="5" step="0.1" class="slider" id="corrT1">
</div>
<div class="control-holder humidity-holder">
<label>Humidity#1</label>
<input type="range" min="-25" max="25" step="0.1" class="slider" id="corrH0">
</div>
<div class="control-holder humidity-holder2">
<label>Humidity#2</label>
<input type="range" min="-25" max="25" step="0.1" class="slider" id="corrH1">
</div>
<div class="control-holder wordclock-holder">
<label>CathodeProtect (minutes)</label>
<input type="range" min="1" max="60" step="1" class="slider" id="cathProtMin">
</div>
<div class="control-holder">
<label>Firmware Server</label>
<input type="text" id="firmware">
</div>
<br><br><br>
<div class="control-holder">
<button id="cath-prot-btn" onclick="areYouSure('cathodeProtect')">Cathode Protect</button>
<button id="fw-update-btn" onclick="areYouSure('firmwareupdate')">Firmware Update</button>
<button id="restart-btn" onclick="areYouSure('reset')">Restart</button>
<button id="factory-reset-btn" onclick="areYouSure('factoryreset')">Factory Reset</button>
</div>
<div id="clock-details">
</div>
</div>
</div>
<div class="separator"></div>
<div class="footer">
© 2020-22 Peter Gautier<span>-</span><a href="mailto: gautier.p62@gmail.com">gautier.p62@gmail.com</a><br>
Modified by Claude for the RetroModding NixieIN12v2 clock<span>-</span><a href="https://mangavalk.com/mangavalk/nixie-clock" target="_blank">mangavalk.com/mangavalk/nixie-clock</a><br>
<div id="version" class="info" pagemenu="settings"></div>
</div>
</div>
</body>
</html>
Binary file not shown.
-2
View File
@@ -1,2 +0,0 @@
/*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.5.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),D=function(e,t){return e===t&&(l=!0),0},j={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-lLine truncated
-2
View File
@@ -1,2 +0,0 @@
/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),j=function(e,t){return e===t&&(l=!0),0},D={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^Line truncated
@@ -1,627 +0,0 @@
var isTest = (location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.href.indexOf("file://") != -1);
var controlInfos = {
"version": '<a href="https://github.com/gpeter62/ESP_UniClock" target="_blank">https://github.com/gpeter62/ESP_UniClock</a>',
"maxDigits": "Number of tubes",
"maxBrightness": "MAX Brightness",
"currentDate": "Date",
"currentTime": "Time",
"temperature": "Temperature sensor #1",
"temperature2": "Temperature sensor #2",
"humidity": "Humidity sensor #1",
"humidity2": "Humidity sensor #2",
"pressure": "Pressure sensor #1",
"lux": "Lux sensor current value",
"rssi": "WiFi RSSI level dB (connection quality)",
"wifiMode": "WiFi Client or Access Point",
"alarmEnable": "Switch ON/OFF alarm",
"alarmTime": "Alarm time (hour/minute)",
"alarmPeriod": "Alarm maximum length (sec)",
//Tube display settings
"utc_offset": 'Timezone setting. <a href="https://en.wikipedia.org/wiki/List_of_time_zones_by_country" target="_blank"></a>https://en.wikipedia.org/wiki/List_of_time_zones_by_country',
"enableDST": "Daylight Saving Time ON/OFF",
"set12_24": "Clock display 12 / 24 hours",
"showZero": "Show starting zero on hours",
"enableBlink": "ON / OFF",
"interval": "Cathode protect interval (minutes)",
"enableAutoShutoff": "Enable automatic day/night switch",
"dayTime": "Day starts (manual brightness control)",
"nightTime": "Night starts (manual brightness control)",
"dayBright": "Day brightness",
"nightBright": "Night brightness",
"manualOverride": "Manual Day/Night change",
"animMode": "Tube animation mode: 0=OFF, 1-5: Animations 6-7: Random",
"dateMode": "0:dd/mm/yyyy 1:mm/dd/yyyy 2:yyyy/mm/dd",
"tempCF": "Celsius / Fahrenheit display",
"enableTimeDisplay": "Enable time&date display (Use OFF for thermometers)" ,
"dateStart": "Date display start: Date is shown between Start/End seconds",
"dateEnd": "Date display end",
"tempStart": "Temperature display time slice start",
"tempEnd": "Temperature display end",
"humidStart": "Humidity display time slice start",
"humidEnd": "Humidity display end",
"dateRepeatMin": "Date is shown in every xx minutes. 0 = Disable date display",
"tempRepeatMin": "Temperature/humidity is shown in every xx minutes. 0 = Disable temp/humid display",
"enableDoubleBlink": "Enable both blinking dots",
"enableAutoDim": "Enable auto brightness control (if sensor is installed)",
"enableRadar": "Enable Radar/Pir tube switch (if sensor is installed)",
"radarTimeout": "If Radar is used, automatic switch off after this timeout (minutes)",
//RGB settings
"rgbDir" : "RGB animation direction (left/right)",
"rgbEffect": "RGB animation#",
"rgbBrightness": "RGB leds brightness 0..255",
"rgbFixColor": "RGB color, if FixColor Effect is used",
"rgbSpeed": "RGB animation speed",
"wledEnable": "Let SignalRGB control the LEDs: the clock shows up there as a WLED device",
"wledDarkWithTubes": "LEDs stay dark while the tubes / backlight are off, also when SignalRGB is running",
"wledUseBrightness": "Scale SignalRGB colours by RGB Brightness (and auto dim). Off: colours as sent",
"wledLive": "SignalRGB is sending colours right now",
//Wifi settings
"wifiSsid": "WiFi network SSID to connect",
"wifiPsw": "WiFI password",
"ApSsid": "AccessPoint name, if standalone mode is used",
"ApPsw": "AP password",
"NtpServer": "Timeserver name, using WiFi. (Default is: pool.ntp.org)",
"mqttBrokerAddr": "MQTT server address, if MQTT used",
"mqttBrokerUser": "MQTT user",
"mqttBrokerPsw": "MQTT password",
"mqttBrokerRefresh": "MQTT send data in every xx sec",
"mqttEnable": "Enable/Disable MQTT refresh",
"firmware": "http server + firmware name to download new firmware",
"corrT0": "Temperature sensor#1 correction",
"corrT1": "Temperature sensor#2 correction",
"corrH0": "Humidity sensor#1 correction",
"corrH1": "Humidity sensor#2 correction" ,
"cathProtMin": "Cathode Protect procedure (minutes)",
"FW": "firmware code",
"tubeDriver": "Tube driver modul"
};
//Example config that UI recieves
var configuration = {
//Main screen
"version": "UniClock 3.0",
"maxDigits": 6,
"maxBrightness": 10,
"currentDate": "2020.10.24",
"currentTime": "15:01",
"temperature": 22.1,
"temperature2": 255,
"humidity": 45,
"humidity2": 255,
"pressure": 255,
"lux": 100,
"rssi": 0,
"wifiMode": true,
"alarmEnable": false,
"alarmTime": "6:30",
"alarmPeriod": 15,
"enableRadar": false,
"radarTimeout": 5,
//Tube display settings
"utc_offset": 1,
"enableDST": true,
"set12_24": true,
"showZero": true,
"enableBlink": true,
"interval": 15,
"enableAutoShutoff": true,
"dayTime": "7:00",
"nightTime": "22:00",
"dayBright": 10,
"nightBright": 3,
"manualOverride": true,
"animMode": 6,
"dateMode": 2, // 0:dd/mm/yyyy 1:mm/dd/yyyy 2:yyyy/mm/dd
"tempCF": false, //Temperature Celsius / Fahrenheit
"enableTimeDisplay": true,
"dateStart": 45,
"dateEnd": 50,
"tempStart": 35,
"tempEnd": 40,
"humidStart": 40,
"humidEnd": 45,
"dateRepeatMin": 3,
"tempRepeatMin": 1,
"enableDoubleBlink": true,
"enableAutoDim": false,
//RGB settings
"rgbDir" : true,
"rgbEffect": 1,
"rgbBrightness": 100,
"rgbFixColor": 150,
"rgbSpeed": 50,
"wledEnable": false,
"wledDarkWithTubes": true,
"wledUseBrightness": true,
"wledLive": false,
//Wifi settings
"wifiSsid": "mywifi",
"wifiPsw": "mypsw",
"ApSsid": "UniClock",
"ApPsw": "uniclock",
"NtpServer": "pool.ntp.org",
"mqttBrokerAddr": "10.0.99.12",
"mqttBrokerUser": "mqtt",
"mqttBrokerPsw": "mqttPW",
"mqttBrokerRefresh": 30,
"mqttEnable": false,
"firmware": "http://server/fw.bin",
"corrT0": 0.0,
"corrT1": 0.0,
"corrH0": 0.0,
"corrH1": 0.0,
"cathProtMin": 5,
"FW": "fw",
"tubeDriver": "xxx"
};
var isMouseDown = 0;
//Runs, when HTML document is fully loaded
$(document).ready(function(){
$(document).on('mousedown touchstart',function(event) {
++isMouseDown;
});
$(document).on('mouseup touchend',function(event) {
--isMouseDown;
});
if(isTest){
Init();
setCurrentInfos();
}
else{
getConfiguration();
//Set current infos, like time, humidity and temperature
getCurrentInfos();
}
});
function setLocalPagination(){
$('[page]').not('[hidden]').each(function(){
var page = $(this).attr('page');
$('#menu tr').append('<td><div class="menu-item" pageMenu="'+page+'">'+page+'</div></td>');
});
}
function getConfiguration(){
$.get('/getConfiguration/').done(function(data){
configuration = data;
}).always(function(){
Init();
});
}
function sendMsgToArduino(key,value) {
if(isTest){
console.log(key + " " + value);
}
else{
$.post('/saveSetting/', {"key" : key ,"value" : value }).done(function(data){
console.log(data);
});
}
}
var COLORSATURATION = 255;
var WHITE_INDEX = 192;
function getColorFrom(WheelPos){
if (WheelPos == WHITE_INDEX)
return RgbColor(COLORSATURATION/2, COLORSATURATION/2, COLORSATURATION/2);
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return RgbColor(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return RgbColor(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return RgbColor(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}
function RgbColor(r, g, b){
return 'rgb('+r+','+g+','+b+')';
}
function setPreviewColor(){
var color = getColorFrom($('#rgbFixColor').val());
$('#selectedColor').css('background-color',color);
}
function setCurrentInfos(){
$('#currentTime').html(getCurrentDate(configuration["currentDate"]) + " " + configuration["currentTime"]);
$('#lux').html(configuration["lux"]);
$('#rssi').html(configuration["rssi"]);
$('#wledLive').html(configuration["wledLive"] ? "yes" : "no");
$('#pressure').html(round(configuration["pressure"],1));
$('#humidity').html(round(configuration["humidity"],1));
$('#humidity2').html(round(configuration["humidity2"],1));
$('#temperature').html(getTemperature(configuration["temperature"]));
$('#temperature2').html(getTemperature(configuration["temperature2"]));
$('#temperature, #temperature2').toggleClass('fahrenheit',configuration["tempCF"]);
}
function round(value, decimals) {
return parseFloat(value).toFixed(decimals);
//return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
}
function getTemperature(temperatureInC){
if(configuration["tempCF"]){ //Fahrenheit
return round(temperatureInC * 1.8 + 32,1);
}
else{
return round(temperatureInC,1);
}
}
function getControlInfo(index){
return controlInfos[index];
}
//Contains the most important initializes
function Init(){
$('#dayBright, #nightBright').attr('max',configuration['maxBrightness']);
document.title = configuration['version'];
$('#versionHeader').html(configuration['version']);
setLocalPagination();
$('[pagemenu]').on('click',function(){
$('.menu-item.active').removeClass('active');
$('[page].active').removeClass('active');
$(this).addClass('active');
$('[page="'+$(this).attr('pagemenu')+'"]').addClass('active');
if($(this).attr('pagemenu') == 'settings'){
getClockDetails();
}
});
$('.menu-item').eq(0).trigger('click');
$('#rgbFixColor').on('input',function(){
setPreviewColor();
});
var sliderFadeOutTimer;
function setFadeOutTimer(element){
setTimeout(function(){
if(isMouseDown > 0){
clearTimeout(sliderFadeOutTimer);
sliderFadeOutTimer = setFadeOutTimer(element);
}
else{
$(element).addClass('fading').fadeOut('slow',function(){
$(this).remove();
});
}
},600);
}
$('input[type="range"]').on('mousedown touchstart input',function(){
clearTimeout(sliderFadeOutTimer);
var id = $(this).attr('id');
var parent = $(this).closest('.control-holder');
$('[sliderfor]:not(.fading)').each(function(){
if($(this).attr('sliderfor') != id && !$(this).hasClass('fading')){
$(this).addClass('fading').fadeOut('slow',function(){
$(this).remove();
});
}
});
if($(parent).children('.slider-info').length == 0){
$(parent).append('<div class="slider-info" sliderfor="'+id+'"></div>');
$(parent).children('.slider-info').fadeIn(300);
}
var _this = $(parent).children('.slider-info').text($(this).val());
sliderFadeOutTimer = setFadeOutTimer(_this);
});
$('.form label').on('click',function(){
var id = '';
if(!!$(this).attr('for')){
id = $(this).attr('for');
}
else{
id = $(this).closest('.control-holder').find('input, select, .info').eq(0).attr('id');
}
var info = getControlInfo(id);
if(!!info){
showPopUp($(this).text(), info, 450, true);
}
});
$('#popup-close-btn, #info-popup').on('click',function(){
if($('#info-popup').hasClass('cantClose')){
return;
}
else{
$('#info-popup').fadeOut(450);
}
});
$("#popup-box").click(function(event){
event.stopPropagation();
});
//binds custom switch functionality
$('.switcher').on('click',function(){
$('#'+$(this).attr('for')).prop('checked',!$('#'+$(this).attr('for')).is(":checked")).trigger('change');
});
//binds custom switch text functionality
$('.switcher-text').on('click',function(){
$('#'+$(this).attr('for')).prop('checked',$(this).hasClass('right')).trigger('change');
});
//fills autogenerated select drop downs
/*
Possible css class:
two-digit - fills with two digit values if value lower than 10
Possible attributes:
min (mandatory) - auto generation's minimum value
max (mandatory) - auto generation's maximum value
step (optional) - auto generation's step, if not set, default is 1
prefix (optional) - concatanate this string before value
suffix (optional) - concatanate this string after value
*/
$('.number-select').each(function(){
let from = $(this).attr('min')*1;
let to = $(this).attr('max')*1;
let step = !!$(this).attr('step') ? $(this).attr('step') : 1;
for(let i = from; i < to+1; i){
let value = $(this).hasClass('two-digit') ? formatToTwoDigit(i) : i;
let text_value = value;
if($(this).attr('prefix') != null){
text_value = $(this).attr('prefix') + text_value
}
if($(this).attr('suffix') != null){
text_value += $(this).attr('suffix')
}
$(this).append('<option value="'+value+'">'+text_value+'</option>');
i += step*1;
}
});
//fills the inputs with configuration values
for(var index in configuration){
let value = configuration[index];
if(index == 'dayTime' || index == 'nightTime' || index == 'alarmTime'){
value = value.split(':');
$('#'+index+'Hours').val(formatToTwoDigit(value[0]));
$('#'+index+'Minutes').val(formatToTwoDigit(value[1]));
}
else if(index == 'version'
){
$('#'+index).html(value);
}
else if(index == 'utc_offset' || index == 'maxBrightness' ||
index == 'dayBright' || index == 'nightBright' ||
index == 'animMode' || index == 'rgbBrightness' ||
index == 'rgbFixColor' || index == 'rgbSpeed' ||
index == 'rgbEffect' || index == 'interval' ||
index == 'alarmPeriod' || index == 'radarTimeout' ||
index == 'dateRepeatMin' || index == 'dateMode' ||
index == 'dateStart' || index == 'dateEnd' ||
index == 'timeStart' || index == 'timeEnd' ||
index == 'tempStart' || index == 'tempEnd' ||
index == 'humidStart' || index == 'humidEnd' ||
index == 'mqttBrokerRefresh' || index == 'tempRepeatMin' ||
index == 'wifiSsid' || index == 'wifiPsw' ||
index == 'ApSsid' || index == 'ApPsw' ||
index == 'mqttBrokerAddr' || index == 'NtpServer' ||
index == 'mqttBrokerUser' || index =='mqttBrokerPsw' ||
index == 'firmware' || index == 'corrT0' || index == 'corrT1' ||
index == 'corrH0' || index == 'corrH1' || index == 'cathProtMin'
){
$('#'+index).val(value);
}
else if((index == 'enableDST' || index == 'set12_24' ||
index == 'showZero' || index == 'enableBlink' ||
index == 'enableAutoShutoff' || index == 'alarmEnable' ||
index == 'rgbDir' || index == 'manualOverride' ||
index == 'enableAutoDim' || index == 'enableRadar' ||
index == 'enableDoubleBlink' || index == 'enableTimeDisplay' ||
index == 'mqttEnable' || index == 'tempCF' || index == "wifiMode" ||
index == 'wledEnable' || index == 'wledDarkWithTubes' || index == 'wledUseBrightness'
) && !!value
){
$('#'+index).prop('checked',true);
}
else if(index == "maxDigits"){
//TODO
}
}
$('.radar-holder').toggleClass('hidden',configuration['radarTimeout'] == 0);
$('.mqtt-holder').toggleClass('hidden',configuration['mqttBrokerRefresh'] == 0);
$('.lux-holder').toggleClass('hidden',configuration['lux'] == 255);
$('.pressure-holder').toggleClass('hidden',configuration['pressure'] == 255);
$('.humidity-holder').toggleClass('hidden',configuration['humidity'] == 255);
$('.humidity-holder2').toggleClass('hidden',configuration['humidity2'] == 255);
$('.temperature-holder').toggleClass('hidden',configuration['temperature'] == 255);
$('.temperature-holder2').toggleClass('hidden',configuration['temperature2'] == 255);
$('.rgb-holder').toggleClass('hidden',configuration['rgbEffect'] == 255);
$('.wled-holder').toggleClass('hidden',configuration['wledEnable'] === undefined); //firmware without USE_WLED_REALTIME
$('.tube-holder').toggleClass('hidden',configuration['tubeDriver'] == "DUMMY");
$('.wordclock-holder').toggleClass('hidden',configuration['tubeDriver'] == "WORDCLOCK");
$('.sensors-holder').toggleClass('hidden',configuration['temperature'] == 255);
setPreviewColor();
//sets a possible good timezone, if not already set
//if(!configuration['utc_offset']){
// //Intl.DateTimeFormat().resolvedOptions().timeZone <- I am in this Zone
// var tryToFindCurrentZone = -(new Date().getTimezoneOffset() / 60);
// $('#utc_offset').val(tryToFindCurrentZone);
//}
setTimeout(function(){
$('input, select').on('change',function(){
var value = '';
if($(this).attr('id').indexOf("Hours") == -1 || $(this).attr('id').indexOf("Minutes") == -1){
if($(this).attr('type') == 'checkbox'){
value = $(this).is(':checked');
}
else{
value = $(this).val();
}
sendMsgToArduino($(this).attr('id'), value);
}
else{
var key = $(this).attr('id').replace('Hours','').replace('Minutes','');
value = $('#'+key+'Hours').val() + ":" + $('#'+key+'Minutes').val();
sendMsgToArduino(key, value);
}
});
$('#dateMode').on('change',function(){
configuration["dateMode"] = $(this).val();
setCurrentInfos();
});
$('#tempCF').on('change',function(){
configuration["tempCF"] = !configuration["tempCF"];
setCurrentInfos();
});
},200);
}
function showPopUp(header, content, timeout, canClose){
$('#popup-box h2').text(header);
$('#popup-box .content').html(content);
$('#info-popup').toggleClass('cantClose',!canClose);
$('#info-popup').fadeIn(timeout);
}
function areYouSure(fn){
if (confirm("Are you sure to run " + fn + "?")) {
if(fn == "reset"){
callReset();
}
else if(fn == "factoryreset"){
callFactoryReset();
}
else if(fn == "firmwareupdate"){
callFirmwareUpdate();
}
else if(fn == "cathodeProtect"){
callCathodeProtect();
}
}
}
function callReset(){
if(isTest){return;}
$.post('/reset/', {}).done(function(data){
location.reload();
}).always(function(){
});
}
function callFactoryReset(){
if(isTest){return;}
$.post('/factoryreset/', {}).done(function(data){
location.reload();
}).always(function(){
});
}
function callFirmwareUpdate(){
if(isTest){return;}
showPopUp("Firmware is updating", "Please do not turn off the clock", 300, false);
$.post('/firmwareupdate/', {}).done(function(data){
if(!!data.header){
showPopUp(data.header, data.content, 300, data.canClose);
}
}).always(function(){
});
}
function callCathodeProtect(){
if(isTest){return;}
$.post('/cathodeProtect/', {}).done(function(data){
location.reload();
}).always(function(){
});
}
function getClockDetails(){
if(isTest){return;}
$.get('/getClockDetails/').done(function(data){
$('#clock-details').html(data);
}).always(function(){
});
}
function getCurrentInfos(){
if(isTest){return;}
$.get('/getCurrentInfos/').done(function(data){
for(var i in data){
configuration[i] = data[i];
}
if(!!data["popupMsg"] && data["popupMsg"].length > 0){
showPopUp("Info", data["popupMsg"], 300, true);
}
setCurrentInfos();
setTimeout(getCurrentInfos,20000); //refreshes time every 20 second by calling itself
}).always(function(){
});
}
function getCurrentDate(date){
var splittedDate = date.split('.');
var yyyy = splittedDate[0];
var mm = splittedDate[1];
var dd = splittedDate[2];
if(configuration["dateMode"] == 0){
return dd+"/"+mm+"/"+yyyy;
}
else if(configuration["dateMode"] == 1){
return mm+"/"+dd+"/"+yyyy;
}
else if(configuration["dateMode"] == 2){
return yyyy+"/"+mm+"/"+dd;
}
else{
return yyyy+"/"+mm+"/"+dd; //if dateMode?? // 0:dd/mm/yyyy 1:mm/dd/yyyy 2:yyyy/mm/dd
}
}
//Gets the current time from browser and gives back as readable format
function getCurrentTime(){
var today = new Date();
var dd = formatToTwoDigit(today.getDate());
var mm = formatToTwoDigit(today.getMonth()+1);
var yyyy = today.getFullYear();
var hour = formatToTwoDigit(today.getHours());
var minute = formatToTwoDigit(today.getMinutes());
if(configuration["dateMode"] == 0){
return dd+"-"+mm+"-"+yyyy+" "+hour+":"+minute;
}
else if(configuration["dateMode"] == 1){
return mm+"-"+dd+"-"+yyyy+" "+hour+":"+minute;
}
else if(configuration["dateMode"] == 2){
return yyyy+"-"+mm+"-"+dd+" "+hour+":"+minute;
}
else{
return yyyy+"-"+mm+"-"+dd+" "+hour+":"+minute; //if dateMode?? // 0:dd/mm/yyyy 1:mm/dd/yyyy 2:yyyy/mm/dd
}
}
//if number is lower than 10, adds a zero
function formatToTwoDigit(number){
return ("0" + number).slice(-2);
}
@@ -1,479 +0,0 @@
*, *:before, *:after{
box-sizing: border-box;
}
.non-selectable{
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome, Edge, Opera and Firefox */
}
html {
-webkit-font-smoothing: antialiased;
background-image: radial-gradient(#222, #111);
min-height: 100%;
background-attachment: fixed;
color: #c35;
}
.hidden{
display: none !important;
}
a, a:visited{
color: #c35;
text-decoration: none;
}
a:hover{
text-decoration: underline;
color: #777;
}
body {
font-family: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", FreeSans, sans-serif;
margin: 0;
}
.form{
overflow: auto;
}
.max-width{
max-width: 800px;
margin: auto;
}
.row{
clear: both;
overflow: auto;
}
.row + .row{
margin-top: 15px;
}
.control-holder{
width: 33.333333%;
display: block;
float: left;
padding: 5px;
min-height: 80px;
position: relative;
}
.header{
overflow: auto;
}
.form label {
cursor: help;
width: 100%;
display: inline-block;
font-weight: bold;
padding-top: 0;
padding-left: 0;
letter-spacing: 0.025em;
font-size: 20px;
vertical-align: top;
line-height: 30px;
position: relative;
text-shadow: 1px 1px 0 black;
margin-bottom: 5px;
}
input, select, button{
margin: 0;
font: inherit;
line-height: normal;
width: 100%;
max-width: 250px;
background: #222222;
color: #eee;
position: relative;
padding: 5px;
min-height: 30px;
outline: none;
line-height: normal;
border-radius: 3px;
border: 1px solid #666;
transition: 0.15s background;
}
input:not([type="text"]):not(:disabled),select:not(:disabled),button:not(:disabled){
cursor: pointer;
}
input:hover, select:hover, button:hover{
background: #333;
}
input:focus, select:focus, button:focus{
background: #4E4E4E;
border-color: #888;
}
input:active, select:active, button:active{
background: #5E5E5E;
border-color: #aaa;
}
button{
border: 2px solid #c35;
color: #c35;
text-transform: uppercase;
font-weight: bold;
}
button:hover{
color: #ddd;
}
.multiple-input span{
color: white;
font-weight: bold;
}
.two-digit, .small{
max-width: 60px;
}
[pagemenu="settings"]:hover{
cursor: pointer;
text-decoration: underline;
}
[type="checkbox"].switch{
position: fixed;
left: -300px;
top: -300px;
}
[type="checkbox"].switch ~ .switcher{
width: 60px;
display: inline-block;
vertical-align: top;
height: 30px;
padding: 2px;
background: #222222;
border: 1px solid #666;
transition: 0.15s background;
border-radius: 30px;
position: relative;
cursor: pointer;
}
[type="checkbox"].switch:focus ~ .switcher{
background: #5E5E5E;
border-color: #aaa;
}
[type="checkbox"].switch ~ .switcher:after{
display: inline-block;
content: '';
vertical-align: top;
width: 20px;
height: 20px;
position: absolute;
top: 4px;
left: 4px;
border-radius: 50%;
background: rgba(255,255,255,0.4);
transition: 0.3s all;
}
[type="checkbox"].switch:checked ~ .switcher:after{
left: 34px;
}
[type="checkbox"].switch:not(.two-side):checked ~ .switcher:after{
background: rgba(255,255,255,0.7);
}
[type="checkbox"].switch:not(.two-side):checked ~ .switcher{
background: #37bfb9;
background-color: #c35;
}
[page]{
display: none;
}
[page].active{
display: block;
}
#menu-holder{
padding-bottom: 40px;
}
#menu-holder > .floating-menu{
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 110;
background: #161616;
}
#menu{
width: 100%;
}
#menu td{
padding: 0 18px;
}
#menu td .menu-item{
cursor: pointer;
border-bottom: 2px solid gray;
text-align: center;
text-transform: uppercase;
font-weight: bold;
line-height: 30px;
background-color: transparent;
transition: 0.3s border, 0.3s background, 0.3s color;
}
#menu td .menu-item:hover{
background-color: #4E4E4E;
border-color: #ddd;
}
#menu td .menu-item.active{
color: #ddd;
border-color: #c35;
}
.switcher-text{
text-transform: uppercase;
font-weight: bold;
line-height: 30px;
cursor: pointer;
transition: 0.3s color;
text-shadow: 1px 1px 0 black;
}
.switcher-text:hover{
color: #c35 !important;
}
.switcher-text.left{
margin-right: 10px;
}
.switcher-text.right{
margin-left: 10px;
color: #555;
}
[type="checkbox"].switch:checked ~ .switcher-text.left{
color: #555;
}
[type="checkbox"].switch:checked ~ .switcher-text.right{
color: inherit;
}
.footer{
margin: auto;
display: block;
text-align: center;
text-shadow: 1px 1px 0 black;
}
.footer span{
margin: 0 10px;
font-size: 26px;
color: #555;
}
.separator{
border-top: 1px dotted #555;
margin-top: 20px;
margin-bottom: 20px;
}
.info{
color: #555;
padding: 10px 0;
font-style: italic;
display: inline-block;
text-shadow: 1px 1px 0 black;
}
.info.medium{
color: #888;
font-weight: bold;
font-size: 25px;
line-height: 32px;
}
.info.big{
color: #888;
font-weight: bold;
font-size: 32px;
line-height: 32px;
}
.info:after{
color: #666;
display: inline-block;
padding-left: 5px;
font-size: 28px;
}
#temperature:after{
content: ' °C';
}
#temperature.fahrenheit:after{
content: ' °F';
}
#temperature2:after{
content: ' °C';
}
#temperature2.fahrenheit:after{
content: ' °F';
}
#humidity:after{
content: '%';
}
#pressure:after{
content: ' hPa';
}
#lux:after{
content: ' lux';
}
#color-select-holder > div{
float: left;
}
#color-select-holder > div:first-child{
width: calc(100% - 40px);
}
#color-select-holder > div:last-child{
width: 40px;
}
#info-popup{
display: none;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 9999;
background: rgba(0,0,0,0.6);
}
#popup-box{
padding: 12px;
border: 2px solid;
margin: auto;
width: 100%;
background: #161616;
margin-top: 50px;
border-radius: 12px;
position: relative;
}
#popup-box h2{
margin-top: 0;
color: #ddd;
}
#popup-close-btn{
position: absolute;
left: 100%;
top: 0;
background: #161616;
width: 30px;
height: 30px;
border-radius: 50%;
border: 2px solid;
line-height: 30px;
text-align: center;
font-weight: bold;
cursor: pointer;
margin-left: -15px;
margin-top: -15px;
transition: 0.3s background, 0.3s color;
}
#popup-close-btn:hover{
color: #ddd;
}
#info-popup.cantClose #popup-close-btn{
display: none;
}
#selectedColor{
width: 30px;
height: 30px;
background-color: white;
border-radius: 50%;
margin: auto;
}
.slider-info{
display: none;
position: absolute;
padding: 3px;
font-weight: bold;
font-size: 24px;
background: #161616;
border: 2px solid #c35;
z-index: 3;
border-radius: 50%;
text-align: center;
color: #ddd;
min-width: 50px;
top: 0;
right: 10px;
}
/* slider control */
.slidecontainer {
width: 100%; /* Width of the outside container */
}
/* The slider itself */
.slider {
margin-top: 9px;
height: 10px;
min-height: auto;
-webkit-appearance: none; /* Override default CSS styles */
appearance: none;
outline: none; /* Remove outline */
opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */
-webkit-transition: .2s; /* 0.2 seconds transition on hover */
transition: opacity .2s;
}
/* Mouse-over effects */
.slider:hover {
opacity: 1; /* Fully shown on mouse-over */
}
/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
.slider::-webkit-slider-thumb {
-webkit-appearance: none; /* Override default look */
appearance: none;
width: 20px; /* Set a specific slider handle width */
height: 20px; /* Slider handle height */
background: #c35;
cursor: pointer; /* Cursor on hover */
border-radius: 50%;
border: 2px solid #ddd;
}
.slider::-moz-range-thumb {
width: 20px; /* Set a specific slider handle width */
height: 20px; /* Slider handle height */
background: #c35;
cursor: pointer; /* Cursor on hover */
border-radius: 50%;
border: 2px solid #ddd;
}
/* slider control end */
/* width */
::-webkit-scrollbar {
width: 10px;
}
/* Track */
::-webkit-scrollbar-track {
background: #333;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #c35;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #d43d5f;
}
@media screen and (max-width: 600px){
.control-holder{
width: 50%;
}
.form label{
font-size: 15px;
}
.switcher-text{
font-size: 14px;
}
.info{
padding: 5px 0;
}
.info:after{
font-size: 16px;
}
.info.big{
font-size: 20px;
}
.info.medium{
font-size: 15px;
}
}
@media screen and (max-width: 360px){
body{
text-align: center;
}
.control-holder{
width: 100%;
}
}
@@ -467,6 +467,8 @@ void mqttSend() {
DPRINTLN(" "); DPRINTLN(" ");
} }
bool mqttIsConnected() { return mqtt.isConnected(); } //for /getCurrentInfos
#else #else
void mqttSend() {} void mqttSend() {}
#endif #endif
+7 -3
View File
@@ -3,8 +3,12 @@
Firmware for this clock, based on [ESP_UniClock](https://github.com/gpeter62/ESP_UniClock) by Firmware for this clock, based on [ESP_UniClock](https://github.com/gpeter62/ESP_UniClock) by
Peter Gautier (GPL-3.0-or-later), vendored from upstream commit `1189810` (2026-09-07). Peter Gautier (GPL-3.0-or-later), vendored from upstream commit `1189810` (2026-09-07).
- `ESP32_UniClock2/`: the upstream sketch folder (all `.ino`/`.h` files and the web UI in `data/`). - `ESP32_UniClock2/`: the upstream sketch folder (all `.ino`/`.h` files; `data/` is the SPIFFS
It keeps the upstream layout, so it still opens in the Arduino IDE. content). It keeps the upstream layout, so it still opens in the Arduino IDE.
- `web/index.html`: the web UI (replaces the upstream jQuery page), one file with its CSS and JS.
`web/gzip_web.py` gzips it to `data/index.html.gz`; PlatformIO runs it before every build, in the
Arduino IDE run `python web/gzip_web.py` before uploading the data folder. Opened straight from
disk, the page runs on sample data, so layout changes can be checked without the clock.
- `lib/`: the library versions bundled upstream (`libraries/*.zip`), only those the ESP8266 build - `lib/`: the library versions bundled upstream (`libraries/*.zip`), only those the ESP8266 build
needs. The upstream manuals, datasheets, photos and ESP32-only libraries were left out. needs. The upstream manuals, datasheets, photos and ESP32-only libraries were left out.
Exception: `arduino-home-assistant` is v2.1.0 (upstream bundles 1.3.0, which has no light, Exception: `arduino-home-assistant` is v2.1.0 (upstream bundles 1.3.0, which has no light,
@@ -18,7 +22,7 @@ Local changes are separate commits on top of the import (`git log -- firmware/un
```sh ```sh
pio run # build pio run # build
pio run -t upload # flash the firmware over COM7 pio run -t upload # flash the firmware over COM7
pio run -t uploadfs # flash the web UI (data/) to SPIFFS pio run -t uploadfs # flash the web UI (data/) to SPIFFS; over WiFi: -e nixie_in12_ota
pio device monitor # serial log, 115200 Bd pio device monitor # serial log, 115200 Bd
``` ```
+2
View File
@@ -19,6 +19,8 @@ board_build.flash_mode = dio
board_build.f_cpu = 80000000L board_build.f_cpu = 80000000L
; evaluate #ifdefs when resolving includes: the sketch includes ESP32-only libraries inside #if ; evaluate #ifdefs when resolving includes: the sketch includes ESP32-only libraries inside #if
lib_ldf_mode = chain+ lib_ldf_mode = chain+
; the web UI source is web/index.html; this writes data/index.html.gz for uploadfs
extra_scripts = pre:web/gzip_web.py
; CH340C adapter on COM7 without auto-reset: put the clock in flash mode by hand ; CH340C adapter on COM7 without auto-reset: put the clock in flash mode by hand
; (hold GPIO0 to GND, tap RST, release GPIO0) before every upload/uploadfs. ; (hold GPIO0 to GND, tap RST, release GPIO0) before every upload/uploadfs.
upload_port = COM7 upload_port = COM7
+23
View File
@@ -0,0 +1,23 @@
# Gzips web/index.html into the SPIFFS data folder (ESP32_UniClock2/data/index.html.gz).
# Runs before every PlatformIO build/uploadfs (extra_scripts in platformio.ini); also runs on its own:
# python web/gzip_web.py
# The web server sends the .gz file with Content-Encoding: gzip (serveStatic in ESP32_UniClock2.ino).
import gzip
import os
try:
Import("env") # noqa: F821 (PlatformIO/SCons)
root = env["PROJECT_DIR"] # noqa: F821
except NameError:
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
src = os.path.join(root, "web", "index.html")
dst = os.path.join(root, "ESP32_UniClock2", "data", "index.html.gz")
with open(src, "rb") as f:
packed = gzip.compress(f.read(), 9, mtime=0) # mtime=0: same input, same bytes (no git noise)
old = open(dst, "rb").read() if os.path.exists(dst) else b""
if packed != old:
with open(dst, "wb") as f:
f.write(packed)
print("gzip_web: %s (%d bytes)" % (dst, len(packed)))
+646
View File
@@ -0,0 +1,646 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#0e0c0b">
<title>Nixie Clock</title>
<link rel="icon" href="favicon.ico">
<!-- Web UI for ESP_UniClock on the RetroModding NixieIN12v2 clock. Source file: firmware/uniclock/web/.
The build gzips it to data/index.html.gz (gzip_web.py). Opened from disk or localhost it runs on
sample data and only logs what it would save. -->
<style>
:root{--bg:#0e0c0b;--card:#181514;--card2:#221e1b;--line:#2e2825;--text:#ece5de;--muted:#978d85;
--glow:#ff8a3d;--glow2:#ffb47a;--dim:rgba(255,138,61,.15);--ok:#4cc38a;--warn:#f2b84b;--bad:#ef5b5b}
*{box-sizing:border-box}
html{background:var(--bg);color:var(--text);font:15px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;-webkit-text-size-adjust:100%}
body{margin:0;min-height:100vh;background:radial-gradient(900px 420px at 50% -180px,#2b1a0e 0,transparent 70%)}
[hidden]{display:none!important}
.wrap{max-width:760px;margin:0 auto;padding:0 14px}
.muted{color:var(--muted)}
header.wrap{padding:24px 14px 12px;text-align:center}
.tubes{display:inline-flex;gap:8px;align-items:center;transition:opacity .3s}
.tubes.dark{opacity:.35}
.tube{width:54px;height:84px;border-radius:26px 26px 10px 10px;background:linear-gradient(#1f1a17,#110e0c);
border:1px solid #3b312b;box-shadow:inset 0 0 18px rgba(255,140,60,.07);display:flex;align-items:center;
justify-content:center;font:200 60px/1 "Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif;color:var(--glow2);
text-shadow:0 0 5px var(--glow),0 0 16px rgba(255,120,40,.75),0 0 34px rgba(255,100,20,.45)}
.tube.off{color:transparent;text-shadow:none}
.neon{display:flex;flex-direction:column;gap:18px}
.neon i{width:9px;height:9px;border-radius:50%;background:#ff7a2e;box-shadow:0 0 6px #ff7a2e,0 0 14px rgba(255,110,40,.8)}
.neon.off i{background:#3a2a20;box-shadow:none}
.secs{font-size:15px;color:var(--muted);align-self:flex-end;font-variant-numeric:tabular-nums;width:22px}
.date{margin-top:10px;color:var(--muted)}
.name{font-weight:600;margin-top:2px}
.chips{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;margin-top:12px;min-height:24px}
.chip{font-size:12.5px;padding:3px 10px;border-radius:99px;background:var(--card2);border:1px solid var(--line);color:var(--muted)}
.chip::before{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;background:currentColor;margin-right:6px;vertical-align:1px}
.chip.ok{color:var(--ok)}.chip.warn{color:var(--warn)}.chip.bad{color:var(--bad)}
nav{position:sticky;top:0;z-index:5;background:rgba(14,12,11,.93);backdrop-filter:blur(6px);border-bottom:1px solid var(--line)}
nav .wrap{display:flex;overflow-x:auto}
nav button{flex:1 0 auto;background:none;border:0;border-bottom:2px solid transparent;color:var(--muted);font:inherit;font-weight:600;padding:12px 10px;cursor:pointer}
nav button:hover{color:var(--text)}
nav button[aria-selected=true]{color:var(--glow);border-color:var(--glow)}
main{padding:16px 0 30px}
main>section{display:none}main>section.on{display:block}
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;margin-bottom:14px;overflow:hidden}
.card h2{margin:0;padding:13px 16px 5px;font-size:12.5px;text-transform:uppercase;letter-spacing:.08em;color:var(--glow)}
.row{display:flex;align-items:center;gap:14px;padding:11px 16px;border-top:1px solid var(--line)}
.row.first{border-top:0}
.lbl{flex:1;min-width:0}
.lbl label,.lbl b{display:block;font-weight:500}
.lbl small{display:block;color:var(--muted);font-size:12.5px;margin-top:1px}
.ctl{flex:0 0 auto;display:flex;align-items:center;gap:10px;justify-content:flex-end}
.ctl.wide{flex:0 1 320px;width:320px}
.val{font-variant-numeric:tabular-nums;color:var(--text);text-align:right}
output{min-width:86px;white-space:nowrap;text-align:right;font-variant-numeric:tabular-nums;color:var(--glow2)}
.sw{appearance:none;-webkit-appearance:none;width:46px;height:26px;border-radius:99px;background:#3d3531;position:relative;cursor:pointer;transition:background .2s;margin:0;flex:none}
.sw::after{content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:#d2c9c2;transition:left .2s}
.sw:checked{background:var(--glow)}.sw:checked::after{left:23px;background:#fff}
input[type=range]{-webkit-appearance:none;appearance:none;width:100%;height:6px;border-radius:9px;margin:0;cursor:pointer;
background:linear-gradient(90deg,var(--glow) var(--p,0%),#3d3531 var(--p,0%))}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:20px;height:20px;border-radius:50%;background:var(--glow);border:3px solid #fff1e6}
input[type=range]::-moz-range-thumb{width:15px;height:15px;border-radius:50%;background:var(--glow);border:3px solid #fff1e6}
input[type=range].hue::-webkit-slider-thumb{background:transparent;border-color:#fff;box-shadow:0 0 0 1px #000}
input[type=range].hue::-moz-range-thumb{background:transparent;border-color:#fff}
.swatch{width:26px;height:26px;border-radius:50%;flex:none;border:2px solid #fff3;box-shadow:0 0 12px currentColor}
select,input[type=text],input[type=password],input[type=time],input[type=number]{width:100%;background:var(--card2);color:var(--text);
border:1px solid var(--line);border-radius:8px;padding:8px 10px;font:inherit;outline:0;color-scheme:dark}
select:focus,input:focus-visible{border-color:var(--glow)}
input[type=time]{width:auto}
input.num{width:64px;text-align:center}
.pw{position:relative;width:100%}.pw input{padding-right:58px}
.pw button{position:absolute;right:4px;top:4px;bottom:4px;background:none;border:0;color:var(--muted);font:inherit;font-size:12.5px;cursor:pointer}
.seg{display:inline-flex;border:1px solid var(--line);border-radius:9px;overflow:hidden}
.seg button{background:var(--card2);border:0;color:var(--muted);padding:7px 13px;font:inherit;cursor:pointer}
.seg button+button{border-left:1px solid var(--line)}
.seg button.on{background:var(--dim);color:var(--glow)}
.btn{background:var(--card2);border:1px solid var(--line);color:var(--text);padding:8px 16px;border-radius:9px;font:inherit;font-weight:600;cursor:pointer;white-space:nowrap}
.btn:hover{border-color:var(--muted)}
.btn.pri{background:var(--glow);border-color:var(--glow);color:#1c0e04}
.btn.danger{color:var(--bad);border-color:rgba(239,91,91,.45)}
.btn.sm{padding:5px 10px;font-size:13px}
.acts{display:flex;gap:10px;align-items:center;justify-content:flex-end;padding:11px 16px;border-top:1px solid var(--line);background:var(--card2)}
.acts span{margin-right:auto;color:var(--warn);font-size:13px}
.details{padding:12px 16px;font:12.5px/1.6 ui-monospace,Consolas,monospace;color:var(--muted);border-top:1px solid var(--line);overflow-x:auto}
.details br:first-child,.details br:first-child+br{display:none}
#msg{padding:40px 0;text-align:center;color:var(--muted)}
#toast{position:fixed;left:50%;bottom:22px;transform:translate(-50%,20px);opacity:0;transition:.25s;pointer-events:none;z-index:20;
background:#2a2421;border:1px solid var(--line);padding:9px 16px;border-radius:9px;box-shadow:0 6px 24px #0008}
#toast.on{opacity:1;transform:translate(-50%,0)}#toast.err{border-color:var(--bad);color:#ffc9c9}
#overlay{position:fixed;inset:0;background:#0e0c0bee;z-index:30;display:flex;align-items:center;justify-content:center;text-align:center;padding:20px}
#overlay div{max-width:420px}#overlay b{display:block;font-size:20px;margin-bottom:8px;color:var(--glow)}
footer{text-align:center;color:var(--muted);font-size:12.5px;padding:0 0 30px}
footer a{color:var(--muted)}
@media (max-width:560px){
.row{flex-wrap:wrap}.ctl.wide{flex:1 1 100%;width:100%}
.tube{width:42px;height:68px;font-size:46px;border-radius:20px 20px 8px 8px}.tubes{gap:6px}.neon{gap:14px}
}
</style>
</head>
<body>
<header class="wrap">
<div id="tubes" class="tubes"></div>
<div id="date" class="date">&nbsp;</div>
<div id="name" class="name"></div>
<div id="chips" class="chips"></div>
</header>
<nav><div class="wrap" id="tabs" role="tablist"></div></nav>
<main class="wrap" id="main"><div id="msg">Loading…</div></main>
<footer class="wrap">
© 2020-22 Peter Gautier · <a href="https://github.com/gpeter62/ESP_UniClock" target="_blank">ESP_UniClock</a><br>
Modified by Claude for the RetroModding NixieIN12v2 clock · <a href="https://mangavalk.com/mangavalk/nixie-clock" target="_blank">mangavalk.com/mangavalk/nixie-clock</a>
</footer>
<div id="toast"></div>
<div id="overlay" hidden><div><b id="ovT"></b><span id="ovM" class="muted"></span></div></div>
<script>
"use strict";
const TEST = location.protocol == "file:" || /^(localhost|127\.0\.0\.1)$/.test(location.hostname);
const $ = s => document.querySelector(s);
const pad = n => String(n).padStart(2, "0");
let cfg = {}, online = true;
// Sample data for TEST mode, in the format /getConfiguration and /getCurrentInfos send.
const SAMPLE = {
version: "IN-12 Nixie Clock", FW: "fw90", tubeDriver: "NIXIE595_MULTIPLEX", maxDigits: 4, maxBrightness: 100,
currentDate: "2026.10.28", currentTime: "21:47", currentSec: 12, ip: "10.1.1.97",
temperature: 255, temperature2: 255, humidity: 255, humidity2: 255, pressure: 255, lux: 41, rssi: -58,
uptime: 93780, heap: 21456, mqtt: 2, wledLive: false, hasAlarm: false, hasRadar: false,
utc_offset: 1, enableDST: true, set12_24: true, showZero: true, enableBlink: true, enableDoubleBlink: false, interval: 15,
enableAutoShutoff: true, dayTime: "07:00", nightTime: "22:30", dayBright: 72, nightBright: 10, manualOverride: false,
animMode: 6, alarmEnable: false, alarmTime: "06:30", alarmPeriod: 15, enableRadar: false, radarTimeout: 5,
rgbEffect: 1, rgbBrightness: 120, rgbFixColor: 30, rgbSpeed: 50, rgbDir: false, rgbMinBrightness: 8,
wledEnable: true, wledDarkWithTubes: true, wledUseBrightness: true,
wifiMode: true, wifiSsid: "dlink-iot", wifiPsw: "", wifiPswSet: true, ApSsid: "UNICLOCK", ApPsw: "", ApPswSet: false,
NtpServer: "pool.ntp.org", firmware: "", mqttBrokerAddr: "10.1.1.175", mqttBrokerUser: "mqtt", mqttBrokerPsw: "",
mqttBrokerPswSet: true, mqttEnable: true, mqttBrokerRefresh: 30, dateMode: 0, dateRepeatMin: 3, tempRepeatMin: 1,
tempCF: false, enableTimeDisplay: true, dateStart: 45, dateEnd: 50, tempStart: 35, tempEnd: 40, humidStart: 40,
humidEnd: 45, enableAutoDim: true, corrT0: 0, corrT1: 0, corrH0: 0, corrH1: 0, cathProtMin: 5
};
const SAMPLE_DETAILS = "<br><br><strong>FirmwareID:fw90<br> Tube driver:NIXIE595_MULTIPLEX<br> Mac:30:83:98:99:BF:DE</strong><br>MAXBRIGHTNESS:100<br>Used pins: 12 NEOPIXEL_PIN, 13 SPI MOSI, 14 SPI SCK, 15 PIN_LATCH, A0 LIGHT_SENSOR_PIN<br>";
// ---------- talking to the clock ----------
function timeout(ms) { const c = new AbortController(); setTimeout(() => c.abort(), ms); return c.signal; }
async function getJSON(url) {
if (TEST) {
const t = new Date();
return url == "/getConfiguration" ? { ...SAMPLE } : { currentDate: SAMPLE.currentDate, currentTime: pad(t.getHours()) + ":" +
pad(t.getMinutes()), currentSec: t.getSeconds(), lux: 30 + (t.getSeconds() % 20), rssi: -58, uptime: SAMPLE.uptime += 5,
heap: 21456, mqtt: 2, wledLive: false };
}
const r = await fetch(url, { signal: timeout(6000), cache: "no-store" });
if (!r.ok) throw Error("HTTP " + r.status);
return r.json();
}
let queue = Promise.resolve(); // one request at a time: the ESP8266 writes its EEPROM on every setting
function post(url, data) {
const p = queue.then(() => TEST ? (console.log("POST", url, data || ""), { ok: true, status: 200 })
: fetch(url, { method: "POST", body: new URLSearchParams(data || {}), signal: timeout(8000) }));
queue = p.catch(() => {});
return p;
}
// dayTime/nightTime/alarmTime are stored as two settings each
const expand = (k, v) => /Time$/.test(k) ? [[k + "Hours", +v.split(":")[0]], [k + "Minutes", +v.split(":")[1]]] : [[k, v]];
async function saveAll(pairs) {
try {
for (const [k, v] of pairs) {
const r = await post("/saveSetting", { key: k, value: String(v) });
if (!r.ok) throw Error(r.status == 404 ? "the clock doesn't know '" + k + "'" : "HTTP " + r.status);
}
toast("Saved");
return true;
} catch (e) {
toast("Not saved: " + (e.name == "AbortError" ? "no answer from the clock" : e.message), true);
return false;
}
}
// ---------- formatting ----------
const val = x => typeof x == "function" ? x() : x;
const has = k => cfg[k] !== undefined && cfg[k] != 255;
const hasTemp = () => has("temperature") || has("temperature2");
const opts = o => val(o).map((x, i) => Array.isArray(x) ? x : [i, x]);
const fmtB = v => v == 0 ? "off" : cfg.maxBrightness == 100 ? v + "%" : v + " / " + cfg.maxBrightness;
const fmtPct = v => Math.round(v * 100 / 255) + "%";
const fmtMin = (v, zero) => v == 0 ? zero : "every " + v + " min";
const fmtT = v => cfg.tempCF ? (v * 1.8 + 32).toFixed(1) + " °F" : (+v).toFixed(1) + " °C";
function fmtUp(s) {
const d = Math.floor(s / 86400), h = Math.floor(s / 3600) % 24, m = Math.floor(s / 60) % 60;
return d ? d + " d " + h + " h" : h ? h + " h " + m + " min" : m + " min";
}
function fmtDate(t) {
const d = pad(t.getDate()), m = pad(t.getMonth() + 1), y = t.getFullYear();
const s = cfg.dateMode == 1 ? m + "/" + d + "/" + y : cfg.dateMode == 2 ? y + "/" + m + "/" + d : d + "/" + m + "/" + y;
return t.toLocaleDateString("en", { weekday: "long" }) + " " + s;
}
// Same colour wheel as WheelRaw() in z_neopixel.ino; 192 is white
function wheel(p) {
if (p == 192) return "rgb(255,255,255)";
p = 255 - p;
const c = p < 85 ? [255 - p * 3, 0, p * 3] : p < 170 ? [0, (p - 85) * 3, 255 - (p - 85) * 3] : [(p - 170) * 3, 255 - (p - 170) * 3, 0];
return "rgb(" + c + ")";
}
const HUE_BG = "linear-gradient(90deg," + Array.from({ length: 18 }, (_, i) => wheel(Math.min(255, i * 15) == 192 ? 191 : Math.min(255, i * 15))) + ")";
// ---------- what is on the page ----------
// Row types: sw (switch), range, hue, select, seg (segmented buttons), time, text, pass, pair (two 0..59
// fields), info (read-only), btn, html. k = setting key, l = label, h = help (text or function),
// show = only shown when it returns true, inv = switch shows the inverse of the setting.
const ANIM = ["Off", "Count up", "Count down", "Shift right", "Shift left", "Transition", "Random (1–5)", "Random (1–4)"];
const FX = ["Off", "Fixed colour", "Rainbow flow", "Rainbow stepper", "Colour dimmer", "Colour changer", "Colour flow",
"Colour flow, random", "Colour flow, random per tube", "Random per tube", "Knight Rider"];
const ZONES = Array.from({ length: 27 }, (_, i) => [i - 12, "UTC" + (i < 12 ? "−" : "+") + pad(Math.abs(i - 12)) + ":00"]);
const hasRGB = () => cfg.rgbEffect != 255;
const fxOn = () => cfg.rgbEffect > 0;
const fxAnim = () => cfg.rgbEffect > 1;
const R = {
tubes: { t: "sw", k: "manualOverride", inv: 1, l: "Tubes", h: "Switch the display on or off" },
autoDim: { t: "sw", k: "enableAutoDim", l: "Auto dim", h: () => has("lux") ? "Follows the light sensor, now " + cfg.lux + " lux" : "Follows the light sensor" },
dayBright: { t: "range", k: "dayBright", l: "Day brightness", min: 1, max: () => cfg.maxBrightness, f: fmtB },
effect: { t: "select", k: "rgbEffect", l: "Backlight", o: FX },
colour: { t: "hue", k: "rgbFixColor", l: "Colour", show: () => cfg.rgbEffect == 1 },
rgbBright: { t: "range", k: "rgbBrightness", l: "Backlight brightness", min: () => cfg.rgbMinBrightness || 0, max: 255, f: fmtPct, show: fxOn },
cathode: { t: "btn", l: "Cathode protection", h: () => "Cycles every digit for " + cfg.cathProtMin + " min to keep the tubes healthy", b: "Run now", a: runCathode }
};
const PAGES = [
{ id: "home", l: "Home", cards: [
{ l: "Quick controls", rows: [R.tubes, R.autoDim, R.dayBright, { ...R.effect, show: hasRGB }, R.colour, R.rgbBright] },
{ l: "Sensors", show: () => hasTemp() || has("humidity") || has("pressure"), rows: [
{ t: "info", k: "temperature", l: "Temperature", f: fmtT, show: () => has("temperature") },
{ t: "info", k: "temperature2", l: "Temperature 2", f: fmtT, show: () => has("temperature2") },
{ t: "info", k: "humidity", l: "Humidity", f: v => (+v).toFixed(1) + " %", show: () => has("humidity") },
{ t: "info", k: "humidity2", l: "Humidity 2", f: v => (+v).toFixed(1) + " %", show: () => has("humidity2") },
{ t: "info", k: "pressure", l: "Pressure", f: v => (+v).toFixed(1) + " hPa", show: () => has("pressure") }] },
{ l: "Maintenance", rows: [R.cathode] }
] },
{ id: "tubes", l: "Tubes", cards: [
{ l: "Time", rows: [
{ t: "seg", k: "set12_24", l: "Clock", o: [[false, "12 h"], [true, "24 h"]] },
{ t: "sw", k: "showZero", l: "Leading zero", h: "Show 07:30 instead of 7:30" },
{ t: "sw", k: "enableBlink", l: "Blinking dots", h: "Off: the dots stay lit" },
{ t: "sw", k: "enableDoubleBlink", l: "Double blink", h: "For clocks with separately wired dots", show: () => cfg.enableBlink },
{ t: "select", k: "animMode", l: "Digit animation", h: "When the minute changes", o: ANIM }] },
{ l: "Time zone", rows: [
{ t: "select", k: "utc_offset", l: "Time zone", h: "Offset in winter", o: ZONES },
{ t: "sw", k: "enableDST", l: "Summer time", h: "EU rules: last Sunday of March to last Sunday of October" },
{ t: "text", k: "NtpServer", l: "Time server", h: "NTP server name", max: 29 }] },
{ l: "Date", rows: [
{ t: "sw", k: "enableTimeDisplay", l: "Show time and date", h: "Off: the clock only shows sensor values", show: hasTemp },
{ t: "range", k: "dateRepeatMin", l: "Show the date", min: 0, max: 10, f: v => fmtMin(v, "never") },
{ t: "pair", k: "dateStart", k2: "dateEnd", l: "During seconds", h: "From – to, within that minute", show: () => cfg.dateRepeatMin > 0 },
{ t: "seg", k: "dateMode", l: "Format", o: ["dd/mm/yy", "mm/dd/yy", "yy/mm/dd"] }] },
{ l: "Temperature and humidity", show: hasTemp, rows: [
{ t: "seg", k: "tempCF", l: "Unit", o: [[false, "°C"], [true, "°F"]] },
{ t: "range", k: "tempRepeatMin", l: "Show the values", min: 0, max: 10, f: v => fmtMin(v, "never") },
{ t: "pair", k: "tempStart", k2: "tempEnd", l: "Temperature during seconds", show: () => cfg.tempRepeatMin > 0 },
{ t: "pair", k: "humidStart", k2: "humidEnd", l: "Humidity during seconds", show: () => cfg.tempRepeatMin > 0 && has("humidity") }] },
{ l: "Cathode protection", rows: [
{ t: "range", k: "interval", l: "Automatic", h: "Short run of all digits", min: 0, max: 60, f: v => fmtMin(v, "off") },
{ t: "range", k: "cathProtMin", l: "Manual run length", min: 1, max: 60, f: v => v + " min" },
{ ...R.cathode, l: "Manual run", h: "Full brightness, every digit" }] },
{ l: "Alarm", show: () => cfg.hasAlarm, rows: [
{ t: "sw", k: "alarmEnable", l: "Alarm" },
{ t: "time", k: "alarmTime", l: "Time" },
{ t: "range", k: "alarmPeriod", l: "Rings for", min: 1, max: 240, f: v => v + " s" }] },
{ l: "Presence sensor", show: () => cfg.hasRadar, rows: [
{ t: "sw", k: "enableRadar", l: "Switch the tubes off when nobody is there" },
{ t: "range", k: "radarTimeout", l: "After", min: 1, max: 60, f: v => v + " min" }] }
] },
{ id: "light", l: "Light", cards: [
{ l: "Tube brightness", rows: [R.autoDim, R.dayBright,
{ t: "sw", k: "enableAutoShutoff", l: "Night mode", h: "Night brightness between the times below" },
{ t: "range", k: "nightBright", l: "Night brightness", min: 0, max: () => cfg.maxBrightness, f: fmtB, show: () => cfg.enableAutoShutoff },
{ t: "time", k: "nightTime", l: "Night starts", show: () => cfg.enableAutoShutoff },
{ t: "time", k: "dayTime", l: "Day starts", show: () => cfg.enableAutoShutoff }] },
{ l: "Backlight", show: hasRGB, rows: [R.effect, R.colour, R.rgbBright,
{ t: "range", k: "rgbSpeed", l: "Speed", min: 1, max: 255, show: fxAnim },
{ t: "seg", k: "rgbDir", l: "Direction", o: [[false, "Left"], [true, "Right"]], show: fxAnim }] },
{ l: "SignalRGB", show: () => cfg.wledEnable !== undefined, rows: [
{ t: "sw", k: "wledEnable", l: "SignalRGB control", h: "The clock shows up in SignalRGB as a WLED device" },
{ t: "sw", k: "wledDarkWithTubes", l: "Off with the tubes", h: "LEDs stay dark while the tubes are off" },
{ t: "sw", k: "wledUseBrightness", l: "Use backlight brightness", h: "Off: colours exactly as SignalRGB sends them" },
{ t: "info", k: "wledLive", l: "Receiving colours", f: v => v ? "yes" : "no" }] }
] },
{ id: "network", l: "Network", cards: [
{ l: "WiFi", save: 1, restart: "Restart now to use the new WiFi settings?", rows: [
{ t: "seg", k: "wifiMode", l: "Mode", o: [[true, "Join network"], [false, "Access point"]] },
{ t: "text", k: "wifiSsid", l: "Network name", max: 19 },
{ t: "pass", k: "wifiPsw", l: "Password", max: 19 },
{ t: "text", k: "ApSsid", l: "Access point name", h: "Used when there is no network", max: 19 },
{ t: "pass", k: "ApPsw", l: "Access point password", h: "At least 8 characters", max: 19 }] },
{ l: "MQTT / Home Assistant", save: 1, restart: "Restart now? The clock reads the MQTT settings at startup.",
show: () => cfg.mqttBrokerRefresh != 0, rows: [
{ t: "sw", k: "mqttEnable", l: "MQTT" },
{ t: "text", k: "mqttBrokerAddr", l: "Broker address", max: 29 },
{ t: "text", k: "mqttBrokerUser", l: "User", max: 19 },
{ t: "pass", k: "mqttBrokerPsw", l: "Password", max: 19 },
{ t: "range", k: "mqttBrokerRefresh", l: "Sensor updates", min: 10, max: 100, f: v => "every " + v + " s" }] }
] },
{ id: "system", l: "System", cards: [
{ l: "Status", rows: [
{ t: "info", k: "version", l: "Clock" },
{ t: "info", k: "FW", l: "Firmware", f: v => v + " · " + cfg.tubeDriver },
{ t: "info", k: "ip", l: "IP address" },
{ t: "info", k: "rssi", l: "WiFi signal", f: v => v + " dBm" },
{ t: "info", k: "uptime", l: "Uptime", f: fmtUp },
{ t: "info", k: "heap", l: "Free memory", f: v => (v / 1024).toFixed(1) + " KB" },
{ t: "info", k: "stalls", l: "Loop stalls", show: () => cfg.stalls !== undefined },
{ t: "html", id: "details" }] },
{ l: "Sensor calibration", show: () => hasTemp() || has("humidity"), rows: [
{ t: "range", k: "corrT0", l: "Temperature", min: -5, max: 5, step: .1, f: v => (v > 0 ? "+" : "") + v + " °C", show: () => has("temperature") },
{ t: "range", k: "corrT1", l: "Temperature 2", min: -5, max: 5, step: .1, f: v => (v > 0 ? "+" : "") + v + " °C", show: () => has("temperature2") },
{ t: "range", k: "corrH0", l: "Humidity", min: -25, max: 25, step: .1, f: v => (v > 0 ? "+" : "") + v + " %", show: () => has("humidity") },
{ t: "range", k: "corrH1", l: "Humidity 2", min: -25, max: 25, step: .1, f: v => (v > 0 ? "+" : "") + v + " %", show: () => has("humidity2") }] },
{ l: "Update over HTTP", rows: [
{ t: "text", k: "firmware", l: "Firmware URL", h: "Normal updates use ArduinoOTA", max: 77 },
{ t: "btn", l: "Download and install", h: "From the URL above", b: "Update", a: firmwareUpdate, show: () => !!cfg.firmware }] },
{ l: "Restart and reset", rows: [
{ t: "btn", l: "Restart", h: "Settings are kept", b: "Restart", a: () => confirm("Restart the clock?") && restart() },
{ t: "btn", l: "Factory reset", h: "Erases all settings, WiFi included", b: "Factory reset", cls: "danger", a: factoryReset }] }
] }
];
// ---------- building the page ----------
const binds = [], rows = [], cards = [];
let uid = 0;
function h(tag, props, ...kids) {
const e = document.createElement(tag);
for (const k in props || {}) {
const v = props[k];
if (k == "class") e.className = v; else if (k in e) e[k] = v; else e.setAttribute(k, v);
}
for (const c of kids.flat()) if (c != null && c !== false) e.append(c);
return e;
}
const cast = (k, s) => typeof cfg[k] == "boolean" ? s == "true" : typeof cfg[k] == "number" ? +s : s;
const bind = (r, k, set, node, live) => binds.push({ r, k, set, node, live });
function makeRow(d, card) {
const r = { d, card }, id = "c" + ++uid;
if (d.t == "html") { r.el = h("div", { class: "details", id: d.id }); rows.push(r); return r.el; }
r.help = h("small");
const ctl = h("div", { class: "ctl" });
const lbl = ["info", "btn", "seg"].includes(d.t) ? h("b", {}, d.l) : h("label", { htmlFor: id }, d.l);
r.el = h("div", { class: "row" }, h("div", { class: "lbl" }, lbl, r.help), ctl);
const change = (k, v) => onChange(r, k, v);
switch (d.t) {
case "sw": {
const n = h("input", { type: "checkbox", class: "sw", id, onchange: () => change(d.k, d.inv ? !n.checked : n.checked) });
bind(r, d.k, v => n.checked = d.inv ? !v : !!v, n);
ctl.append(n);
break;
}
case "range": {
ctl.classList.add("wide");
const n = h("input", { type: "range", id, step: d.step || 1 }), o = h("output");
const upd = () => {
o.textContent = d.f ? d.f(+n.value) : n.value;
n.style.setProperty("--p", (n.value - n.min) / ((n.max - n.min) || 1) * 100 + "%");
};
n.oninput = upd;
n.onchange = () => change(d.k, +n.value);
bind(r, d.k, v => { n.min = val(d.min); n.max = val(d.max); n.value = v; upd(); }, n);
ctl.append(n, o);
break;
}
case "hue": {
ctl.classList.add("wide");
const n = h("input", { type: "range", id, min: 0, max: 255, class: "hue" }), s = h("span", { class: "swatch" });
n.style.background = HUE_BG;
const upd = () => { s.style.background = s.style.color = wheel(+n.value); };
n.oninput = upd;
n.onchange = () => change(d.k, +n.value);
const w = h("button", { type: "button", class: "btn sm", onclick: () => { n.value = 192; upd(); change(d.k, 192); } }, "White");
bind(r, d.k, v => { n.value = v; upd(); }, n);
ctl.append(n, s, w);
break;
}
case "select": {
ctl.classList.add("wide");
const n = h("select", { id, onchange: () => change(d.k, cast(d.k, n.value)) }, opts(d.o).map(([v, t]) => h("option", { value: v }, t)));
bind(r, d.k, v => n.value = String(v), n);
ctl.append(n);
break;
}
case "seg": {
const o = opts(d.o), g = h("div", { class: "seg", role: "group" });
const sel = v => [...g.children].forEach((b, i) => b.classList.toggle("on", String(o[i][0]) == String(v)));
o.forEach(([v, t]) => g.append(h("button", { type: "button", onclick: () => { sel(v); change(d.k, cast(d.k, String(v))); } }, t)));
bind(r, d.k, sel, null);
ctl.append(g);
break;
}
case "time": {
const n = h("input", { type: "time", id, onchange: () => n.value && change(d.k, n.value) });
bind(r, d.k, v => n.value = v ? v.split(":").map(x => pad(+x)).join(":") : "", n);
ctl.append(n);
break;
}
case "text": case "pass": {
ctl.classList.add("wide");
const n = h("input", { type: d.t == "pass" ? "password" : "text", id, maxLength: d.max || 64, autocomplete: "off", spellcheck: false });
n.onchange = () => change(d.k, n.value);
if (card.save) n.oninput = n.onchange;
bind(r, d.k, v => {
n.value = v == null ? "" : v;
if (d.t == "pass") n.placeholder = cfg[d.k + "Set"] ? "unchanged" : "not set";
}, n);
if (d.t == "pass") {
const eye = h("button", { type: "button", onclick: () => { n.type = n.type == "password" ? "text" : "password"; eye.textContent = n.type == "password" ? "show" : "hide"; } }, "show");
ctl.append(h("div", { class: "pw" }, n, eye));
} else ctl.append(n);
break;
}
case "pair": {
const num = (k, first) => {
const n = h("input", { type: "number", min: 0, max: 59, class: "num", id: first ? id : "" });
n.onchange = () => { const v = Math.max(0, Math.min(59, parseInt(n.value) || 0)); n.value = v; change(k, v); };
bind(r, k, v => n.value = v, n);
return n;
};
ctl.append(num(d.k, 1), h("span", { class: "muted" }, "–"), num(d.k2));
break;
}
case "info": {
const o = h("span", { class: "val" });
bind(r, d.k, v => o.textContent = v === undefined ? "–" : d.f ? d.f(v) : v, null, true);
ctl.append(o);
break;
}
case "btn":
ctl.append(h("button", { type: "button", class: "btn " + (d.cls || ""), onclick: d.a }, d.b));
break;
}
rows.push(r);
return r.el;
}
function build() {
const main = $("#main");
main.textContent = "";
for (const p of PAGES) {
const sec = h("section", { id: "p-" + p.id, role: "tabpanel" });
for (const c of p.cards) {
c.dirty = {};
c.el = h("div", { class: "card" }, h("h2", {}, c.l), c.rows.map(d => makeRow(d, c)));
if (c.save) {
c.bar = h("div", { class: "acts", hidden: true }, h("span", {}, "Unsaved changes"),
h("button", { type: "button", class: "btn", onclick: () => discard(c) }, "Discard"),
h("button", { type: "button", class: "btn pri", onclick: () => commit(c) }, "Save"));
c.el.append(c.bar);
}
cards.push(c);
sec.append(c.el);
}
main.append(sec);
$("#tabs").append(h("button", { type: "button", role: "tab", id: "t-" + p.id, onclick: () => { location.hash = p.id; } }, p.l));
}
window.onhashchange = showTab;
showTab();
}
function showTab() {
const id = PAGES.some(p => p.id == location.hash.slice(1)) ? location.hash.slice(1) : "home";
for (const p of PAGES) {
$("#p-" + p.id).classList.toggle("on", p.id == id);
$("#t-" + p.id).setAttribute("aria-selected", p.id == id);
}
if (id == "system") loadDetails();
}
// ---------- keeping the page and the clock in step ----------
function onChange(r, k, v) {
const c = r.card;
if (c.save) { c.dirty[k] = v; c.bar.hidden = false; return; }
const old = cfg[k];
cfg[k] = v;
applyKey(k);
saveAll(expand(k, v)).then(ok => { if (!ok) { cfg[k] = old; applyKey(k); } });
}
async function commit(c) {
const pairs = Object.entries(c.dirty).flatMap(([k, v]) => expand(k, v));
if (!pairs.length || !await saveAll(pairs)) return;
for (const [k, v] of Object.entries(c.dirty)) {
if (k + "Set" in cfg) { cfg[k + "Set"] = v !== ""; cfg[k] = ""; } else cfg[k] = v; //passwords are never sent back
}
discard(c);
if (c.restart && confirm(c.restart)) restart();
}
function discard(c) { c.dirty = {}; c.bar.hidden = true; applyAll(); }
function applyKey(k) { binds.forEach(b => b.k == k && b.set(cfg[b.k])); refresh(); }
function applyAll() {
for (const b of binds) {
if (b.k in b.r.card.dirty) continue;
if (b.node && b.node === document.activeElement && b.node.type != "checkbox" && b.node.type != "range") continue; //being typed in
b.set(cfg[b.k]);
}
refresh();
}
function applyLive() { binds.forEach(b => b.live && b.set(cfg[b.k])); refresh(); }
// Visibility, help texts that depend on values, header chips
function refresh() {
for (const r of rows) {
r.el.hidden = !!r.d.show && !r.d.show();
if (r.help) r.help.textContent = val(r.d.h) || "";
}
for (const c of cards) {
c.el.hidden = (c.show && !c.show()) || c.rows.every(d => d.show && !d.show());
let first = true; //no divider above the first visible row
for (const e of c.el.querySelectorAll(".row")) { e.classList.toggle("first", first && !e.hidden); if (!e.hidden) first = false; }
}
$("#name").textContent = cfg.version || "";
document.title = cfg.version || "Nixie Clock";
$("#tubes").classList.toggle("dark", !!cfg.manualOverride || !online);
const chips = [];
if (!online) chips.push(["bad", "Offline, retrying"]);
else {
if (cfg.rssi != null) chips.push([cfg.rssi > -67 ? "ok" : cfg.rssi > -78 ? "warn" : "bad", "WiFi " + cfg.rssi + " dBm"]);
if (cfg.mqtt != null) chips.push(cfg.mqtt == 2 ? ["ok", "MQTT connected"] : cfg.mqtt == 1 ? ["warn", "MQTT not connected"] : ["", "MQTT off"]);
if (cfg.wledEnable) chips.push(cfg.wledLive ? ["ok", "SignalRGB live"] : ["", "SignalRGB idle"]);
if (cfg.manualOverride) chips.push(["warn", "Tubes off"]);
}
$("#chips").replaceChildren(...chips.map(([c, t]) => h("span", { class: "chip " + c }, t)));
}
// ---------- the clock in the header ----------
let base = 0, baseAt = 0, tubeCount = 0;
function syncClock() {
const [y, mo, d] = String(cfg.currentDate).split(".").map(Number), [hh, mm] = String(cfg.currentTime).split(":").map(Number);
if (!y) return;
base = new Date(y, mo - 1, d, hh, mm, cfg.currentSec || 0).getTime();
baseAt = Date.now();
}
function buildTubes() {
tubeCount = cfg.maxDigits == 6 ? 6 : 4;
const el = $("#tubes");
el.textContent = "";
for (let i = 0; i < tubeCount; i++) {
if (i && i % 2 == 0) el.append(h("div", { class: "neon" }, h("i"), h("i")));
el.append(h("div", { class: "tube" }, "0"));
}
el.append(h("span", { class: "secs" }));
}
function tick() {
setTimeout(tick, 1000 - Date.now() % 1000 + 10);
if (!base) return;
if (tubeCount != (cfg.maxDigits == 6 ? 6 : 4)) buildTubes();
const t = new Date(base + Date.now() - baseAt);
let hr = t.getHours();
if (cfg.set12_24 === false) hr = hr % 12 || 12;
const s = (pad(hr) + pad(t.getMinutes()) + pad(t.getSeconds())).slice(0, tubeCount);
document.querySelectorAll(".tube").forEach((e, i) => {
e.textContent = s[i];
e.classList.toggle("off", i == 0 && s[0] == "0" && cfg.showZero === false);
});
document.querySelectorAll(".neon").forEach(e => e.classList.toggle("off", cfg.enableBlink !== false && t.getSeconds() % 2 == 1));
$(".secs").textContent = tubeCount == 4 && cfg.currentSec !== undefined ? pad(t.getSeconds()) : "";
$("#date").textContent = fmtDate(t);
}
// ---------- loading ----------
async function loadConfig(first) {
try {
Object.assign(cfg, await getJSON("/getConfiguration"));
if (first) build();
syncClock();
applyAll();
} catch (e) {
if (first) { $("#msg").textContent = "Can't reach the clock (" + e.message + "). Retrying…"; setTimeout(() => loadConfig(true), 3000); }
}
}
async function poll() {
try {
Object.assign(cfg, await getJSON("/getCurrentInfos"));
online = true;
syncClock();
} catch (e) { online = false; }
if (cards.length) applyLive();
setTimeout(poll, 5000);
}
let detailsLoaded = false;
async function loadDetails() {
if (detailsLoaded) return;
try {
const html = TEST ? SAMPLE_DETAILS : await (await fetch("/getClockDetails", { signal: timeout(6000) })).text();
$("#details").innerHTML = html;
detailsLoaded = true;
} catch (e) {}
}
// ---------- actions ----------
let toastTimer;
function toast(msg, err) {
const t = $("#toast");
t.textContent = msg;
t.className = "on" + (err ? " err" : "");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => t.className = "", err ? 5000 : 1800);
}
function overlay(title, msg) { $("#ovT").textContent = title; $("#ovM").textContent = msg; $("#overlay").hidden = false; }
// Waits until the clock answers again (after a restart), then reloads the page
function waitForClock(title, msg) {
overlay(title, msg);
if (TEST) { setTimeout(() => $("#overlay").hidden = true, 2500); return; }
const start = Date.now();
setTimeout(async function check() {
try { await getJSON("/getCurrentInfos"); location.reload(); }
catch (e) {
if (Date.now() - start > 60000) $("#ovM").textContent = msg + " It's taking long: if you changed the WiFi settings, the clock may be on another network now.";
setTimeout(check, 2000);
}
}, 5000);
}
async function restart() {
post("/reset").catch(() => {});
waitForClock("Restarting…", "The page reloads when the clock is back.");
}
async function factoryReset() {
if (!confirm("Factory reset: all settings are erased, WiFi included. The clock then starts its own access point and has to be set up again. Continue?")) return;
post("/factoryreset").catch(() => {});
overlay("Factory reset", "The clock restarts with default settings. Connect to its access point to set up WiFi again.");
}
async function firmwareUpdate() {
if (!confirm("Download and install the firmware from " + cfg.firmware + "?")) return;
try {
const r = await post("/firmwareupdate");
if (!r.ok) throw Error("HTTP " + r.status);
waitForClock("Updating firmware…", "Don't unplug the clock. It restarts when the update is done.");
} catch (e) { toast("Update not started: " + e.message, true); }
}
async function runCathode() {
try {
const r = await post("/cathodeProtect");
if (!r.ok) throw Error("HTTP " + r.status);
toast("Cathode protection runs for " + cfg.cathProtMin + " min");
} catch (e) { toast("Not started: " + (e.name == "AbortError" ? "no answer from the clock" : e.message), true); }
}
loadConfig(true).then(() => { poll(); tick(); });
setInterval(() => document.hidden || loadConfig(), 60000); //settings can also change from Home Assistant
document.addEventListener("visibilitychange", () => document.hidden || loadConfig());
</script>
</body>
</html>