+ ]' "${w_refuri}" "${LISTSIZE}" "${tm:+checked=checked}" "${tm:-checked=checked}" "$tf" "$td"
+}
+
+w_index(){
+ cat <<-EOF
+ [form #index method="POST" action="?a=spawnindex"
+ [hidden "ref" "${w_refuri}"]
+ [label Set up for Index view: ]
+ [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories]
+ [submit "spawn" "spawn" Set up]
+ ]
+ EOF
+ 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="#" X]
+ [p .help 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=checked}" "$n" \
+ "$n" "${t:-checked=checked}" "$n" "$n" \
+ "$n" "${t:+checked=checked}" "$n" "$n"
+
+ f="|${f#\~}|"
+ printf '%s\n$:\n' "$w_tags" \
+ | while read tctag; do
+ [ "$tctag" ] || continue
+ category="${tctag#-}"; category="${category%%:*}"
+ tag="${tctag#-}"; tag="${tag#*:}"
+ [ "${tag}" = "${tctag#-}" ] \
+ && category="*"
+
+ if [ "$category" != "$oldcat" ]; then
+ [ "$oldcat" ] && printf '\n]'
+ 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]
+ [div .catselect\n' \
+ $n "$category" "$t" "$lbid" "$lbid" "$category"
+ fi
+
+ if [ "$category" = '$' ]; then
+ tag="${f##*\$:}" tag="${tag%%\|*}"
+ printf '[input name="tag_%i" value="%s"]' "$n" "$(HTML "$tag")"
+ else
+ t=''; [ ! "${f%%*|${tctag}|*}" ] && t=checked
+ printf '[label [checkbox "tag_%s" "%s" %s] %s]' "$n" "$tctag" "$t" "$tag"
+ fi
+
+ oldcat="$category"
+ done
+ [ "$w_tags" ] && printf '\n]'
+ 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="#" X]
+ [fieldset [legend New:]
+ [submit "op" "filedelete" Delete Files]
+ ]]' "$w_refuri"
+}
+
+w_tagging(){
+ local tctag oldcat="" category tag
+
+ cat <<-EOF
+ [a href="#multitag" Add Tags / Remove Tags]
+ [div #multitag [input type="hidden" name="ref" value="${w_refuri}"]
+ [a href="#" X]
+ EOF
+
+ printf '%s\n' "$w_tags" \
+ | while read tctag; do
+ [ "$tctag" ] || continue
+ category="${tctag#-}"; category="${category%%:*}"
+ tag="${tctag#-}"; tag="${tag#*:}"
+
+ [ "${tag}" = "${tctag#-}" ] \
+ && category="Tags"
+
+ if [ "$category" != "$oldcat" ]; then
+ [ "$oldcat" ] && printf ']]'
+ printf '[fieldset [legend %s:][div .tagselect\n' "$category"
+ fi
+ printf '[label [checkbox "tag" "%s"] %s]\n' "$tctag" "$tag"
+
+ oldcat="$category"
+ done
+ [ "$w_tags" ] && printf ']]'
+
+ cat <<-EOF
+ [fieldset [legend New:][textarea name=newtag]
+ [label [checkbox "makegroup" "true"] Join selected into group]
+ [submit "op" "del" Remove][submit "op" "flip" Flip][submit "op" "add" Add]
+ ]]
+ EOF