8000 feat(404): auto fill search box with URL fragment that was not found · Pelican-Elegant/elegant@c0a7f47 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit c0a7f47

Browse files
iranzotalha131
authored andcommitted
feat(404): auto fill search box with URL fragment that was not found
Signed-off-by: Pablo Iranzo Gómez <Pablo.Iranzo@gmail.com>
1 parent e8c5578 commit c0a7f47

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

templates/404.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ <h1>That page doesn't exist!</h1>
1414
</header>
1515
</div>
1616

17-
1817
<div class="row-fluid">
1918
<div class="span8 offset2">
2019
<p>Sorry, but the page you are looking for cannot be found. It seems that the page you were trying to reach doesn't exist, or may be it has just moved, or it no longer exists.</p>
@@ -28,4 +27,22 @@ <h1>That page doesn't exist!</h1>
2827
</div>
2928
</div>
3029
</div>
30+
31+
<script type="text/javascript">
32+
// Get Current location as the initial search item
33+
var newurl = (' ' + window.location.pathname).slice(1);
34+
35+
// Replace "/" in path into spaces
36+
var newurl = newurl.replace(/\//g, ' ');
37+
38+
// Remove html extension
39+
var newurl = newurl.replace(/.html/g, ' ');
40+
41+
// Replace - by ' '
42+
var newurl = newurl.replace(/\-/g, ' ');
43+
44+
// Fill search field with resulting string
45+
document.getElementById('tipue_search_input_404').value = newurl;
46+
</script>
47+
3148
{% endblock content %}

0 commit comments

Comments
 (0)
0