-
Notifications
You must be signed in to change notification settings - Fork 1
/
404.html
52 lines (49 loc) · 1.89 KB
/
404.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
layout: page
title: Error 404
subtitle: Page not found!
---
Sorry, the page you attempted to access doesn't appear to exist!
You may have mistyped the address, or the page may have been moved or deleted.
{% include search.html %}
{% raw %}
<script type="text/javascript">
var StormBit = StormBit || {}
StormBit.fourOhFour = {
resultHtml: false,
searchResultContainer: false,
searchParams: {
engine_key: false,
q: false,
per_page: false,
},
init: function() {
StormBit.fourOhFour.searchResultContainer = $("#search-results");
StormBit.fourOhFour.searchResultContainer.html("");
StormBit.fourOhFour.searchParams.engine_key = "PTCnAnrfYm7pvRS51Wya";
StormBit.fourOhFour.searchParams.q = window.location.pathname.split(/[/-_]/).join(" ");
StormBit.fourOhFour.searchParams.per_page = 10;
$.getJSON(
"http://api.swiftype.com/api/v1/public/engines/search.json?callback=?",
StormBit.fourOhFour.searchParams
).success(StormBit.fourOhFour.renderResults);
},
renderResults: function(data) {
if (data['records']['page'].length > 0) {
StormBit.fourOhFour.searchResultContainer.append("<h2>Suggested pages:</h2>");
$.each(data['records']['page'], function(index, result) {
StormBit.fourOhFour.searchResultContainer.append(
"<p><a href='" + result['url'] + "'>" +
(result['highlight']['title'] || result['title']) + "</a><br>" +
(result['highlight']['body'] || result['body'].substring(0, 300)) +
"</p>"
)
});
}
}
}
$(document).ready(function() {
StormBit.fourOhFour.init();
});
</script>
{% endraw %}