From: Paul Hänsch Date: Mon, 16 Jul 2018 18:14:21 +0000 (+0200) Subject: enabled complete filter reuse X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=503565a7be2813fcf8eba25c542b8e21d29c8d1c;p=serve0 enabled complete filter reuse --- diff --git a/style.css b/style.css index 05d278f..d735b8b 100644 --- a/style.css +++ b/style.css @@ -17,6 +17,8 @@ select { border: 1px solid; padding: .125em .5em; } +select[multiple] { padding: 0; } +select[multiple] option { padding: .25em .5em; } body { color: white; diff --git a/widgets.sh b/widgets.sh index 81807c0..158df4b 100644 --- a/widgets.sh +++ b/widgets.sh @@ -60,6 +60,9 @@ w_index(){ } w_advsearch(){ + local n lbid tag category tn filter f + filter="${FILTER}^" + printf '[form #advsearch action=?a=advsearch method=POST [a href="#" Hide] [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.[br] @@ -68,31 +71,45 @@ w_advsearch(){ ' "$w_refuri" for n in 1 2 3 4 5 6 7 8 9 10; do + f="${filter%%^*}"; filter="${filter#*^}" + lbid="$(HTML "cat_${n}_(none)")" - printf '[input .and type=checkbox name=and id="and_%i"][label for="and_%i" +and + printf '[input .and type=checkbox name=and id="and_%i" %s][label for="and_%i" +and ][fieldset .select - [input .pol type="radio" name=pol_%i id="pol_pos_%i"][label for=pol_pos_%i Any] - [input .pol type="radio" name=pol_%i id="pol_neg_%i"][label for=pol_neg_%i None] + [input .pol type="radio" name=pol_%i %s id="pol_pos_%i"][label for=pol_pos_%i Any] + [input .pol type="radio" name=pol_%i %s id="pol_neg_%i"][label for=pol_neg_%i None] [label .head Category:] - [input .cat type=radio name="cat_%i" id="%s" ][label for="%s" %s] - [select name=tag_%s size=10 multiple' \ - $n $n $n $n $n $n $n $n \ - $n "$lbid" "$lbid" "(none)" $n + [input .cat type=radio name="cat_%i" %s id="%s" ][label for="%s" %s] + [select name=tag_%s size=10 multiple="multiple"' \ + $n "$([ "$f" ] && printf 'checked="checked"')" $n \ + $n "$([ "$f" -a \! "${f%%~*}" ] || printf 'checked="checked"')" $n $n \ + $n "$([ "$f" -a \! "${f%%~*}" ] && printf 'checked="checked"')" $n $n \ + $n "$([ "$f" = "${f%:*}" ] && printf 'checked="checked"')" "$lbid" "$lbid" "(none)" \ + $n + + f="|${f#~}|" printf %s "$w_tags" |grep -vF ":" \ | while read -r tag; do [ ! "$tag" ] && continue - printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "$tag")" + tg="$(HTML "$tag")" + printf '[option %s value="%s" %s]' \ + "$([ "$f" != "${f%|${tag}|*}" ] && printf 'selected="selected"')" \ + "$tg" "$tg" done printf ']' printf %s "$w_tags" |cut -sd: -f1 |sort -u \ | while read -r category; do lbid="$(HTML "cat_${n}_${category}")" - printf '[input .cat type=radio name="cat_%i" id="%s" [label for="%s" %s]] - [select name=tag_%s size=10 multiple' $n "$lbid" "$lbid" "$(HTML "$category")" $n + printf '[input .cat type=radio name="cat_%i" %s id="%s"][label for="%s" %s] + [select name=tag_%s size=10 multiple="multiple"' \ + $n "$([ "$f" != "${f%|${category}:*}" ] && printf 'checked="checked"')" \ + "$lbid" "$lbid" "$(HTML "$category")" $n printf %s "$w_tags" |grep -wF "${category}" \ | while read -r tag; do - tag="$(HTML "$tag")"; tn="${tag#*:}" - printf '[option value="%s" %s]' "$tag" "$tn" + tg="$(HTML "$tag")"; tn="${tg#*:}" + printf '[option %s value="%s" %s]' \ + "$([ "$f" != "${f%|${tag}|*}" ] && printf 'selected="selected"')" \ + "$tg" "$tn" done printf ']' done