Add error styling, and rename url to uri
This commit is contained in:
parent
13b27056db
commit
703d03da3b
1 changed files with 13 additions and 8 deletions
|
|
@ -10,12 +10,14 @@
|
|||
<input
|
||||
type="text"
|
||||
name="Websocket URL"
|
||||
v-model="ws_url"
|
||||
@keyup.enter="submit_ws_url()"
|
||||
:class="has_error ? 'error' : ''"
|
||||
v-model="ws_uri"
|
||||
@change.stop="has_error = false"
|
||||
@keyup.enter="submit_ws_uri()"
|
||||
>
|
||||
<br>
|
||||
<button
|
||||
@onclick.stop="submit_ws_url()"
|
||||
@click.stop="submit_ws_uri()"
|
||||
>
|
||||
Confirm URL
|
||||
</button>
|
||||
|
|
@ -27,14 +29,17 @@ export default {
|
|||
name: 'WebsocketEntry',
|
||||
components: {},
|
||||
data() {return {
|
||||
ws_url: ``,
|
||||
ws_uri: ``,
|
||||
has_error: false,
|
||||
ws_regex: /^(wss?|https?):\/\//,
|
||||
}},
|
||||
methods: {
|
||||
submit_ws_url() {
|
||||
if (this.ws_url.length > 0 && this.ws_url.match(/^wss?:\/\//)) {
|
||||
this.$emit(`set-ws-url`, this.ws_url);
|
||||
submit_ws_uri() {
|
||||
if (this.ws_uri.length > 0 && this.ws_uri.match(this.ws_regex)) {
|
||||
this.$emit(`try-ws-uri`, this.ws_uri);
|
||||
} else {
|
||||
alert(`Invalid websocket URL, it must begin with "wss://" in order to connect.`)
|
||||
this.has_error = true;
|
||||
alert(`Invalid websocket URL, please check that you typed it correctly.`)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue