Bump web libraries, minor cleanup
This commit is contained in:
parent
1567317f03
commit
38a36aaa13
@ -1,11 +1,8 @@
|
||||
var KEYCODE_BACKSPACE = 8;
|
||||
var KEYCODE_RETURN = 13;
|
||||
|
||||
var HEIGHT = 300;
|
||||
var WIDTH = 250;
|
||||
var CHARACTER_HEIGHT = 50;
|
||||
var MARGIN_TOP = 100;
|
||||
var MARGIN_BOTTOM = 75;
|
||||
const HEIGHT = 300;
|
||||
const WIDTH = 250;
|
||||
const CHARACTER_HEIGHT = 50;
|
||||
const MARGIN_TOP = 100;
|
||||
const MARGIN_BOTTOM = 75;
|
||||
|
||||
var client;
|
||||
var sessionId = null;
|
||||
@ -201,12 +198,12 @@ var vm = new Vue({
|
||||
this.games.splice(indexToRemove, 1);
|
||||
},
|
||||
onCanvasKeydown: function(e) {
|
||||
if (e.which === KEYCODE_BACKSPACE) {
|
||||
if (e.key === 'Backspace') {
|
||||
e.preventDefault();
|
||||
this.myGuess = this.myGuess.substr(0, this.myGuess.length - 1);
|
||||
this.repaint();
|
||||
}
|
||||
else if (e.which === KEYCODE_RETURN) {
|
||||
else if (e.key === 'Enter') {
|
||||
if (this.myGuess.length === this.wordLength) {
|
||||
client.publish({destination: '/app/guess', body: this.myGuess})
|
||||
this.myGuess = '';
|
||||
@ -229,7 +226,7 @@ var vm = new Vue({
|
||||
},
|
||||
onChatKeypress: function(e) {
|
||||
var messageInput = e.target;
|
||||
if (e.which === KEYCODE_RETURN) {
|
||||
if (e.key === 'Enter') {
|
||||
// Shift+Enter -> new line
|
||||
if (!e.shiftKey) {
|
||||
e.preventDefault();
|
||||
@ -352,7 +349,7 @@ function main() {
|
||||
};
|
||||
|
||||
usernameInput.addEventListener('keydown', function(e) {
|
||||
if (e.keyCode === KEYCODE_RETURN) {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if (sessionId === null) {
|
||||
vm.usernameError = 'Not connected to server';
|
||||
@ -371,7 +368,7 @@ function main() {
|
||||
}
|
||||
});
|
||||
usernameInput.addEventListener('keyup', function(e) {
|
||||
if (e.keyCode === KEYCODE_RETURN) {
|
||||
if (e.key === 'Enter') {
|
||||
return;
|
||||
}
|
||||
var usernameValue = usernameInput.value.trim();
|
||||
@ -514,9 +511,9 @@ function onGameJoined(message) {
|
||||
var playerOne = game.playerOne.username;
|
||||
var playerTwo = game.playerTwo.username;
|
||||
|
||||
var message = playerTwo + ' joined ' + playerOne + "'s game"
|
||||
console.log(message);
|
||||
addChatAnnouncement(message);
|
||||
var chatMessage = playerTwo + ' joined ' + playerOne + "'s game"
|
||||
console.log(chatMessage);
|
||||
addChatAnnouncement(chatMessage);
|
||||
|
||||
var vueGame = null;
|
||||
for (var i = 0; i < vm.games.length; i++) {
|
||||
@ -555,7 +552,7 @@ function onGameLeft(message) {
|
||||
if (gameLeaver === vm.username) {
|
||||
vm.myGame = null;
|
||||
}
|
||||
if (previousPlayers.indexOf(vm.username) != -1) {
|
||||
if (previousPlayers.indexOf(vm.username) !== -1) {
|
||||
vm.opponentUsername = null;
|
||||
vm.lastWord = null;
|
||||
vm.repaint();
|
||||
|
@ -5,8 +5,8 @@
|
||||
<title>Lingo</title>
|
||||
<link rel="stylesheet" href="layout.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="//cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/@stomp/stompjs@5.2.0/bundles/stomp.umd.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/@stomp/stompjs@5.4.4/bundles/stomp.umd.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="vue-app" v-cloak>
|
||||
|
Loading…
x
Reference in New Issue
Block a user