Skip to content

Commit

Permalink
Confetti
Browse files Browse the repository at this point in the history
- Confetti
- Speed up saves
  • Loading branch information
deanblackborough committed Jul 24, 2022
1 parent d0ffcbe commit 94e60ba
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
19 changes: 15 additions & 4 deletions public/js/public-score-sheet.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function (axios, bootstrap) {
(function (axios, bootstrap, confetti) {
'use strict'

let token = document.getElementById('token');

let timeout = null;
let delay = 1500;
let delay = 1000;
let factors = { "ones": 1, "twos": 2, "threes": 3, "fours": 4, "fives": 5, "sixes": 6 }

let score_upper = document.getElementById('upper-score');
Expand Down Expand Up @@ -233,7 +233,18 @@
let display_toast = function (show_toast) {
if (show_toast !== 'none') {
const toast = new bootstrap.Toast(document.getElementById('toast_' + show_toast))
toast.show()
toast.show();

if (show_toast === 'yahtzee') {
confetti({
particleCount: 100,
})
}
if (show_toast.startsWith('yahtzee_bonus')) {
confetti({
particleCount: 500,
})
}
}
}

Expand Down Expand Up @@ -356,4 +367,4 @@
});
}, delay);
}
})(axios, bootstrap);
})(axios, bootstrap, confetti);
19 changes: 15 additions & 4 deletions public/js/score-sheet.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(function (axios, bootstrap) {
(function (axios, bootstrap, confetti) {
'use strict'

let game_id = document.getElementById('game_id');
let player_id = document.getElementById('player_id');

let timeout = null;
let delay = 1500;
let delay = 1000;
let factors = { "ones": 1, "twos": 2, "threes": 3, "fours": 4, "fives": 5, "sixes": 6 }

let score_upper = document.getElementById('upper-score');
Expand Down Expand Up @@ -238,7 +238,18 @@
let display_toast = function (show_toast) {
if (show_toast !== 'none') {
const toast = new bootstrap.Toast(document.getElementById('toast_' + show_toast))
toast.show()
toast.show();

if (show_toast === 'yahtzee') {
confetti({
particleCount: 100,
})
}
if (show_toast.startsWith('yahtzee_bonus')) {
confetti({
particleCount: 500,
})
}
}
}

Expand Down Expand Up @@ -369,4 +380,4 @@
});
}, delay);
}
})(axios, bootstrap);
})(axios, bootstrap, confetti);
1 change: 1 addition & 0 deletions resources/views/public-score-sheet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@
<x-toast />
<script src="{{ asset('node_modules/axios/dist/axios.min.js') }}" defer></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js" defer></script>
<script src="{{ asset('js/public-score-sheet.js?v0.7.0') }}" defer></script>
<script src="{{ asset('js/public-player-scores.js?v0.7.0') }}" defer></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions resources/views/score-sheet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@
<x-toast />
<script src="{{ asset('node_modules/axios/dist/axios.min.js') }}" defer></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js" defer></script>
<script src="{{ asset('js/score-sheet.js?v0.7.0') }}" defer></script>
<script src="{{ asset('js/player-scores.js?v0.7.0') }}" defer></script>
@endif
Expand Down

0 comments on commit 94e60ba

Please sign in to comment.