fix for game ages not updating in selection box
This commit is contained in:
parent
bb4c77b995
commit
f68ec55d60
|
|
@ -1006,12 +1006,30 @@ $(function (){
|
||||||
</div>
|
</div>
|
||||||
`).appendTo(gameSelectContent);
|
`).appendTo(gameSelectContent);
|
||||||
|
|
||||||
|
var selectBoxIntervalID = undefined;
|
||||||
var selectBox = new jBox('Modal', {
|
var selectBox = new jBox('Modal', {
|
||||||
content: gameSelectContent,
|
content: gameSelectContent,
|
||||||
blockScroll: false,
|
blockScroll: false,
|
||||||
blockScrollAdjust: false,
|
blockScrollAdjust: false,
|
||||||
isolateScroll: false,
|
isolateScroll: false,
|
||||||
delayClose: 750,
|
delayClose: 750,
|
||||||
|
onOpen() {
|
||||||
|
if (selectBoxIntervalID !== undefined) {
|
||||||
|
clearInterval(selectBoxIntervalID);
|
||||||
|
}
|
||||||
|
selectBoxIntervalID = setInterval(() => {
|
||||||
|
updateTileAges();
|
||||||
|
}, 15000);
|
||||||
|
updateTileAges();
|
||||||
|
},
|
||||||
|
onCloseComplete() {
|
||||||
|
if (selectBoxIntervalID !== undefined) {
|
||||||
|
clearInterval(selectBoxIntervalID);
|
||||||
|
selectBoxIntervalID = undefined;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
position: { x: 'center', y: 'center' },
|
||||||
|
reposition: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.new-game-tile').on('click', function() {
|
$('.new-game-tile').on('click', function() {
|
||||||
|
|
@ -1027,10 +1045,10 @@ $(function (){
|
||||||
return `${words[n] || n} ${n === 1 ? singular : (plural || (singular + 's'))}`;
|
return `${words[n] || n} ${n === 1 ? singular : (plural || (singular + 's'))}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTileAges(tiles) {
|
function updateTileAges() {
|
||||||
const now = +new Date();
|
const now = +new Date();
|
||||||
|
|
||||||
for (const tileElem of (tiles || $('.game-tile.existing-game'))) {
|
for (const tileElem of $('.game-tile.existing-game-tile')) {
|
||||||
const tile = $(tileElem);
|
const tile = $(tileElem);
|
||||||
|
|
||||||
const game = tile.data('gameMeta');
|
const game = tile.data('gameMeta');
|
||||||
|
|
@ -1058,8 +1076,6 @@ $(function (){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setInterval(() => { updateTileAges(); }, 15000);
|
|
||||||
|
|
||||||
function updateSelectGameMeta(data, gameId) {
|
function updateSelectGameMeta(data, gameId) {
|
||||||
data = Object.assign({}, data, {
|
data = Object.assign({}, data, {
|
||||||
gameId: gameId || data.gameId,
|
gameId: gameId || data.gameId,
|
||||||
|
|
@ -1118,7 +1134,6 @@ $(function (){
|
||||||
}
|
}
|
||||||
|
|
||||||
$('<div></div>').addClass('game-tile-age').appendTo(tile);
|
$('<div></div>').addClass('game-tile-age').appendTo(tile);
|
||||||
updateTileAges(tile);
|
|
||||||
|
|
||||||
tile.on('click', function() {
|
tile.on('click', function() {
|
||||||
$('.game-tile-selected').removeClass('game-tile-selected');
|
$('.game-tile-selected').removeClass('game-tile-selected');
|
||||||
|
|
@ -1135,6 +1150,7 @@ $(function (){
|
||||||
return (then_a < then_b) ? 1 : (then_a === then_b) ? 0 : -1;
|
return (then_a < then_b) ? 1 : (then_a === then_b) ? 0 : -1;
|
||||||
});
|
});
|
||||||
$(list).appendTo(gameTiles);
|
$(list).appendTo(gameTiles);
|
||||||
|
updateTileAges();
|
||||||
|
|
||||||
tile.show("fold");
|
tile.show("fold");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue