Commit e6ec151eb748e2b4ef4a1d37054dba978f542103
1 parent
62b85a12
Ensure only correct link are dynamised
Showing
1 changed file
with
20 additions
and
2 deletions
Show diff stats
js/crep.js
1 | +function removeAfter(string, pattern) { | |
2 | + var n = string.indexOf(pattern); | |
3 | + return string.substring(0, n != -1 ? n : string.length); | |
4 | +} | |
5 | + | |
6 | +function pageName(href) { | |
7 | + console.debug(href) | |
8 | + if (href.indexOf(window.location.host) >= 0) { | |
9 | + href = removeAfter(removeAfter(href, '?'), '#') | |
10 | + console.debug(href) | |
11 | + hrefE = href.split('/') | |
12 | + console.debug(hrefE) | |
13 | + return hrefE[hrefE.length - 1] | |
14 | + } | |
15 | + return false | |
16 | +} | |
17 | + | |
1 | 18 | function pageSpecific(location) { |
2 | - if (location.indexOf('contact') >= 0) { | |
19 | + if (pageName(location) == 'contact') { | |
3 | 20 | initializeMap() |
4 | 21 | } |
5 | 22 | } |
6 | 23 | |
7 | 24 | function actLink(ev) { |
8 | 25 | var location = ev.currentTarget.href |
9 | - if (location.indexOf(window.location.host) >= 0) { | |
26 | + var page = pageName(location) | |
27 | + if (page && page != pageName(window.location.href)) { | |
10 | 28 | loadDoc(location, function () { |
11 | 29 | history.pushState({ |
12 | 30 | loc: location | ... | ... |