Mercurial > xmpp-account-manager
comparison util.js @ 30:9ba4f8cc32f1
Display the returned error in the title of the spinner.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 23 Dec 2018 17:15:38 +0100 |
parents | d9da5c3e305d |
children | b15e1581c3d4 |
comparison
equal
deleted
inserted
replaced
29:15666446c791 | 30:9ba4f8cc32f1 |
---|---|
51 .t(value) | 51 .t(value) |
52 .up() | 52 .up() |
53 .up(); | 53 .up(); |
54 } | 54 } |
55 | 55 |
56 function parseErrorIq(iq) { | |
57 // TODO: actually check that it is the first one. | |
58 const error = iq.firstChild; | |
59 if (error.namespaceURI !== 'jabber:client' || error.localName !== 'error') | |
60 return null; | |
61 const condition = error.firstChild; | |
62 if (condition.namespaceURI !== 'urn:ietf:params:xml:ns:xmpp-stanzas') | |
63 return null; | |
64 const text = error.lastChild; | |
65 if (text.namespaceURI !== 'urn:ietf:params:xml:ns:xmpp-stanzas' || text.localName !== 'text') | |
66 return null; | |
67 return [condition.localName, text.textContent]; | |
68 } | |
69 | |
56 function displaySpinner(spinner) { | 70 function displaySpinner(spinner) { |
57 if ('timeoutid' in spinner.dataset) | 71 if ('timeoutid' in spinner.dataset) |
58 clearTimeout(spinner.dataset.timeoutid); | 72 clearTimeout(spinner.dataset.timeoutid); |
59 spinner.src = 'spinner.svg'; | 73 spinner.src = 'spinner.svg'; |
74 spinner.title = ''; | |
60 spinner.hidden = false; | 75 spinner.hidden = false; |
61 } | 76 } |
62 | 77 |
63 function spinnerOk(spinner) { | 78 function spinnerOk(spinner) { |
64 if ('timeoutid' in spinner.dataset) | 79 if ('timeoutid' in spinner.dataset) |
65 clearTimeout(spinner.dataset.timeoutid); | 80 clearTimeout(spinner.dataset.timeoutid); |
66 spinner.src = 'ok.svg'; | 81 spinner.src = 'ok.svg'; |
82 spinner.title = ''; | |
67 spinner.hidden = false; | 83 spinner.hidden = false; |
68 spinner.dataset.timeoutid = setTimeout(function () { | 84 spinner.dataset.timeoutid = setTimeout(function () { |
69 spinner.hidden = true; | 85 spinner.hidden = true; |
70 }, 1000); | 86 }, 1000); |
71 } | 87 } |
72 | 88 |
73 function spinnerError(spinner) { | 89 function spinnerError(spinner, title) { |
74 if ('timeoutid' in spinner.dataset) | 90 if ('timeoutid' in spinner.dataset) |
75 clearTimeout(spinner.dataset.timeoutid); | 91 clearTimeout(spinner.dataset.timeoutid); |
76 spinner.src = 'error.svg'; | 92 spinner.src = 'error.svg'; |
93 spinner.title = title ? title : ''; | |
77 spinner.hidden = false; | 94 spinner.hidden = false; |
78 } | 95 } |
79 | 96 |
80 function hideSpinner(spinner) { | 97 function hideSpinner(spinner) { |
81 if ('timeoutid' in spinner.dataset) | 98 if ('timeoutid' in spinner.dataset) |