diff options
Diffstat (limited to 'internal/web')
| -rw-r--r-- | internal/web/server_test.go | 20 | ||||
| -rw-r--r-- | internal/web/templates/index.html | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 3bb5ea7..77dfe74 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -232,6 +232,26 @@ func TestServer(t *testing.T) { }) } +// TestBTHiddenForTraditional checks index.html's server-side initial-hidden +// state for the "bt" version checkbox: hidden (inline style) when the +// lectionary is traditional (bt is meaningless for missalemeum -- see +// render.EffectiveVersions), present and visible otherwise. This is +// presentation-only: it does not touch which versions actually load. +func TestBTHiddenForTraditional(t *testing.T) { + srv := NewServer(config.Default()) + trad := httptest.NewRecorder() + srv.ServeHTTP(trad, httptest.NewRequest("GET", "/?lectionary=traditional", nil)) + if !strings.Contains(trad.Body.String(), `id="ver-bt" style="display:none"`) { + t.Errorf("bt checkbox not hidden for traditional") + } + modern := httptest.NewRecorder() + srv.ServeHTTP(modern, httptest.NewRequest("GET", "/?lectionary=new", nil)) + b := modern.Body.String() + if !strings.Contains(b, `id="ver-bt">`) || strings.Contains(b, `id="ver-bt" style="display:none"`) { + t.Errorf("bt checkbox should be visible for modern") + } +} + func TestReaderDefault(t *testing.T) { srv := NewServer(config.Default()) rec := httptest.NewRecorder() diff --git a/internal/web/templates/index.html b/internal/web/templates/index.html index 26854a8..5dbe7da 100644 --- a/internal/web/templates/index.html +++ b/internal/web/templates/index.html @@ -33,14 +33,14 @@ </span> <label>{{.L.Lectionary}} - <select name="lectionary"> + <select name="lectionary" onchange="var b=document.getElementById('ver-bt');if(b)b.style.display=this.value==='traditional'?'none':'';"> <option value="new" {{if eq .Lectionary "new"}}selected{{end}}>{{.L.OptModern}}</option> <option value="traditional" {{if eq .Lectionary "traditional"}}selected{{end}}>{{.L.OptTraditional}}</option> </select> </label> {{range .VersionOpts}} - <label><input type="checkbox" name="v" value="{{.Code}}" {{if .Checked}}checked{{end}}> {{.Code}}</label> + <label id="ver-{{.Code}}"{{if and (eq .Code "bt") (eq $.Lectionary "traditional")}} style="display:none"{{end}}><input type="checkbox" name="v" value="{{.Code}}" {{if .Checked}}checked{{end}}> {{.Code}}</label> {{end}} <label>{{.L.Parts}} |
