This commit is contained in:
2019-05-30 18:52:14 +08:00
commit aa360a22bf
341 changed files with 30369 additions and 0 deletions

View File

@ -0,0 +1,4 @@
{% include 'busuanzi-counter.swig' %}
{% include 'tencent-mta.swig' %}
{% include 'tencent-analytics.swig' %}
{% include 'cnzz-analytics.swig' %}

View File

@ -0,0 +1,11 @@
{% if theme.application_insights %}
<script>
var appInsights=window.appInsights||function(config){
function i(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s="AuthenticatedUserContext",h="start",c="stop",l="Track",a=l+"Event",v=l+"Page",y=u.createElement(o),r,f;y.src=config.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js";u.getElementsByTagName(o)[0].parentNode.appendChild(y);try{t.cookie=u.cookie}catch(p){}for(t.queue=[],t.version="1.0",r=["Event","Exception","Metric","PageView","Trace","Dependency"];r.length;)i("track"+r.pop());return i("set"+s),i("clear"+s),i(h+a),i(c+a),i(h+v),i(c+v),i("flush"),config.disableExceptionTracking||(r="onerror",i("_"+r),f=e[r],e[r]=function(config,i,u,e,o){var s=f&&f(config,i,u,e,o);return s!==!0&&t["_"+r](config,i,u,e,o),s}),t
}({
instrumentationKey:"{{ theme.application_insights }}"
});
window.appInsights=appInsights;
appInsights.trackPageView();
</script>
{% endif %}

View File

@ -0,0 +1,11 @@
{% if theme.baidu_analytics %}
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?{{ theme.baidu_analytics }}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
{% endif %}

View File

@ -0,0 +1,27 @@
{% if theme.busuanzi_count.enable %}
<div class="busuanzi-count">
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{% if theme.busuanzi_count.total_visitors %}
<span class="post-meta-item-icon">
<i class="fa fa-{{ theme.busuanzi_count.total_visitors_icon }}"></i>
</span>
<span class="site-uv" title="{{ __('footer.total_visitors') }}">
<span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
</span>
{% endif %}
{% if theme.busuanzi_count.total_visitors and theme.busuanzi_count.total_views %}
<span class="post-meta-divider">|</span>
{% endif %}
{% if theme.busuanzi_count.total_views %}
<span class="post-meta-item-icon">
<i class="fa fa-{{ theme.busuanzi_count.total_views_icon }}"></i>
</span>
<span class="site-pv" title="{{ __('footer.total_views') }}">
<span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
</span>
{% endif %}
</div>
{% endif %}

View File

@ -0,0 +1,5 @@
{% if theme.cnzz_siteid %}
<div style="display: none;">
<script src="//s95.cnzz.com/z_stat.php?id={{ theme.cnzz_siteid }}&web_id={{ theme.cnzz_siteid }}"></script>
</div>
{% endif %}

View File

@ -0,0 +1,18 @@
{% if theme.facebook_sdk.enable %}
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{{ theme.facebook_sdk.app_id }}',
xfbml : true,
version: 'v3.3'
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/{{ config.language|replace('-', '_') }}/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
{% endif %}

View File

@ -0,0 +1,99 @@
{% if theme.firestore.enable %}
<script src="https://www.gstatic.com/firebasejs/4.6.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.6.0/firebase-firestore.js"></script>
{% if theme.firestore.bluebird %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.5.1/bluebird.core.min.js"></script>
{% endif %}
<script>
(function () {
firebase.initializeApp({
apiKey: '{{ theme.firestore.apiKey }}',
projectId: '{{ theme.firestore.projectId }}'
})
function getCount(doc, increaseCount) {
//increaseCount will be false when not in article page
return doc.get().then(function (d) {
var count
if (!d.exists) { //has no data, initialize count
if (increaseCount) {
doc.set({
count: 1
})
count = 1
}
else {
count = 0
}
}
else { //has data
count = d.data().count
if (increaseCount) {
if (!(window.localStorage && window.localStorage.getItem(title))) { //if first view this article
doc.set({ //increase count
count: count + 1
})
count++
}
}
}
if (window.localStorage && increaseCount) { //mark as visited
localStorage.setItem(title, true)
}
return count
})
}
function appendCountTo(el) {
return function (count) {
$(el).append(
$('<span>').addClass('post-visitors-count').append(
$('<span>').addClass('post-meta-divider').text('|')
).append(
$('<span>').addClass('post-meta-item-icon').append(
$('<i>').addClass('fa fa-users')
)
).append($('<span>').text('{{ __("post.views")}} ' + count))
)
}
}
var db = firebase.firestore()
var articles = db.collection('{{ theme.firestore.collection }}')
//https://hexo.io/docs/variables.html
var isPost = '{{ page.title }}'.length > 0
var isArchive = '{{ page.archive }}' === 'true'
var isCategory = '{{ page.category }}'.length > 0
var isTag = '{{ page.tag }}'.length > 0
if (isPost) { //is article page
var title = '{{ page.title }}'
var doc = articles.doc(title)
getCount(doc, true).then(appendCountTo($('.post-meta')))
}
else if (!isArchive && !isCategory && !isTag) { //is index page
var titles = [] //array to titles
var postsstr = '{% for post in page.posts %}titles.push("{{ post.title }}");{% endfor %}' //if you have a better way to get titles of posts, please change it
eval(postsstr)
var promises = titles.map(function (title) {
return articles.doc(title)
}).map(function (doc) {
return getCount(doc)
})
Promise.all(promises).then(function (counts) {
var metas = $('.post-meta')
counts.forEach(function (val, idx) {
appendCountTo(metas[idx])(val)
})
})
}
})()
</script>
{% endif %}

View File

@ -0,0 +1,12 @@
{% if theme.google_analytics.tracking_id %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ theme.google_analytics.tracking_id }}"></script>
<script>
var host = window.location.hostname;
if (host !== "localhost" || !{{theme.google_analytics.localhost_ignored}}) {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ theme.google_analytics.tracking_id }}');
}
</script>
{% endif %}

