aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/angular/timestamp-route-transformer.directive.ts51
1 files changed, 25 insertions, 26 deletions
diff --git a/client/src/app/shared/angular/timestamp-route-transformer.directive.ts b/client/src/app/shared/angular/timestamp-route-transformer.directive.ts
index f4d9aeb1f..45e023695 100644
--- a/client/src/app/shared/angular/timestamp-route-transformer.directive.ts
+++ b/client/src/app/shared/angular/timestamp-route-transformer.directive.ts
@@ -10,31 +10,30 @@ export class TimestampRouteTransformerDirective {
10 public onClick ($event: Event) { 10 public onClick ($event: Event) {
11 const target = $event.target as HTMLLinkElement 11 const target = $event.target as HTMLLinkElement
12 12
13 if (target.hasAttribute('href')) { 13 if (target.hasAttribute('href') !== true) return
14 const ngxLink = document.createElement('a') 14
15 ngxLink.href = target.getAttribute('href') 15 const ngxLink = document.createElement('a')
16 16 ngxLink.href = target.getAttribute('href')
17 // we only care about reflective links 17
18 if (ngxLink.host !== window.location.host) return 18 // we only care about reflective links
19 19 if (ngxLink.host !== window.location.host) return
20 const ngxLinkParams = new URLSearchParams(ngxLink.search) 20
21 if (ngxLinkParams.has('start')) { 21 const ngxLinkParams = new URLSearchParams(ngxLink.search)
22 const separators = ['h', 'm', 's'] 22 if (ngxLinkParams.has('start') !== true) return
23 const start = ngxLinkParams 23
24 .get('start') 24 const separators = ['h', 'm', 's']
25 .match(new RegExp('(\\d{1,9}[' + separators.join('') + '])','g')) // match digits before any given separator 25 const start = ngxLinkParams
26 .map(t => { 26 .get('start')
27 if (t.includes('h')) return parseInt(t, 10) * 3600 27 .match(new RegExp('(\\d{1,9}[' + separators.join('') + '])','g')) // match digits before any given separator
28 if (t.includes('m')) return parseInt(t, 10) * 60 28 .map(t => {
29 return parseInt(t, 10) 29 if (t.includes('h')) return parseInt(t, 10) * 3600
30 }) 30 if (t.includes('m')) return parseInt(t, 10) * 60
31 .reduce((acc, t) => acc + t) 31 return parseInt(t, 10)
32 this.timestampClicked.emit(start) 32 })
33 } 33 .reduce((acc, t) => acc + t)
34 34
35 $event.preventDefault() 35 this.timestampClicked.emit(start)
36 } 36
37 37 $event.preventDefault()
38 return
39 } 38 }
40} 39}