-#!/bin/zsh
+# Copyright 2014, 2015 Paul Hänsch
+#
+# This file is part of Serve0
+#
+# Serve0 is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Serve0 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Serve0 If not, see <http://www.gnu.org/licenses/>.
-cat <<LOCATIONend
- <div class="panel footer" id="foot">
- <a class="panel tagger show" href="#foot" onclick="javascript:hide('foot');show_block('tagger');">Add Tags</a>
+category_options(){
+ cat="${1}:"
+ [ "$cat" = "none:" ] && cat=''
- <div class="pagination_nav">
- <span class="label">Page:</span>
- <a href="?${page_prev}"><<</a>
- <a href="?${page_this}">$(($page + 1))</a>
- <a href="?${page_next}">>></a>
- </div>
- </div>
+ printf %s "$taglist_set" \
+ | sed -rn 's;^('"$cat"')([^:]+)$;<option value="\1\2">\2</option>;p'
+}
+category_box(){
+ for cat in "$@"; do
+ cat <<EOF
+ <p class="newtag">
+ <label class="category">${cat}:</label>
+ <input type="hidden" name="category" value="$cat">
+ <select name="ctag" size="12" multiple>
+ $(category_options "$cat")
+ </select>
+ </p>
+EOF
+ done
+}
- <div class="panel footer" id="tagger" style="display: none;">
- <a class="panel tagger hide" href="#"
- onclick="javascript:hide('tagger');$(for n in $(seq 1 4); do echo "hide('filter$n');"; done)show_block('foot')"
- >Hide</a>
- <hr>
- <span class="help">Add selectetd tags to selected videos.</span>
- <div class="newtag">
- <span class="label category">None:</span>
- <select name="ctag" size="12" multiple id="${n}_none">
- $(echo "$taglist" |sed -rn 's;^([^:]+)$;<option value="\1">\1</option>;p')
- </select>
- </div>
- $(echo "$taglist" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u |while read cat; do echo "
- <div class=\"newtag\">
- <span class=\"label category\">${cat}:</span>
- <input type=\"hidden\" name=\"category\" value=\"$cat\">
- <select name=\"ctag\" size=\"12\" multiple id=\"${n}_$cat\">
- $(echo "$taglist" |sed -rn "s;^${cat}:(.*)$;<option value=\"${cat}:\\1\">\\1</option>;p")
- </select>
- </div>"
- done)
- <div class="newtag additional">
- <span class="label additional">Additional Tags (one per line):</span>
+cat <<EOF
+ <div class="panel" id="tagger">
+ <p class="help">Add selectetd tags to selected videos.</p>
+ $(category_box $(list_categories))
+ <p class="newtag additional">
+ <label class="additional">Additional Tags (one per line):</label>
<textarea name="tags" rows="2"></textarea>
- </div>
+ </p>
<input type="submit" value="Add Tags!">
+
+ <a class="panel toggle" href="#foot">Hide</a>
</div>
-LOCATIONend
+EOF
# vi:set filetype=html:
-