View File

@ -0,0 +1,7 @@
{% if theme.growingio_analytics %}
<script>
!function(e,t,n,g,i){e[i]=e[i]||function(){(e[i].q=e[i].q||[]).push(arguments)},n=t.createElement("script"),tag=t.getElementsByTagName("script")[0],n.async=1,n.src=('https:'==document.location.protocol?'https://':'http://')+g,tag.parentNode.insertBefore(n,tag)}(window,document,"script","assets.growingio.com/2.1/gio.js","gio");
gio('init','{{theme.growingio_analytics}}', {});
gio('send');
</script>
{% endif %}

View File

@ -0,0 +1,6 @@
{% include 'facebook-sdk.swig' %}
{% include 'vkontakte-api.swig' %}
{% include 'google-analytics.swig' %}
{% include 'baidu-analytics.swig' %}
{% include 'application-insights.swig' %}
{% include 'growingio.swig' %}

View File

@ -0,0 +1,116 @@
{% if theme.leancloud_visitors.enable and !theme.valine.visitor %}
{# custom analytics part create by xiamo; edited by LEAFERx #}
<script>
{% if page.layout === 'post' %}
function addCount(Counter) {
var $visitors = $('.leancloud_visitors');
var url = $visitors.attr('id').trim();
var title = $visitors.attr('data-flag-title').trim();
Counter('get', '/classes/Counter', { where: JSON.stringify({ url }) })
.done(function({ results }) {
if (results.length > 0) {
var counter = results[0];
{% if theme.leancloud_visitors.betterPerformance %}
var $element = $(document.getElementById(url));
$element.find('.leancloud-visitors-count').text(counter.time + 1);
{% endif %}
Counter('put', '/classes/Counter/' + counter.objectId, JSON.stringify({ time: { '__op': 'Increment', 'amount': 1 } }))
{% if not theme.leancloud_visitors.betterPerformance %}
.done(function() {
var $element = $(document.getElementById(url));
$element.find('.leancloud-visitors-count').text(counter.time + 1);
})
{% endif %}
.fail(function ({ responseJSON }) {
console.log('Failed to save Visitor num, with error message: ' + responseJSON.error);
})
} else {
{% if theme.leancloud_visitors.security %}
var $element = $(document.getElementById(url));
$element.find('.leancloud-visitors-count').text('Counter not initialized! More info at console err msg.');
console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.');
{% else %}
Counter('post', '/classes/Counter', JSON.stringify({ title: title, url: url, time: 1 }))
.done(function() {
var $element = $(document.getElementById(url));
$element.find('.leancloud-visitors-count').text(1);
})
.fail(function() {
console.log('Failed to create');
});
{% endif %}
}
})
.fail(function ({ responseJSON }) {
console.log('LeanCloud Counter Error: ' + responseJSON.code + ' ' + responseJSON.error);
});
}
{% else %}
function showTime(Counter) {
var entries = [];
var $visitors = $('.leancloud_visitors');
$visitors.each(function() {
entries.push( $(this).attr('id').trim() );
});
Counter('get', '/classes/Counter', { where: JSON.stringify({ url: { '$in': entries } }) })
.done(function({ results }) {
var COUNT_CONTAINER_REF = '.leancloud-visitors-count';
if (results.length === 0) {
$visitors.find(COUNT_CONTAINER_REF).text(0);
return;
}
for (var i = 0; i < results.length; i++) {
var item = results[i];
var url = item.url;
var time = item.time;
var element = document.getElementById(url);
$(element).find(COUNT_CONTAINER_REF).text(time);
}
for (var i = 0; i < entries.length; i++) {
var url = entries[i];
var element = document.getElementById(url);
var countSpan = $(element).find(COUNT_CONTAINER_REF);
if (countSpan.text() == '') {
countSpan.text(0);
}
}
})
.fail(function ({ responseJSON }) {
console.log('LeanCloud Counter Error: ' + responseJSON.code + ' ' + responseJSON.error);
});
}
{% endif %}
$(function() {
$.get('https://app-router.leancloud.cn/2/route?appId=' + '{{ theme.leancloud_visitors.app_id }}')
.done(function({ api_server }) {
var Counter = function(method, url, data) {
return $.ajax({
method: method,
url: 'https://' + api_server + '/1.1' + url,
headers: {
'X-LC-Id': '{{ theme.leancloud_visitors.app_id }}',
'X-LC-Key': '{{ theme.leancloud_visitors.app_key }}',
'Content-Type': 'application/json',
},
data: data
});
};
{% if page.layout === 'post' %}
addCount(Counter);
{% else %}
if ($('.post-title-link').length >= 1) {
showTime(Counter);
}
{% endif %}
});
});
</script>
{% endif %}

View File

@ -0,0 +1,10 @@
{% if theme.tencent_analytics %}
<script>
(function() {
var hm = document.createElement("script");
hm.src = "//tajs.qq.com/stats?sId={{ theme.tencent_analytics }}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
{% endif %}

View File

@ -0,0 +1,13 @@
{% if theme.tencent_mta %}
<script>
var _mtac = {};
(function() {
var mta = document.createElement("script");
mta.src = "https://pingjs.qq.com/h5/stats.js";
mta.setAttribute("name", "MTAH5");
mta.setAttribute("sid", "{{theme.tencent_mta}}");
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(mta, s);
})();
</script>
{% endif %}

View File

@ -0,0 +1,25 @@
{% if theme.vkontakte_api.enable %}
<div id="vk_api_transport"></div>
<script>
window.vkAsyncInit = function() {
VK.init({
apiId: {{ theme.vkontakte_api.app_id }}
});
{% if not is_home() and (is_post() and theme.vkontakte_api.like) %}
VK.Widgets.Like("vk_like", {type: "mini", height: 20});
{% endif %}
{% if page.comments and theme.vkontakte_api.comments %}
VK.Widgets.Comments("vk_comments", {limit: {{ theme.vkontakte_api.num_of_posts }}, attach: "*"});
{% endif %}
};
setTimeout(function() {
var el = document.createElement("script");
el.type = "text/javascript";
el.src = "//vk.com/js/api/openapi.js";
el.async = true;
document.getElementById("vk_api_transport").appendChild(el);
}, 0);
</script>
{% endif %}

View File

@ -0,0 +1,11 @@
{% if theme.baidu_push %}
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
{% endif %}

View File

@ -0,0 +1,14 @@
{% if theme.bookmark and theme.bookmark.enable %}
{% set bookmark_uri = url_for(theme.vendors._internal + '/bookmark/bookmark.min.js?v=1.0') %}
{% if theme.vendors.bookmark %}
{% set bookmark_uri = theme.vendors.bookmark %}
{% endif %}
<script src="{{ bookmark_uri }}"></script>
<script>
{% if is_post() %}
bookmark.scrollToMark('{{ theme.bookmark.save }}', "#{{ __('post.more') }}");
{% else %}
bookmark.loadBookmark();
{% endif %}
</script>
{% endif %}

View File

@ -0,0 +1,22 @@
{% if theme.chatra.enable %}
{% if theme.chatra.embed %}
<script>
window.ChatraSetup = {
mode: 'frame',
injectTo: '{{ theme.chatra.embed }}'
};
</script>
{% endif %}
<script>
(function(d, w, c) {
w.ChatraID = '{{ theme.chatra.id }}';
var s = d.createElement('script');
w[c] = w[c] || function() {
(w[c].q = w[c].q || []).push(arguments);
};
s.async = {{ theme.chatra.async }};
s.src = 'https://call.chatra.io/chatra.js';
if (d.head) d.head.appendChild(s);
})(document, window, 'Chatra');
</script>
{% endif %}

View File

@ -0,0 +1,18 @@
{% if is_home() %}
<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{ theme.changyan.appid }}"></script>
{% elif page.comments %}
<script>
(function() {
var appid = '{{ theme.changyan.appid }}';
var conf = '{{ theme.changyan.appkey }}';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>');
}
else {
var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})});
}
})();
</script>
<script src="https://assets.changyan.sohu.com/upload/plugins/plugins.count.js"></script>
{% endif %}

