Add copying to clipboard functionality.
This commit is contained in:
parent
192cae129a
commit
a8d0741436
1 changed files with 30 additions and 1 deletions
|
|
@ -3,6 +3,16 @@
|
|||
<h1>
|
||||
Secret Hitler Online
|
||||
</h1>
|
||||
<h2>
|
||||
Game Code:
|
||||
<code
|
||||
v-clipboard="copy_game_code"
|
||||
v-clipboard:success="copy_success"
|
||||
v-clipboard:error="copy_error"
|
||||
>
|
||||
{{ game_code }}
|
||||
</code>
|
||||
</h2>
|
||||
<div>
|
||||
<h3>Players:</h3>
|
||||
<div
|
||||
|
|
@ -19,7 +29,9 @@ export default {
|
|||
name: 'GameLobby',
|
||||
components: {},
|
||||
data() {return {
|
||||
players: []
|
||||
game_code: ``,
|
||||
is_host: false,
|
||||
players: [],
|
||||
}},
|
||||
mounted() {
|
||||
this.game_code = sessionStorage.getItem(`game-code`);
|
||||
|
|
@ -32,6 +44,23 @@ export default {
|
|||
game_code: this.game_code,
|
||||
});
|
||||
},
|
||||
copy_game_code() {
|
||||
this.$clipboard(this.game_code);
|
||||
},
|
||||
copy_success() {
|
||||
this.$emit(`alert`, {
|
||||
message: `Game code copied to your clipboard.`,
|
||||
classes: [`info`]
|
||||
});
|
||||
setTimeout(() => this.$emit(`alert`, { message: ``, classes: [] }), 2000)
|
||||
},
|
||||
copy_error() {
|
||||
this.$emit(`alert`, {
|
||||
message: `Something went wrong when copying the game code to your clipboard`,
|
||||
classes: [`warning`]
|
||||
});
|
||||
setTimeout(() => this.$emit(`alert`, { message: ``, classes: [] }), 2000)
|
||||
}
|
||||
},
|
||||
sockets: {
|
||||
PlayerListResponse(data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue