diff options
author | jbion <joffrey.bion@amadeus.com> | 2017-01-20 19:47:42 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2017-01-20 19:47:42 +0100 |
commit | d3e7b73e1d30c4a5082a279599ec337a14df3609 (patch) | |
tree | 68300d9b7983e10652df6030c536843dedb4c48a /backend | |
parent | Move frontend and backend into 2 separate subprojects (diff) | |
download | seven-wonders-d3e7b73e1d30c4a5082a279599ec337a14df3609.tar.gz seven-wonders-d3e7b73e1d30c4a5082a279599ec337a14df3609.tar.bz2 seven-wonders-d3e7b73e1d30c4a5082a279599ec337a14df3609.zip |
Remove conflicting old index
Diffstat (limited to 'backend')
-rw-r--r-- | backend/src/main/resources/static/app.js | 90 | ||||
-rw-r--r-- | backend/src/main/resources/static/index.html | 64 |
2 files changed, 0 insertions, 154 deletions
diff --git a/backend/src/main/resources/static/app.js b/backend/src/main/resources/static/app.js deleted file mode 100644 index 0d68d2ef..00000000 --- a/backend/src/main/resources/static/app.js +++ /dev/null @@ -1,90 +0,0 @@ -var stompClient = null; - -function setConnected(connected) { - $("#connect").prop("disabled", connected); - $("#disconnect").prop("disabled", !connected); - if (connected) { - $("#game-list").show(); - } else { - $("#game-list").hide(); - } - $("#greetings").html(""); -} - -function connect() { - var socket = new SockJS('/seven-wonders-websocket'); - stompClient = Stomp.over(socket); - stompClient.connect({}, function (frame) { - setConnected(true); - console.log('Connected: ' + frame); - - stompClient.subscribe('/user/queue/errors', function (msg) { - var error = JSON.parse(msg.body); - console.error(error); - }); - - stompClient.subscribe('/topic/games', function (msg) { - var games = JSON.parse(msg.body); - console.log("Received new games: " + games); - for (var i = 0; i < games.length; i++) { - addNewGame(games[i]); - } - }); - - stompClient.subscribe('/user/queue/join-game', function (msg) { - var game = JSON.parse(msg.body); - console.log("Joined game: " + game); - addNewPlayer(game); - }); - }); -} - -function disconnect() { - if (stompClient !== null) { - stompClient.disconnect(); - } - setConnected(false); - console.log("Disconnected"); -} - -function sendCreateGame(gameName, playerName) { - stompClient.send("/app/lobby/create-game", {}, JSON.stringify({ - 'gameName': gameName, - 'playerName': playerName - })); -} - -function sendJoinGame(gameName, playerName) { - stompClient.send("/app/lobby/join-game", {}, JSON.stringify({ - 'gameName': gameName, - 'playerName': playerName - })); -} - -function addNewGame(game) { - console.log(game); - $("#game-list-content").append('<tr><td>' + game.name + '</td><td><button id="join-' + game.id + - '" type="submit">Join</button></td></tr>'); - $("#join-" + game.id).click(function () { - sendJoinGame(game.name, $("#player-name-field").val()); - }); -} - -function addNewPlayer(player) { - console.log(player); -} - -$(function () { - $("form").on('submit', function (e) { - e.preventDefault(); - }); - $("#connect").click(function () { - connect(); - }); - $("#disconnect").click(function () { - disconnect(); - }); - $("#create-game").click(function () { - sendCreateGame($("#game-name-field").val(), $("#player-name-field").val()); - }); -});
\ No newline at end of file diff --git a/backend/src/main/resources/static/index.html b/backend/src/main/resources/static/index.html deleted file mode 100644 index d5ec178d..00000000 --- a/backend/src/main/resources/static/index.html +++ /dev/null @@ -1,64 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Seven Wonders</title> - <link href="/webjars/bootstrap/css/bootstrap.min.css" rel="stylesheet"> - <link href="/main.css" rel="stylesheet"> - <script src="/webjars/jquery/jquery.min.js"></script> - <script src="/webjars/sockjs-client/sockjs.min.js"></script> - <script src="/webjars/stomp-websocket/stomp.min.js"></script> - <script src="app.js"></script> -</head> -<body> -<noscript> - <h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websocket relies on Javascript being - enabled. Please enable Javascript and reload this page!</h2> -</noscript> - -<h1>Seven Wonders</h1> - -<p>This is a stub index page for the project, for the sake of vertical completeness. We will soon get to work on it!</p> - -<a href="test.html">Go to WS test page</a> - - -<h2>Connection</h2> - -<form class="form-inline"> - <div class="form-group"> - <label for="connect">WebSocket connection:</label> - <button id="connect" class="btn btn-default" type="submit">Connect</button> - <button id="disconnect" class="btn btn-default" type="submit" disabled="disabled">Disconnect</button> - </div> -</form> - -<h2>Games</h2> - -<form class="form-inline"> - <div class="form-group"> - <label for="player-name-field">Player name</label> - <input id="player-name-field"> - </div> -</form> - -<table id="game-list" class="table table-striped"> - <thead> - <tr> - <th>Id</th> - <th></th> - </tr> - </thead> - <tbody id="game-list-content"> - </tbody> -</table> - -<form class="form-inline"> - <div class="form-group"> - <label for="game-name-field">Game name</label> - <input id="game-name-field"> - <button id="create-game" class="btn btn-default" type="submit">Create</button> - </div> -</form> - -</body> -</html>
\ No newline at end of file |