-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from deanblackborough/main
Show player scores
- Loading branch information
Showing
12 changed files
with
241 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(function (axios) { | ||
'use strict' | ||
|
||
let game_id = document.getElementById('game_id'); | ||
|
||
let sleep = time => new Promise(resolve => setTimeout(resolve, time)) | ||
let poll = (promiseFn, time) => promiseFn().then( | ||
sleep(time).then(() => poll(promiseFn, time))) | ||
|
||
let fetchPlayerScores = function() { | ||
let player_scores = document.querySelector('div.player-scores'); | ||
|
||
axios.get('/game/' + game_id.value + '/player-scores') | ||
.then(response => { | ||
if (response.data.length > 0) { | ||
player_scores.innerHTML = response.data; | ||
} | ||
}); | ||
} | ||
|
||
poll(() => new Promise(() => fetchPlayerScores()), 1000 * 30) | ||
})(axios); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(function (axios) { | ||
'use strict' | ||
|
||
let token = document.getElementById('token'); | ||
|
||
let sleep = time => new Promise(resolve => setTimeout(resolve, time)) | ||
let poll = (promiseFn, time) => promiseFn().then( | ||
sleep(time).then(() => poll(promiseFn, time))) | ||
|
||
let fetchPlayerScores = function() { | ||
let player_scores = document.querySelector('div.player-scores'); | ||
|
||
axios.get('/public/game/' + token.value + '/player-scores') | ||
.then(response => { | ||
if (response.data.length > 0) { | ||
player_scores.innerHTML = response.data; | ||
} | ||
}); | ||
} | ||
|
||
poll(() => new Promise(() => fetchPlayerScores()), 1000 * 30) | ||
})(axios); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div class="table-responsive"> | ||
|
||
<hr /> | ||
|
||
<h2 class="text-primary">Player Scores</h2> | ||
|
||
<table class="table table-striped table-sm"> | ||
<caption>Player scores, delayed by thirty seconds.</caption> | ||
<thead> | ||
<tr> | ||
<th scope="col">Name</th> | ||
<th scope="col">Score</th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-group-divider"> | ||
@foreach($scores as $__score) | ||
<tr> | ||
<th scope="row">{{ $__score['name'] }}</th> | ||
<td>{{ $__score['score'] }}</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.