mirror of https://github.com/Mabbs/mabbs.github.io
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.4 KiB
41 lines
1.4 KiB
--- |
|
layout: default |
|
title: 搜索 |
|
--- |
|
|
|
<h1>搜索</h1> |
|
<form action="https://www.google.com/search"> |
|
<input type="hidden" name="as_sitesearch" value="mabbs.github.io" /> |
|
<p><center><input name="q" type="text" id="search-input" placeholder="Search blog posts.." /> <img src="/images/loading.svg" alt="Loading..." id="search-loading" style="width:22px;vertical-align: bottom" /> <input type="submit" value="谷歌搜索" style="margin-left: 5px;" /></center></p> |
|
</form> |
|
<ul id="results-container"></ul> |
|
<script> |
|
function getQueryVariable(variable){ |
|
var query = window.location.search.substring(1); |
|
var vars = query.split("&"); |
|
for (var i=0;i<vars.length;i++) { |
|
var pair = vars[i].split("="); |
|
if(pair[0] == variable){return pair[1];} |
|
} |
|
return(''); |
|
} |
|
var mykeyword = decodeURI(getQueryVariable("keyword")); |
|
var sbox = document.getElementById('search-input'); |
|
if (mykeyword) { |
|
sbox.value = mykeyword; |
|
} |
|
</script> |
|
<script src="/assets/js/simple-jekyll-search.min.js"></script> |
|
<script> |
|
getSearchJSON(function(json){ |
|
var sjs = SimpleJekyllSearch({ |
|
searchInput: sbox, |
|
resultsContainer: document.getElementById('results-container'), |
|
json: json, |
|
searchResultTemplate: '<li><p>{date} - <a href="{url}?kw={query}">{title}</a></p></li>', |
|
limit: 20 |
|
}); |
|
sjs.search(mykeyword); |
|
document.getElementById('search-loading').style.display = "none"; |
|
}); |
|
</script> |