174 window.location.hash = e.target.hash.replace("#", "#" + prefix);
175 })
176 // Read any hash links
177 var hash = document.location.hash;178 if (hash) {
179 $('.nav-tabs a[href="'+hash.replace(prefix,"")+'"]').tab('show');
180 }
169 });
170 // https://stackoverflow.com/questions/7862233
171 // Change hash for page-reload
172 var prefix = "tab_";173 $('.nav-tabs.maintabs a').on('shown.bs.tab', function (e) {
174 window.location.hash = e.target.hash.replace("#", "#" + prefix);
175 })
142
143 var currentdiv = TABS[CURRENTTAB] +"-ui";
144 $("#"+currentdiv).css("display", "block");
145 var btndiv = TABS[CURRENTTAB] +"-btn";146 $("#"+btndiv).removeClass().addClass("btn btn-primary");
147
148 $('#next-btn').prop('disabled', ((CURRENTTAB + 1) == TABS.length));
140 $("#"+btndiv).removeClass().addClass("btn btn-default");
141 CURRENTTAB = TABS.indexOf(tabtitle);
142
143 var currentdiv = TABS[CURRENTTAB] +"-ui";144 $("#"+currentdiv).css("display", "block");
145 var btndiv = TABS[CURRENTTAB] +"-btn";
146 $("#"+btndiv).removeClass().addClass("btn btn-primary");
136 var tabtitle = $(this).attr("id").replace("-btn", "");
137 var currentdiv = TABS[CURRENTTAB] +"-ui";
138 $("#"+currentdiv).css("display", "none");
139 var btndiv = TABS[CURRENTTAB] +"-btn";140 $("#"+btndiv).removeClass().addClass("btn btn-default");
141 CURRENTTAB = TABS.indexOf(tabtitle);
142
Declare variables at the top of their scope as it improves code readability, performance and also helps in code navigation.
The vars-on-top
rule generates warnings when variable declarations are not used serially at the top of a function scope or the top of a program. By default variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter. This rule forces the programmer to represent that behavior by manually moving the variable declaration to the top of its containing scope.
// Variable declarations in a block:
function doSomething() {
var first;
if (true) {
first = true;
}
var second;
}
// Variable declaration in for initializer:
function doSomething() {
for (var i=0; i<10; i++) {}
}
function doSomething() {
var first;
var second; //multiple declarations are allowed at the top
if (true) {
first = true;
}
}
function doSomething() {
var i;
for (i=0; i<10; i++) {}
}