git.haldean.org docstore / master
Ignore query params after page name. Fix for issue #1, where additional query params added from a mailing list were causing pages to fail to load. Will Haldean Brown 8 years ago
1 changed file(s) with 17 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
11
22 var converter = new Showdown.converter();
33
4 function findFirstOf(str, chars) {
5 var first = -1;
6 for (var i = 0; i < chars.length; i++) {
7 var loc = str.indexOf(chars[i])
8 if (loc != -1 && (loc < first || first == -1)) {
9 first = loc;
10 }
11 }
12 return first;
13 }
14
415 $.domReady(function() {
516 var page = document.location.search.substring(1)
6 if (page[page.length - 1] == '/') page = page.substring(0, page.length - 1)
17 var pageEnd = findFirstOf(page, ['&', '/'])
18 if (pageEnd >= 0) {
19 page = page.substring(0, pageEnd)
20 }
721 if (!page) {
822 window.location = homepage
923 return
2539 }})
2640
2741 document.title = page;
28 document.getElementById('viewsource').setAttribute('href',
42 document.getElementById('viewsource').setAttribute('href',
2943 'https://raw.github.com/haldean/docstore/master/' + url)
30
44
3145 MathJax.Hub.Config({
3246 tex2jax: {
3347 inlineMath: [['$','$'], ['\\(','\\)']],