View File

@ -0,0 +1,44 @@
{% if theme.disqus.count %}
<script id="dsq-count-scr" src="https://{{ theme.disqus.shortname }}.disqus.com/count.js" async></script>
{% endif %}
{% if page.comments %}
<script>
var disqus_config = function() {
this.page.url = {{ page.permalink | json }};
this.page.identifier = {{ page.path | json }};
this.page.title = '{{ page.title | addslashes }}';
{% if __('disqus') !== 'disqus' -%}
this.language = '{{ __('disqus') }}';
{% endif -%}
};
function loadComments() {
var d = document, s = d.createElement('script');
s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
}
{% if theme.disqus.lazyload %}
$(function() {
var offsetTop = $('#comments').offset().top - $(window).height();
if (offsetTop <= 0) {
// load directly when there's no a scrollbar
loadComments();
} else {
$(window).on('scroll.disqus_scroll', function() {
// offsetTop may changes because of manually resizing browser window or lazy loading images.
var offsetTop = $('#comments').offset().top - $(window).height();
var scrollTop = $(window).scrollTop();
// pre-load comments a bit? (margin or anything else)
if (offsetTop - scrollTop < 60) {
$(window).off('.disqus_scroll');
loadComments();
}
});
}
});
{% else %}
loadComments();
{% endif %}
</script>
{% endif %}

View File

@ -0,0 +1,19 @@
{% set disqusjs_css_url = '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css' %}
{% if theme.vendors.disqusjs_css %}
{% set disqusjs_css_url = theme.vendors.disqusjs_css %}
{% endif %}
<link rel="stylesheet" href="{{ disqusjs_css_url }}"/>
{% set disqusjs_js_url = '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js' %}
{% if theme.vendors.disqusjs_js %}
{% set disqusjs_js_url = theme.vendors.disqusjs_js %}
{% endif %}
<script src="{{ disqusjs_js_url }}"></script>
<script>
var dsqjs = new DisqusJS({
api: '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/',
apikey: '{{ theme.disqusjs.apikey }}',
shortname: '{{ theme.disqusjs.shortname }}'
});
</script>

View File

