annotate client.js @ 56:010b905a74d4

Update translation strings - prepend i18n loading for all "templates" - add some strings - commit the po files to the repo
author mathieui
date Sun, 24 May 2020 11:27:10 +0200
parents 8b69b3a1ef8e
children 427807059ca8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 'use strict';
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 document.addEventListener('DOMContentLoaded', function () {
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
4 let connection = null;
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 const jid_element = document.getElementById('jid');
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 const pass_element = document.getElementById('pass');
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 const connect_button = document.getElementById('connect');
10
e47b9bd55192 Also use a spinner on nickname get/set.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5
diff changeset
9 const spinner_img = document.getElementById('connect-spinner');
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 const connected_div = document.getElementById('connected');
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 const avatar_img = document.getElementById('avatar');
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
23
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
15 const tabs = ['profile', 'mam', 'pep', 'account'];
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
16 function onHashChange() {
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
17 const hash = location.hash.substr(1);
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
18 if (!tabs.includes(hash))
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
19 return;
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
20 for (let tab of tabs) {
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
21 const tab_name = 'tab-' + tab;
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
22 const tab_element = document.getElementById(tab_name);
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
23 if (tab == hash) {
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
24 tab_element.classList.add('active')
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
25 const content_elements = document.getElementsByClassName(tab_name);
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
26 for (let element of content_elements)
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
27 element.hidden = false;
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
28 } else {
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
29 tab_element.classList.remove('active')
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
30 const content_elements = document.getElementsByClassName(tab_name);
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
31 for (let element of content_elements)
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
32 element.hidden = true;
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
33 }
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
34 }
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
35 }
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
36
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
37 onHashChange();
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
38 window.addEventListener('hashchange', onHashChange);
e99984564b17 Implement a tab system, thanks Zash!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 17
diff changeset
39
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
40 function rawInput(data)
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
41 {
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
42 console.log('RECV', data);
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
43 }
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
44
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
45 function rawOutput(data)
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
46 {
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
47 console.log('SENT', data);
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
48 }
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
49
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 connect_button.addEventListener('click', function (evt) {
13
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
51 if (!connect_button.classList.contains('disconnect')) {
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
52 const jid = jid_element.value;
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
53 getBOSHService(jid).then((bosh_service) => {
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
54 connection = new Strophe.Connection(bosh_service);
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
55 connection.rawInput = rawInput;
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
56 connection.rawOutput = rawOutput;
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
57 connection.connect(jid,
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
58 pass_element.value,
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
59 onConnect);
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
60 });
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
61 } else if (connection != null) {
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 connection.disconnect();
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 }
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 evt.preventDefault();
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65 });
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
67 function getBOSHService(jid)
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
68 {
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
69 return new Promise((resolve, reject) => {
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
70 const [nodepart, domainpart] = jid.split('@', 2);
14
962f64b156dd Stop hardcoding XEP-0156 file to the current domain.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 13
diff changeset
71 const url = 'https://' + domainpart + '/.well-known/host-meta';
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
72 const xhr = new XMLHttpRequest();
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
73 xhr.onload = function (evt) {
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
74 const xml = evt.target.responseXML;
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
75 const links = parseXPath(xml, './xrd:XRD/xrd:Link', XPathResult.ORDERED_NODE_ITERATOR_TYPE);
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
76 let bosh_service = null;
45
8b69b3a1ef8e Add support for WebSocket.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 42
diff changeset
77 let ws_service = null;
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
78 while (true) {
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
79 const link = links.iterateNext();
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
80 if (!link)
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
81 break;
45
8b69b3a1ef8e Add support for WebSocket.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 42
diff changeset
82 const rel = link.getAttributeNS(null, 'rel');
8b69b3a1ef8e Add support for WebSocket.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 42
diff changeset
83 if (rel == 'urn:xmpp:alt-connections:xbosh')
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
84 bosh_service = link.getAttributeNS(null, 'href');
45
8b69b3a1ef8e Add support for WebSocket.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 42
diff changeset
85 else if (rel == 'urn:xmpp:alt-connections:websocket')
8b69b3a1ef8e Add support for WebSocket.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 42
diff changeset
86 ws_service = link.getAttributeNS(null, 'href');
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
87 }
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
88 console.log('bosh_service', bosh_service);
45
8b69b3a1ef8e Add support for WebSocket.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 42
diff changeset
89 console.log('ws_service', ws_service);
8b69b3a1ef8e Add support for WebSocket.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 42
diff changeset
90 resolve(ws_service || bosh_service);
1
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
91 };
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
92 xhr.open('GET', url);
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
93 xhr.send();
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
94 });
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
95 }
d6df73b466f6 Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
96
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 function onConnect(status)
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 {
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99 if (status == Strophe.Status.CONNECTING) {
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 console.log('Strophe is connecting.');
13
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
101 connect_button.value = 'Log out';
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
102 connect_button.classList.add('disconnect');
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 jid_element.disabled = true;
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 pass_element.disabled = true;
15
3eed9fe0bd7c End spinners with either a green ✔ or a red ✘.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 14
diff changeset
105 displaySpinner(spinner_img);
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 } else if (status == Strophe.Status.CONNFAIL) {
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107 console.log('Strophe failed to connect.');
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
108 onDisconnected();
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109 } else if (status == Strophe.Status.DISCONNECTING) {
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 console.log('Strophe is disconnecting.');
15
3eed9fe0bd7c End spinners with either a green ✔ or a red ✘.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 14
diff changeset
111 displaySpinner(spinner_img);
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 } else if (status == Strophe.Status.DISCONNECTED) {
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 console.log('Strophe is disconnected.');
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
114 onDisconnected();
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115 } else if (status == Strophe.Status.CONNECTED) {
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 console.log('Strophe is connected.');
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 onConnected();
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 }
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 }
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 function onConnected()
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 {
42
fe59565063af mathieui: Add our current JID in the top bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 40
diff changeset
123 const new_node = document.createElementNS('http://www.w3.org/1999/xhtml', 'span');
fe59565063af mathieui: Add our current JID in the top bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 40
diff changeset
124 const parent_node = connect.parentNode;
56
010b905a74d4 Update translation strings
mathieui
parents: 45
diff changeset
125 const text = document.createTextNode('{% trans 'Logged in as {} ' %}'.replace('{}', connection.authzid));
42
fe59565063af mathieui: Add our current JID in the top bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 40
diff changeset
126 new_node.appendChild(text);
fe59565063af mathieui: Add our current JID in the top bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 40
diff changeset
127 parent_node.insertBefore(new_node, connect);
fe59565063af mathieui: Add our current JID in the top bar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 40
diff changeset
128
13
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
129 jid_element.hidden = true;
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
130 pass_element.hidden = true;
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131 connected_div.hidden = false;
15
3eed9fe0bd7c End spinners with either a green ✔ or a red ✘.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 14
diff changeset
132 hideSpinner(spinner_img);
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
133 initRoster(connection);
3
5aa1bf7154b0 Add a simple PEP node viewer and editor.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 1
diff changeset
134 initPEP(connection);
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
135 initNickname(connection);
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
136 initAvatar(connection);
25
d9da5c3e305d Add support for setting some vCard4 fields.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 23
diff changeset
137 initVCard(connection);
17
07543f7f5e89 Retrieve and change the default MAM prefs.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 15
diff changeset
138 initMAM(connection);
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
139 }
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
140
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
141 function onDisconnected()
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
142 {
13
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
143 connect_button.value = 'Log in';
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
144 connect_button.classList.remove('disconnect');
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
145 jid_element.hidden = false;
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
146 jid_element.disabled = false;
13
8724e28ccbd7 Improve styling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 12
diff changeset
147 pass_element.hidden = false;
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
148 pass_element.disabled = false;
15
3eed9fe0bd7c End spinners with either a green ✔ or a red ✘.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 14
diff changeset
149 hideSpinner(spinner_img);
12
139b223dafb0 Actually remove all of the extra data on disconnect.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 10
diff changeset
150 connected_div.hidden = true;
139b223dafb0 Actually remove all of the extra data on disconnect.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 10
diff changeset
151 let table = document.getElementById('roster-table');
139b223dafb0 Actually remove all of the extra data on disconnect.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 10
diff changeset
152 while (table.hasChildNodes()) {
139b223dafb0 Actually remove all of the extra data on disconnect.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 10
diff changeset
153 table.removeChild(table.lastChild);
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
154 }
12
139b223dafb0 Actually remove all of the extra data on disconnect.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 10
diff changeset
155 table = document.getElementById('pep-table');
139b223dafb0 Actually remove all of the extra data on disconnect.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 10
diff changeset
156 while (table.hasChildNodes()) {
139b223dafb0 Actually remove all of the extra data on disconnect.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 10
diff changeset
157 table.removeChild(table.lastChild);
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
158 }
40
bd343ef0942f mathieui: Reload the page on logout.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 25
diff changeset
159 location.reload();
4
5e97e1808a35 Add support for the roster.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3
diff changeset
160 }
0
2a8d4e8600d0 Initial commit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
161 });