From 70419c8b26f74c2ed97394cb09c16186cef5c352 Mon Sep 17 00:00:00 2001 From: Kerry Shetline Date: Sat, 28 May 2022 22:02:04 -0400 Subject: [PATCH] New option to step one sidereal day at a time (instead of 24 hours at a time)... * New option to step one sidereal day at a time (instead of 24 hours at a time) during high-speed animation. * Auto-repeat on backward/forward event buttons. * Improved event messages. --- .eslintrc.json | 15 -- .vscode/settings.json | 3 +- CHANGELOG.md | 6 + messages.xlf | 135 ++++++++--------- package-lock.json | 18 +-- package.json | 6 +- .../advanced-options.component.html | 3 + .../advanced-options.component.ts | 1 + src/app/app.component.html | 8 +- src/app/app.component.ts | 63 +++++++- src/index.html | 4 +- src/locales/messages.cs.xlf | 136 +++++++++--------- src/locales/messages.de.xlf | 136 +++++++++--------- src/locales/messages.es.xlf | 136 +++++++++--------- src/locales/messages.fr.xlf | 136 +++++++++--------- src/math/math.ts | 1 + 16 files changed, 448 insertions(+), 359 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5cb1f11..df878cc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -138,10 +138,6 @@ "sourceType": "module" }, "rules": { - "@typescript-eslint/consistent-type-assertions": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/indent": "off", - "@typescript-eslint/no-unused-vars": "off", "indent": [ "error", 2, @@ -155,17 +151,6 @@ } ] } - }, - { - "files": ["*.es5.js"], - "env": { - "browser": true - }, - "rules": { - "no-eval": "off", - "no-template-curly-in-string": "off", - "no-var": "off" - } } ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 73e8e01..b02e5ec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,6 +25,7 @@ "recalibrated", "recalibrations", "Recents", + "stylelint", "subzone", "subzones", "tieredmenu", @@ -33,4 +34,4 @@ "tspan" ], "xliffSync.baseFile": "messages.xlf" -} +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f08b4f..513e84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.7.0 + +* New option to step one sidereal day at a time (instead of 24 hours at a time) during high-speed animation. +* Auto-repeat on backward/forward event buttons. +* Improved event messages. + ## 1.6.2 * Relaxed browser requirements, with WebGL capability no long required. diff --git a/messages.xlf b/messages.xlf index d0b1153..54a0cf7 100644 --- a/messages.xlf +++ b/messages.xlf @@ -30,88 +30,95 @@ 21 + + Fast animation uses sidereal days + + src/advanced-options/advanced-options.component.html + 24 + + Faster graphics / less shading src/advanced-options/advanced-options.component.html - 24 + 27 Sun/moon real position markers src/advanced-options/advanced-options.component.html - 27 + 30 Additional planet markers src/advanced-options/advanced-options.component.html - 30 + 33 Show info panel src/advanced-options/advanced-options.component.html - 32 + 35 Post-2018 colors src/advanced-options/advanced-options.component.ts - 29 + 30 Post-2018 colors, no map src/advanced-options/advanced-options.component.ts - 30 + 31 Pre-2018 colors src/advanced-options/advanced-options.component.ts - 31 + 32 Original 1410 look? src/advanced-options/advanced-options.component.ts - 32 + 33 Astronomically-accurate, non-mechanical timing src/advanced-options/advanced-options.component.ts - 36 + 37 Sun constrained by hour hand src/advanced-options/advanced-options.component.ts - 37 + 38 Pre-1866 mechanical timing, recalibrated quarterly src/advanced-options/advanced-options.component.ts - 38 + 39 Updated mechanical timing, recalibrated yearly src/advanced-options/advanced-options.component.ts - 39 + 40 @@ -125,221 +132,221 @@ Uncheck "Track current time" to modify the time src/app/app.component.html - 30 + 31 ISO time format src/app/app.component.html - 42 + 44 Disable DST on clock src/app/app.component.html - 44 + 46 Track current time src/app/app.component.html - 50 + 52 Now src/app/app.component.html - 51 + 53 Local mean time: src/app/app.component.html - 612 + 614 Local solar time: src/app/app.component.html - 614 + 616 Sidereal time: src/app/app.component.html - 616 + 618 Bohemian time: src/app/app.component.html - 618 + 620 Sun rise/set: src/app/app.component.html - 620 + 622 Moon rise/set: src/app/app.component.html - 622 + 624 Last virtual recalibration: src/app/app.component.html - 626 + 628 Actual src/app/app.component.html - 632 + 634 Sun λ src/app/app.component.html - 638 + 640 mins src/app/app.component.html - 643 + 645 Moon λ src/app/app.component.html - 647 + 649 days src/app/app.component.html - 652 + 654 src/app/app.component.html - 661 + 663 Moon phase src/app/app.component.html - 656 + 658 Original SVG clock graphics by Jan Tošovský src/app/app.component.html - 668 + 670 Change time src/app/app.component.html - 671 + 673 Prague, CZE src/app/app.component.ts - 41 + 45 Default src/app/app.component.ts - 116 + 121 ↔ Equinox/solstice src/app/app.component.ts - 195 + 202 ↔ Moon phase src/app/app.component.ts - 197 + 204 ↔ Sunrise/transit/sunset src/app/app.component.ts - 199 + 206 Advanced options... src/app/app.component.ts - 202 + 209 Language src/app/app.component.ts - 206 + 213 Code on GitHub src/app/app.component.ts - 210 + 217 Czech Horological Society site src/app/app.component.ts - 212 + 219 About the real clock src/app/app.component.ts - 214 + 221 https://en.wikipedia.org/wiki/Prague_astronomical_clock src/app/app.component.ts - 215 + 222 Language-specific Wikipedia URL @@ -347,21 +354,21 @@ About this simulator src/app/app.component.ts - 217 + 224 Suppress onscreen keyboard src/app/app.component.ts - 313 + 321 Yes src/app/app.component.ts - 350 + 358 for dialog button @@ -369,7 +376,7 @@ No src/app/app.component.ts - 351 + 359 for dialog button @@ -377,109 +384,109 @@ Turn off "Track current time" so you can edit the time? src/app/app.component.ts - 1010 + 1025 Turn off "Track current time" and change the clock time? src/app/app.component.ts - 1085 + 1134 Event src/app/app.component.ts - 1126 + 1177 src/app/app.component.ts - 1130 + 1181 Event outside of - year range. src/app/app.component.ts - 1127 + 1178 Sunrise src/app/app.component.ts - 1137 + 1188 Sunset src/app/app.component.ts - 1139 + 1190 Transit src/app/app.component.ts - 1141 + 1192 Vernal equinox src/app/app.component.ts - 1143 + 1194 Summer solstice src/app/app.component.ts - 1145 + 1196 Autumnal equinox src/app/app.component.ts - 1147 + 1198 Winter Solstice src/app/app.component.ts - 1149 + 1200 New moon src/app/app.component.ts - 1151 + 1202 First quarter src/app/app.component.ts - 1153 + 1204 Full moon src/app/app.component.ts - 1155 + 1206 Third quarter src/app/app.component.ts - 1157 + 1208 diff --git a/package-lock.json b/package-lock.json index 1ee58eb..929697b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "prague-clock", - "version": "1.6.8", + "version": "1.7.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prague-clock", - "version": "1.6.8", + "version": "1.7.0", "dependencies": { "@angular/animations": "~13.2.0", "@angular/cdk": "^13.2.6", @@ -43,7 +43,7 @@ "@angular/cli": "~13.2.5", "@angular/compiler-cli": "~13.2.0", "@angular/localize": "^13.2.7", - "@tubular/browser-check": "^1.1.0", + "@tubular/browser-check": "^1.2.0", "@types/jasmine": "~3.10.6", "@types/node": "^12.20.50", "@types/three": "^0.139.0", @@ -3028,9 +3028,9 @@ } }, "node_modules/@tubular/browser-check": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@tubular/browser-check/-/browser-check-1.1.0.tgz", - "integrity": "sha512-XI5SSTIsSw/VA/yLQYQEFI8H5bzf/cr3LWLXuoSrZipDvaBiWBeVPIX9buot0Nr39cdoTDo7sXuuneKwBP7YUg==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@tubular/browser-check/-/browser-check-1.2.0.tgz", + "integrity": "sha512-rLtDajb56gYJvrZheENgM8u9bejncJ0ITXUJTWedNiosL/q36j0f/NgEM2da5mUmIqXIfrLCIW2Kbkg+Nmf9gQ==", "dev": true }, "node_modules/@tubular/math": { @@ -16777,9 +16777,9 @@ } }, "@tubular/browser-check": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@tubular/browser-check/-/browser-check-1.1.0.tgz", - "integrity": "sha512-XI5SSTIsSw/VA/yLQYQEFI8H5bzf/cr3LWLXuoSrZipDvaBiWBeVPIX9buot0Nr39cdoTDo7sXuuneKwBP7YUg==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@tubular/browser-check/-/browser-check-1.2.0.tgz", + "integrity": "sha512-rLtDajb56gYJvrZheENgM8u9bejncJ0ITXUJTWedNiosL/q36j0f/NgEM2da5mUmIqXIfrLCIW2Kbkg+Nmf9gQ==", "dev": true }, "@tubular/math": { diff --git a/package.json b/package.json index 31219ae..dee1dc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prague-clock", - "version": "1.6.8", + "version": "1.7.0", "scripts": { "ng": "ng", "start": "ng serve --configuration=development", @@ -52,7 +52,7 @@ "@angular/cli": "~13.2.5", "@angular/compiler-cli": "~13.2.0", "@angular/localize": "^13.2.7", - "@tubular/browser-check": "^1.1.0", + "@tubular/browser-check": "^1.2.0", "@types/jasmine": "~3.10.6", "@types/node": "^12.20.50", "@types/three": "^0.139.0", @@ -75,4 +75,4 @@ "stylelint-scss": "^4.2.0", "typescript": "~4.5.5" } -} +} \ No newline at end of file diff --git a/src/advanced-options/advanced-options.component.html b/src/advanced-options/advanced-options.component.html index 3cb214d..bab6d1e 100644 --- a/src/advanced-options/advanced-options.component.html +++ b/src/advanced-options/advanced-options.component.html @@ -20,6 +20,9 @@ + + diff --git a/src/advanced-options/advanced-options.component.ts b/src/advanced-options/advanced-options.component.ts index 406de80..29c2d56 100644 --- a/src/advanced-options/advanced-options.component.ts +++ b/src/advanced-options/advanced-options.component.ts @@ -5,6 +5,7 @@ export enum Timing { MODERN, MECHANICAL_ORIGINAL, MECHANICAL_UPDATED, CONSTRAINE export interface SettingsHolder { additionalPlanets: boolean; + animateBySiderealDays: boolean; appearance: Appearance; background: string; detailedMechanism: boolean; diff --git a/src/app/app.component.html b/src/app/app.component.html index 63d2d9b..99741fa 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -20,7 +20,8 @@
- + - +
Original SVG clock graphics by Jan Tošovský
- + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d9d8775..e7aa8c4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -19,14 +19,18 @@ import { faForward, faPlay, faStop } from '@fortawesome/free-solid-svg-icons'; import { AdvancedOptionsComponent, Appearance, SettingsHolder, Timing } from '../advanced-options/advanced-options.component'; import { - adjustForEclipticWheel, AngleTriplet, BasicPositions, calculateBasicPositions, calculateMechanicalPositions, MILLIS_PER_DAY, - solarSystem, ZeroAngles + adjustForEclipticWheel, AngleTriplet, BasicPositions, calculateBasicPositions, calculateMechanicalPositions, + MILLIS_PER_DAY, MILLIS_PER_SIDEREAL_DAY, solarSystem, ZeroAngles } from 'src/math/math'; import { adjustGraphicsForLatitude, initSvgHost, sunlitMoonPath, SvgHost } from 'src/svg/svg'; import { sizeChanges } from '../main'; +import { Subscription, timer } from 'rxjs'; const { DATE, DATETIME_LOCAL, julianDay, TIME } = ttime; +const CLICK_REPEAT_DELAY = 500; +const CLICK_REPEAT_RATE = 100; + const RESUME_FILTERING_DELAY = 1000; const SIMPLE_FILTER_IS_SLOW_TOO = isAndroid() || (isSafari() && isMacOS()); const STOP_FILTERING_DELAY = SIMPLE_FILTER_IS_SLOW_TOO ? 1000 : 3000; @@ -44,6 +48,7 @@ const pragueLon = 14.4185; const defaultSettings = { additionalPlanets: false, + animateBySiderealDays: false, appearance: Appearance.CURRENT, background: '#4D4D4D', collapsed: false, @@ -161,7 +166,9 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost { private _background = '#4D4D4D'; private _collapsed = false; private delayedCollapse = false; + private eventClickTimer: Subscription; private eventFinder = new EventFinder(); + private eventGoBack = false; private eventType = EventType.EQUISOLSTICE; private globe: Globe private graphicsChangeLastTime = -1; @@ -222,6 +229,7 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost { self: AppComponent & SvgHost = this; altFour = false; + animateBySiderealDays = false; bohemianTime = ''; canEditName = false; canSaveName = false; @@ -615,7 +623,13 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost { } stop(): void { - this.playing = false; + if (this.playing) { + this.playing = false; + + // Round time to the nearest whole minute when animation stops. + if (this.playSpeed === PlaySpeed.FAST) + this.time = floor((this.time + 30000) / 60000) * 60000; + } } private playStep = (): void => { @@ -627,7 +641,8 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost { if (this.playSpeed === PlaySpeed.NORMAL) this.time = this.playTimeBase + floor(elapsed / 25) * 60_000; else - this.time = this.playTimeBase + floor(elapsed / 100) * MILLIS_PER_DAY; + this.time = this.playTimeBase + floor(elapsed / 100) * + (this.animateBySiderealDays ? MILLIS_PER_SIDEREAL_DAY : MILLIS_PER_DAY); if (this.lastWallTime && this.lastWallTime.y === this.MAX_YEAR && this.lastWallTime.m === 12 && this.lastWallTime.d === 31) @@ -1079,8 +1094,42 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost { this.canSaveName = false; } - skipToEvent(previous = false): void { + eventClick(evt?: TouchEvent | MouseEvent, goBack = false): void { + if (!evt) + this.stopEventClickTimer(); + else if (evt?.type === 'touchstart' || evt?.type === 'mousedown') { + if (evt.type === 'touchstart' && evt.cancelable) + evt.preventDefault(); + + this.eventGoBack = goBack; + + if (!this.eventClickTimer) { + this.eventClickTimer = timer(CLICK_REPEAT_DELAY, CLICK_REPEAT_RATE).subscribe(() => { + this.skipToEvent(this.eventGoBack); + }); + } + } + else if (evt?.type === 'touchend' || evt?.type === 'mouseup') { + if (evt.type === 'touchend' && evt.cancelable) + evt.preventDefault(); + + if (this.eventClickTimer) { + this.stopEventClickTimer(); + this.skipToEvent(this.eventGoBack); + } + } + } + + private stopEventClickTimer(): void { + if (this.eventClickTimer) { + this.eventClickTimer.unsubscribe(); + this.eventClickTimer = undefined; + } + } + + private skipToEvent(previous: boolean): void { if (this.trackTime) { + this.stopEventClickTimer(); this.confirmService.confirm({ message: $localize`Turn off "Track current time" and change the clock time?`, accept: () => { @@ -1122,12 +1171,14 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost { const eventText = AppComponent.translateEvent(evt.eventText); const year = new DateTime(evt.eventTime.utcMillis, this.zone).wallTime.year; + this.messageService.clear(); + if (year < this.MIN_YEAR || year > this.MAX_YEAR) this.messageService.add({ severity: 'error', summary: $localize`Event`, detail: $localize`Event outside of ${this.MIN_YEAR}-${this.MAX_YEAR} year range.` }); else { this.time = evt.eventTime.utcMillis; - this.messageService.add({ severity: 'info', summary: $localize`Event`, detail: eventText, life: 1000 }); + this.messageService.add({ severity: 'info', summary: $localize`Event`, detail: eventText }); } } } diff --git a/src/index.html b/src/index.html index 9bff013..b928b11 100644 --- a/src/index.html +++ b/src/index.html @@ -23,8 +23,8 @@ - +