fix(ui): fix app click URL interpolation via data-url attribute
This commit is contained in:
parent
a12d860523
commit
863b87ffb7
2 changed files with 4 additions and 3 deletions
|
|
@ -285,8 +285,9 @@ templ launcherJS() {
|
|||
let longPressTimer = null;
|
||||
let currentUrl = null;
|
||||
|
||||
function openApp(url) { window.open(url, "_blank"); } function openAppEl() {
|
||||
window.open(url, '_blank');
|
||||
function openApp() {
|
||||
var url = this.getAttribute('data-url');
|
||||
if (url) window.open(url, '_blank');
|
||||
}
|
||||
|
||||
function startLongPress(e, url) {
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ func launcherJS() templ.Component {
|
|||
templ_7745c5c3_Var20 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<script type=\"text/javascript\">\n\t\tlet longPressTimer = null;\n\t\tlet currentUrl = null;\n\n\t\tfunction openApp(url) { window.open(url, \"_blank\"); } function openAppEl() {\n\t\t\twindow.open(url, '_blank');\n\t\t}\n\n\t\tfunction startLongPress(e, url) {\n\t\t\tcurrentUrl = url || null;\n\t\t\tlongPressTimer = setTimeout(function() {\n\t\t\t\tshowPWA();\n\t\t\t}, 600);\n\t\t}\n\n\t\tfunction cancelLongPress() {\n\t\t\tif (longPressTimer) {\n\t\t\t\tclearTimeout(longPressTimer);\n\t\t\t\tlongPressTimer = null;\n\t\t\t}\n\t\t}\n\n\t\tfunction showPWA() {\n\t\t\tdocument.getElementById('pwa-overlay').style.display = 'flex';\n\t\t}\n\n\t\tfunction closePWA() {\n\t\t\tdocument.getElementById('pwa-overlay').style.display = 'none';\n\t\t}\n\n\t\tfunction toggleUserMenu(e) {\n\t\t\te.stopPropagation();\n\t\t\tdocument.getElementById('userDropdown').classList.toggle('show');\n\t\t}\n\t\tdocument.addEventListener('click', function() {\n\t\t\tvar d = document.getElementById('userDropdown');\n\t\t\tif (d) d.classList.remove('show');\n\t\t});\n\n\t\twindow.showSettings = function() {\n\t\t\tdocument.getElementById('settings-overlay').classList.add('open');\n\t\t\tdocument.getElementById('settings-drawer').classList.add('open');\n\t\t\tdocument.getElementById('userDropdown').classList.remove('show');\n\t\t\tdocument.getElementById('setting-lang').value = localStorage.getItem('lang')||'en';\n\t\t\tdocument.getElementById('setting-tz').value = localStorage.getItem('tz')||'UTC';\n\t\t};\n\t\tfunction closeSettings() {\n\t\t\tdocument.getElementById('settings-overlay').classList.remove('open');\n\t\t\tdocument.getElementById('settings-drawer').classList.remove('open');\n\t\t}\n\n\t\tfunction saveSettings() {\n\t\t\tlocalStorage.setItem('lang', document.getElementById('setting-lang').value);\n\t\t\tlocalStorage.setItem('tz', document.getElementById('setting-tz').value);\n\t\t\tcloseSettings();\n\t\t}\n\n\t\t// PWA install handler\n\t\tlet deferredPrompt = null;\n\t\twindow.addEventListener('beforeinstallprompt', function(e) {\n\t\t\te.preventDefault();\n\t\t\tdeferredPrompt = e;\n\t\t});\n\n\t\t// Override showPWA to try native prompt first\n\t\tdocument.addEventListener('DOMContentLoaded', function() {\n\t\t\tvar origShowPWA = showPWA;\n\t\t\tshowPWA = function() {\n\t\t\t\tif (deferredPrompt) {\n\t\t\t\t\tdeferredPrompt.prompt();\n\t\t\t\t\tdeferredPrompt.userChoice.then(function() { deferredPrompt = null; });\n\t\t\t\t} else {\n\t\t\t\t\torigShowPWA();\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t</script>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<script type=\"text/javascript\">\n\t\tlet longPressTimer = null;\n\t\tlet currentUrl = null;\n\n\t\tfunction openApp() {\n\t\t\tvar url = this.getAttribute('data-url');\n\t\t\tif (url) window.open(url, '_blank');\n\t\t}\n\n\t\tfunction startLongPress(e, url) {\n\t\t\tcurrentUrl = url || null;\n\t\t\tlongPressTimer = setTimeout(function() {\n\t\t\t\tshowPWA();\n\t\t\t}, 600);\n\t\t}\n\n\t\tfunction cancelLongPress() {\n\t\t\tif (longPressTimer) {\n\t\t\t\tclearTimeout(longPressTimer);\n\t\t\t\tlongPressTimer = null;\n\t\t\t}\n\t\t}\n\n\t\tfunction showPWA() {\n\t\t\tdocument.getElementById('pwa-overlay').style.display = 'flex';\n\t\t}\n\n\t\tfunction closePWA() {\n\t\t\tdocument.getElementById('pwa-overlay').style.display = 'none';\n\t\t}\n\n\t\tfunction toggleUserMenu(e) {\n\t\t\te.stopPropagation();\n\t\t\tdocument.getElementById('userDropdown').classList.toggle('show');\n\t\t}\n\t\tdocument.addEventListener('click', function() {\n\t\t\tvar d = document.getElementById('userDropdown');\n\t\t\tif (d) d.classList.remove('show');\n\t\t});\n\n\t\twindow.showSettings = function() {\n\t\t\tdocument.getElementById('settings-overlay').classList.add('open');\n\t\t\tdocument.getElementById('settings-drawer').classList.add('open');\n\t\t\tdocument.getElementById('userDropdown').classList.remove('show');\n\t\t\tdocument.getElementById('setting-lang').value = localStorage.getItem('lang')||'en';\n\t\t\tdocument.getElementById('setting-tz').value = localStorage.getItem('tz')||'UTC';\n\t\t};\n\t\tfunction closeSettings() {\n\t\t\tdocument.getElementById('settings-overlay').classList.remove('open');\n\t\t\tdocument.getElementById('settings-drawer').classList.remove('open');\n\t\t}\n\n\t\tfunction saveSettings() {\n\t\t\tlocalStorage.setItem('lang', document.getElementById('setting-lang').value);\n\t\t\tlocalStorage.setItem('tz', document.getElementById('setting-tz').value);\n\t\t\tcloseSettings();\n\t\t}\n\n\t\t// PWA install handler\n\t\tlet deferredPrompt = null;\n\t\twindow.addEventListener('beforeinstallprompt', function(e) {\n\t\t\te.preventDefault();\n\t\t\tdeferredPrompt = e;\n\t\t});\n\n\t\t// Override showPWA to try native prompt first\n\t\tdocument.addEventListener('DOMContentLoaded', function() {\n\t\t\tvar origShowPWA = showPWA;\n\t\t\tshowPWA = function() {\n\t\t\t\tif (deferredPrompt) {\n\t\t\t\t\tdeferredPrompt.prompt();\n\t\t\t\t\tdeferredPrompt.userChoice.then(function() { deferredPrompt = null; });\n\t\t\t\t} else {\n\t\t\t\t\torigShowPWA();\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t</script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue