This commit is contained in:
Zsolt Ero
2025-10-22 14:36:29 +02:00
parent ca337345f2
commit c4aecd01f6
7 changed files with 109 additions and 118 deletions

View File

@@ -1,15 +1,15 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenFreeMap Debug</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" />
</head>
<body>
</head>
<body>
<div id="map" class="w-full h-screen"></div>
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
<script src="colon.js"></script>
</body>
</body>
</html>

View File

@@ -1,106 +1,97 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenFreeMap Debug</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" />
</head>
<body class="flex flex-col h-screen">
</head>
<body class="flex flex-col h-screen">
<!-- UI Panel -->
<div class="bg-gray-900 border-b border-gray-700 shadow-md">
<div class="max-w-7xl mx-auto px-4 py-2">
<div class="flex items-center gap-3">
<div class="flex-1">
<label for="line1" class="block text-xs font-medium text-gray-400 mb-1">
Line 1
</label>
<input
type="text"
id="line1"
class="w-full px-3 py-1.5 text-sm border border-gray-600 rounded bg-gray-800 text-gray-100 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-mono"
/>
<input
type="text"
id="line1-expr"
readonly
class="w-full px-3 py-1 text-xs border border-gray-700 rounded bg-gray-950 text-gray-500 font-mono mt-1"
<div class="max-w-7xl mx-auto px-4 py-2">
<div class="flex items-center gap-3">
<div class="flex-1">
<label for="line1" class="block text-xs font-medium text-gray-400 mb-1"> Line 1 </label>
<input
type="text"
id="line1"
class="w-full px-3 py-1.5 text-sm border border-gray-600 rounded bg-gray-800 text-gray-100 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-mono"
/>
<input
type="text"
id="line1-expr"
readonly
class="w-full px-3 py-1 text-xs border border-gray-700 rounded bg-gray-900 text-gray-400 font-mono mt-1 cursor-default focus:outline-none focus:ring-0 focus:border-gray-700"
/>
</div>
/>
</div>
<div class="flex-1">
<label for="line2" class="block text-xs font-medium text-gray-400 mb-1"> Line 2 </label>
<input
type="text"
id="line2"
class="w-full px-3 py-1.5 text-sm border border-gray-600 rounded bg-gray-800 text-gray-100 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-mono"
/>
<input
type="text"
id="line2-expr"
readonly
class="w-full px-3 py-1 text-xs border border-gray-700 rounded bg-gray-900 text-gray-400 font-mono mt-1 cursor-default focus:outline-none focus:ring-0 focus:border-gray-700"
/>
</div>
<div class="flex-1">
<label for="line2" class="block text-xs font-medium text-gray-400 mb-1">
Line 2
</label>
<input
type="text"
id="line2"
class="w-full px-3 py-1.5 text-sm border border-gray-600 rounded bg-gray-800 text-gray-100 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-mono"
/>
<input
type="text"
id="line2-expr"
readonly
class="w-full px-3 py-1 text-xs border border-gray-700 rounded bg-gray-950 text-gray-500 font-mono mt-1"
<div class="w-24">
<label for="lang" class="block text-xs font-medium text-gray-400 mb-1"> Lang </label>
<input
type="text"
id="lang"
class="w-full px-3 py-1.5 text-sm border border-gray-600 rounded bg-gray-800 text-gray-100 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-mono text-center"
maxlength="5"
/>
</div>
/>
</div>
<div class="w-24">
<label for="lang" class="block text-xs font-medium text-gray-400 mb-1">
Lang
</label>
<input
type="text"
id="lang"
class="w-full px-3 py-1.5 text-sm border border-gray-600 rounded bg-gray-800 text-gray-100 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-mono text-center"
maxlength="5"
/>
</div>
<div class="pt-5 flex gap-2">
<button
id="shareBtn"
class="px-4 py-1.5 text-sm font-medium text-white bg-blue-600 rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900 transition-all"
>
Share
</button>
<button
id="resetBtn"
class="px-4 py-1.5 text-sm font-medium text-white bg-gray-700 rounded hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 focus:ring-offset-gray-900 transition-all"
>
Reset
</button>
</div>
</div>
<div class="pt-5 flex gap-2">
<button
id="shareBtn"
class="px-4 py-1.5 text-sm font-medium text-white bg-blue-600 rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900 transition-all"
>
Share
</button>
<button
id="resetBtn"
class="px-4 py-1.5 text-sm font-medium text-white bg-gray-700 rounded hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 focus:ring-offset-gray-900 transition-all"
>
Reset
</button>
</div>
</div>
</div>
</div>
<div id="map" class="flex-1"></div>
<!-- Modal Dialog -->
<div id="shareModal" class="hidden fixed inset-0 z-50">
<div id="modalOverlay" class="fixed inset-0 bg-black/50"></div>
<div class="fixed inset-0 flex items-center justify-center p-4">
<div class="relative bg-gray-800 rounded-lg p-8 max-w-md shadow-2xl">
<p class="text-gray-300 text-center leading-relaxed mb-6">
Your settings have been saved to the URL.<br>
Copy the address bar to share this map.
</p>
<button
id="closeModalBtn"
class="w-full py-2.5 text-sm text-white bg-gray-700 rounded hover:bg-gray-600 transition-all"
>
Close
</button>
</div>
<div id="modalOverlay" class="fixed inset-0 bg-black/50"></div>
<div class="fixed inset-0 flex items-center justify-center p-4">
<div class="relative bg-gray-800 rounded-lg p-8 max-w-md shadow-2xl">
<p class="text-gray-300 text-center leading-relaxed mb-6">
Your settings have been saved to the URL.<br />
Copy the address bar to share this map.
</p>
<button
id="closeModalBtn"
class="w-full py-2.5 text-sm text-white bg-gray-700 rounded hover:bg-gray-600 transition-all"
>
Close
</button>
</div>
</div>
</div>
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
<script src="mix.js"></script>
</body>
</html>
</body>
</html>

