comparison client.js @ 23:e99984564b17

Implement a tab system, thanks Zash!
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 23 Dec 2018 14:00:59 +0100
parents 07543f7f5e89
children d9da5c3e305d
comparison
equal deleted inserted replaced
22:07e33207e598 23:e99984564b17
9 const spinner_img = document.getElementById('connect-spinner'); 9 const spinner_img = document.getElementById('connect-spinner');
10 10
11 const connected_div = document.getElementById('connected'); 11 const connected_div = document.getElementById('connected');
12 12
13 const avatar_img = document.getElementById('avatar'); 13 const avatar_img = document.getElementById('avatar');
14
15 const tabs = ['profile', 'mam', 'pep', 'account'];
16 function onHashChange() {
17 const hash = location.hash.substr(1);
18 if (!tabs.includes(hash))
19 return;
20 for (let tab of tabs) {
21 const tab_name = 'tab-' + tab;
22 const tab_element = document.getElementById(tab_name);
23 if (tab == hash) {
24 tab_element.classList.add('active')
25 const content_elements = document.getElementsByClassName(tab_name);
26 for (let element of content_elements)
27 element.hidden = false;
28 } else {
29 tab_element.classList.remove('active')
30 const content_elements = document.getElementsByClassName(tab_name);
31 for (let element of content_elements)
32 element.hidden = true;
33 }
34 }
35 }
36
37 onHashChange();
38 window.addEventListener('hashchange', onHashChange);
14 39
15 function rawInput(data) 40 function rawInput(data)
16 { 41 {
17 console.log('RECV', data); 42 console.log('RECV', data);
18 } 43 }