Skip to content

Commit 70419c8

Browse files
authored
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.
1 parent b0e73a5 commit 70419c8

16 files changed

Lines changed: 448 additions & 359 deletions

.eslintrc.json

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@
138138
"sourceType": "module"
139139
},
140140
"rules": {
141-
"@typescript-eslint/consistent-type-assertions": "off",
142-
"@typescript-eslint/explicit-function-return-type": "off",
143-
"@typescript-eslint/indent": "off",
144-
"@typescript-eslint/no-unused-vars": "off",
145141
"indent": [
146142
"error",
147143
2,
@@ -155,17 +151,6 @@
155151
}
156152
]
157153
}
158-
},
159-
{
160-
"files": ["*.es5.js"],
161-
"env": {
162-
"browser": true
163-
},
164-
"rules": {
165-
"no-eval": "off",
166-
"no-template-curly-in-string": "off",
167-
"no-var": "off"
168-
}
169154
}
170155
]
171156
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"recalibrated",
2626
"recalibrations",
2727
"Recents",
28+
"stylelint",
2829
"subzone",
2930
"subzones",
3031
"tieredmenu",
@@ -33,4 +34,4 @@
3334
"tspan"
3435
],
3536
"xliffSync.baseFile": "messages.xlf"
36-
}
37+
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.7.0
2+
3+
* New option to step one sidereal day at a time (instead of 24 hours at a time) during high-speed animation.
4+
* Auto-repeat on backward/forward event buttons.
5+
* Improved event messages.
6+
17
## 1.6.2
28

39
* Relaxed browser requirements, with WebGL capability no long required.

messages.xlf

Lines changed: 71 additions & 64 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prague-clock",
3-
"version": "1.6.8",
3+
"version": "1.7.0",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve --configuration=development",
@@ -52,7 +52,7 @@
5252
"@angular/cli": "~13.2.5",
5353
"@angular/compiler-cli": "~13.2.0",
5454
"@angular/localize": "^13.2.7",
55-
"@tubular/browser-check": "^1.1.0",
55+
"@tubular/browser-check": "^1.2.0",
5656
"@types/jasmine": "~3.10.6",
5757
"@types/node": "^12.20.50",
5858
"@types/three": "^0.139.0",
@@ -75,4 +75,4 @@
7575
"stylelint-scss": "^4.2.0",
7676
"typescript": "~4.5.5"
7777
}
78-
}
78+
}

src/advanced-options/advanced-options.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<p-checkbox [(ngModel)]="settingsHolder.detailedMechanism" [binary]="true"
2121
i18n-label label="Mechanically detailed clock face"></p-checkbox>
2222

23+
<p-checkbox [(ngModel)]="settingsHolder.animateBySiderealDays" [binary]="true"
24+
i18n-label label="Fast animation uses sidereal days"></p-checkbox>
25+
2326
<p-checkbox [(ngModel)]="settingsHolder.fasterGraphics" [binary]="true"
2427
i18n-label label="Faster graphics / less shading"></p-checkbox>
2528

