new file: .env.example
new file: .gitignore new file: Dockerfile new file: README.md new file: app.py new file: app/__init__.py new file: app/game.py new file: app/models.py new file: app/routes.py new file: app/seed.py new file: data/movies.json new file: docker-compose.yml new file: requirements.txt new file: static/css/style.css new file: static/js/game.js new file: static/js/player.js new file: templates/index.html
This commit is contained in:
36
static/js/player.js
Normal file
36
static/js/player.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// Spieler-Verwaltung (Nickname -> player_id in localStorage)
|
||||
const PlayerStore = (() => {
|
||||
const KEY = "filmdle_player";
|
||||
const STREAK_KEY = "filmdle_streaks";
|
||||
|
||||
function save(player) {
|
||||
localStorage.setItem(KEY, JSON.stringify(player));
|
||||
}
|
||||
|
||||
function load() {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(KEY));
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getStreaks() {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(STREAK_KEY));
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function setStreaks(streaks) {
|
||||
localStorage.setItem(STREAK_KEY, JSON.stringify(streaks));
|
||||
}
|
||||
|
||||
function clear() {
|
||||
localStorage.removeItem(KEY);
|
||||
localStorage.removeItem(STREAK_KEY);
|
||||
}
|
||||
|
||||
return { save, load, getStreaks, setStreaks, clear };
|
||||
})();
|
||||
Reference in New Issue
Block a user