Mayx's Home Page https://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.

38 lines
1.2 KiB

  1. ---
  2. layout: default
  3. title: 搜索
  4. ---
  5. <h1>搜索</h1>
  6. <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>
  7. <ul id="results-container"></ul>
  8. <script src="/js/simple-jekyll-search.min.js"></script>
  9. <script>
  10. function getQueryVariable(variable)
  11. {
  12. var query = window.location.search.substring(1);
  13. var vars = query.split("&");
  14. for (var i=0;i<vars.length;i++) {
  15. var pair = vars[i].split("=");
  16. if(pair[0] == variable){return pair[1];}
  17. }
  18. return(false);
  19. }
  20. var mykeyword = decodeURI(getQueryVariable("keyword"));
  21. var sbox = document.getElementById('search-input');
  22. var status = false;
  23. if(mykeyword != null && mykeyword.toString().length>1){
  24. sbox.value = mykeyword;
  25. }
  26. getSearchJSON(function(json){
  27. var sjs = SimpleJekyllSearch({
  28. searchInput: sbox,
  29. resultsContainer: document.getElementById('results-container'),
  30. json: json,
  31. searchResultTemplate: '<p><li>{date} - <a href="{url}">{title}</a></li></p>',
  32. limit: 20
  33. });
  34. sjs.search(mykeyword);
  35. document.getElementById('search-loading').style.display = "none";
  36. });
  37. </script>

Powered by TurnKey Linux.