-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
37 lines (32 loc) · 881 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function loadScript( scriptName ){
$.getScript( scriptName )
.done(function( script, textStatus ) {
console.log( getInfo() );
onLoad();
}).fail(function( jqxhr, settings, exception ) {
console.log( "Triggered ajaxError handler." );
});
}
function displayHash(hash){
if(hash){
console.log(hash );
// assumes that the anchor tag and li tag
//remove the current anchor tag
$( ".active" ).removeClass("active");
$('a[href="'+ hash +'"]').parent().addClass("active");
loadScript(hash.replace("#", "") + ".js" );
}
}
$( document ).ready(function() {
console.log( "ready!" );
if(window.location.hash){
displayHash(window.location.hash );
}
else{
loadScript('overview.js');
}
$(window).on('hashchange', function(){
// On every hash change the render function is called with the new hash.
displayHash(window.location.hash );
});
});