mirror of
https://codeberg.org/mayx/pages
synced 2026-02-16 11:14:52 +08:00
update
This commit is contained in:
41
search.html
Normal file
41
search.html
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
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>
|
||||
Reference in New Issue
Block a user