-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,53 @@ | ||
!function(){null!==document.getElementById("vcomments")&&new Valine({el:"#vcomments",appId:rebirth_option.valine_appid,appKey:rebirth_option.valine_appkey,serverURLs:rebirth_option.valine_serverurls,notify:!0,verify:!0,avatar:"mm",visitor:!0,highlight:!0,recordIP:!0,placeholder:"请您理智发言,共建美好社会!",path:window.location.pathname});let e={},t=$(this).index(),a=rebirth_option.home_url;function r(e,t){let a=new RegExp(t,"gi");return e=e.replace(a,function(e){return"<mark>"+e+"</mark>"})}$("#ghost-search-field").focus(function(){e[t]||$.ajax({type:"GET",url:a+"/wp-json/rebirth/v1/cache_search/json",dataType:"json",success:function(a){e[t]=a}})}),$("#ghost-search-field").on("input propertychange",function(){let a=$("#ghost-search-field").val();if(""===a){$("#ghost-search-results").html("");let e=$(".search-meta").attr("data-no-results-text").replace("[results]",0);$(".search-meta").text(e)}else{let s="",n=0;$.each(e[t],function(e,t){-1===t.title.toUpperCase().indexOf(a.toUpperCase())&&-1===t.text.toUpperCase().indexOf(a.toUpperCase())||(s+=function(e,t,a,s,n){let i=e.trim().split(" "),l=t.indexOf(i[i.length-1]),o=a.indexOf(i[i.length-1]);return t=l<20?t.slice(0,30):t.slice(l-10,l+10),a=o<40?a.slice(0,70):a.slice(o-45,o+45),'<a data-pjax href="'+n+'" class="ghost-search-item"><h2>'+(t=r(t,e))+'</h2><span id="search-span">'+(a=r(a,e)+"...")+"</span><br><span>发布日期:"+s+"</span></a>"}(a,t.title,t.text,t.time,t.link),n++)}),$("#ghost-search-results").html(s);let i=$(".search-meta").attr("data-no-results-text").replace("[results]",n);$(".search-meta").text(i)}})}(); | ||
! | ||
function() { | ||
null !== document.getElementById("vcomments") && new Valine({ | ||
el: "#vcomments", | ||
appId: rebirth_option.valine_appid, | ||
appKey: rebirth_option.valine_appkey, | ||
serverURLs: rebirth_option.valine_serverurls, | ||
notify: !1, | ||
verify: !0, | ||
avatar: "mm", | ||
visitor: !0, | ||
highlight: !0, | ||
recordIP: !0, | ||
placeholder: "请您理智发言,共建美好社会!", | ||
path: window.location.pathname | ||
}); | ||
let e = {}, t = $(this).index(), a = rebirth_option.home_url; | ||
|
||
function r(e, t) { | ||
let a = new RegExp(t, "gi"); | ||
return e = e.replace(a, function(e) { | ||
return "<mark>" + e + "</mark>" | ||
}) | ||
} | ||
$("#ghost-search-field").focus(function() { | ||
e[t] || $.ajax({ | ||
type: "GET", | ||
url: a + "/wp-json/rebirth/v1/cache_search/json", | ||
dataType: "json", | ||
success: function(a) { | ||
e[t] = a | ||
} | ||
}) | ||
}), $("#ghost-search-field").on("input propertychange", function() { | ||
let a = $("#ghost-search-field").val(); | ||
if ("" === a) { | ||
$("#ghost-search-results").html(""); | ||
let e = $(".search-meta").attr("data-no-results-text").replace("[results]", 0); | ||
$(".search-meta").text(e) | ||
} else { | ||
let s = "", n = 0; | ||
$.each(e[t], function(e, t) { | ||
-1 === t.title.toUpperCase().indexOf(a.toUpperCase()) && -1 === t.text.toUpperCase().indexOf(a.toUpperCase()) || (s += | ||
function(e, t, a, s, n) { | ||
let i = e.trim().split(" "), l = t.indexOf(i[i.length - 1]), o = a.indexOf(i[i.length - 1]); | ||
return t = l < 20 ? t.slice(0, 30) : t.slice(l - 10, l + 10), a = o < 40 ? a.slice(0, 70) : a.slice(o - 45, o + 45), '<a data-pjax href="' + n + '" class="ghost-search-item"><h2>' + (t = r(t, e)) + '</h2><span id="search-span">' + (a = r(a, e) + "...") + "</span><br><span>发布日期:" + s + "</span></a>" | ||
}(a, t.title, t.text, t.time, t.link), n++) | ||
}), $("#ghost-search-results").html(s); | ||
let i = $(".search-meta").attr("data-no-results-text").replace("[results]", n); | ||
$(".search-meta").text(i) | ||
} | ||
}) | ||
}(); |