Allow anchor links

This commit is contained in:
Alan Bernstein 2017-04-27 18:47:07 -05:00
parent 05782f0b73
commit 3fb3ceac3e
2 changed files with 22 additions and 8 deletions

View file

@ -229,16 +229,20 @@ function populate_version() {
xhr.send(null)
}
function setNav(e) {
function handle_nav_click(e) {
// e.id = "nav-xxx"
name = e.id.substring(4)
set_active_pane_by_name(name)
}
function set_active_pane_by_name(name) {
// toggle the nav buttons
document.getElementsByClassName("nav-active")[0].classList.remove("nav-active")
e.classList.add("nav-active")
document.getElementById("nav-" + name).classList.add("nav-active")
// toggle the main interface content divs
document.getElementsByClassName("interface-active")[0].classList.remove("interface-active")
name = e.id.substring(4)
interface_el = document.getElementById('interface-' + name)
interface_el.classList.add("interface-active")
document.getElementById('interface-' + name).classList.add("interface-active")
// hack hack
switch(name) {
@ -351,6 +355,14 @@ function open_external_docs() {
window.open("https://www.pilosa.com/docs");
}
function check_anchor_uri() {
const pane_names = {"console": 0, "cluster": 0, "documentation": 0}
var anchor = window.location.hash.substr(1);
if(anchor in pane_names) {
set_active_pane_by_name(anchor)
}
}
Date.prototype.today = function () {
return this.getFullYear() +"/"+ (((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ ((this.getDate() < 10)?"0":"") + this.getDate();
}
@ -370,3 +382,5 @@ repl.populate_index_dropdown()
repl.bind_events()
input.focus()
check_anchor_uri()

View file

@ -15,17 +15,17 @@
</div>
<div class="container">
<div class="nav">
<div class="nav-item nav-active" id="nav-console" onclick="setNav(this)">
<div class="nav-item nav-active" id="nav-console" onclick="handle_nav_click(this)">
<img style='margin-bottom:10px;' height='40px' src="/assets/nav-console.svg" alt="" class="nav-image">
<img style='margin-bottom:10px;' height='40px' src="/assets/nav-console-active.svg" alt="" class="nav-image-active">
Console
</div>
<div class="nav-item" id="nav-cluster" onclick="setNav(this)">
<div class="nav-item" id="nav-cluster" onclick="handle_nav_click(this)">
<img style='margin-bottom:10px;' height='20px' src="/assets/nav-cluster.svg" alt="" class="nav-image">
<img style='margin-bottom:10px;' height='20px' src="/assets/nav-cluster-active.svg" alt="" class="nav-image-active">
Cluster Admin
</div>
<div class="nav-item" id="nav-documentation" onclick="setNav(this)">
<div class="nav-item" id="nav-documentation" onclick="handle_nav_click(this)">
<img style='margin-bottom:10px;' height='30px' src="/assets/nav-documentation.svg" alt="" class="nav-image">
<img style='margin-bottom:10px;' height='30px' src="/assets/nav-documentation-active.svg" alt="" class="nav-image-active">
Documentation