View File

@@ -63,7 +63,7 @@ function initializeModal() {
modal.classList.add('hidden')
})
document.addEventListener('keydown', (e) => {
document.addEventListener('keydown', e => {
if (e.key === 'Escape' && !modal.classList.contains('hidden')) {
modal.classList.add('hidden')
}
@@ -190,8 +190,8 @@ function buildFieldAccessor(config, langCode) {
const parts = []
const fields = config
.split(',')
.map((f) => f.trim())
.filter((f) => f)
.map(f => f.trim())
.filter(f => f)
for (const field of fields) {
if (field === 'underscore') {
@@ -210,4 +210,4 @@ function buildFieldAccessor(config, langCode) {
}
return parts.length > 0 ? ['coalesce', ...parts] : null
}
}

View File

@@ -1,15 +1,15 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenFreeMap Debug</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" />
</head>
<body>
</head>
<body>
<div id="map" class="w-full h-screen"></div>
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
<script src="params.js"></script>
</body>
</body>
</html>

View File

@@ -52,23 +52,23 @@ function applyLanguage() {
}
map.on('load', () => {
let langCode = getLanguageParam()
const langCode = getLanguageParam()
// Alert the URL param value on first load
alert(
`Language parameter: ${langCode || 'not set (defaulting to en)'}\n\n` +
'To change the map language, modify the ?lang= parameter in the URL.\n' +
'Labels will be RED when different.\n' +
'name_xx on line 1, name:xx on line 2'
'To change the map language, modify the ?lang= parameter in the URL.\n' +
'Labels will be RED when different.\n' +
'name_xx on line 1, name:xx on line 2',
)
// Add default param if not present
if (!langCode) {
const url = new URL(window.location)
url.searchParams.set('lang', 'en')
window.history.replaceState({}, '', url)
}
applyLanguage()
})

View File

@@ -1,15 +1,15 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenFreeMap Debug</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" />
</head>
<body>
</head>
<body>
<div id="map" class="w-full h-screen"></div>
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
<script src="switch.js"></script>
</body>
</body>
</html>

View File

@@ -23,4 +23,4 @@ const map = new maplibregl.Map({
map.on('load', () => {
console.log('Terrain map loaded')
})
})