# HG changeset patch # User Emmanuel Gil Peyrot # Date 1545570059 -3600 # Node ID e99984564b17951254b2d3619147fe0ba9877018 # Parent 07e33207e598a3ed5523f604210df158d878ae24 Implement a tab system, thanks Zash! diff --git a/client.js b/client.js --- a/client.js +++ b/client.js @@ -12,6 +12,31 @@ document.addEventListener('DOMContentLoa const avatar_img = document.getElementById('avatar'); + const tabs = ['profile', 'mam', 'pep', 'account']; + function onHashChange() { + const hash = location.hash.substr(1); + if (!tabs.includes(hash)) + return; + for (let tab of tabs) { + const tab_name = 'tab-' + tab; + const tab_element = document.getElementById(tab_name); + if (tab == hash) { + tab_element.classList.add('active') + const content_elements = document.getElementsByClassName(tab_name); + for (let element of content_elements) + element.hidden = false; + } else { + tab_element.classList.remove('active') + const content_elements = document.getElementsByClassName(tab_name); + for (let element of content_elements) + element.hidden = true; + } + } + } + + onHashChange(); + window.addEventListener('hashchange', onHashChange); + function rawInput(data) { console.log('RECV', data); diff --git a/index.xhtml b/index.xhtml --- a/index.xhtml +++ b/index.xhtml @@ -49,7 +49,14 @@