From 970beadfb87df0c3ff92d7e73a2feb396360f5a0 Mon Sep 17 00:00:00 2001 From: zkayns <80561998+zkayns@users.noreply.github.com> Date: Tue, 23 Jan 2024 17:18:59 -0500 Subject: [PATCH 01/12] Update date-display.js --- new-tab/date-display.js | 44 +++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/new-tab/date-display.js b/new-tab/date-display.js index 91e14cf..90ffe92 100644 --- a/new-tab/date-display.js +++ b/new-tab/date-display.js @@ -1,12 +1,22 @@ -const DateStyles = { - DEFAULT: 1, - SWAP_MD: 2 -} - +const DateStyles = ["1", "2", "3"] +// DEFAULT, SWAP_MD, YMD class DateDisplay { constructor(element) { this.element = element this.dateStyle = this.getSavedStyle() + if (typeof this.dateStyle === 'string' || this.dateStyle instanceof String) { + // ok cool + } else { + if (this.dateStyle = DateStyles.DEFAULT) { + this.dateStyle = "1" + } + else if (this.dateStyle = DateStyles.SWAP_MD) { + this.dateStyle = "2" + } + else if (this.dateStyle = DateStyles.YMD) { + this.dateStyle = "3" + } + } this.render() this.startInterval() } @@ -25,24 +35,28 @@ class DateDisplay { year: date.getFullYear() } - if (this.dateStyle == 2) { + if (this.dateStyle == "1") { + this.element.textContent = [ + parts.day, parts.month, parts.year + ].join('/') + } + else if (this.dateStyle == "2") { this.element.textContent = [ parts.month, parts.day, parts.year ].join('/') - } else { + } + else if (this.dateStyle == "3") { this.element.textContent = [ - parts.day, parts.month, parts.year + parts.year, parts.month, parts.day ].join('/') } } onClickedDate() { - if (this.dateStyle === DateStyles.DEFAULT) { - this.dateStyle = DateStyles.SWAP_MD - } else { - this.dateStyle = DateStyles.DEFAULT - } // TODO: fix this middery - + this.dateStyle = parseInt(this.dateStyle)+1 + if (parseInt(this.dateStyle) > 3) { + this.dateStyle = 1 + } this.setSavedStyle(this.dateStyle) } @@ -51,7 +65,7 @@ class DateDisplay { } getSavedStyle() { - return Number(localStorage.dateStyle) || DateStyles.DEFAULT + return localStorage.dateStyle || "1" } } From e701c7038c7507631752baaf4f3961e72adc52a9 Mon Sep 17 00:00:00 2001 From: zkayns <80561998+zkayns@users.noreply.github.com> Date: Tue, 23 Jan 2024 17:40:00 -0500 Subject: [PATCH 02/12] Update main.html --- new-tab/main.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/new-tab/main.html b/new-tab/main.html index 4533722..e88bcc4 100644 --- a/new-tab/main.html +++ b/new-tab/main.html @@ -10,7 +10,7 @@