comparison client.js @ 13:8724e28ccbd7

Improve styling.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 22 Dec 2018 18:07:00 +0100
parents 139b223dafb0
children 962f64b156dd
comparison
equal deleted inserted replaced
12:139b223dafb0 13:8724e28ccbd7
21 { 21 {
22 console.log('SENT', data); 22 console.log('SENT', data);
23 } 23 }
24 24
25 connect_button.addEventListener('click', function (evt) { 25 connect_button.addEventListener('click', function (evt) {
26 if (connect_button.value == 'connect') { 26 if (!connect_button.classList.contains('disconnect')) {
27 const jid = jid_element.value; 27 const jid = jid_element.value;
28 getBOSHService(jid).then((bosh_service) => { 28 getBOSHService(jid).then((bosh_service) => {
29 connection = new Strophe.Connection(bosh_service); 29 connection = new Strophe.Connection(bosh_service);
30 connection.rawInput = rawInput; 30 connection.rawInput = rawInput;
31 connection.rawOutput = rawOutput; 31 connection.rawOutput = rawOutput;
70 70
71 function onConnect(status) 71 function onConnect(status)
72 { 72 {
73 if (status == Strophe.Status.CONNECTING) { 73 if (status == Strophe.Status.CONNECTING) {
74 console.log('Strophe is connecting.'); 74 console.log('Strophe is connecting.');
75 connect_button.value = 'disconnect'; 75 connect_button.value = 'Log out';
76 connect_button.classList.add('disconnect');
76 jid_element.disabled = true; 77 jid_element.disabled = true;
77 pass_element.disabled = true; 78 pass_element.disabled = true;
78 spinner_img.hidden = false; 79 spinner_img.hidden = false;
79 } else if (status == Strophe.Status.CONNFAIL) { 80 } else if (status == Strophe.Status.CONNFAIL) {
80 console.log('Strophe failed to connect.'); 81 console.log('Strophe failed to connect.');
91 } 92 }
92 } 93 }
93 94
94 function onConnected() 95 function onConnected()
95 { 96 {
97 jid_element.hidden = true;
98 pass_element.hidden = true;
96 connected_div.hidden = false; 99 connected_div.hidden = false;
97 spinner_img.hidden = true; 100 spinner_img.hidden = true;
98 initRoster(connection); 101 initRoster(connection);
99 initPEP(connection); 102 initPEP(connection);
100 initNickname(connection); 103 initNickname(connection);
101 initAvatar(connection); 104 initAvatar(connection);
102 } 105 }
103 106
104 function onDisconnected() 107 function onDisconnected()
105 { 108 {
106 connect_button.value = 'connect'; 109 connect_button.value = 'Log in';
110 connect_button.classList.remove('disconnect');
111 jid_element.hidden = false;
107 jid_element.disabled = false; 112 jid_element.disabled = false;
113 pass_element.hidden = false;
108 pass_element.disabled = false; 114 pass_element.disabled = false;
109 spinner_img.hidden = true; 115 spinner_img.hidden = true;
110 connected_div.hidden = true; 116 connected_div.hidden = true;
111 let table = document.getElementById('roster-table'); 117 let table = document.getElementById('roster-table');
112 while (table.hasChildNodes()) { 118 while (table.hasChildNodes()) {