Initial commit
This commit is contained in:
67
js/config.js
Normal file
67
js/config.js
Normal file
@@ -0,0 +1,67 @@
|
||||
// config.js
|
||||
import { getEnv, waitForEnv } from './env-loader.js';
|
||||
|
||||
// Initialize environment variables
|
||||
let envInitialized = false;
|
||||
let initPromise = null;
|
||||
|
||||
// Function to ensure environment variables are loaded
|
||||
export async function ensureEnvLoaded() {
|
||||
if (envInitialized) return;
|
||||
|
||||
if (!initPromise) {
|
||||
initPromise = waitForEnv().then(() => {
|
||||
envInitialized = true;
|
||||
console.log('Environment variables loaded in config.js');
|
||||
});
|
||||
}
|
||||
|
||||
return initPromise;
|
||||
}
|
||||
|
||||
// Initialize immediately
|
||||
ensureEnvLoaded();
|
||||
|
||||
// Direct access to environment variables (synchronous, may return default values if called too early)
|
||||
export function getPublicVapidKey() {
|
||||
return getEnv('PUBLIC_VAPID_KEY');
|
||||
}
|
||||
|
||||
export function getBackendUrl() {
|
||||
return getEnv('BACKEND_URL');
|
||||
}
|
||||
|
||||
export const FLIC_BUTTON_ID = 'game-button'; // Example ID, might need configuration
|
||||
export const LOCAL_STORAGE_KEY = 'gameTimerData';
|
||||
|
||||
// Default player settings
|
||||
export const DEFAULT_PLAYER_TIME_SECONDS = 300; // 5 minutes
|
||||
export const DEFAULT_PLAYERS = [
|
||||
{ id: 1, name: 'Player 1', timeInSeconds: DEFAULT_PLAYER_TIME_SECONDS, remainingTime: DEFAULT_PLAYER_TIME_SECONDS, image: null },
|
||||
{ id: 2, name: 'Player 2', timeInSeconds: DEFAULT_PLAYER_TIME_SECONDS, remainingTime: DEFAULT_PLAYER_TIME_SECONDS, image: null }
|
||||
];
|
||||
|
||||
// CSS Classes (optional, but can help consistency)
|
||||
export const CSS_CLASSES = {
|
||||
ACTIVE_PLAYER: 'active-player',
|
||||
INACTIVE_PLAYER: 'inactive-player',
|
||||
TIMER_ACTIVE: 'timer-active',
|
||||
TIMER_FINISHED: 'timer-finished',
|
||||
MODAL_ACTIVE: 'active',
|
||||
CAMERA_ACTIVE: 'active'
|
||||
};
|
||||
|
||||
// Game States
|
||||
export const GAME_STATES = {
|
||||
SETUP: 'setup',
|
||||
RUNNING: 'running',
|
||||
PAUSED: 'paused',
|
||||
OVER: 'over'
|
||||
};
|
||||
|
||||
// Flic Actions
|
||||
export const FLIC_ACTIONS = {
|
||||
SINGLE_CLICK: 'SingleClick',
|
||||
DOUBLE_CLICK: 'DoubleClick',
|
||||
HOLD: 'Hold'
|
||||
};
|
||||
Reference in New Issue
Block a user