diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-29 17:18:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-29 17:18:39 +0200 |
commit | 911186dae411d78788ccede093c251303187589a (patch) | |
tree | 967a07cd985ae4e2ea5249855726455fe929471d /client/src/app/+videos/+video-watch/timestamp-route-transformer.directive.ts | |
parent | b0c43e36dbdc2c964f6828a78b146faebfb75b21 (diff) | |
download | PeerTube-911186dae411d78788ccede093c251303187589a.tar.gz PeerTube-911186dae411d78788ccede093c251303187589a.tar.zst PeerTube-911186dae411d78788ccede093c251303187589a.zip |
Reorganize watch components
Diffstat (limited to 'client/src/app/+videos/+video-watch/timestamp-route-transformer.directive.ts')
-rw-r--r-- | client/src/app/+videos/+video-watch/timestamp-route-transformer.directive.ts | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/client/src/app/+videos/+video-watch/timestamp-route-transformer.directive.ts b/client/src/app/+videos/+video-watch/timestamp-route-transformer.directive.ts deleted file mode 100644 index 45e023695..000000000 --- a/client/src/app/+videos/+video-watch/timestamp-route-transformer.directive.ts +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | import { Directive, EventEmitter, HostListener, Output } from '@angular/core' | ||
2 | |||
3 | @Directive({ | ||
4 | selector: '[timestampRouteTransformer]' | ||
5 | }) | ||
6 | export class TimestampRouteTransformerDirective { | ||
7 | @Output() timestampClicked = new EventEmitter<number>() | ||
8 | |||
9 | @HostListener('click', ['$event']) | ||
10 | public onClick ($event: Event) { | ||
11 | const target = $event.target as HTMLLinkElement | ||
12 | |||
13 | if (target.hasAttribute('href') !== true) return | ||
14 | |||
15 | const ngxLink = document.createElement('a') | ||
16 | ngxLink.href = target.getAttribute('href') | ||
17 | |||
18 | // we only care about reflective links | ||
19 | if (ngxLink.host !== window.location.host) return | ||
20 | |||
21 | const ngxLinkParams = new URLSearchParams(ngxLink.search) | ||
22 | if (ngxLinkParams.has('start') !== true) return | ||
23 | |||
24 | const separators = ['h', 'm', 's'] | ||
25 | const start = ngxLinkParams | ||
26 | .get('start') | ||
27 | .match(new RegExp('(\\d{1,9}[' + separators.join('') + '])','g')) // match digits before any given separator | ||
28 | .map(t => { | ||
29 | if (t.includes('h')) return parseInt(t, 10) * 3600 | ||
30 | if (t.includes('m')) return parseInt(t, 10) * 60 | ||
31 | return parseInt(t, 10) | ||
32 | }) | ||
33 | .reduce((acc, t) => acc + t) | ||
34 | |||
35 | this.timestampClicked.emit(start) | ||
36 | |||
37 | $event.preventDefault() | ||
38 | } | ||
39 | } | ||