-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.html
80 lines (69 loc) · 2.96 KB
/
search.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
layout: page
title: Search Results
---
{% include read-config.liquid %}
<hr/>
<div id="searchResultsDiv"></div>
<script type="text/javascript">
"use strict";
var whenDocumentReady = whenDocumentReady || function() {};
var whenSearchTermsReady = function() {
var searchText = decodeURIComponent(QueryString["txtSearch"] || "").split("+").join(" ");
if(searchText) {
$("#txtSearch").val(searchText);
// TODO: Hack to fix double render. Ajax or document.ready is being called twice.
$("#searchResultsDiv").text("");
var visitedUrls = [];
$.each(typeaheadHandler.getData(searchText), function(index, post) {
if(post && post.url && visitedUrls.indexOf(post.url) >= 0) return;
var regex = new RegExp(searchText, "gi");
var div = $("<div/>");
var header = null;
var excerpt = null;
var tags = null;
if(post.title) {
var title = $("<div/>").html(post.title).text();
header = $("<h3/>")
.css("font-weight", "bold")
.html(title.replace(regex, "<span class='searchHit'>$&</span>"));
} else {
header = $("<h3/>")
.css("font-weight", "bold")
.text("{Title Unknown}");
}
var date = $("<span/>");
if(post.date) {
date = $("<p/>")
.css("font-weight","bold")
.text(new Date(post.date.substr(0,10)).toString().substr(0,15));
}
if(post.excerpt) {
excerpt = $("<p/>")
.html(post.excerpt.replace(regex, "<span class='searchHit'>$&</span>"));
}
if(post.tags) {
var tagsText = post.tags.split(",").sort().join(", ");
tags = $("<p/>")
.html("<b>Tags:</b> " + tagsText.replace(regex, "<span class='searchHit'>$&</span>"));
}
var link = $("<p/>").html("<a href='" + post.url + "'>View " +
(post.isPost ? "Post" : "Page") +
" »</a>");
$("#searchResultsDiv").append($("<div/>")
.append(header || $("<span/>"))
.append(date || $("<span/>"))
.append(excerpt || $("<span/>"))
.append(tags || $("<span/>"))
.append(link)
);
visitedUrls.push(post.url);
});
}
};
</script>
<!-- --------------- -->
<!-- Edit the `metadata.copyright` value in the `_jekyllfaces/config.md` file to suit your needs. -->
<!-- --------------- -->
<hr/>
{{ config.metadata.copyright | markdownify }}