From 92a60c3030477481b775f690fd930a32be480351 Mon Sep 17 00:00:00 2001 From: David Goodenough Date: Sat, 7 Oct 2023 14:31:13 -0700 Subject: [PATCH] Working on custom.html --- apps/travelwatch/app.js | 13 +++++---- apps/travelwatch/custom.html | 49 +++++++++++++++++++++++----------- apps/travelwatch/metadata.json | 2 +- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/apps/travelwatch/app.js b/apps/travelwatch/app.js index 30888994d8..b320b51366 100644 --- a/apps/travelwatch/app.js +++ b/apps/travelwatch/app.js @@ -27,11 +27,14 @@ const dows = "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]; -var zones = require("Storage").readJSON("timezones.json", 1) || -[ - { "name": "SFO", "offset": -480, "current_offset": 0, "next_change": 0, "is_dst": false, "dst_month": 3, "dst_date": 8, "dst_dow": 0, "dst_hour": 2, "std_month": 11, "std_date": 1, "std_dow": 0, "std_hour": 2 }, - { "name": "LON", "offset": 0, "current_offset": 0, "next_change": 0, "is_dst": false, "dst_month": 3, "dst_date": -7, "dst_dow": 0, "dst_hour": 1, "std_month": 10, "std_date": -7, "std_dow": 0, "std_hour": 2 }, -]; +var zones = require("Storage").readJSON("timezones.json", 1); +if (!zones || zones.length < 2) +{ + zones = [ + { "name": "SFO", "offset": -480, "current_offset": -28800000, "next_change": 0, "is_dst": false, "dst_month": 3, "dst_date": 8, "dst_dow": 0, "dst_hour": 2, "std_month": 11, "std_date": 1, "std_dow": 0, "std_hour": 2 }, + { "name": "LON", "offset": 0, "current_offset": 0, "next_change": 0, "is_dst": false, "dst_month": 3, "dst_date": -7, "dst_dow": 0, "dst_hour": 1, "std_month": 10, "std_date": -7, "std_dow": 0, "std_hour": 2 }, + ]; +} // We use GetDate() to get dates for rendering, since it takes care of both the various timezones in use, and automatic switching between // daylight and standard times. Rather than rely on the TZ offset stored in the watch, we start by removing that, and then applying our diff --git a/apps/travelwatch/custom.html b/apps/travelwatch/custom.html index 2115d58076..0f4ebbf7a9 100644 --- a/apps/travelwatch/custom.html +++ b/apps/travelwatch/custom.html @@ -52,7 +52,7 @@ { offsets = JSON.parse(stored); } - if (!offsets || offsets.length != 4) + if (!offsets || offsets.length != 5) { throw "Offsets invalid"; } @@ -60,26 +60,32 @@ catch(e) { offsets = [ - [true, "LON", "europe/london" ], - [true, "ZRC", "europe/berlin" ], - [false, "JER", "asia/jerusalem" ], - [false, "SYD", "australia/sydney" ], + [true, "SFO", 2 ], + [true, "LON", 8 ], + [true, "ZRC", 10 ], + [false, "JER", 13 ], + [false, "SYD", 15 ], ]; } console.log(offsets); var tbl = document.getElementById("travelwatch-offsets"); - for (var i = 0; i < 4; i++) + for (var i = 0; i < 5; i++) { var $offset = document.createElement('tr') var innerHTML = ` - ` for (var j = 0; j < timeZones.length; j++) { - innerHTML = innerHTML + ''; + innerHTML += '