-
-
Notifications
You must be signed in to change notification settings - Fork 226
/
DocumentTitle.js
39 lines (33 loc) · 1 KB
/
DocumentTitle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { formatBytes } from '@/helpers'
import store from '../store'
export class DocumentTitle {
static setDefault() {
this.set('VueTorrent')
}
static setGlobalSpeed() {
const status = store.getters.getStatus()
this.set(`[D: ${formatBytes(status.dlspeed)}/s, U: ${formatBytes(status.upspeed)}/s] VueTorrent`)
}
static setFirstTorrentStatus() {
const torrents = store.getters.getTorrents()
if (!torrents && !torrents.length) return
const torrent = torrents[0]
this.set(`[D: ${formatBytes(torrent.dlspeed)}/s, U: ${formatBytes(torrent.upspeed)}/s] ${torrent.progress}%`)
}
static update() {
const mode = store.getters.getWebuiSettings().title
switch (mode) {
case 'Default':
return this.setDefault()
case 'Global Speed':
return this.setGlobalSpeed()
case 'First Torrent Status':
return this.setFirstTorrentStatus()
default:
return this.setDefault()
}
}
static set(title) {
document.title = title
}
}