Mercurial > xmpp-account-manager
annotate vcard.js @ 63:ee1df80a1715 default tip
Nicer-looking input form
author | mathieui |
---|---|
date | Sun, 24 May 2020 14:19:29 +0200 |
parents | 6d861d881b96 |
children |
rev | line source |
---|---|
60
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
1 // SPDX-License-Identifier: AGPL-3.0-only |
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
2 /* |
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
3 * Copyright © 2018-2020 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
4 * Copyright © 2020 Mathieu Pasquet <mathieui@mathieui.net> |
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
5 * |
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
6 * Released under GNU AGPL v3 only, read the file 'LICENSE' for more information. |
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
7 */ |
6d861d881b96
Add license headers to all source files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
55
diff
changeset
|
8 |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 'use strict'; |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 function initVCard(connection) { |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 const vcard_access = document.getElementById('vcard-access'); |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
13 const vcard_fn = document.getElementById('vcard-fn'); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 const vcard_email = document.getElementById('vcard-email'); |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
15 const vcard_bday = document.getElementById('vcard-bday'); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 const spinner_img = document.getElementById('vcard-spinner'); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 const access_spinner_img = document.getElementById('vcard-access-spinner'); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 const vcard_data = {}; |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 const iq = $iq({type: 'get'}) |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 .c('items', {node: 'urn:xmpp:vcard4'}) |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 .c('item', {id: 'current'}); |
31
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
25 connection.sendIQ(iq, onVCard4, onVCard4RetrievalError); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 displaySpinner(spinner_img); |
55
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
27 getAccessModel(); |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
28 |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
29 function getAccessModel() |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
30 { |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
31 vcard_access.disabled = true; |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
32 displaySpinner(access_spinner_img); |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
33 retrieveConfiguration(connection, 'urn:xmpp:vcard4').then((access_model) => { |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
34 if (access_model !== null) { |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
35 if (access_model === 'open') |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
36 vcard_access.value = 'open'; |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
37 else if (access_model === 'presence') |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
38 vcard_access.value = 'presence'; |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
39 else |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
40 console.log('Unsupported vCard4 access model: ' + access_model); |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
41 vcard_access.disabled = false; |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
42 } |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
43 hideSpinner(access_spinner_img); |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
44 }, (reason) => { |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
45 console.log('Failed to retrieve vCard4 configuration:', reason); |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
46 hideSpinner(access_spinner_img); |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
47 }); |
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
48 } |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 function onVCard4(result_iq) |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 { |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 const item = parseXPath(result_iq, './pubsub:pubsub/pubsub:items/pubsub:item'); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 if (item === null) |
31
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
54 return onVCard4RetrievalError(null, 'no item found.'); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 const vcard = parseXPath(item, './vcard4:vcard'); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 if (vcard === null) |
31
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
57 return onVCard4RetrievalError(null, 'no vCard4 found, your PubSub node is broken.'); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 vcard_data.fn = parseXPathText(vcard, './vcard4:fn/vcard4:text'); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 vcard_data.email = parseXPathText(vcard, './vcard4:email/vcard4:text'); |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
61 vcard_data.bday = parseXPathText(vcard, './vcard4:bday/vcard4:date'); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
63 vcard_fn.value = vcard_data.fn; |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
64 vcard_fn.disabled = false; |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 vcard_email.value = vcard_data.email; |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 vcard_email.disabled = false; |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
67 vcard_bday.value = vcard_data.bday; |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
68 vcard_bday.disabled = false; |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 hideSpinner(spinner_img); |
55
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
70 getAccessModel(); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 } |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 |
31
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
73 function onVCard4RetrievalError(iq, string) |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 { |
31
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
75 if (!string) { |
32
b15e1581c3d4
Allow iq error to not have a <text/>.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
31
diff
changeset
|
76 string = parseErrorIq(iq); |
31
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
77 } |
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
78 string = 'Failed to retrieve vCard4: ' + string; |
e561bdd81777
Display better vCard4 errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
30
diff
changeset
|
79 console.log(string); |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
80 vcard_fn.disabled = false; |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 vcard_email.disabled = false; |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
82 vcard_bday.disabled = false; |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 hideSpinner(spinner_img); |
55
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
84 vcard_access.disabled = true; |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
85 } |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 function setVCard4() { |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 // TODO: avoid overriding fields we don’t understand. |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 const iq = $iq({type: 'set'}) |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
90 .c('vcard', {xmlns: 'urn:ietf:params:xml:ns:vcard-4.0'}); |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
91 if (vcard_fn.value) |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
92 iq.c('fn') |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
93 .c('text').t(vcard_fn.value).up().up(); |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
94 if (vcard_email.value) |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
95 iq.c('email') |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
96 .c('text').t(vcard_email.value).up().up(); |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
97 if (vcard_bday.value) |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
98 iq.c('bday') |
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
99 .c('date').t(vcard_bday.value).up().up(); |
30
9ba4f8cc32f1
Display the returned error in the title of the spinner.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
27
diff
changeset
|
100 connection.sendIQ(iq, onVCard4Changed, onVCard4ChangeError); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 displaySpinner(spinner_img); |
55
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
102 vcard_access.disabled = true; |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 } |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 |
34
45bd945c5722
Change all blur events to change, prevents a stanza when no change occured.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
33
diff
changeset
|
105 vcard_fn.addEventListener('change', setVCard4); |
45bd945c5722
Change all blur events to change, prevents a stanza when no change occured.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
33
diff
changeset
|
106 vcard_email.addEventListener('change', setVCard4); |
27
02b5bceeca64
Add vCard birthday support, and only include complete values in the vCard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
25
diff
changeset
|
107 vcard_bday.addEventListener('change', setVCard4); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
109 function onVCard4Changed(result_iq) |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
110 { |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
111 console.log('Successfully set vCard4.') |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
112 spinnerOk(spinner_img); |
55
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
113 getAccessModel(); |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
114 } |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
115 |
30
9ba4f8cc32f1
Display the returned error in the title of the spinner.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
27
diff
changeset
|
116 function onVCard4ChangeError(iq) |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
117 { |
55
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
118 const string = 'Failed to set vCard4: ' + parseErrorIq(iq); |
30
9ba4f8cc32f1
Display the returned error in the title of the spinner.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
27
diff
changeset
|
119 console.log(string); |
9ba4f8cc32f1
Display the returned error in the title of the spinner.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
27
diff
changeset
|
120 spinnerError(spinner_img, string); |
55
6a7a99f5a0ca
Add pubsub#access_model retrieval for the vCard4 node.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
34
diff
changeset
|
121 vcard_access.disabled = true; |
25
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 } |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 vcard_access.addEventListener('change', function (evt) { |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 const iq = configurePEPField('urn:xmpp:vcard4', 'pubsub#access_model', evt.target.value); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 connection.sendIQ(iq, onAccessConfigured, onAccessConfigureError.bind(null, 'PubSub configuration failed.')); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 displaySpinner(access_spinner_img); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
128 }); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
129 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 function onAccessConfigured(result_iq) |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
131 { |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
132 console.log('Successfully set vCard4 access model.') |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
133 spinnerOk(access_spinner_img); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
134 } |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
135 |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 function onAccessConfigureError(string) |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 { |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
138 console.log('Failed to configure vCard4 node: ' + string); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
139 spinnerError(access_spinner_img); |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
140 } |
d9da5c3e305d
Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
141 } |