X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=widgets.sh;h=f9c0380b740c6c0c856db3e7a20c2c6c5750e8ee;hb=0a576d1d2ce23eb3043adcd7adb7b45c89ba6051;hp=3142b4485aedbdeece2d7bd89a0c090c063f4fb3;hpb=bbf0a951d1ff6106d1d2dd8032333b1b1ccd67f2;p=serve0 diff --git a/widgets.sh b/widgets.sh index 3142b44..f9c0380 100644 --- a/widgets.sh +++ b/widgets.sh @@ -13,18 +13,23 @@ w_tags="$(find "$_DATA/" -path '*/.index/meta' -print0 \ w_tags="$(UNSTRING "$w_tags")" w_tagcategories="$(printf %s "$w_tags" |cut -sd: -f1 |sort -u)" +CHECK(){ [ "$1" = "$2" ] && printf checked; } + w_search(){ printf ' [form #search method=GET action=? [select name=o size=1 [option disabled=disabled Order By] - [option value=Name Name] - [option value=Date Date] - [option value=Length Length] + [option value=Name %s Name] + [option value=Date %s Date] + [option value=Length %s Length] ] [input name=s placeholder=Search value="%s"] ] ' \ + "$(CHECK "$ORDER" Name)" \ + "$(CHECK "$ORDER" Date)" \ + "$(CHECK "$ORDER" Length)" \ "$(HTML "$SEARCH")" } @@ -45,9 +50,9 @@ w_prefs(){ ] ' \ "$w_refuri" "$LISTSIZE" \ - "$([ "$mode" = index ] || printf checked)" \ - "$([ "$mode" = index ] && printf checked)" \ - "$([ "$fakemp4" = yes ] && printf checked)" + "$([ "$mode" = index ] || CHECK)" \ + "$(CHECK "$mode" index)" \ + "$(CHECK "$fakemp4" yes)" } w_index(){ @@ -69,8 +74,7 @@ w_advsearch(){ [a href="#" Hide] [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.[br] Refine the search further by setting additional search tags using the [strong "+and"] button.] - [hidden "ref" "%s"] - ' "$w_refuri" + ' for n in 1 2 3 4 5 6 7 8 9 10; do f="${filter%%^*}"; filter="${filter#*^}" @@ -78,29 +82,31 @@ w_advsearch(){ lbid="$(HTML "cat_${n}_(none)")" 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 %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] + [radio "pol_%i" "pos" .pol %s #pol_pos_%i"][label for=pol_pos_%i Any] + [radio "pol_%i" "neg" .pol %s #pol_neg_%i"][label for=pol_neg_%i None] [label .head Category:]' \ - $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" ] && printf checked)" $n \ + $n "$([ "$f" -a ! "${f%%~*}" ] || printf checked)" $n $n \ + $n "$([ "$f" -a ! "${f%%~*}" ] && printf checked)" $n $n f="|${f#~}|" printf '*\n%s\n' "$w_tagcategories" \ | while read -r category; do - lbid="$(HTML "cat_${n}_${category}")" - printf '[input .cat type=radio %s name="cat_%i" id="%s"][label for="%s" %s] - [select name=tag_%s size=10 multiple="multiple"' \ - "$([ ! "${f%%*|${category}:*}" -o ! "${category%\*}" ] && printf 'checked="checked"')" \ - $n "$lbid" "$lbid" "$(HTML "$category")" $n + catn="$(HTML "$category")" + lbid="cat_${n}_${catn}" + printf '[radio "cat_%i" "%s" .cat id="%s" %s][label for="%s" %s] + [select name=tag_%s size=10 multiple' \ + $n "$catn" "$lbid" \ + "$([ ! "${f%%*|${category}:*}" -o ! "${category%\*}" ] && printf checked)" \ + "$lbid" "$catn" $n printf %s "$w_tags" \ | { [ "$category" = '*' ] && grep -vF ':' || grep -wF "${category}"; } \ | while read -r tag; do [ ! "$tag" ] && continue tg="$(HTML "$tag")"; tn="${tg#*:}" - printf '[option %s value="%s" %s]' \ - "$([ ! "${f%%*|${tag}|*}" ] && printf 'selected="selected"')" \ + printf '[option %s value="%s"\n%s]' \ + "$([ ! "${f%%*|${tag}|*}" ] && printf selected)" \ "$tg" "$tn" done printf '\n]' @@ -110,11 +116,14 @@ w_advsearch(){ printf '[fieldset .submit [select name=order [option disabled=disabled Order By] - [option value=Name Name] - [option value=Date Date] - [option value=Length Length] + [option value=Name %s Name] + [option value=Date %s Date] + [option value=Length %s Length] ][button type=submit Apply Filter]] - ]' + ]' \ + "$(CHECK "$ORDER" Name)" \ + "$(CHECK "$ORDER" Date)" \ + "$(CHECK "$ORDER" Length)" } w_tagging(){ @@ -130,7 +139,7 @@ w_tagging(){ | while read -r tag; do [ ! "$tag" ] && continue tag="$(HTML "$tag")"; tn="${tag#*:}" - printf '[option value="%s" %s]' "$tag" "$tn" + printf '[option value="%s"\n%s]' "$tag" "$tn" done printf ']]' done