This commit is contained in:
Zsolt Ero
2025-10-22 12:42:58 +02:00
parent cd76d94aac
commit f2161e868d
2 changed files with 23 additions and 9 deletions

View File

@@ -20,7 +20,6 @@
type="text" type="text"
id="line1" 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" 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"
placeholder="underscore,colon,name,latin"
/> />
</div> </div>
@@ -32,7 +31,6 @@
type="text" type="text"
id="line2" 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" 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"
placeholder="nonlatin"
/> />
</div> </div>
@@ -44,7 +42,6 @@
type="text" type="text"
id="lang" 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" 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"
placeholder="en"
maxlength="5" maxlength="5"
/> />
</div> </div>
@@ -85,4 +82,4 @@
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script> <script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
<script src="mix.js"></script> <script src="mix.js"></script>
</body> </body>
</html> </html>

View File

@@ -25,11 +25,10 @@ map.on('load', () => {
url.searchParams.set('lang', 'en') url.searchParams.set('lang', 'en')
window.history.replaceState({}, '', url) window.history.replaceState({}, '', url)
} }
syncInputsFromParams() syncInputsFromParams()
applyConfiguration() applyConfiguration()
initializeInputListeners() initializeInputListeners()
initializeModal() // initializeModal()
}) })
// ============================================ // ============================================
@@ -37,9 +36,16 @@ map.on('load', () => {
// ============================================ // ============================================
function initializeInputListeners() { function initializeInputListeners() {
line1Input.addEventListener('input', updateParamsFromInputs) const debouncedApplyConfig = debounce(applyConfiguration, 1000)
line2Input.addEventListener('input', updateParamsFromInputs)
langInput.addEventListener('input', updateParamsFromInputs) const handleInput = () => {
updateParamsFromInputs()
debouncedApplyConfig()
}
line1Input.addEventListener('input', handleInput)
line2Input.addEventListener('input', handleInput)
langInput.addEventListener('input', handleInput)
} }
function initializeModal() { function initializeModal() {
@@ -135,6 +141,17 @@ function modifyStyle({ style, line1Config, line2Config, langCode }) {
// 5. UTILITY FUNCTIONS // 5. UTILITY FUNCTIONS
// ============================================ // ============================================
function debounce(func, delay) {
let timeoutId
return function (...args) {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => {
func.apply(this, args)
}, delay)
}
}
function parseParams() { function parseParams() {
const params = new URLSearchParams(window.location.search) const params = new URLSearchParams(window.location.search)
return { return {