Nicer handling of dead tabs, introduced version.

This commit is contained in:
Magnus Åhall 2025-11-10 10:02:34 +01:00
parent 0c0811a5fc
commit 5a15824ed5
3 changed files with 26 additions and 11 deletions

View file

@ -16,6 +16,8 @@ import (
"strings" "strings"
) )
const VERSION = "v1"
var ( var (
flagVerbose bool flagVerbose bool
flagWsURL string flagWsURL string
@ -70,7 +72,11 @@ func pageIndex(w http.ResponseWriter, r *http.Request) { // {{{
return return
} }
tmpl.Execute(w, sites) data := map[string]any{
"Sites": sites,
"VERSION": VERSION,
}
tmpl.Execute(w, data)
} // }}} } // }}}
func pageCSS(w http.ResponseWriter, r *http.Request) { // {{{ func pageCSS(w http.ResponseWriter, r *http.Request) { // {{{
w.Header().Add("Content-Type", "text/css") w.Header().Add("Content-Type", "text/css")

View file

@ -3,6 +3,12 @@ body {
margin: 32px; margin: 32px;
} }
#version {
position: absolute;
right: 16px;
top: 16px;
}
input { input {
font-size: 1em; font-size: 1em;
} }

View file

@ -44,8 +44,9 @@
for (const uuid of Object.keys(json.Sites)) { for (const uuid of Object.keys(json.Sites)) {
const site = json.Sites[uuid] const site = json.Sites[uuid]
if (site.StopLoop) { if (site.StopLoop) {
document.querySelector(`.url[data-uuid="${uuid}"]`)?.classList.add('dead') const els = document.querySelectorAll(`[data-uuid="${uuid}"]`)
document.querySelector(`.watch[data-uuid="${uuid}"]`)?.classList.add('dead') for (const el of els)
el.remove()
} }
} }
}) })
@ -64,6 +65,7 @@
</script> </script>
<body> <body>
<div id="version">{{ .VERSION }}</div>
<div class="browser"> <div class="browser">
<h1>Browser</h1> <h1>Browser</h1>
<input type="text" class="user-data-dir" placeholder="~/.local/share/chrome-dev"> <input type="text" class="user-data-dir" placeholder="~/.local/share/chrome-dev">
@ -81,14 +83,15 @@
<input type="text" class="new watch" placeholder="~/example.com/css/"> <input type="text" class="new watch" placeholder="~/example.com/css/">
<button onclick="newSite()">Start</button> <button onclick="newSite()">Start</button>
{{ range . }} {{ range .Sites }}
{{ if .StopLoop }} {{ if .StopLoop }}
{{ continue }} {{ continue }}
{{ end }} {{ end }}
<div class="line"></div> <div class="line" data-uuid="{{ .UUID }}"></div>
<div class="url {{ if .StopLoop }}dead{{ end }}" data-uuid="{{ .UUID }}">{{ .URL }}</div> <div class="url" data-uuid="{{ .UUID }}">{{ .URL }}</div>
<div class="watch {{ if .StopLoop }}dead{{ end }}" data-uuid="{{ .UUID }}">{{ .Watch }}</div> <div class="watch" data-uuid="{{ .UUID }}">{{ .Watch }}</div>
<div class="stop" onclick="stopSite('{{ .UUID }}')">{{ if not .StopLoop }}❌{{ end }}</div> <div class="stop" onclick="stopSite('{{ .UUID }}')" data-uuid="{{ .UUID }}">{{ if not .StopLoop }}❌{{
end }}</div>
{{ end }} {{ end }}
</div> </div>
<script>init()</script> <script>init()</script>