From 595d70975585f32e917c7a1a56a0201e28f14beb Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Wed, 15 May 2019 21:59:46 -0400 Subject: Implement basic clock face --- app/index.js | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'app') diff --git a/app/index.js b/app/index.js index c466b90..6c8d4cc 100644 --- a/app/index.js +++ b/app/index.js @@ -6,14 +6,13 @@ import * as messaging from "messaging"; import { preferences } from "user-settings"; import * as util from "./utils"; -const SETTINGS_TYPE = "cbor"; -const SETTINGS_FILE = "settings.cbor"; +// const SETTINGS_TYPE = "cbor"; +// const SETTINGS_FILE = "settings.cbor"; -let settings = loadSettings(); -applyTheme(settings.background, settings.foreground); +// let settings = loadSettings(); +// applyTheme(settings.background, settings.foreground); // TIME -let separator = document.getElementById("separator"); let hours1 = document.getElementById("hours1"); let hours2 = document.getElementById("hours2"); let mins1 = document.getElementById("mins1"); @@ -49,9 +48,6 @@ clock.ontick = evt => { // MINUTES let minute = ("0" + d.getMinutes()).slice(-2); setMins(minute); - - // BLINK SEPARATOR - setSeparator(d.getSeconds()); } // Apply theme colors to elements @@ -68,11 +64,6 @@ function applyTheme(background, foreground) { settings.foreground = foreground; } -// Blink time separator -function setSeparator(val) { - separator.style.display = (val % 2 === 0 ? "inline" : "none"); -} - function setHours(val) { if (val > 9) { drawDigit(Math.floor(val / 10), hours1); @@ -88,8 +79,8 @@ function setMins(val) { } function setDate(val) { - drawDigit(Math.floor(val / 10), date1); - drawDigit(Math.floor(val % 10), date2); + drawDateDigit(Math.floor(val / 10), date1); + drawDateDigit(Math.floor(val % 10), date2); } function setDay(val) { @@ -97,21 +88,25 @@ function setDay(val) { } function drawDigit(val, place) { - place.image = `${val}.png`; + place.image = `numerals/${val}.png`; +} + +function drawDateDigit(val, place) { + place.image = `dates/${val}.png` } function getDayImg(index) { let days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; - return `day_${days[index]}.png`; + return `dates/${days[index]}.png`; } // Listen for the onmessage event -messaging.peerSocket.onmessage = evt => { - applyTheme(evt.data.background, evt.data.foreground); -} +// messaging.peerSocket.onmessage = evt => { +// applyTheme(evt.data.background, evt.data.foreground); +// } // Register for the unload event -me.onunload = saveSettings; +// me.onunload = saveSettings; function loadSettings() { try { -- cgit v1.2.3