Define jQuery helper in head
This commit is contained in:
parent
e4da49b215
commit
76bc50355a
|
@ -28,5 +28,9 @@ templ Head() {
|
|||
if ctx.Value(c.EnvContextKey) == "development" {
|
||||
<script defer src="/js/hotreload.js"></script>
|
||||
}
|
||||
<script type="text/javascript">
|
||||
// helper functions
|
||||
var $ = selector => document.querySelector(selector)
|
||||
</script>
|
||||
</head>
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ templ Invoice(hash string, bolt11 string, msats int, expiresIn int, paid bool, r
|
|||
@InvoiceStatus(hash, expiresIn, paid, redirectUrl)
|
||||
<div class="none" id="bolt11-data" bolt11-data={ templ.JSONString(bolt11) } hx-preserve></div>
|
||||
<script type="text/javascript" id="bolt11-js" hx-preserve>
|
||||
var $ = selector => document.querySelector(selector)
|
||||
$("#close").addEventListener("click", function () {
|
||||
// abort in-flight polls and prevent new polls
|
||||
htmx.trigger("#poll", "htmx:abort")
|
||||
|
@ -42,7 +41,6 @@ templ InvoiceStatus(hash string, expiresIn int, paid bool, redirectUrl templ.Saf
|
|||
<!-- invoice is pending -->
|
||||
<div class="font-mono my-1" id="countdown" countdown-data={ templ.JSONString(expiresIn) } hx-preserve></div>
|
||||
<script type="text/javascript" id="countdown-js" hx-preserve>
|
||||
var $ = selector => document.querySelector(selector)
|
||||
var expiresIn = JSON.parse($("#countdown").getAttribute("countdown-data"))
|
||||
|
||||
function pad(num, places) {
|
||||
|
|
|
@ -13,7 +13,6 @@ templ Modal(component templ.Component) {
|
|||
@component
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var $ = selector => document.querySelector(selector)
|
||||
$("#close").addEventListener("click", function () {
|
||||
$("#modal").removeAttribute("class")
|
||||
$("#modal").setAttribute("class", "hidden")
|
||||
|
|
|
@ -26,7 +26,6 @@ templ Qr(value string, href string) {
|
|||
templ CopyButton(value string) {
|
||||
<div class="none" id="copy-data" copy-data={ templ.JSONString(value) } hx-preserve></div>
|
||||
<script type="text/javascript" id="copy-js" hx-preserve>
|
||||
var $ = selector => document.querySelector(selector)
|
||||
var value = JSON.parse($("#copy-data").getAttribute("copy-data"))
|
||||
$("#copy").onclick = function () {
|
||||
window.navigator.clipboard.writeText(value)
|
||||
|
|
Loading…
Reference in New Issue