@ -0,0 +1,35 @@
{% set gitalk_js_url = '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js' %}
{% if theme.vendors.gitalk_js %}
{% set gitalk_js_url = theme.vendors.gitalk_js %}
{% endif %}
<script src="{{ gitalk_js_url }}"></script>
{% set gitalk_css_url = '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css' %}
{% if theme.vendors.gitalk_css %}
{% set gitalk_css_url = theme.vendors.gitalk_css %}
{% endif %}
<link rel="stylesheet" href="{{ gitalk_css_url }}"/>
{% set md5_url = '//cdn.jsdelivr.net/npm/js-md5@0.7.3/src/md5.min.js' %}
{% if theme.vendors.md5 %}
{% set md5_url = theme.vendors.md5 %}
{% endif %}
<script src="{{ md5_url }}"></script>
<script>
var gitalk = new Gitalk({
clientID: '{{ theme.gitalk.client_id }}',
clientSecret: '{{ theme.gitalk.client_secret }}',
repo: '{{ theme.gitalk.repo }}',
owner: '{{ theme.gitalk.github_id }}',
admin: ['{{ theme.gitalk.admin_user }}'],
id: md5(location.pathname),
{% if theme.gitalk.language == '' %}
language: window.navigator.language || window.navigator.userLanguage,
{% else %}
language: '{{ theme.gitalk.language }}',
{% endif %}
distractionFreeMode: '{{ theme.gitalk.distraction_free_mode }}'
});
gitalk.render('gitalk-container');
</script>

View File

@ -0,0 +1,45 @@
<!-- LOCAL: You can save these files to your site and update links -->
{% if theme.gitment.mint %}
{% set CommentsClass = 'Gitmint' %}
<script src="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/gitmint.browser.js"></script>
{% else %}
{% set CommentsClass = 'Gitment' %}
<script src="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/gitment.browser.js"></script>
{% endif %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/default.css"/>
<!-- END LOCAL -->
<script>
function renderGitment() {
var gitment = new {{ CommentsClass }}({
id: window.location.pathname,
owner: '{{ theme.gitment.github_user }}',
repo: '{{ theme.gitment.github_repo }}',
{% if theme.gitment.mint %}
lang: '{{ theme.gitment.language }}' || navigator.language || navigator.systemLanguage || navigator.userLanguage,
{% endif %}
oauth: {
{% if theme.gitment.mint and theme.gitment.redirect_protocol %}
redirect_protocol: '{{ theme.gitment.redirect_protocol }}',
{% endif %}
{% if theme.gitment.mint and theme.gitment.proxy_gateway %}
proxy_gateway: '{{ theme.gitment.proxy_gateway }}',
{% else %}
client_secret: '{{ theme.gitment.client_secret }}',
{% endif %}
client_id: '{{ theme.gitment.client_id }}'
}
});
gitment.render('gitment-container');
}
{% if not theme.gitment.lazy %}
renderGitment();
{% else %}
function showGitment() {
document.getElementById('gitment-display-button').style.display = 'none';
document.getElementById('gitment-container').style.display = 'block';
renderGitment();
}
{% endif %}
</script>

View File

@ -0,0 +1,19 @@
{% if theme.disqus.enable %}
{% include 'disqus.swig' %}
{% elif theme.changyan.enable and theme.changyan.appid and theme.changyan.appkey %}
{% include 'changyan.swig' %}
{% elif theme.valine.enable and theme.valine.appid and theme.valine.appkey %}
{% include 'valine.swig' %}
{% endif %}
{% if page.comments %}
{% if theme.livere_uid %}
{% include 'livere.swig' %}
{% elif theme.gitment.enable and theme.gitment.client_id %}
{% include 'gitment.swig' %}
{% elif theme.gitalk.enable %}
{% include 'gitalk.swig' %}
{% elif theme.disqusjs.enable and theme.disqusjs.apikey and theme.disqusjs.shortname %}
{% include 'disqusjs.swig' %}
{% endif %}
{% endif %}

View File

@ -0,0 +1,13 @@
<script>
window.livereOptions = {
refer: '{{ page.path }}'
};
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>

View File

@ -0,0 +1,32 @@
{% set leancloud_uri = '//cdn1.lncld.net/static/js/3.11.1/av-min.js' %}
{% if theme.vendors.leancloud %}
{% set leancloud_uri = theme.vendors.leancloud %}
{% endif %}
<script src="{{ leancloud_uri }}"></script>
{% set valine_uri = '//unpkg.com/valine/dist/Valine.min.js' %}
{% if theme.vendors.valine %}
{% set valine_uri = theme.vendors.valine %}
{% endif %}
<script src="{{ valine_uri }}"></script>
<script>
var GUEST = ['nick', 'mail', 'link'];
var guest = '{{ theme.valine.guest_info }}';
guest = guest.split(',').filter(function(item) {
return GUEST.indexOf(item) > -1;
});
new Valine({
el: '#comments',
verify: {{ theme.valine.verify }},
notify: {{ theme.valine.notify }},
appId: '{{ theme.valine.appid }}',
appKey: '{{ theme.valine.appkey }}',
placeholder: '{{ theme.valine.placeholder }}',
avatar: '{{ theme.valine.avatar }}',
meta: guest,
pageSize: '{{ theme.valine.pageSize }}' || 10,
visitor: {{ theme.valine.visitor }},
lang: '{{ theme.valine.language }}' || 'zh-cn'
});
</script>

View File

@ -0,0 +1,36 @@
{% if theme.codeblock.copy_button.enable %}
<script>
$('.highlight').not('.gist .highlight').each(function(i, e) {
var $wrap = $('<div>').addClass('highlight-wrap');
$(e).after($wrap);
$wrap.append($('<button>').addClass('copy-btn').append('{{__("post.copy_button")}}').on('click', function(e) {
var code = $(this).parent().find('.code').find('.line').map(function(i, e) {
return $(e).text();
}).toArray().join('\n');
var ta = document.createElement('textarea');
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
ta.style.top = yPosition + 'px'; // Prevent page scroll
ta.style.position = 'absolute';
ta.style.opacity = '0';
ta.readOnly = true;
ta.value = code;
document.body.appendChild(ta);
ta.select();
ta.setSelectionRange(0, code.length);
ta.readOnly = false;
var result = document.execCommand('copy');
{% if theme.codeblock.copy_button.show_result %}
if (result) $(this).text('{{__("post.copy_success")}}');
else $(this).text('{{__("post.copy_failure")}}');
{% endif %}
ta.blur(); // For iOS
$(this).blur();
})).on('mouseleave', function(e) {
var $b = $(this).find('.copy-btn');
setTimeout(function() {
$b.text('{{__("post.copy_button")}}');
}, 300);
}).append(e);
})
</script>
{% endif %}

View File

@ -0,0 +1,20 @@
{% if theme.math.enable %}
{% set is_index_has_math = false %}
{# At home, check if there has `mathjax: true` post #}
{% if is_home() %}
{% for post in page.posts %}
{% if post.mathjax and not is_index_has_math %}
{% set is_index_has_math = true %}
{% endif %}
{% endfor %}
{% endif %}
{% if not theme.math.per_page or (is_index_has_math or page.mathjax) %}
{% if theme.math.engine == 'mathjax' %}
{% include 'mathjax.swig' %}
{% elif theme.math.engine == 'katex' %}
{% include 'katex.swig' %}
{% endif %}
{% endif %}
{% endif %}

View File

@ -0,0 +1,9 @@
<link rel="stylesheet" href="{{ theme.math.katex.cdn }}"/>
{% if theme.math.katex.copy_tex.enable %}
{% if theme.math.katex.copy_tex.copy_tex_js %}
<script src="{{ theme.math.katex.copy_tex.copy_tex_js }}"></script>
{% endif %}
{% if theme.math.katex.copy_tex.copy_tex_css %}
<link rel="stylesheet" href="{{ theme.math.katex.copy_tex.copy_tex_css }}"/>
{% endif %}
{% endif %}

View File

@ -0,0 +1,40 @@
<script type="text/x-mathjax-config">
{% if theme.math.mathjax.mhchem %}
MathJax.Ajax.config.path['mhchem'] = '{{ theme.math.mathjax.mhchem }}';
{% endif %}
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$', '$'], ['\\(', '\\)'] ],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
TeX: {
{% if theme.math.mathjax.mhchem %}
extensions: ['[mhchem]/mhchem.js'],
{% endif %}
equationNumbers: {
autoNumber: 'AMS'
}
}
});
MathJax.Hub.Register.StartupHook('TeX Jax Ready', function() {
MathJax.InputJax.TeX.prefilterHooks.Add(function(data) {
if (data.display) {
var next = data.script.nextSibling;
while (next && next.nodeName.toLowerCase() === '#text') { next = next.nextSibling }
if (next && next.nodeName.toLowerCase() === 'br') { next.parentNode.removeChild(next) }
}
});
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i += 1) {
document.getElementById(all[i].inputID + '-Frame').parentNode.className += ' has-jax';
}
});
</script>
<script src="{{ theme.math.mathjax.cdn }}"></script>

