+ "$w_refuri" "$LISTSIZE" \
+ "${tm:-checked}" "${tm:+checked}" "$tf" "$td"
+}
+
+w_index(){
+ printf '
+ [form #index method="POST" action="?a=spawnindex"
+ [hidden "ref" "%s"]
+ [label Set up for Index view: ]
+ [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories]
+ [submit "spawn" "spawn" Set up]
+ ]
+ ' "$w_refuri"
+ return 0
+}
+
+w_advsearch(){
+ local n lbid tag category filter f t d
+ filter="$(HTML "${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]
+ Refine the search further by setting additional search tags using the [strong "+and"] button.]'
+
+ for n in 1 2 3 4 5 6 7 8 9 10; do
+ f="${filter%%^*}"; filter="${filter#*^}"
+
+ t=''; [ "$f" -a ! "${f%%~*}" ] && t=" "
+
+ lbid="cat_${n}_(none)"
+ printf '[input .and type=checkbox name=and id="and_%i" %s][label for="and_%i" +and
+ ][fieldset .select
+ [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:+checked}" $n \
+ $n "${t:-checked}" $n $n \
+ $n "${t:+checked}" $n $n
+
+ f="|${f#\~}|"
+ printf '*\n%s\n' "$w_tagcategories" \
+ | while read -r category; do
+ lbid="cat_${n}_${category}"
+
+ t=''
+ [ "$category" = '*' -a "${f%%|${category}:*}" ] && t=checked
+ [ "$category" != '*' -a ! "${f%%|${category}:*}" ] && t=checked
+ [ "$category" != '*' -a ! "${f%%|-${category}:*}" ] && t=checked
+
+ printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
+ [select name=tag_%s size=10 multiple' \
+ $n "$category" "$t" "$lbid" "$lbid" "$category" $n
+
+ printf '%s\n' "$w_tags" \
+ | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
+ | { for n in 1 2 3 4 5 6 7 8 9 0; do
+ read -r line && printf '%s\n' "$line" || break;
+ done; # pass 10 lines through without modification
+ sort; # and sort remaining lines
+ } | while read -r tag; do
+ [ "$tag" ] || continue
+ t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
+ d="${tag#-}"; d="${d#*:}"
+ printf '[option %s value="%s"\n%s]' "$t" "$tag" "$d"
+ done
+ printf '\n]'
+ done
+ printf ']'
+ done
+
+ printf '[fieldset .submit [select name=order
+ [option disabled=disabled Order By]
+ [option value=Name %s Name]
+ [option value=Date %s Date]
+ [option value=Length %s Length]
+ [option value=Group %s Group]
+ ][button type=submit Apply Filter]]
+ ]' \
+ "$w_coname" "$w_codate" \
+ "$w_colength" "$w_cogroup"
+}
+
+w_delete(){
+ printf '[a href="#multitag" Add Tags / Remove Tags]
+ [div #multitag [input type="hidden" name="ref" value="%s"]
+ [a href="#" Hide][br]
+ [fieldset [legend New:]
+ [submit "op" "filedelete" Delete Files]
+ ]]' "$w_refuri"
+}
+
+w_tagging(){
+ local tag category d
+ printf '[a href="#multitag" Add Tags / Remove Tags]
+ [div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri"
+ printf '[a href="#" Hide][br]'
+
+ printf 'Tags\n%s\n' "$w_tagcategories" \
+ | while read -r category; do
+ [ "$category" ] || continue
+ printf '[fieldset [legend %s:][select name=tag size=4 multiple\n' "$category"
+ printf %s "$w_tags" \
+ | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
+ | { for n in 1 2 3 4 5 6 7 8 9 0; do
+ read -r line && printf '%s\n' "$line" || break
+ done;
+ sort;
+ } | while read -r tag; do
+ [ "$tag" ] || continue
+ d="${tag#-}"; d="${d#*:}"
+ printf '[option value="%s"\n%s]' "$tag" "$d"
+ done
+ printf ']]'
+ done
+
+ printf '[fieldset [legend New:][textarea name=newtag\n]
+ [submit "op" "del" Remove Tags][submit "op" "add" Add Tags]
+ ]]'