mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-18 17:16:04 +00:00
* Remove jQuery * Remove browser (vendor) prefixes for some CSS properties * Use simple device orientation test * Realign D-pad pointers * Make GameBoy text unselectable * Cleanup console.log * Keep 90% size on mobile browsers due to gh-ribbon overlap * Remove legacy `unselectable="on"` attributes * Align UI buttons * Remove not used UI elements * Change Options button * Don't show player change message when not in a game * Add click/touch handler for circle-pad
46 lines
986 B
JavaScript
Vendored
46 lines
986 B
JavaScript
Vendored
/**
|
|
* App UI message module.
|
|
*
|
|
* @version 1
|
|
*/
|
|
const message = (() => {
|
|
const popupBox = document.getElementById('noti-box');
|
|
|
|
// fifo queue
|
|
let queue = [];
|
|
const queueMaxSize = 5;
|
|
|
|
let isScreenFree = true;
|
|
|
|
const _popup = () => {
|
|
// recursion edge case:
|
|
// no messages in the queue or one on the screen
|
|
if (!(queue.length > 0 && isScreenFree)) {
|
|
return;
|
|
}
|
|
|
|
isScreenFree = false;
|
|
popupBox.innerText = queue.shift();
|
|
gui.anim.fadeInOut(popupBox, 1000, .05).finally(() => {
|
|
isScreenFree = true;
|
|
_popup();
|
|
})
|
|
}
|
|
|
|
const _storeMessage = (text) => {
|
|
if (queue.length <= queueMaxSize) {
|
|
queue.push(text);
|
|
}
|
|
}
|
|
|
|
const _proceed = (text) => {
|
|
_storeMessage(text);
|
|
_popup();
|
|
}
|
|
|
|
const show = utils.throttle(_proceed, 1000);
|
|
|
|
return Object.freeze({
|
|
show: show
|
|
})
|
|
})(document, gui, utils);
|