View File

@ -0,0 +1,21 @@
{% if theme.mermaid.enable %}
<script>
if ($('body').find('pre.mermaid').length) {
$.ajax({
type: 'GET',
url: '{{ theme.mermaid.cdn }}',
dataType: 'script',
cache: true,
success: function() {
mermaid.initialize({
theme: '{{ theme.mermaid.theme }}',
logLevel: 3,
flowchart: { curve: 'linear' },
gantt: { axisFormat: '%m/%d/%Y' },
sequence: { actorMargin: 50 }
});
}
});
}
</script>
{% endif %}

View File

@ -0,0 +1,23 @@
{% if theme.needmoreshare2.enable %}
{% set needmoreshare2_js = url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.js') %}
{% if theme.vendors.needmoreshare2_js %}
{% set needmoreshare2_js = theme.vendors.needmoreshare2_js %}
{% endif %}
<script src="{{ needmoreshare2_js }}"></script>
<script>
{% if theme.needmoreshare2.postbottom.enable %}
pbOptions = {};
{% for k,v in theme.needmoreshare2.postbottom.options %}
pbOptions.{{ k }} = "{{ v }}";
{% endfor %}
new needShareButton('#needsharebutton-postbottom', pbOptions);
{% endif %}
{% if theme.needmoreshare2.float.enable %}
flOptions = {};
{% for k,v in theme.needmoreshare2.float.options %}
flOptions.{{ k }} = "{{ v }}";
{% endfor %}
new needShareButton('#needsharebutton-float', flOptions);
{% endif %}
</script>
{% endif %}

View File

@ -0,0 +1,8 @@
{% if theme.pangu %}
{% set pangu_uri = url_for(theme.vendors._internal + '/pangu/dist/pangu.min.js?v=3.3') %}
{% if theme.vendors.pangu %}
{% set pangu_uri = theme.vendors.pangu %}
{% endif %}
<script src="{{ pangu_uri }}"></script>
<script>pangu.spacingPage();</script>
{% endif %}

View File

@ -0,0 +1,27 @@
{% if theme.pdf.enable %}
<script>
if ($('body').find('div.pdf').length) {
$.ajax({
type: 'GET',
url: '{{ theme.pdf.pdfobject.cdn }}',
dataType: 'script',
cache: true,
success: function() {
$('body').find('div.pdf').each(function(i, o) {
PDFObject.embed($(o).attr('target'), $(o), {
pdfOpenParams: {
navpanes: 0,
toolbar: 0,
statusbar: 0,
pagemode: 'thumbs',
view: 'FitH'
},
PDFJS_URL: '/lib/pdf/web/viewer.html',
height: $(o).attr('height') || '{{ theme.pdf.height }}'
});
});
},
});
}
</script>
{% endif %}

View File

@ -0,0 +1,35 @@
{% if theme.quicklink.enable %}
{% set quicklink_uri = url_for(theme.vendors._internal + '/quicklink/quicklink.umd.js') %}
{% if theme.vendors.quicklink %}
{% set quicklink_uri = theme.vendors.quicklink %}
{% endif %}
{% if is_home() %}
{% if theme.quicklink.home %}
{% set loadQL = true %}
{% endif %}
{% endif %}
{% if is_archive() %}
{% if theme.quicklink.archive %}
{% set loadQL = true %}
{% endif %}
{% endif %}
{% if loadQL or (page.quicklink or post.quicklink) %}
<script src="{{ quicklink_uri }}"></script>
<script>
{% if theme.quicklink.delay %}
window.addEventListener('load', () => {
{% endif %}
quicklink({
timeout: {{ theme.quicklink.timeout }},
priority: {{ theme.quicklink.priority }},
ignores: [uri => uri.includes('#'),uri => uri == '{{ url.replace('index.html', '') }}',{{ theme.quicklink.ignores }}]
});
{% if theme.quicklink.delay %}
});
{% endif %}
</script>
{% endif %}
{% endif %}

View File

@ -0,0 +1,20 @@
{% if theme.rating.enable and (not is_home() and is_post()) %}
<script>
wpac_init = window.wpac_init || [];
wpac_init.push({
widget: 'Rating',
id: {{ theme.rating.id }},
el: 'wpac-rating',
color: '{{ theme.rating.color }}'
});
(function() {
if ('WIDGETPACK_LOADED' in window) return;
WIDGETPACK_LOADED = true;
var mc = document.createElement('script');
mc.type = 'text/javascript';
mc.async = true;
mc.src = '//embed.widgetpack.com/widget.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
})();
</script>
{% endif %}

View File

@ -0,0 +1,171 @@
{% if theme.calendar.enable && page.type === 'schedule' %}
<script>
// Initialization
function _n(arg) {
if (arg) return arg;
else return void 0;
}
var now = new Date();
var timeMax = new Date();
var timeMin = new Date();
// Read config form theme config file
var calId = _n('{{ theme.calendar.calendar_id }}') ;
var apiKey = _n('{{ theme.calendar.api_key }}') ;
var orderBy = _n('{{ theme.calendar.ordarBy }}') || 'startTime';
var showLocation = _n('{{ theme.calendar.showLocation }}') || 'false' ;
var offsetMax = _n( {{ theme.calendar.offsetMax }} ) || 72 ;
var offsetMin = _n( {{ theme.calendar.offsetMin }} ) || 4 ;
var showDeleted = _n( {{ theme.calendar.showDeleted }} ) || 'false' ;
var singleEvents = _n( {{ theme.calendar.singleEvents }} ) || 'true' ;
var maxResults = _n( {{ theme.calendar.maxResults }} ) || '250' ;
timeMax.setHours(now.getHours() + offsetMax);
timeMin.setHours(now.getHours() - offsetMin);
// Build URL
BASE_URL = 'https://www.googleapis.com/calendar/v3/calendars/';
FIELD_KEY = 'key';
FIELD_ORDERBY = 'orderBy';
FIELD_TIMEMAX = 'timeMax';
FIELD_TIMEMIN = 'timeMin';
FIELD_SHOWDELETED = 'showDeleted';
FIELD_SINGLEEVENTS = 'singleEvents';
FIELD_MAXRESULTS = 'maxResults';
timeMaxISO = timeMax.toISOString();
timeMinISO = timeMin.toISOString();
request_url = BASE_URL + calId + '/events?' +
FIELD_KEY + '=' + apiKey + '&' +
FIELD_ORDERBY + '=' + orderBy + '&' +
FIELD_TIMEMAX + '=' + timeMaxISO + '&' +
FIELD_TIMEMIN + '=' + timeMinISO + '&' +
FIELD_SHOWDELETED + '=' + showDeleted + '&' +
FIELD_SINGLEEVENTS + '=' + singleEvents + '&' +
FIELD_MAXRESULTS + '=' + maxResults;
fetchData();
var queryLoop = setInterval(fetchData, 60000);
function fetchData() {
$.ajax({
dataType: 'json',
url: request_url,
success: function(data) {
$eventList = $('#schedule #event-list');
// clean the event list
$eventList.html('');
var prevEnd = 0; // used to decide where to insert an <hr/>
data.items.forEach((event) => {
// parse data
var utc = new Date().getTimezoneOffset() * 60000;
var start = event.start.dateTime = new Date(event.start.dateTime || (new Date(event.start.date).getTime() + utc));
var end = event.end.dateTime = new Date(event.end.dateTime || (new Date(event.end.date).getTime() + utc));
tense = judgeTense(now, start, end); // 0:now 1:future -1:past
if (tense == 1 && prevEnd < now) $eventList.append('<hr/>');
eventDOM = buildEventDOM(tense, event);
$eventList.append(eventDOM);
prevEnd = end;
});
}
});
}
function getRelativeTime(current, previous) {
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
var tense = elapsed > 0 ? 'ago' : 'later';
elapsed = Math.abs(elapsed);
if ( elapsed < msPerHour ) {
return Math.round(elapsed/msPerMinute) + ' minutes ' + tense;
}
else if ( elapsed < msPerDay ) {
return Math.round(elapsed/msPerHour) + ' hours ' + tense;
}
else if ( elapsed < msPerMonth ) {
return 'about ' + Math.round(elapsed/msPerDay) + ' days ' + tense;
}
else if ( elapsed < msPerYear ) {
return 'about ' + Math.round(elapsed/msPerMonth) + ' months ' + tense;
}
else {
return 'about' + Math.round(elapsed/msPerYear) + ' years' + tense;
}
}
function judgeTense(now, eventStart, eventEnd) {
if (eventEnd < now) { return -1; }
else if (eventStart > now) { return 1; }
else { return 0; }
}
function buildEventDOM(tense, event) {
var tenseClass = '';
var start = event.start.dateTime;
var end = event.end.dateTime;
switch(tense) {
case 0 : // now
tenseClass = 'event-now';
break;
case 1 : // future
tenseClass = 'event-future';
break;
case -1: // past
tenseClass = 'event-past';
break;
default:
throw 'Time data error';
}
durationFormat = {
weekday: 'short',
hour : '2-digit',
minute : '2-digit'
};
relativeTimeStr = (tense == 0) ? 'NOW' : getRelativeTime(now, start);
durationStr = start.toLocaleTimeString([], durationFormat) + ' - ' +
end.toLocaleTimeString([], durationFormat);
liOpen = '<li class="event ' + tenseClass + '">';
liClose = '</li>';
h2Open = '<h2 class="event-summary">';
h2Close = '</h2>';
locationDOM = '';
if (showLocation && event.location) {
locationDOM = '<span class="event-location event-details">' + event.location + '</span>';
}
relativeTimeDOM = '<span class="event-relative-time">' + relativeTimeStr + '</span>';
durationDOM = '<span class="event-duration event-details">' + durationStr + '</span>';
eventContent =
liOpen +
h2Open +
event.summary +
relativeTimeDOM+
h2Close +
locationDOM +
durationDOM +
liClose;
return eventContent;
}
</script>
{% endif %}

View File

@ -0,0 +1,18 @@
{% if theme.algolia_search.enable %}
{# S: Include Algolia instantsearch.js library #}
{% set algolia_instant_css = url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.css') %}
{% if theme.vendors.algolia_instant_css %}
{% set algolia_instant_css = theme.vendors.algolia_instant_css %}
{% endif %}
<link rel="stylesheet" href="{{ algolia_instant_css }}"/>
{% set algolia_instant_js = url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.js') %}
{% if theme.vendors.algolia_instant_js %}
{% set algolia_instant_js = theme.vendors.algolia_instant_js %}
{% endif %}
<script src="{{ algolia_instant_js }}"></script>
{# E: Include Algolia instantsearch.js library #}
<script src="{{ url_for(theme.js) }}/algolia-search.js?v={{ version }}"></script>
{% endif %}

View File

@ -0,0 +1,2 @@
{% include 'localsearch.swig' %}
{% include 'algolia-search.swig' %}

View File

@ -0,0 +1,336 @@
{% if theme.local_search.enable %}
<script>
// Popup Window;
var isfetched = false;
var isXml = true;
// Search DB path;
var search_path = "{{ config.search.path }}";
if (search_path.length === 0) {
search_path = "search.xml";
} else if (/json$/i.test(search_path)) {
isXml = false;
}
var path = "{{ config.root }}" + search_path;
// monitor main search box;
var onPopupClose = function (e) {
$('.popup').hide();
$('#local-search-input').val('');
$('.search-result-list').remove();
$('#no-result').remove();
$(".local-search-pop-overlay").remove();
$('body').css('overflow', '');
}
function proceedsearch() {
$("body")
.append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
.css('overflow', 'hidden');
$('.search-popup-overlay').click(onPopupClose);
$('.popup').toggle();
var $localSearchInput = $('#local-search-input');
$localSearchInput.attr("autocapitalize", "none");
$localSearchInput.attr("autocorrect", "off");
$localSearchInput.focus();
}
// search function;
var searchFunc = function(path, search_id, content_id) {
'use strict';
// start loading animation
$("body")
.append('<div class="search-popup-overlay local-search-pop-overlay">' +
'<div id="search-loading-icon">' +
'<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
'</div>' +
'</div>')
.css('overflow', 'hidden');
$("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');
{% if theme.local_search.unescape %}
// ref: https://github.com/ForbesLindesay/unescape-html
var unescapeHtml = function(html) {
return String(html)
.replace(/&quot;/g, '"')
.replace(/&#39;/g, '\'')
.replace(/&#x3A;/g, ':')
// replace all the other &#x; chars
.replace(/&#(\d+);/g, function (m, p) { return String.fromCharCode(p); })
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&');
};
{% endif %}
$.ajax({
url: path,
dataType: isXml ? "xml" : "json",
async: true,
success: function(res) {
// get the contents from search data
isfetched = true;
$('.popup').detach().appendTo('.header-inner');
var datas = isXml ? $("entry", res).map(function() {
return {
title: $("title", this).text(),
content: $("content",this).text(),
url: $("url" , this).text()
};
}).get() : res;
var input = document.getElementById(search_id);
var resultContent = document.getElementById(content_id);
var inputEventFunction = function() {
var searchText = input.value.trim().toLowerCase();
var keywords = searchText.split(/[\s\-]+/);
if (keywords.length > 1) {
keywords.push(searchText);
}
var resultItems = [];
if (searchText.length > 0) {
// perform local searching
datas.forEach(function(data) {
var isMatch = false;
var hitCount = 0;
var searchTextCount = 0;
var title = data.title.trim();
var titleInLowerCase = title.toLowerCase();
var content = data.content.trim().replace(/<[^>]+>/g,"");
{% if theme.local_search.unescape %}
content = unescapeHtml(content);
{% endif %}
var contentInLowerCase = content.toLowerCase();
var articleUrl = decodeURIComponent(data.url).replace(/\/{2,}/g, '/');
var indexOfTitle = [];
var indexOfContent = [];
// only match articles with not empty titles
if(title != '') {
keywords.forEach(function(keyword) {
function getIndexByWord(word, text, caseSensitive) {
var wordLen = word.length;
if (wordLen === 0) {
return [];
}
var startPosition = 0, position = [], index = [];
if (!caseSensitive) {
text = text.toLowerCase();
word = word.toLowerCase();
}
while ((position = text.indexOf(word, startPosition)) > -1) {
index.push({position: position, word: word});
startPosition = position + wordLen;
}
return index;
}
indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
});
if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
isMatch = true;
hitCount = indexOfTitle.length + indexOfContent.length;
}
}
// show search results
if (isMatch) {
// sort index by position of keyword
[indexOfTitle, indexOfContent].forEach(function (index) {
index.sort(function (itemLeft, itemRight) {
if (itemRight.position !== itemLeft.position) {
return itemRight.position - itemLeft.position;
} else {
return itemLeft.word.length - itemRight.word.length;
}
});
});
// merge hits into slices
function mergeIntoSlice(text, start, end, index) {
var item = index[index.length - 1];
var position = item.position;
var word = item.word;
var hits = [];
var searchTextCountInSlice = 0;
while (position + word.length <= end && index.length != 0) {
if (word === searchText) {
searchTextCountInSlice++;
}
hits.push({position: position, length: word.length});
var wordEnd = position + word.length;
// move to next position of hit
index.pop();
while (index.length != 0) {
item = index[index.length - 1];
position = item.position;
word = item.word;
if (wordEnd > position) {
index.pop();
} else {
break;
}
}
}
searchTextCount += searchTextCountInSlice;
return {
hits: hits,
start: start,
end: end,
searchTextCount: searchTextCountInSlice
};
}
var slicesOfTitle = [];
if (indexOfTitle.length != 0) {
slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
}
var slicesOfContent = [];
while (indexOfContent.length != 0) {
var item = indexOfContent[indexOfContent.length - 1];
var position = item.position;
var word = item.word;
// cut out 100 characters
var start = position - 20;
var end = position + 80;
if(start < 0){
start = 0;
}
if (end < position + word.length) {
end = position + word.length;
}
if(end > content.length){
end = content.length;
}
slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
}
// sort slices in content by search text's count and hits' count
slicesOfContent.sort(function (sliceLeft, sliceRight) {
if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
return sliceRight.searchTextCount - sliceLeft.searchTextCount;
} else if (sliceLeft.hits.length !== sliceRight.hits.length) {
return sliceRight.hits.length - sliceLeft.hits.length;
} else {
return sliceLeft.start - sliceRight.start;
}
});
// select top N slices in content
var upperBound = parseInt('{{ theme.local_search.top_n_per_article }}');
if (upperBound >= 0) {
slicesOfContent = slicesOfContent.slice(0, upperBound);
}
// highlight title and content
function highlightKeyword(text, slice) {
var result = '';
var prevEnd = slice.start;
slice.hits.forEach(function (hit) {
result += text.substring(prevEnd, hit.position);
var end = hit.position + hit.length;
result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
prevEnd = end;
});
result += text.substring(prevEnd, slice.end);
return result;
}
var resultItem = '';
if (slicesOfTitle.length != 0) {
resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
} else {
resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
}
slicesOfContent.forEach(function (slice) {
resultItem += "<a href='" + articleUrl + "'>" +
"<p class=\"search-result\">" + highlightKeyword(content, slice) +
"...</p>" + "</a>";
});
resultItem += "</li>";
resultItems.push({
item: resultItem,
searchTextCount: searchTextCount,
hitCount: hitCount,
id: resultItems.length
});
}
})
};
if (keywords.length === 1 && keywords[0] === "") {
resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x"></i></div>'
} else if (resultItems.length === 0) {
resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x"></i></div>'
} else {
resultItems.sort(function (resultLeft, resultRight) {
if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
return resultRight.searchTextCount - resultLeft.searchTextCount;
} else if (resultLeft.hitCount !== resultRight.hitCount) {
return resultRight.hitCount - resultLeft.hitCount;
} else {
return resultRight.id - resultLeft.id;
}
});
var searchResultList = '<ul class=\"search-result-list\">';
resultItems.forEach(function (result) {
searchResultList += result.item;
})
searchResultList += "</ul>";
resultContent.innerHTML = searchResultList;
}
}
if ('auto' === '{{ theme.local_search.trigger }}') {
input.addEventListener('input', inputEventFunction);
} else {
$('.search-icon').click(inputEventFunction);
input.addEventListener('keypress', function (event) {
if (event.keyCode === 13) {
inputEventFunction();
}
});
}
// remove loading animation
$(".local-search-pop-overlay").remove();
$('body').css('overflow', '');
proceedsearch();
}
});
}
// handle and trigger popup window;
$('.popup-trigger').click(function(e) {
e.stopPropagation();
if (isfetched === false) {
searchFunc(path, 'local-search-input', 'local-search-result');
} else {
proceedsearch();
};
});
$('.popup-btn-close').click(onPopupClose);
$('.popup').click(function(e){
e.stopPropagation();
});
$(document).on('keyup', function (event) {
var shouldDismissSearchPopup = event.which === 27 &&
$('.search-popup').is(':visible');
if (shouldDismissSearchPopup) {
onPopupClose();
}
});
</script>
{% endif %}

View File

@ -0,0 +1,3 @@
{% if theme.tidio.enable %}
<script src="//code.tidio.co/{{ theme.tidio.key }}.js"></script>
{% endif %}