From e6ec151eb748e2b4ef4a1d37054dba978f542103 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Tue, 3 Mar 2015 13:15:53 +0100 Subject: [PATCH] Ensure only correct link are dynamised --- js/crep.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/js/crep.js b/js/crep.js index 6bd4e64..a7e5f6d 100755 --- a/js/crep.js +++ b/js/crep.js @@ -1,12 +1,30 @@ +function removeAfter(string, pattern) { + var n = string.indexOf(pattern); + return string.substring(0, n != -1 ? n : string.length); +} + +function pageName(href) { + console.debug(href) + if (href.indexOf(window.location.host) >= 0) { + href = removeAfter(removeAfter(href, '?'), '#') + console.debug(href) + hrefE = href.split('/') + console.debug(hrefE) + return hrefE[hrefE.length - 1] + } + return false +} + function pageSpecific(location) { - if (location.indexOf('contact') >= 0) { + if (pageName(location) == 'contact') { initializeMap() } } function actLink(ev) { var location = ev.currentTarget.href - if (location.indexOf(window.location.host) >= 0) { + var page = pageName(location) + if (page && page != pageName(window.location.href)) { loadDoc(location, function () { history.pushState({ loc: location -- libgit2 0.21.2