refactor: fix ts-check complaints; remove gtag
This commit is contained in:
parent
369d530978
commit
d03f218d42
1 changed files with 16 additions and 34 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
import {
|
import {
|
||||||
LeaderBoardService,
|
LeaderBoardService,
|
||||||
LoggerService,
|
LoggerService,
|
||||||
|
@ -75,10 +77,11 @@ export const Minesweeper = function(appId) {
|
||||||
headingElement.innerText = `Minesweeper v${VERSION}`;
|
headingElement.innerText = `Minesweeper v${VERSION}`;
|
||||||
gameBoard.setAttribute('id', 'game-board');
|
gameBoard.setAttribute('id', 'game-board');
|
||||||
gameBoard.append(initializeToolbar(), grid, initializeFootbar());
|
gameBoard.append(initializeToolbar(), grid, initializeFootbar());
|
||||||
|
if(appElement) {
|
||||||
appElement.innerHTML = '';
|
appElement.innerHTML = '';
|
||||||
appElement.append(headingElement, gameBoard);
|
appElement.append(headingElement, gameBoard);
|
||||||
appElement.append(initializeSourceLink());
|
appElement.append(initializeSourceLink());
|
||||||
|
}
|
||||||
generateGrid();
|
generateGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +99,7 @@ export const Minesweeper = function(appId) {
|
||||||
const title = `Best Times (${setting.name})`;
|
const title = `Best Times (${setting.name})`;
|
||||||
leaderBoard.update(setting.name, leaderWrapper, title);
|
leaderBoard.update(setting.name, leaderWrapper, title);
|
||||||
|
|
||||||
appElement.append(leaderWrapper);
|
appElement?.append(leaderWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeFootbar() {
|
function initializeFootbar() {
|
||||||
|
@ -259,9 +262,11 @@ export const Minesweeper = function(appId) {
|
||||||
gameStatus.value = 'inactive';
|
gameStatus.value = 'inactive';
|
||||||
grid.setAttributeNode(gameStatus);
|
grid.setAttributeNode(gameStatus);
|
||||||
|
|
||||||
|
if (appElement) {
|
||||||
appElement.style.minWidth = '260px';
|
appElement.style.minWidth = '260px';
|
||||||
appElement.style.width = `${grid.offsetWidth + 40}px`;
|
appElement.style.width = `${grid.offsetWidth + 40}px`;
|
||||||
appElement.style.margin = '0 auto';
|
appElement.style.margin = '0 auto';
|
||||||
|
}
|
||||||
|
|
||||||
if (!CASUAL_MODE) {
|
if (!CASUAL_MODE) {
|
||||||
initializeLeaderBoard();
|
initializeLeaderBoard();
|
||||||
|
@ -271,14 +276,6 @@ export const Minesweeper = function(appId) {
|
||||||
updateFlagsCountDisplay();
|
updateFlagsCountDisplay();
|
||||||
addMines(setting.mines);
|
addMines(setting.mines);
|
||||||
|
|
||||||
// send google analytics event
|
|
||||||
if (gtag) {
|
|
||||||
gtag('event', 'mw-event', {
|
|
||||||
'event_category' : 'mw-game',
|
|
||||||
'event_label' : 'loaded-game'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBusy() {
|
function setBusy() {
|
||||||
|
@ -326,8 +323,7 @@ export const Minesweeper = function(appId) {
|
||||||
|
|
||||||
function initializeEventHandlers(_cell) {
|
function initializeEventHandlers(_cell) {
|
||||||
|
|
||||||
let cell = document.createElement('td');
|
let cell = _cell;
|
||||||
cell = _cell;
|
|
||||||
skip = false;
|
skip = false;
|
||||||
skipCondition = false;
|
skipCondition = false;
|
||||||
|
|
||||||
|
@ -398,7 +394,7 @@ export const Minesweeper = function(appId) {
|
||||||
skipCondition = false;
|
skipCondition = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isBusy && typeof e === 'object' && e.button != '2') {
|
if (!isBusy && typeof e === 'object' && e.button != 2) {
|
||||||
mouseUpCallBackArray[e.button].call(_this, this);
|
mouseUpCallBackArray[e.button].call(_this, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -539,13 +535,6 @@ export const Minesweeper = function(appId) {
|
||||||
leaderBoard.send(game, 'time');
|
leaderBoard.send(game, 'time');
|
||||||
}
|
}
|
||||||
|
|
||||||
// send google analytics event
|
|
||||||
if (gtag) {
|
|
||||||
gtag('event', 'mw-event', {
|
|
||||||
'event_category' : 'mw-game',
|
|
||||||
'event_label' : 'ended-game'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleWinRevelation(cell) {
|
function handleWinRevelation(cell) {
|
||||||
|
@ -704,13 +693,6 @@ export const Minesweeper = function(appId) {
|
||||||
grid.setAttribute('game-status', 'active');
|
grid.setAttribute('game-status', 'active');
|
||||||
// start timer
|
// start timer
|
||||||
timerService.start();
|
timerService.start();
|
||||||
// send google analytics event
|
|
||||||
if (gtag) {
|
|
||||||
gtag('event', 'mw-event', {
|
|
||||||
'event_category' : 'mw-game',
|
|
||||||
'event_label' : 'activated-game'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gameIsDone() {
|
function gameIsDone() {
|
||||||
|
@ -896,7 +878,7 @@ export const Minesweeper = function(appId) {
|
||||||
} else {
|
} else {
|
||||||
updateCellValue(cell, mineCount.toString());
|
updateCellValue(cell, mineCount.toString());
|
||||||
const dataValue = document.createAttribute('data-value');
|
const dataValue = document.createAttribute('data-value');
|
||||||
dataValue.value = mineCount;
|
dataValue.value = mineCount.toString();
|
||||||
cell.setAttributeNode(dataValue);
|
cell.setAttributeNode(dataValue);
|
||||||
}
|
}
|
||||||
//Count and display the number of adjacent mines
|
//Count and display the number of adjacent mines
|
||||||
|
|
Loading…
Reference in a new issue