Commit initial

Chargement des données en local
This commit is contained in:
2026-06-01 11:17:21 +02:00
parent 9a66b93c95
commit 20baa91611
72 changed files with 29436 additions and 0 deletions

View File

@@ -0,0 +1,358 @@
/* ============================================
CONFIGURATION AVANCÉE (OPTIONNEL)
Personnalisez le jeu selon vos besoins
============================================ */
/**
* CONFIGURATION GLOBALE
* Décommentez et modifiez les valeurs selon vos besoins
*/
// ============================================
// 1. ANALYTICS (Backend)
// ============================================
// Si vous avez un serveur pour collecter les analytics
// window.ANALYTICS_ENDPOINT = 'https://votre-api.com/analytics';
// Activer/désactiver les analytics
// window.ANALYTICS_ENABLED = true;
// ============================================
// 2. PERSONNALISATION VISUELLE
// ============================================
// Couleur dominante (remplacer --teal par une autre variable)
// Changez dans memory-game.css : :root { --couleur-dominante: ... }
// Dark mode auto (selon les préférences système)
// Déjà géré avec @media (prefers-color-scheme: dark)
// ============================================
// 3. COMPORTEMENT DU JEU
// ============================================
// Désactiver les sons (si ajoutés plus tard)
// window.SOUND_ENABLED = false;
// Désactiver les animations pour accessibilité
// window.REDUCE_MOTION = true;
// (Détecté automatiquement avec prefers-reduced-motion)
// ============================================
// 4. DURÉES DE TRANSITION
// ============================================
// Durée du flip de carte (ms)
// const FLIP_DURATION = 1200;
// Délai avant vérification d'une paire (ms)
// const MATCH_CHECK_DELAY = 1200;
// ============================================
// 5. LIMITES DE STOCKAGE
// ============================================
// Nombre maximum de scores à conserver
// const MAX_SCORES = 100;
// Taille maximale du localStorage (bytes)
// const MAX_STORAGE_SIZE = 5242880; // 5MB
// ============================================
// 6. INTÉGRATION CMS
// ============================================
// URL de callback après fin de jeu (optionnel)
// window.ON_GAME_COMPLETE_CALLBACK = function(gameData) {
// // Envoyer les données au CMS
// fetch('/api/game-complete', {
// method: 'POST',
// body: JSON.stringify(gameData)
// });
// };
// URL pour les récompenses (certifications, badges)
// window.REWARDS_API = 'https://votre-api.com/rewards';
// ============================================
// 7. MODES PERSONNALISÉS
// ============================================
// Ajouter des niveaux supplémentaires
// DIFFICULTY_MODES.custom = {
// name: "Mon Niveau",
// paires: 6,
// timeLimit: 240,
// scoreMultiplier: 1.5,
// description: "Description personnalisée"
// };
// ============================================
// 8. ACHIEVEMENTS PERSONNALISÉS
// ============================================
// Ajouter des achievements
// ACHIEVEMENTS.custom = {
// id: 'custom_achievement',
// name: '🎖 Mon Achievement',
// icon: '🎖',
// description: 'Description',
// condition: (moves, time, pairs, difficulty) => {
// // Votre condition
// return true;
// }
// };
// ============================================
// 9. STYLES PERSONNALISÉS
// ============================================
// Exemple : Charger une police personnalisée
// const link = document.createElement('link');
// link.href = 'https://fonts.googleapis.com/css2?family=..';
// link.rel = 'stylesheet';
// document.head.appendChild(link);
// Exemple : Ajouter un CSS personnalisé
// const style = document.createElement('style');
// style.textContent = `
// :root {
// --custom-color: #FF0000;
// }
// `;
// document.head.appendChild(style);
// ============================================
// 10. WEBHOOKS & ÉVÉNEMENTS
// ============================================
// Fonction callback au démarrage du jeu
// window.ON_GAME_START = function(difficulty) {
// console.log('Jeu démarré en mode:', difficulty);
// };
// Fonction callback à la fin du jeu
// window.ON_GAME_END = function(gameData) {
// console.log('Jeu terminé:', gameData);
// // Faire quelque chose (rediriger, afficher popup, etc.)
// };
// Fonction callback pour chaque match réussi
// window.ON_PAIR_MATCHED = function(pictogrammeId) {
// console.log('Paire trouvée:', pictogrammeId);
// };
// ============================================
// 11. TRADUCTION & LOCALISATION
// ============================================
// Dictionnaire de traduction (exemple pour l'espagnol)
// const TRANSLATIONS = {
// en: {
// 'memory-title': 'Memory Game',
// 'score': 'Score',
// 'time': 'Time'
// },
// es: {
// 'memory-title': 'Juego de Memoria',
// 'score': 'Puntuación',
// 'time': 'Tiempo'
// }
// };
// ============================================
// 12. DONNÉES UTILISATEUR & RGPD
// ============================================
// Pseudo anonyme au lieu du nom complet
// window.ANONYMOUS_MODE = true;
// Acceptation RGPD requise
// window.GDPR_CONSENT_REQUIRED = true;
// Politique de confidentialité
// window.PRIVACY_POLICY_URL = 'https://votre-site.com/privacy';
// ============================================
// 13. INTÉGRATION LMS (Moodle, Canvas, etc.)
// ============================================
// Paramètres SCORM pour intégration LMS
// window.SCORM_ENABLED = false;
// window.SCORM_API_URL = 'https://lms.example.com/scorm';
// Passer les scores au LMS
// window.ON_GAME_COMPLETE = function(score) {
// if (window.SCORM_ENABLED && window.parent && window.parent.postMessage) {
// window.parent.postMessage({
// type: 'game_score',
// score: score
// }, '*');
// }
// };
// ============================================
// 14. DEBUGGING & MONITORING
// ============================================
// Mode debug global
// localStorage.setItem('nextgn_debug', 'true');
// Profiling des performances
// window.ENABLE_PERFORMANCE_MONITORING = true;
// Logs dans la console (au lieu de localStorage)
// window.DEBUG_TO_CONSOLE = true;
// ============================================
// 15. EXEMPLE DE CONFIGURATION COMPLÈTE
// ============================================
/*
// Configuration pour établissement scolaire
window.GAME_CONFIG = {
mode: 'classroom',
classroom_id: 'CLASS-001',
teacher_email: 'prof@ecole.edu',
// Colorier selon établissement
schoolColors: {
primary: '#1D9E75',
secondary: '#FF9800'
},
// Analytics vers serveur école
analyticsEndpoint: 'https://ecole.edu/api/analytics',
// Logo de l'école
schoolLogo: 'https://ecole.edu/logo.png',
// Branding
appName: 'Memory Pictogrammes - École XYZ',
// Récompenses (badges)
rewardsEnabled: true,
rewardsAPI: 'https://ecole.edu/api/rewards',
// Leaderboard public pour la classe
clashroomLeaderboard: true,
// Rapport pour professeur
reportingEnabled: true,
reportAPI: 'https://ecole.edu/api/teacher-reports'
};
*/
// ============================================
// HELPERS POUR CONFIGURATION
// ============================================
/**
* Charger une configuration personnalisée depuis un fichier JSON
* Exemple : config.json
*/
function loadCustomConfig(configUrl) {
fetch(configUrl)
.then(response => response.json())
.then(config => {
Object.assign(window.GAME_CONFIG || {}, config);
console.log('Configuration chargée:', config);
})
.catch(err => console.error('Erreur chargement config:', err));
}
/**
* Appliquer des styles personnalisés
*/
function applyCustomStyles(styleObject) {
const root = document.documentElement;
Object.keys(styleObject).forEach(key => {
root.style.setProperty(`--${key}`, styleObject[key]);
});
}
/**
* Enregistrer un hook personnalisé
*/
function registerHook(hookName, callback) {
if (!window._hooks) window._hooks = {};
window._hooks[hookName] = callback;
}
/**
* Exécuter un hook
*/
function executeHook(hookName, ...args) {
if (window._hooks && window._hooks[hookName]) {
return window._hooks[hookName](...args);
}
}
// ============================================
// EXEMPLE D'UTILISATION
// ============================================
/*
// Dans votre HTML ou un script chargé avant memory-game.js :
// 1. Charger une config personnalisée
loadCustomConfig('/config.json');
// 2. Appliquer des styles personnalisés
applyCustomStyles({
'teal': '#0F6E56',
'primary-color': '#185FA5'
});
// 3. Enregistrer des hooks
registerHook('onGameComplete', function(gameData) {
console.log('Jeu terminé!', gameData);
// Envoyer au serveur, ouvrir un formulaire, etc.
});
// 4. Exécuter le hook
executeHook('onGameComplete', { score: 2500, difficulty: 'normal' });
*/
// ============================================
// AUTO-CONFIGURATION (Détection d'environnement)
// ============================================
(function detectEnvironment() {
// Détecter si nous sommes dans un iFrame (LMS, CMS)
if (window.self !== window.top) {
console.log('Running in iFrame');
window.IN_IFRAME = true;
}
// Détecter les paramètres URL
const params = new URLSearchParams(window.location.search);
if (params.has('debug')) {
localStorage.setItem('nextgn_debug', 'true');
}
if (params.has('difficulty')) {
window.DEFAULT_DIFFICULTY = params.get('difficulty');
}
if (params.has('player')) {
localStorage.setItem('nextgn_playerName', params.get('player'));
}
// Détecter le thème sombre
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
console.log('Système en mode sombre');
}
// Détecter la langue
const lang = navigator.language || navigator.userLanguage;
window.BROWSER_LANG = lang.split('-')[0];
console.log('Langue du navigateur:', lang);
})();
// ============================================
// FIN DE LA CONFIGURATION
// ============================================
console.log('✓ Configuration avancée chargée');