src/advanced-options/advanced-options.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum Timing { MODERN, MECHANICAL_ORIGINAL, MECHANICAL_UPDATED, CONSTRAINE
55

66
export interface SettingsHolder {
77
additionalPlanets: boolean;
8+
animateBySiderealDays: boolean;
89
appearance: Appearance;
910
background: string;
1011
detailedMechanism: boolean;

src/app/app.component.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
<i *ngIf="canSaveName" class="pi pi-undo" (click)="cancelEdit()"></i>
2121
</div>
2222
<div class="time-row">
23-
<i class="pi pi-caret-left" (click)="skipToEvent(true)"></i>
23+
<i class="pi pi-caret-left" (touchstart)="eventClick($event, true)" (touchend)="eventClick($event)"
24+
(mousedown)="eventClick($event, true)" (mouseup)="eventClick($event)" (mouseleave)="eventClick()"></i>
2425
<tbw-time-editor
2526
[max]="MAX_YEAR + '-12-31'"
2627
[min]="MIN_YEAR + '-01-01'"
@@ -35,7 +36,8 @@
3536
[timezone]="getZone()"
3637
[disableMobileKeyboard]="suppressOsKeyboard"
3738
[(ngModel)]="time"></tbw-time-editor>
38-
<i class="pi pi-caret-right" (click)="skipToEvent()"></i>
39+
<i class="pi pi-caret-right" (touchstart)="eventClick($event)" (touchend)="eventClick($event)"
40+
(mousedown)="eventClick($event)" (mouseup)="eventClick($event)" (mouseleave)="eventClick()"></i>
3941
</div>
4042
<div class="button-row">
4143
<p-checkbox [(ngModel)]="isoFormat" [binary]="true"
@@ -667,6 +669,6 @@
667669

668670
<div i18n id="graphics-credit">Original SVG clock graphics by Jan Tošovský</div>
669671

670-
<p-toast position="center"></p-toast>
672+
<p-toast position="bottom-center" [showTransitionOptions]="'0ms'" [hideTransitionOptions]="'0ms'"></p-toast>
671673
<p-confirmDialog i18n-header header="Change time"></p-confirmDialog>
672674
</div>

src/app/app.component.ts

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ import { faForward, faPlay, faStop } from '@fortawesome/free-solid-svg-icons';
1919
import { AdvancedOptionsComponent, Appearance, SettingsHolder, Timing }
2020
from '../advanced-options/advanced-options.component';
2121
import {
22-
adjustForEclipticWheel, AngleTriplet, BasicPositions, calculateBasicPositions, calculateMechanicalPositions, MILLIS_PER_DAY,
23-
solarSystem, ZeroAngles
22+
adjustForEclipticWheel, AngleTriplet, BasicPositions, calculateBasicPositions, calculateMechanicalPositions,
23+
MILLIS_PER_DAY, MILLIS_PER_SIDEREAL_DAY, solarSystem, ZeroAngles
2424
} from 'src/math/math';
2525
import { adjustGraphicsForLatitude, initSvgHost, sunlitMoonPath, SvgHost } from 'src/svg/svg';
2626
import { sizeChanges } from '../main';
27+
import { Subscription, timer } from 'rxjs';
2728

2829
const { DATE, DATETIME_LOCAL, julianDay, TIME } = ttime;
2930

31+
const CLICK_REPEAT_DELAY = 500;
32+
const CLICK_REPEAT_RATE = 100;
33+
3034
const RESUME_FILTERING_DELAY = 1000;
3135
const SIMPLE_FILTER_IS_SLOW_TOO = isAndroid() || (isSafari() && isMacOS());
3236
const STOP_FILTERING_DELAY = SIMPLE_FILTER_IS_SLOW_TOO ? 1000 : 3000;
@@ -44,6 +48,7 @@ const pragueLon = 14.4185;
4448

4549
const defaultSettings = {
4650
additionalPlanets: false,
51+
animateBySiderealDays: false,
4752
appearance: Appearance.CURRENT,
4853
background: '#4D4D4D',
4954
collapsed: false,
@@ -161,7 +166,9 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
161166
private _background = '#4D4D4D';
162167
private _collapsed = false;
163168
private delayedCollapse = false;
169+
private eventClickTimer: Subscription;
164170
private eventFinder = new EventFinder();
171+
private eventGoBack = false;
165172
private eventType = EventType.EQUISOLSTICE;
166173
private globe: Globe
167174
private graphicsChangeLastTime = -1;
@@ -222,6 +229,7 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
222229
self: AppComponent & SvgHost = this;
223230

224231
altFour = false;
232+
animateBySiderealDays = false;
225233
bohemianTime = '';
226234
canEditName = false;
227235
canSaveName = false;
@@ -615,7 +623,13 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
615623
}
616624

617625
stop(): void {
618-
this.playing = false;
626+
if (this.playing) {
627+
this.playing = false;
628+
629+
// Round time to the nearest whole minute when animation stops.
630+
if (this.playSpeed === PlaySpeed.FAST)
631+
this.time = floor((this.time + 30000) / 60000) * 60000;
632+
}
619633
}
620634

621635
private playStep = (): void => {
@@ -627,7 +641,8 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
627641
if (this.playSpeed === PlaySpeed.NORMAL)
628642
this.time = this.playTimeBase + floor(elapsed / 25) * 60_000;
629643
else
630-
this.time = this.playTimeBase + floor(elapsed / 100) * MILLIS_PER_DAY;
644+
this.time = this.playTimeBase + floor(elapsed / 100) *
645+
(this.animateBySiderealDays ? MILLIS_PER_SIDEREAL_DAY : MILLIS_PER_DAY);
631646

632647
if (this.lastWallTime && this.lastWallTime.y === this.MAX_YEAR &&
633648
this.lastWallTime.m === 12 && this.lastWallTime.d === 31)
@@ -1079,8 +1094,42 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
10791094
this.canSaveName = false;
10801095
}
10811096

1082-
skipToEvent(previous = false): void {
1097+
eventClick(evt?: TouchEvent | MouseEvent, goBack = false): void {
1098+
if (!evt)
1099+
this.stopEventClickTimer();
1100+
else if (evt?.type === 'touchstart' || evt?.type === 'mousedown') {
1101+
if (evt.type === 'touchstart' && evt.cancelable)
1102+
evt.preventDefault();
1103+
1104+
this.eventGoBack = goBack;
1105+
1106+
if (!this.eventClickTimer) {
1107+
this.eventClickTimer = timer(CLICK_REPEAT_DELAY, CLICK_REPEAT_RATE).subscribe(() => {
1108+
this.skipToEvent(this.eventGoBack);
1109+
});
1110+
}
1111+
}
1112+
else if (evt?.type === 'touchend' || evt?.type === 'mouseup') {
1113+
if (evt.type === 'touchend' && evt.cancelable)
1114+
evt.preventDefault();
1115+
1116+
if (this.eventClickTimer) {
1117+
this.stopEventClickTimer();
1118+
this.skipToEvent(this.eventGoBack);
1119+
}
1120+
}
1121+
}
1122+
1123+
private stopEventClickTimer(): void {
1124+
if (this.eventClickTimer) {
1125+
this.eventClickTimer.unsubscribe();
1126+
this.eventClickTimer = undefined;
1127+
}
1128+
}
1129+
1130+
private skipToEvent(previous: boolean): void {
10831131
if (this.trackTime) {
1132+
this.stopEventClickTimer();
10841133
this.confirmService.confirm({
10851134
message: $localize`Turn off "Track current time" and change the clock time?`,
10861135
accept: () => {
@@ -1122,12 +1171,14 @@ export class AppComponent implements OnInit, SettingsHolder, SvgHost {
11221171
const eventText = AppComponent.translateEvent(evt.eventText);
11231172
const year = new DateTime(evt.eventTime.utcMillis, this.zone).wallTime.year;
11241173

1174+
this.messageService.clear();
1175+
11251176
if (year < this.MIN_YEAR || year > this.MAX_YEAR)
11261177
this.messageService.add({ severity: 'error', summary: $localize`Event`,
11271178
detail: $localize`Event outside of ${this.MIN_YEAR}-${this.MAX_YEAR} year range.` });
11281179
else {
11291180
this.time = evt.eventTime.utcMillis;
1130-
this.messageService.add({ severity: 'info', summary: $localize`Event`, detail: eventText, life: 1000 });
1181+
this.messageService.add({ severity: 'info', summary: $localize`Event`, detail: eventText });
11311182
}
11321183
}
11331184
}

0 commit comments

Comments
 (0)