]> git.plutz.net Git - confetti/blob - templates/edit_attendee.sh
basic update functions for vcards
[confetti] / templates / edit_attendee.sh
1 edit_card_item() {
2   case "$key" in
3     BEGIN|VERSION|END);;
4     PHOTO)
5       echo "<img class=\"PHOTO\" src=\"data:image/$tag[TYPE];base64,$value\"/>"
6       ;;
7     *)
8       echo -n "<span class=\"item\"><span class=\"KEY\">$(l10n "$key")"
9       [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])"
10       echo ":</span>"
11       ;|
12     *)
13       echo "<input class=\"VALUE\" name=\"$key\" value=\"$value\" /></item>"
14       echo "<button name=\"deletefield\" value=\"$key $value\">$(l10n edit_deletefield)</button>"
15       ;;
16   esac
17 }
18
19 edit_attendee() {
20   cardfile="vcard/$1"
21   tempfile="temp/$1"
22   [ -f "$tempfile" ] && cardfile="$tempfile"
23   debug Using card: $cardfile
24   unset key
25   vcf_parse "$cardfile" |debug |while read -r line; do
26     declare -A tag
27     case "$line" in
28       value*) eval "$line";;
29       tag*)   eval "$line";;
30       key*)
31         if [ -z "$key" ]; then
32           eval "$line"
33         else
34           edit_card_item
35           eval "$line"
36           unset value
37           unset tag
38         fi
39       ;;
40     esac
41   done
42 }