mirror of
https://github.com/Mabbs/mabbs.github.io
synced 2025-09-10 04:15:23 +02:00
Restore deleted repositories
This commit is contained in:
41
search.html
Normal file
41
search.html
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
layout: default
|
||||
title: 搜索
|
||||
---
|
||||
|
||||
<h1>搜索</h1>
|
||||
<!-- HTML elements for search -->
|
||||
<p>Keyword: <input type="text" id="search-input" placeholder="Search blog posts.."> <img src="/images/loading.svg" id="search-loading" style="width:22px;vertical-align: bottom"></p>
|
||||
<ul id="results-container"></ul>
|
||||
|
||||
<!-- or without installing anything -->
|
||||
<script src="https://unpkg.com/simple-jekyll-search@latest/dest/simple-jekyll-search.min.js"></script>
|
||||
<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(false);
|
||||
}
|
||||
var mykeyword = decodeURI(getQueryVariable("keyword"));
|
||||
var sbox = document.getElementById('search-input');
|
||||
var status = false;
|
||||
if(mykeyword != null && mykeyword.toString().length>1){
|
||||
sbox.value = mykeyword;
|
||||
}
|
||||
$.getJSON("search.json", function(json){
|
||||
var sjs = SimpleJekyllSearch({
|
||||
searchInput: sbox,
|
||||
resultsContainer: document.getElementById('results-container'),
|
||||
json: json,
|
||||
searchResultTemplate: '<p><li>{date} - <a href="{url}">{title}</a></li></p>',
|
||||
limit: 20
|
||||
});
|
||||
sjs.search(mykeyword);
|
||||
document.getElementById('search-loading').style.display = "none";
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user