Spaces:
Sleeping
Sleeping
Joffrey Thomas
commited on
Commit
·
a3f099e
1
Parent(s):
6139d24
change
Browse files
chess_game/static/room.js
CHANGED
|
@@ -66,6 +66,7 @@
|
|
| 66 |
// chessboard.js prefers element id string in many setups
|
| 67 |
board = Chessboard('boardUI', {
|
| 68 |
position: 'start', draggable: true, dropOffBoard: 'snapback',
|
|
|
|
| 69 |
onDragStart, onDrop, onSnapEnd
|
| 70 |
});
|
| 71 |
await syncFromServer();
|
|
@@ -74,6 +75,7 @@
|
|
| 74 |
document.getElementById('startBtn').addEventListener('click', async () => {
|
| 75 |
const color = document.getElementById('color').value;
|
| 76 |
await getJSON(`${basePath}/room/${roomId}/start`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ player_color: color })});
|
|
|
|
| 77 |
await syncFromServer();
|
| 78 |
});
|
| 79 |
|
|
|
|
| 66 |
// chessboard.js prefers element id string in many setups
|
| 67 |
board = Chessboard('boardUI', {
|
| 68 |
position: 'start', draggable: true, dropOffBoard: 'snapback',
|
| 69 |
+
pieceTheme: 'https://cdnjs.cloudflare.com/ajax/libs/chessboard.js/1.0.0/img/chesspieces/wikipedia/{piece}.png',
|
| 70 |
onDragStart, onDrop, onSnapEnd
|
| 71 |
});
|
| 72 |
await syncFromServer();
|
|
|
|
| 75 |
document.getElementById('startBtn').addEventListener('click', async () => {
|
| 76 |
const color = document.getElementById('color').value;
|
| 77 |
await getJSON(`${basePath}/room/${roomId}/start`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ player_color: color })});
|
| 78 |
+
board.orientation(color);
|
| 79 |
await syncFromServer();
|
| 80 |
});
|
| 81 |
|
chess_game/templates/room.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<title>Chess Room {{ room_id }}</title>
|
| 6 |
<link rel="stylesheet" href="{{ base_path }}/static/style.css">
|
| 7 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chessboard.js/1.0.0/chessboard-1.0.0.min.css"
|
| 8 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 9 |
<style>
|
| 10 |
.layout { display: grid; grid-template-columns: 520px 1fr; gap: 16px; align-items: start; }
|
|
@@ -53,8 +53,8 @@
|
|
| 53 |
</div>
|
| 54 |
</div>
|
| 55 |
|
| 56 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.13.4/chess.min.js"
|
| 57 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chessboard.js/1.0.0/chessboard-1.0.0.min.js"
|
| 58 |
<script src="{{ base_path }}/static/room.js"></script>
|
| 59 |
</body>
|
| 60 |
</html>
|
|
|
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<title>Chess Room {{ room_id }}</title>
|
| 6 |
<link rel="stylesheet" href="{{ base_path }}/static/style.css">
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chessboard.js/1.0.0/chessboard-1.0.0.min.css" />
|
| 8 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 9 |
<style>
|
| 10 |
.layout { display: grid; grid-template-columns: 520px 1fr; gap: 16px; align-items: start; }
|
|
|
|
| 53 |
</div>
|
| 54 |
</div>
|
| 55 |
|
| 56 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.13.4/chess.min.js"></script>
|
| 57 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/chessboard.js/1.0.0/chessboard-1.0.0.min.js"></script>
|
| 58 |
<script src="{{ base_path }}/static/room.js"></script>
|
| 59 |
</body>
|
| 60 |
</html>
|