beginning admin api

This commit is contained in:
AlecM33
2022-07-04 15:08:47 -04:00
parent f57cbc44bd
commit 3796aab81b
13 changed files with 166 additions and 28 deletions

View File

@@ -2,9 +2,15 @@ import { DeckStateManager } from '../modules/DeckStateManager.js';
import { GameCreationStepManager } from '../modules/GameCreationStepManager.js';
import { injectNavbar } from '../modules/Navbar.js';
import createTemplate from '../view_templates/CreateTemplate.js';
import { io } from 'socket.io-client';
import { toast } from '../modules/Toast';
const create = () => {
injectNavbar();
const socket = io();
socket.on('broadcast', (message) => {
toast(message, 'warning', true, false);
});
document.getElementById('game-creation-container').innerHTML = createTemplate;
const deckManager = new DeckStateManager();
const gameCreationStepManager = new GameCreationStepManager(deckManager);

View File

@@ -34,6 +34,9 @@ const game = () => {
UserUtility.validateAnonUserSignature(res.content)
);
});
socket.on('broadcast', (message) => {
toast(message, 'warning', true, false);
});
socket.on('connect_error', (err) => {
toast(err, 'error', true, false);
});

View File

@@ -1,8 +1,13 @@
import { XHRUtility } from '../modules/XHRUtility.js';
import { toast } from '../modules/Toast.js';
import { injectNavbar } from '../modules/Navbar.js';
import { io } from 'socket.io-client';
const home = () => {
const socket = io();
socket.on('broadcast', (message) => {
toast(message, 'warning', true, false);
});
injectNavbar();
document.getElementById('join-form').addEventListener('submit', attemptToJoinGame);
};

View File

@@ -1,6 +1,14 @@
import { injectNavbar } from '../modules/Navbar.js';
import { io } from 'socket.io-client';
import { toast } from '../modules/Toast';
const howToUse = () => { injectNavbar(); };
const howToUse = () => {
injectNavbar();
const socket = io();
socket.on('broadcast', (message) => {
toast(message, 'warning', true, false);
});
};
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = howToUse;

View File

@@ -3,9 +3,14 @@ import { toast } from '../modules/Toast.js';
import { XHRUtility } from '../modules/XHRUtility.js';
import { UserUtility } from '../modules/UserUtility.js';
import { globals } from '../config/globals.js';
import { io } from 'socket.io-client';
const join = () => {
injectNavbar();
const socket = io();
socket.on('broadcast', (message) => {
toast(message, 'warning', true, false);
});
const splitUrl = window.location.pathname.split('/join/');
const accessCode = splitUrl[1];
if (/^[a-zA-Z0-9]+$/.test(accessCode) && accessCode.length === globals.ACCESS_CODE_LENGTH) {

View File

@@ -1,6 +1,14 @@
import { injectNavbar } from '../modules/Navbar.js';
import { io } from 'socket.io-client';
import { toast } from '../modules/Toast';
const notFound = () => { injectNavbar(); };
const notFound = () => {
injectNavbar();
const socket = io();
socket.on('broadcast', (message) => {
toast(message, 'warning', true, false);
});
};
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = notFound;