From 57ea1a8416bef71547254bdc5d94dc6d0d4f5336 Mon Sep 17 00:00:00 2001 From: oupala Date: Sun, 15 Jan 2017 23:54:43 +0100 Subject: [PATCH] feat(): move javascript code into a separate js file Move javascript code into a separate js file as it enable apaxy to be compliant with the most secure content security policy (aka CSP). You can now use the following Content Security Policy : Content-Security-Policy: default-src 'self' --- apaxy/theme/apaxy.js | 12 ++++++++++++ apaxy/theme/footer.html | 15 +-------------- 2 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 apaxy/theme/apaxy.js diff --git a/apaxy/theme/apaxy.js b/apaxy/theme/apaxy.js new file mode 100644 index 0000000..763198f --- /dev/null +++ b/apaxy/theme/apaxy.js @@ -0,0 +1,12 @@ +// grab the 2nd child and add the parent class. tr:nth-child(2) +document.getElementsByTagName('tr')[1].className = 'parent'; +// fix links when not adding a / at the end of the URI +var uri = window.location.pathname.substr(1); +if (uri.substring(uri.length-1) != '/'){ + var indexes = document.getElementsByClassName('indexcolname'), + i = indexes.length; + while (i--){ + var a = indexes[i].getElementsByTagName('a')[0]; + a.href = '/' + uri + '/' + a.getAttribute('href',2); + } +} diff --git a/apaxy/theme/footer.html b/apaxy/theme/footer.html index 204bad9..bbfd284 100644 --- a/apaxy/theme/footer.html +++ b/apaxy/theme/footer.html @@ -7,17 +7,4 @@ - +