separeted text view and edit section
[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       ;;
15   esac
16 }
17
18 edit_attendee() {
19   cardfile="$1"
20   unset key
21   vcf_parse "$cardfile" |while read -r line; do
22     declare -A tag
23     case "$line" in
24       value*) eval "$line";;
25       tag*)   eval "$line";;
26       key*)
27         if [ -z "$key" ]; then
28           eval "$line"
29         else
30           edit_card_item
31           eval "$line"
32           unset value
33           unset tag
34         fi
35       ;;
36     esac
37   done
38 }