organized modules
This commit is contained in:
parent
6a9fc1e1c7
commit
1ed4884100
16 changed files with 20 additions and 78 deletions
2
ayo.js
2
ayo.js
|
@ -1,4 +1,4 @@
|
||||||
import { LeaderBoardService } from './src/services/leader-board.service.js';
|
import { LeaderBoardService } from './src/modules/leader-board/leader-board';
|
||||||
|
|
||||||
const leaderBoard = new LeaderBoardService('mw-leaders', 'mw-all');
|
const leaderBoard = new LeaderBoardService('mw-leaders', 'mw-all');
|
||||||
|
|
||||||
|
|
10
src/index.js
10
src/index.js
|
@ -1,15 +1,7 @@
|
||||||
/*
|
|
||||||
Author: Ayo Ayco
|
|
||||||
Email: ramon.aycojr@gmail.com
|
|
||||||
Website: AyoAyco.com
|
|
||||||
Blog: FullHacker.com
|
|
||||||
Live: games.fullhacker.com/minesweeper
|
|
||||||
*/
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import './services/loading/loading.css';
|
import './modules/loading/loading.css';
|
||||||
import './assets/favicon.ico';
|
import './assets/favicon.ico';
|
||||||
import { Minesweeper } from './minesweeper.js';
|
import { Minesweeper } from './minesweeper.js';
|
||||||
|
|
||||||
/** start the game **/
|
|
||||||
const myMinesweeper = new Minesweeper();
|
const myMinesweeper = new Minesweeper();
|
||||||
myMinesweeper.initialize();
|
myMinesweeper.initialize();
|
|
@ -1,20 +1,12 @@
|
||||||
/*
|
|
||||||
Author: Ayo Ayco
|
|
||||||
Email: ramon.aycojr@gmail.com
|
|
||||||
Website: AyoAyco.com
|
|
||||||
Blog: FullHacker.com
|
|
||||||
Live: games.fullhacker.com/minesweeper
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
LeaderBoardService,
|
LeaderBoardService,
|
||||||
LoggerService,
|
LoggerService,
|
||||||
StorageService,
|
StorageService,
|
||||||
TimerService
|
TimerService
|
||||||
} from './services';
|
} from './modules';
|
||||||
import { levels } from './levels.js';
|
import { levels } from './levels.js';
|
||||||
|
|
||||||
const VERSION = "0.3.7";
|
const VERSION = "0.3.8";
|
||||||
const MOBILE_BUSY_DELAY = 250;
|
const MOBILE_BUSY_DELAY = 250;
|
||||||
const PC_BUSY_DELAY = 500;
|
const PC_BUSY_DELAY = 500;
|
||||||
const TEST_MODE = false;
|
const TEST_MODE = false;
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'firebase/firestore';
|
||||||
|
|
||||||
export class DatabaseService {
|
export class DatabaseService {
|
||||||
constructor() {
|
constructor() {
|
||||||
// Your web app's Firebase configuration
|
|
||||||
const config = {
|
const config = {
|
||||||
apiKey: "AIzaSyAbDzNHCSFh59e3r5sZA4_2ZHJnJ6SCCxM",
|
apiKey: "AIzaSyAbDzNHCSFh59e3r5sZA4_2ZHJnJ6SCCxM",
|
||||||
authDomain: "moment-188701.firebaseapp.com",
|
authDomain: "moment-188701.firebaseapp.com",
|
||||||
|
@ -13,7 +12,6 @@ export class DatabaseService {
|
||||||
messagingSenderId: "113827947104",
|
messagingSenderId: "113827947104",
|
||||||
appId: "1:113827947104:web:b176f746d8358302c51905"
|
appId: "1:113827947104:web:b176f746d8358302c51905"
|
||||||
};
|
};
|
||||||
// Initialize Firebase
|
|
||||||
firebase.initializeApp(config);
|
firebase.initializeApp(config);
|
||||||
this.store = firebase.firestore();
|
this.store = firebase.firestore();
|
||||||
}
|
}
|
|
@ -1,11 +1,3 @@
|
||||||
/*
|
|
||||||
Author: Ayo Ayco
|
|
||||||
Email: ramon.aycojr@gmail.com
|
|
||||||
Website: AyoAyco.com
|
|
||||||
Blog: FullHacker.com
|
|
||||||
Live: games.fullhacker.com/minesweeper
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const DialogService = function() {
|
export const DialogService = function() {
|
||||||
let isOpen = false;
|
let isOpen = false;
|
||||||
let isInitialized = false;
|
let isInitialized = false;
|
||||||
|
@ -16,7 +8,6 @@ export const DialogService = function() {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
container.className = 'dialog-container';
|
container.className = 'dialog-container';
|
||||||
|
|
||||||
// add dialog wrapper and container elements
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
const bodyElement = document.getElementsByTagName('body')[0];
|
const bodyElement = document.getElementsByTagName('body')[0];
|
||||||
wrapper.appendChild(container);
|
wrapper.appendChild(container);
|
0
src/modules/encryption/encryption.js
Normal file
0
src/modules/encryption/encryption.js
Normal file
9
src/modules/index.js
Normal file
9
src/modules/index.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export * from './database/db.js';
|
||||||
|
export * from './dialog/dialog.js';
|
||||||
|
export * from './encryption/encryption.js';
|
||||||
|
export * from './leader-board/leader-board.js';
|
||||||
|
export * from './loading/loading.js';
|
||||||
|
export * from './logger/logger.js';
|
||||||
|
export * from './storage/storage.js';
|
||||||
|
export * from './timer/timer.js';
|
||||||
|
export * from './user/user.js';
|
|
@ -1,7 +1,7 @@
|
||||||
import { DatabaseService } from "./db.service.js";
|
import { DatabaseService } from '../database/db';
|
||||||
import { TimerService } from "./timer.service.js";
|
import { TimerService } from '../timer/timer';
|
||||||
import { UserService } from "./user.service.js";
|
import { UserService } from '../user/user';
|
||||||
import { LoadingService } from "./loading/loading.js";
|
import { LoadingService } from '../loading/loading';
|
||||||
|
|
||||||
const dbService = new DatabaseService();
|
const dbService = new DatabaseService();
|
||||||
const timerService = new TimerService();
|
const timerService = new TimerService();
|
||||||
|
@ -63,6 +63,7 @@ export class LeaderBoardService {
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
}
|
}
|
||||||
this.lastPlace = Number.MAX_SAFE_INTEGER;
|
this.lastPlace = Number.MAX_SAFE_INTEGER;
|
||||||
|
// todo: use 'where' to filter by day, week, month, and all-time
|
||||||
this.topList = this.leaders.doc(level)
|
this.topList = this.leaders.doc(level)
|
||||||
.collection('games').orderBy('time').limit(10);
|
.collection('games').orderBy('time').limit(10);
|
||||||
this.unsubscribe = this.setListener(this.topList, displayElement, title);
|
this.unsubscribe = this.setListener(this.topList, displayElement, title);
|
||||||
|
@ -98,7 +99,7 @@ export class LeaderBoardService {
|
||||||
const name = game.data().name || 'Anonymous';
|
const name = game.data().name || 'Anonymous';
|
||||||
const item = document.createElement('div');
|
const item = document.createElement('div');
|
||||||
item.style.display = 'flex';
|
item.style.display = 'flex';
|
||||||
const nameElement =document.createElement('div'); // `<span class="ellipsis" title="${name}">${name}</span>` ;
|
const nameElement =document.createElement('div');
|
||||||
nameElement.innerHTML = name;
|
nameElement.innerHTML = name;
|
||||||
nameElement.setAttribute('title', name);
|
nameElement.setAttribute('title', name);
|
||||||
nameElement.style.textOverflow = 'ellipsis';
|
nameElement.style.textOverflow = 'ellipsis';
|
|
@ -1,11 +1,3 @@
|
||||||
/*
|
|
||||||
Author: Ayo Ayco
|
|
||||||
Email: ramon.aycojr@gmail.com
|
|
||||||
Website: AyoAyco.com
|
|
||||||
Blog: FullHacker.com
|
|
||||||
Live: games.fullhacker.com/minesweeper
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class LoggerService {
|
export class LoggerService {
|
||||||
debug(message, data) {
|
debug(message, data) {
|
||||||
if (typeof message === 'string') {
|
if (typeof message === 'string') {
|
|
@ -1,11 +1,3 @@
|
||||||
/*
|
|
||||||
Author: Ayo Ayco
|
|
||||||
Email: ramon.aycojr@gmail.com
|
|
||||||
Website: AyoAyco.com
|
|
||||||
Blog: FullHacker.com
|
|
||||||
Live: games.fullhacker.com/minesweeper
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class StorageService {
|
export class StorageService {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
|
@ -1,12 +1,4 @@
|
||||||
import { LoggerService } from "./logger.service.js";
|
import { LoggerService } from "../logger/logger";
|
||||||
|
|
||||||
/*
|
|
||||||
Author: Ayo Ayco
|
|
||||||
Email: ramon.aycojr@gmail.com
|
|
||||||
Website: AyoAyco.com
|
|
||||||
Blog: FullHacker.com
|
|
||||||
Live: games.fullhacker.com/minesweeper
|
|
||||||
*/
|
|
||||||
|
|
||||||
const INTERVAL = 1;
|
const INTERVAL = 1;
|
||||||
|
|
||||||
|
@ -30,7 +22,6 @@ export class TimerService {
|
||||||
start() {
|
start() {
|
||||||
if (this.running || !this.display) return;
|
if (this.running || !this.display) return;
|
||||||
|
|
||||||
// run timer
|
|
||||||
this.running = true;
|
this.running = true;
|
||||||
this.startTime = new Date().getTime();
|
this.startTime = new Date().getTime();
|
||||||
this.id = window.setInterval(() => this.updateDisplay(), INTERVAL);
|
this.id = window.setInterval(() => this.updateDisplay(), INTERVAL);
|
|
@ -1,8 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
Author: Ayo Ayco
|
|
||||||
Email: ramon.aycojr@gmail.com
|
|
||||||
Website: AyoAyco.com
|
|
||||||
Blog: FullHacker.com
|
|
||||||
Live: games.fullhacker.com/minesweeper
|
|
||||||
*/
|
|
|
@ -1,8 +0,0 @@
|
||||||
export * from './db.service';
|
|
||||||
export * from './dialog.service';
|
|
||||||
export * from './leader-board.service';
|
|
||||||
export * from './loading/loading';
|
|
||||||
export * from './logger.service';
|
|
||||||
export * from './storage.service';
|
|
||||||
export * from './timer.service';
|
|
||||||
export * from './user.service';
|
|
Loading…
Reference in a new issue