diff --git a/.gitignore b/.gitignore index 65ca5ca2..d51c8f46 100644 --- a/.gitignore +++ b/.gitignore @@ -125,3 +125,7 @@ static/locales/* # No docker-compose.yml files docker-compose.yml + +static/css/themes/* +!static/css/themes/default.css +!static/css/themes/*.css.example \ No newline at end of file diff --git a/src/routes/ui.js b/src/routes/ui.js index 32a498e3..b9c2d031 100644 --- a/src/routes/ui.js +++ b/src/routes/ui.js @@ -105,6 +105,9 @@ const handlePage = async (req, res) => { await updateAvailableForms(config.icons); data.available_icon_styles_json = JSON.stringify(config.icons); + const themes = await getAvailableThemes(); + data.available_themes_json = JSON.stringify(themes); + // Build available items list const availableItems = [-1, -2, -3, -4, -5, -6, -7, -8]; //const keys = Object.keys(InventoryItemId); @@ -115,11 +118,7 @@ const handlePage = async (req, res) => { data.available_items_json = JSON.stringify(availableItems); // Build available areas list - const areas = []; - const areaKeys = Object.keys(config.areas).sort(); - areaKeys.forEach(key => { - areas.push({ 'area': key }); - }); + const areas = Object.keys(config.areas).sort().map(x => { return { 'area': x }; }); data.areas = areas; // Available raid boss filters @@ -188,8 +187,8 @@ const handlePage = async (req, res) => { } if (city) { - for (let i = 0; i < areaKeys.length; i++) { - const key = areaKeys[i]; + for (let i = 0; i < areas.length; i++) { + const key = areas[i]; if (city.toLowerCase() === key.toLowerCase()) { const area = config.areas[key]; lat = parseFloat(area.lat); @@ -239,6 +238,24 @@ const getAvailableTileservers = () => { return tileservers; }; +const getAvailableThemes = async () => { + const themes = {}; + const themesDir = path.resolve(__dirname, '../../static/css/themes'); + const files = await fs.promises.readdir(themesDir); + if (files) { + files.forEach(file => { + const ext = path.extname(file); + if (ext !== '.css') { + return; + } + let name = path.basename(file, ext); + name = name.charAt(0).toUpperCase() + name.slice(1); + themes[name] = `/css/themes/${file}`; + }); + } + return themes; +}; + const updateAvailableForms = async (icons) => { for (const icon of Object.values(icons)) { if (icon.path.startsWith('/')) { diff --git a/src/views/header.mustache b/src/views/header.mustache index 555932fd..584587ff 100644 --- a/src/views/header.mustache +++ b/src/views/header.mustache @@ -19,6 +19,7 @@ + diff --git a/src/views/index.mustache b/src/views/index.mustache index 98d44eb2..aff793d8 100644 --- a/src/views/index.mustache +++ b/src/views/index.mustache @@ -49,6 +49,7 @@ const availableItems = {{{available_items_json}}}; const availableTileservers = {{{available_tileservers_json}}}; const availableIconStyles = {{{available_icon_styles_json}}}; + const availableThemes = {{{available_themes_json}}}; const availableRaidBosses = {{{available_raid_bosses_json}}}; const availableQuestRewards = {{{available_quest_rewards_json}}}; const availableNestPokemon = {{{available_nest_pokemon_json}}}; @@ -818,7 +819,7 @@
@@ -909,4 +914,4 @@ -{{> footer}} +{{> footer}} \ No newline at end of file diff --git a/src/views/navbar.mustache b/src/views/navbar.mustache index 7916e24f..abf4c8e5 100644 --- a/src/views/navbar.mustache +++ b/src/views/navbar.mustache @@ -1,4 +1,4 @@ -