File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -517,8 +517,8 @@ canvas.addEventListener("touchstart", (e) => {
517517
518518
519519function setupWebSocket ( ) {
520- // ws = new WebSocket("ws://" + location.hostname + "/ws");
521- ws = new WebSocket ( "ws://192.168.4.1/ws" ) ;
520+ ws = new WebSocket ( "ws://" + location . hostname + "/ws" ) ;
521+ // ws = new WebSocket("ws://192.168.4.1/ws");
522522
523523 ws . onmessage = ( event ) => {
524524 const data = JSON . parse ( event . data ) ;
Original file line number Diff line number Diff line change @@ -59,11 +59,27 @@ async function getMotivationalQuote() {
5959 const local = await fetch("/quote");
6060 if (local.ok) {
6161 const data = await local.json();
62- quoteText = data.content || fallbackQuotes[0].text;
63- quoteAuthor = data.author || fallbackQuotes[0].author;
64- return;
62+
63+ // case 1: single quote object
64+ if (data.content && data.author) {
65+ quoteText = data.content;
66+ quoteAuthor = data.author;
67+ return;
68+ }
69+
70+ // case 2: array of quote objects
71+ if (Array.isArray(data) && data.length > 0) {
72+ const random = data[Math.floor(Math.random() * data.length)];
73+ if (random.content && random.author) {
74+ quoteText = random.content;
75+ quoteAuthor = random.author;
76+ return;
77+ }
78+ }
6579 }
66- } catch (_) {}
80+ } catch (err) {
81+ console.warn("[Quote] Local ESP fetch failed:", err);
82+ }
6783
6884 // 3. else local code
6985 const fallback = fallbackQuotes[Math.floor(Math.random() * fallbackQuotes.length)];
You can’t perform that action at this time.
0 commit comments