From 0c9cdfa8bf93acb038ea62dc3da6db691acb9d9f Mon Sep 17 00:00:00 2001 From: SpamNeko Date: Mon, 15 May 2017 01:01:04 +0100 Subject: [PATCH] Sorting arrows on table headers (#504) * Sorting arrows on table headers * Better arrows and seperate S/L/D columns --- public/css/style.css | 12 ++++++++++++ router/templateFunctions.go | 19 +++++++++++++++++++ templates/home.html | 20 ++++++++++---------- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 8d34bb88..dfb5f837 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -136,6 +136,18 @@ tr.torrent-info td.date { border-top: 1px solid #ddd; } +th a:hover { + text-decoration: none; +} + +.sortarrowleft { + letter-spacing: -0.6rem; +} + +.sortarrowdim { + opacity: 0.25; +} + div.container div.blockBody:nth-of-type(2) table{table-layout:fixed;} div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:first-of-type, div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:nth-of-type(5){width:10%;} div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:nth-of-type(3){width:15%;} diff --git a/router/templateFunctions.go b/router/templateFunctions.go index d1e5ae73..0a480c9e 100644 --- a/router/templateFunctions.go +++ b/router/templateFunctions.go @@ -57,6 +57,25 @@ var FuncMap = template.FuncMap{ return template.URL(url.String()) }, + "genSortArrows": func(currentUrl url.URL, sortBy string) template.HTML { + values := currentUrl.Query() + leftclass := "sortarrowdim" + rightclass := "sortarrowdim" + + if _, ok := values["order"]; ok { + if values["sort"][0] == sortBy { + if values["order"][0] == "true" { + rightclass = "" + } else { + leftclass = "" + } + } + } + + arrows := "" + + return template.HTML(arrows) + }, "genNav": func(nav Navigation, currentUrl *url.URL, pagesSelectable int) template.HTML { var ret = "" if nav.TotalItem > 0 { diff --git a/templates/home.html b/templates/home.html index 4720bb62..4473475c 100644 --- a/templates/home.html +++ b/templates/home.html @@ -13,16 +13,14 @@ - - - - + + + + + {{ range .ListTorrents}} @@ -41,7 +39,9 @@ {{.Name}} - + + +
- {{T "name"}} + + {{T "name"}}{{ genSortArrows .URL "1" }}