]> git.plutz.net Git - confetti/blobdiff - templates/view_attendee.sh
basic editing functions
[confetti] / templates / view_attendee.sh
index 1e02e3db017c1845f1a753927c91d73e8029ccbd..01fb3f0383565c3f9baa56a26aac6b1eb2367705 100755 (executable)
@@ -73,6 +73,23 @@ view_card_item() {
   esac
 }
 
+edit_card_item() {
+  case "$key" in
+    BEGIN|VERSION|END);;
+    PHOTO)
+      echo "<img class=\"PHOTO\" src=\"data:image/$tag[TYPE];base64,$value\"/>"
+      ;;
+    *)
+      echo -n "<span class=\"item\"><span class=\"KEY\">$(l10n "$key")"
+      [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])"
+      echo ":</span>"
+      ;|
+    *)
+      echo "<input class=\"VALUE\" name=\"$key\" value=\"$value\" /></item>"
+      ;;
+  esac
+}
+
 view_attendee() {  #Parameter: Cardfile
   cardfile="$1"
   cachefile="cache/vcf_$(basename "$cardfile").cache"
@@ -96,3 +113,25 @@ view_attendee() {  #Parameter: Cardfile
     esac
   done |tee "$cachefile"
 }
+
+edit_attendee() {
+  cardfile="$1"
+  unset key
+  vcf_parse "$cardfile" |while read -r line; do
+    declare -A tag
+    case "$line" in
+      value*) eval "$line";;
+      tag*)   eval "$line";;
+      key*)
+        if [ -z "$key" ]; then
+          eval "$line"
+        else
+          edit_card_item
+          eval "$line"
+         unset value
+         unset tag
+        fi
+      ;;
+    esac
+  done
+}