Completed
Branch master (d2f96a)
by Rafael S.
02:27
created

docs/scripts/nav.js   A

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 12
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
mnd 1
bc 1
fnc 2
dl 0
loc 12
rs 10
bpm 0.5
cpm 1.5
noi 1
c 0
b 0
f 0
1
function scrollToNavItem() {
2
    var path = window.location.href.split('/').pop().replace(/\.html/, '');
3
    document.querySelectorAll('nav a').forEach(function(link) {
4
      var href = link.attributes.href.value.replace(/\.html/, '');
5
      if (path === href) {
6
        link.scrollIntoView({block: 'center'});
7
        return;
8
      }
9
    })
10
  }
11
12
  scrollToNavItem();
13