自己的一套, 存在读者本地(localStorage),不占服务器、不跨设备。 后台「搜索记录」里的数据是另一套,一条都不受这里影响。 */ (function () { var KEY = 'szw_searchhist'; var SHOW = 10; /* 面板里最多显示几条 */ var KEEP = 30; /* 本地最多存几条 */ function read() { try { return JSON.parse(localStorage.getItem(KEY) || '[]') || []; } catch (e) { return []; } } function write(list) { try { localStorage.setItem(KEY, JSON.stringify(list)); } catch (e) {} } function esc(s) { return String(s == null ? '' : s) .replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); } /* 记一条:已存在的先删掉再放到最前面,所以最新的永远在最上 */ function add(word) { word = String(word || '').replace(/^\s+|\s+$/g, ''); if (!word) return; var list = read(), out = [word], i; for (i = 0; i < list.length; i++) { if (list[i] !== word) out.push(list[i]); } if (out.length > KEEP) out = out.slice(0, KEEP); write(out); } function render() { var box = document.getElementById('szwHistList'); if (!box) return 0; var list = read(), h = '', n = 0, i; for (i = 0; i < list.length && n < SHOW; i++) { if (!list[i]) continue; h += '
  • ' + esc(list[i]) + '
  • '; n++; } box.innerHTML = h || '
  • 还没有搜索记录
  • '; var as = box.querySelectorAll('a[data-w]'); for (i = 0; i < as.length; i++) { as[i].onclick = function () { var inp = document.getElementById('szwSearchInput'); var fm = document.getElementById('szwSearchForm'); if (inp) inp.value = this.getAttribute('data-w'); if (fm) fm.submit(); return false; }; } return n; } function init() { var inp = document.getElementById('szwSearchInput'); var fm = document.getElementById('szwSearchForm'); var panel = document.getElementById('szwHistPanel'); var clr = document.getElementById('szwHistClear'); if (!inp || !panel) return; /* 提交时把关键词记下来 */ if (fm) { fm.onsubmit = function () { add(inp.value); return true; }; } inp.onfocus = function () { render(); panel.style.display = 'block'; }; inp.onclick = function (e) { render(); panel.style.display = 'block'; if (e && e.stopPropagation) e.stopPropagation(); }; if (clr) { clr.onclick = function (e) { write([]); render(); if (e && e.stopPropagation) e.stopPropagation(); return false; }; } document.addEventListener('click', function (e) { if (panel.style.display !== 'block') return; var n = e.target; while (n) { if (n === panel || n === inp) return; n = n.parentNode; } panel.style.display = 'none'; }); /* 搜索结果页:把地址里的关键词也记上,直接点结果页链接过来的也能留痕 */ try { var m = location.search.match(/[?&]q=([^&]+)/); if (m) add(decodeURIComponent(m[1].replace(/\+/g, ' '))); } catch (e) {} } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();

    穿过旷原的风 第23章 重逢

    正在加载中……

    一键收藏分享已经复制成功,粘贴即可分享或保存 已加入书架,可在顶部「书架」查看加入书架