-
-
Notifications
You must be signed in to change notification settings - Fork 233
/
app-whitelabel.vue
143 lines (135 loc) · 3.47 KB
/
app-whitelabel.vue
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<script lang="ts">
import { trackSilentException } from '../bugs'
import { DEFAULT_ROOM, LICENSE, ROOM_PATH, ROOM_URL } from '../config'
import { generateName } from '../lib/names'
import { state } from '../state'
import './app-whitelabel.scss'
export default {
name: 'AppWhitelabel',
components: {},
data() {
const defaultName = DEFAULT_ROOM ?? generateName()
return {
defaultName,
LICENSE,
room: defaultName,
url: '',
initialWidth: -1,
currentChar: 0,
observer: null,
roomHtml: ROOM_URL.replace(/^https?:\/\//gm, '')
.replaceAll('/', '<span class="slash">/</span>')
.replaceAll('.', '<span class="dot">.</span>'),
}
},
watch: {
room() {
this.updateInput()
},
},
async mounted() {
await this.$nextTick()
const input = this.$refs.input
if (input) {
input.style.width = `${input.scrollWidth}px`
this.updateInput()
this.observer = new ResizeObserver(this.updateInput)
this.observer.observe(document.body)
this.charAnimation()
if (
!/Android|webOS|iPhone|iPad|iPod|Opera Mini/i.test(navigator.userAgent)
)
input.focus()
}
},
beforeUnmount() {
this.observer?.disconnect()
},
methods: {
doEnterRoom() {
const room = this.room || this.defaultName || ''
state.room = room
try {
window.history.pushState(
null, // { room },
null, // room,
ROOM_PATH + room,
)
}
catch (err) {
trackSilentException(err)
}
},
updateInput() {
const input = this.$refs.input
if (input) {
if (this.initialWidth < 0)
this.initialWidth = input.scrollWidth
const value = input.value.trim()
input.style.width = '1px'
input.style.width = `${value ? input.scrollWidth : this.initialWidth}px`
this.url = ROOM_PATH + (value || this.defaultName)
}
},
charAnimation() {
setTimeout(() => {
const input = this.$refs.input
if (input) {
this.currentChar++
this.$refs.input.value = this.defaultName.substr(0, this.currentChar)
this.updateInput()
if (this.currentChar < this.defaultName.length)
this.charAnimation()
}
}, 100)
},
},
}
</script>
<template>
<div class="-scroll">
<div class="page1">
<div class="logo">
<form id="form" @submit.prevent="doEnterRoom">
<a
id="link"
:href="url"
class="link"
@click.prevent="doEnterRoom"
v-html="roomHtml"
/>
<wbr>
<input
id="room"
ref="input"
v-model="room"
type="text"
name="room"
enterkeyhint="go"
spellcheck="false"
:placeholder="defaultName"
>
</form>
<div class="button-container">
<a
id="button"
:href="url"
class="button start-button"
@click.prevent="doEnterRoom"
>{{ $t('welcome.start') }}</a>
</div>
</div>
<div class="footer links">
<p v-if="LICENSE">
{{ LICENSE }}
</p>
<p v-else>
FOR WHITELABEL USE WE ASK YOU TO PURCHASE A
<a href="https://github.com/holtwick/briefing/#commercial-license">
COMMERCIAL LICENSE
</a>
</p>
</div>
</div>
</div>
</template>