jekyll-theme-h2o-ac 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e55eebbb35107b6aa365137d1ef4936751fa9bb2f4f99bfe6414175d01c6207f
4
- data.tar.gz: aaa8762de9cb1fd05a4a187d8be38ab1b86412a8849da9a994b13dc14e15e67b
3
+ metadata.gz: 7a04ed392c774972afa0103abedf72d32d2f9f624649dfaf5208db154b4af881
4
+ data.tar.gz: 4af35d9f4d8c86c6ccc372e89939544754560d47e518b7048d6f55b71ec15384
5
5
  SHA512:
6
- metadata.gz: 4e8852b4af9bdb2781c4a9c07e10d00143b21f7cb5051ef44ae796feb4e38579db5b0e9a96f82d0c84721a4842b8a39750c4dd6ad4e20833fae0e5a841d84d49
7
- data.tar.gz: 4a08baf90d910857aa6d78a037b5176750c1fd2fde32197d99b3258b6af209d047cb7748e197b20252e405b59443c1a487855d79b032d9f04bfc82745a86f305
6
+ metadata.gz: 140295505805ffdd32b2132980220dd2b8d769860215413ab786b050ab43815fa361d570288547b46e9a89f12401d191e9af59d72e5ae369dabfe953ea6bfe9c
7
+ data.tar.gz: 3aaf0a320d12d4796c8a198944a1ce8781042e66c576e7a9cc823ac7262050907c1acdc0219a50adfbc153bd0329f33e7afd1b3d75112768a782d5985da9811d
@@ -0,0 +1,25 @@
1
+ ---
2
+ layout: page
3
+ home-title: Welcome to zhonger's blog!
4
+ description: Writing, writing, writing ...
5
+ permalink: /archives.html
6
+ cover: https://images.unsplash.com/photo-1465189684280-6a8fa9b19a7a?w=1600&q=900
7
+ ---
8
+
9
+ <h2>Archives</h2>
10
+
11
+ {% for post in site.posts %}
12
+
13
+ {% unless post.next %}
14
+ <h3>{{ post.date | date: '%Y' }}</h3>
15
+ {% else %}
16
+ {% capture year %}{{ post.date | date: '%Y' }}{% endcapture %}
17
+ {% capture nyear %}{{ post.next.date | date: '%Y' }}{% endcapture %}
18
+ {% if year != nyear %}
19
+ <h3>{{ post.date | date: '%Y' }}</h3>
20
+ {% endif %}
21
+ {% endunless %}
22
+
23
+ <li><p class="archives-title"><span class="archives-date">{{ post.date | date: "%b %-d, %Y" }} </span><a href="{{ post.url | prepend: site.baseurl }}"> {{ post.title }} </a></p></li>
24
+
25
+ {% endfor %}
@@ -0,0 +1,118 @@
1
+ ---
2
+ layout: default
3
+ home-title: H2O Theme For Jekyll
4
+ description: 或许是最漂亮的Jekyll主题
5
+ ---
6
+
7
+ {% include header.html %}
8
+
9
+ <div
10
+ class="g-banner home-banner {{ site.theme-color | prepend: 'banner-theme-' }}"
11
+ data-theme="{{ site.theme-color }}"
12
+ style="{% if page.header-img %}background: url({{ page.header-img | relative_url }}) no-repeat center center; background-size: cover;{% endif %}"
13
+ >
14
+ <h2>{{ page.home-title }}</h2>
15
+ <h3>{{ page.description }}</h3>
16
+ </div>
17
+
18
+ <main class="g-container home-content">
19
+ <div class="article-list">
20
+ {% for post in paginator.posts %}
21
+ <article class="article-item">
22
+ {% if post.cover %}
23
+ <div class="post-cover">
24
+ <a class="post-link" href="{{ post.url | relative_url }}" title="{{ post.title }}"></a>
25
+ <img src="{{ post.cover | relative_url }}" href="{{ post.url | relative_url }}" alt="">
26
+ </div>
27
+ {% endif %}
28
+ <section class="post-preview">
29
+ <a class="post-link" href="{{ post.url | relative_url }}" title="{{ post.title }}"></a>
30
+ <h2 class="post-title">{{ post.title }}</h2>
31
+ {% if post.subtitle %}
32
+ <h3 class="post-subtitle">{{ post.subtitle }}</h3>
33
+ {% endif %}
34
+ {% if post.subtitle.size==0 or post.subtitle==nil %}
35
+ <p class="post-excerpt">{{ post.excerpt | strip_html | strip_newlines | truncate: 126}}</p>
36
+ {% endif %}
37
+ </section>
38
+ <footer class="post-meta">
39
+ <div class="post-tags">
40
+ {% if post.tags.size > 0 %}
41
+ {% for tag in post.tags %}
42
+ <a href={{ "/tags.html#" | append: tag | relative_url }} class="post-tag">{{ tag }}</a>
43
+ {% endfor %}
44
+ {% endif %}
45
+ </div>
46
+ <time class="post-date" datetime="{{ post.date | date:"%y-%m-%d" }}">{{ post.date | date_to_string }}</time>
47
+ </footer>
48
+ </article>
49
+ {% endfor %}
50
+
51
+ {% if paginator.total_pages > 1 %}
52
+ {% include pageNav.html %}
53
+ {% endif %}
54
+
55
+ </div>
56
+
57
+ <aside class="g-sidebar-wrapper">
58
+ <div class="g-sidebar">
59
+ <section class="author-card">
60
+ <div class="avatar">
61
+ <img src="{{ site.avatar | relative_url }}" alt="">
62
+ </div>
63
+ <div class="author-name" rel="author">{{ site.author }}</div>
64
+ <div class="bio">
65
+ <p>{{ site.bio }}</p>
66
+ </div>
67
+ {% if site.sns.size > 0 %}
68
+ <ul id="sns-links" class="sns-links">
69
+ {% for s in site.sns %}
70
+ <li>
71
+ <a href="{{ s[1] }}" target="_blank">
72
+ <svg class="icon" aria-hidden="true">
73
+ <use xlink:href="#icon-{{ s[0] }}"></use>
74
+ </svg>
75
+ </a>
76
+ </li>
77
+ {% endfor %}
78
+ </ul>
79
+ {% endif %}
80
+ </section>
81
+
82
+ {% if site.recommend-tags and site.tags.size>0 %}
83
+ <section class="tags-card">
84
+ {% for tag in site.tags %}
85
+ {% if forloop.index > site.recommend-condition-size %}
86
+ {% break %}
87
+ {% endif %}
88
+ <a href="{{ "tags.html#" | append: tag[0] | relative_url }}" class="tag">{{ tag[0]}}</a>
89
+ {% endfor %}
90
+ </section>
91
+ {% endif %}
92
+
93
+ {% if site.links.size > 0 %}
94
+ <section class="tags-card">
95
+ <div class="links" rel="links">Links</div>
96
+ {% for link in site.links %}
97
+ <a href="{{ link[1] }}" target="_blank" class="tag" rel="noreferrer"> {{ link[0] }} </a>
98
+ {% endfor %}
99
+ </section>
100
+ {% endif %}
101
+
102
+ </div>
103
+
104
+ {% if site.search %}
105
+ <div class="search-card">
106
+ <input id="search_input" type="text" placeholder="Search..." autocomplete="off">
107
+ <svg class="icon" aria-hidden="true">
108
+ <use xlink:href="#icon-search"></use>
109
+ </svg>
110
+ <div class="search_result"></div>
111
+ </div>
112
+ {% endif %}
113
+
114
+ </aside>
115
+
116
+ </main>
117
+
118
+ {% include footer.html %}
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Tags
3
+ layout: default
4
+ ---
5
+
6
+ {% include header.html %}
7
+
8
+ <div class="g-banner tags-banner {{ site.postPatterns | prepend: 'post-pattern-' }} {{ site.theme-color | prepend: 'bgcolor-' }}" data-theme="{{ site.theme-color }}">
9
+ <h2>TAGS</h2>
10
+ </div>
11
+
12
+ <main class="tags-content">
13
+
14
+ <ul class="tags-list">
15
+ <li>
16
+ {% if site.recommend-tags and site.tags.size>0 %}
17
+ {% for tag in site.tags %}
18
+ <a href="#{{ tag[0] }}" class="tag">{{ tag[0]}}</a>
19
+ {% endfor %}
20
+ {% endif %}
21
+ </li>
22
+
23
+ {% for tag in site.tags %}
24
+ <li>
25
+ <span class="tag-name" id="{{ tag[0] }}">「{{ tag[0] }}」</span>
26
+ {% for post in tag[1] %}
27
+ <a class="tag-post" href="{{ post.url | relative_url }}" title="{{ post.title }}">{{ post.title }}</a>
28
+ {% endfor %}
29
+ </li>
30
+ {% endfor%}
31
+ </ul>
32
+ </main>
33
+
34
+ {% include footer.html %}
@@ -1 +1 @@
1
- $(document).ready(function(){var t,o,n,s,r,c,e,a,i=$(".g-nav");function l(){var t,o,n,e=$("#search_input"),a=$(".search_result");e.focus(function(){$(".icon-search").css("color","#3199DB"),a.show()}),e.keyup((t=this.autoComplete,o=o||120,function(){var e=this,a=arguments;clearTimeout(n),n=setTimeout(function(){t.apply(e,a)},o)})),$(document).click(function(e){"search_input"!==e.target.id&&"search_result"!==e.target.className&&"search_item"!==e.target.className&&($(".icon-search").css("color","#CAD3DC"),a.hide())})}$("#menu-toggle").on("click",function(e){i.slideToggle(200),$(document).on("click",function(){i.slideUp(200)}),e.stopPropagation()}),i.on("click",function(e){e.stopPropagation()}),695<$(window).width()&&(t=$(".g-header"),o=t.outerHeight(),n=$(".g-logo"),s=i.find("a"),r=$(".g-banner").attr("data-theme"),c=$(document).scrollTop(),$(document).scroll(function(){var e=$(this).scrollTop(),a="nav-"+r;o<e?(3*o<e&&t.addClass("headerUp"),t.css({"background-color":"rgba(255, 255, 255, .98)","box-shadow":"0 1px 12px rgba(0, 0, 0, .08)"}),n.css({background:"url(/assets/icons/logo_"+r+".svg) no-repeat center","background-size":"100% 100%"}),s.css("color","#666"),i.addClass(a)):(t.removeClass("headerUp"),t.css({"background-color":"transparent","box-shadow":"none"}),n.css({background:"url(/assets/icons/logo.svg) no-repeat center","background-size":"100% 100%"}),s.css("color","#fff"),i.removeClass(a)),e<c?t.addClass("headerDown"):t.removeClass("headerDown"),c=e})),$(".read-next-item section").each(function(){var e=$(this).height(),a=$(".read-next-item").height();$(this).css("margin-top",(a-e)/2+"px"),$(this).fadeIn()}),$(".read-next-item img").each(function(){var e,a,t,o,n,s;e=$(this),a=$(".read-next-item"),t=e.width(),o=a.width(),n=e.height(),s=a.height(),n<s?(e.css({width:"auto",height:"100%"}),t=e.width(),o=a.width(),e.css("margin-left","-"+(t-o)/2+"px")):e.css("margin-top",(s-n)/2+"px"),e.fadeIn()}),function(){for(var e=parseInt($("#total_pages").val()),a=parseInt($("#current_pages").val()),t=$("#base_url").val(),o="",n=a-3;n<a;n++)0<n&&1!==n?o+='<a href="'+t+"page"+n+'" class="page-link page-num">'+n+"</a>":1===n&&(o+='<a href="'+t+'" class="page-link page-num">'+n+"</a>");o+='<span class="page-link page-num active">'+a+"</span>";for(var s=a+1;s<=a+3;s++)s<=e&&(o+='<a href="'+t+"page"+s+'" class="page-link page-num">'+s+"</a>");$("#page-link-container").html(o)}(),l.prototype.autoComplete=function(){var r=this.value.toLowerCase();r.length?$(".icon-search").css("color","#3199DB"):$(".icon-search").css("color","#CAD3DC"),$.getJSON("search.json").done(function(e){var a,t="";for(a in e){var o=e[a],n=o.title,s=o.tags;o.url;""!==r&&0<=(n+s).toLowerCase().indexOf(r)&&(t+='<a class="search_item" href="'+o.url+'">'+o.title+"</a>")}$(".search_result").html(t)})},new l,"true"===$("#nm-switch").val()&&(e=$("body"),((a=(new Date).getHours())<=6||18<=a)&&e.addClass("night-mode")),$(".post-content").on("mouseup",function(e){var a,t=window.getSelection();30<=t.toString().length&&(a=t,a+="\n\n著作权归作者所有。\n商业转载请联系作者获得授权,非商业转载请注明出处。\n原文: "+location.href,$(".post-content").on("copy",function(e){(window.clipboardData||e.originalEvent.clipboardData).setData("text/plain",a),e.preventDefault()}))})});
1
+ $(document).ready(function(){var t,o,n,s,r,c,e,a,i=$(".g-nav");function l(){var t,o,n,e=$("#search_input"),a=$(".search_result");e.focus(function(){$(".icon-search").css("color","#3199DB"),a.show()}),e.keyup((t=this.autoComplete,o=o||120,function(){var e=this,a=arguments;clearTimeout(n),n=setTimeout(function(){t.apply(e,a)},o)})),$(document).click(function(e){"search_input"!==e.target.id&&"search_result"!==e.target.className&&"search_item"!==e.target.className&&($(".icon-search").css("color","#CAD3DC"),a.hide())})}$("#menu-toggle").on("click",function(e){i.slideToggle(200),$(document).on("click",function(){i.slideUp(200)}),e.stopPropagation()}),i.on("click",function(e){e.stopPropagation()}),695<$(window).width()&&(t=$(".g-header"),o=t.outerHeight(),n=$(".g-logo"),s=i.find("a"),r=$(".g-banner").attr("data-theme"),c=$(document).scrollTop(),$(document).scroll(function(){var e=$(this).scrollTop(),a="nav-"+r;o<e?(3*o<e&&t.addClass("headerUp"),t.css({"background-color":"rgba(255, 255, 255, .98)","box-shadow":"0 1px 12px rgba(0, 0, 0, .08)"}),n.css({background:"url(/assets/icons/logo_"+r+".svg) no-repeat center","background-size":"100% 100%"}),s.css("color","#666"),i.addClass(a)):(t.removeClass("headerUp"),t.css({"background-color":"transparent","box-shadow":"none"}),n.css({background:"url(/assets/icons/logo.svg) no-repeat center","background-size":"100% 100%"}),s.css("color","#fff"),i.removeClass(a)),e<c?t.addClass("headerDown"):t.removeClass("headerDown"),c=e})),$(".read-next-item section").each(function(){var e=$(this).height(),a=$(".read-next-item").height();$(this).css("margin-top",(a-e)/2+"px"),$(this).fadeIn()}),$(".read-next-item img").each(function(){var e,a,t,o,n,s;e=$(this),a=$(".read-next-item"),t=e.width(),o=a.width(),n=e.height(),s=a.height(),n<s?(e.css({width:"auto",height:"100%"}),t=e.width(),o=a.width(),e.css("margin-left","-"+(t-o)/2+"px")):e.css("margin-top",(s-n)/2+"px"),e.fadeIn()}),function(){for(var e=parseInt($("#total_pages").val()),a=parseInt($("#current_pages").val()),t=$("#base_url").val(),o="",n=a-3;n<a;n++)0<n&&1!==n?o+='<a href="'+t+"page"+n+'" class="page-link page-num">'+n+"</a>":1===n&&(o+='<a href="'+t+'" class="page-link page-num">'+n+"</a>");o+='<span class="page-link page-num active">'+a+"</span>";for(var s=a+1;s<=a+3;s++)s<=e&&(o+='<a href="'+t+"page"+s+'" class="page-link page-num">'+s+"</a>");$("#page-link-container").html(o)}(),l.prototype.autoComplete=function(){var r=this.value.toLowerCase();r.length?$(".icon-search").css("color","#3199DB"):$(".icon-search").css("color","#CAD3DC"),$.getJSON("/assets/search.json").done(function(e){var a,t="";for(a in e){var o=e[a],n=o.title,s=o.tags;o.url;""!==r&&0<=(n+s).toLowerCase().indexOf(r)&&(t+='<a class="search_item" href="'+o.url+'">'+o.title+"</a>")}$(".search_result").html(t)})},new l,"true"===$("#nm-switch").val()&&(e=$("body"),((a=(new Date).getHours())<=6||18<=a)&&e.addClass("night-mode")),$(".post-content").on("mouseup",function(e){var a,t=window.getSelection();30<=t.toString().length&&(a=t,a+="\n\n著作权归作者所有。\n商业转载请联系作者获得授权,非商业转载请注明出处。\n原文: "+location.href,$(".post-content").on("copy",function(e){(window.clipboardData||e.originalEvent.clipboardData).setData("text/plain",a),e.preventDefault()}))})});
@@ -0,0 +1,13 @@
1
+ ---
2
+ layout: null
3
+ ---
4
+
5
+ [
6
+ {% for post in site.posts %}
7
+ {
8
+ "title" : "{{ post.title | escape }}",
9
+ "tags" : "{% for tag in post.tags %}{% if forloop.rindex != 1 %}{{ tag }} {% else %}{{ tag }}{% endif %}{% endfor %}",
10
+ "url" : "{{ post.url | relative_url }}"
11
+ } {% unless forloop.last %},{% endunless %}
12
+ {% endfor %}
13
+ ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-h2o-ac
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhonger
@@ -41,9 +41,12 @@ files:
41
41
  - _includes/mathjax.html
42
42
  - _includes/pageNav.html
43
43
  - _includes/post-head.html
44
+ - _layouts/archives.html
45
+ - _layouts/blog.html
44
46
  - _layouts/default.html
45
47
  - _layouts/page.html
46
48
  - _layouts/post.html
49
+ - _layouts/tags.html
47
50
  - assets/css/app.min.css
48
51
  - assets/css/plugins.min.css
49
52
  - assets/fonts/Merriweather-Black.ttf
@@ -65,16 +68,7 @@ files:
65
68
  - assets/js/prism.js
66
69
  - assets/js/social-share.min.js
67
70
  - assets/js/util.js
68
- - dev/js/index.js
69
- - dev/sass/app.css
70
- - dev/sass/app.scss
71
- - dev/sass/base.scss
72
- - dev/sass/common.scss
73
- - dev/sass/github-markdown.css
74
- - dev/sass/helper.scss
75
- - dev/sass/layouts.scss
76
- - dev/sass/prism.css
77
- - dev/sass/share.min.css
71
+ - assets/search.json
78
72
  homepage: https://github.com/zhonger/jekyll-theme-H2O-ac
79
73
  licenses:
80
74
  - MIT
data/dev/js/index.js DELETED
@@ -1,248 +0,0 @@
1
- $(document).ready(function(){
2
- var nav = $('.g-nav');
3
-
4
- /**
5
- * Responsive Navigation
6
- */
7
- $('#menu-toggle').on('click', function(e) {
8
- var duration = 200;
9
- nav.slideToggle(duration);
10
- $(document).on('click', function() {
11
- nav.slideUp(duration);
12
- });
13
- e.stopPropagation();
14
- });
15
-
16
- nav.on('click', function(e) {
17
- e.stopPropagation();
18
- });
19
-
20
- /*
21
- * Header Bar
22
- */
23
- if($(window).width() > 695) {
24
- var header = $('.g-header');
25
- var headerHeight = header.outerHeight();
26
- var logo = $('.g-logo');
27
- var navText = nav.find('a');
28
- var themeStyle = $('.g-banner').attr('data-theme');
29
- var scFlag = $(document).scrollTop();
30
-
31
- $(document).scroll(function() {
32
- var scrollTop = $(this).scrollTop();
33
- var navClassName = 'nav-' + themeStyle;
34
-
35
- if (scrollTop > headerHeight) {
36
- if(scrollTop > 3 * headerHeight) {
37
- header.addClass('headerUp');
38
- }
39
- header.css({
40
- 'background-color': 'rgba(255, 255, 255, .98)',
41
- 'box-shadow': '0 1px 12px rgba(0, 0, 0, .08)'
42
- });
43
- logo.css({
44
- 'background': 'url(/assets/icons/logo_' + themeStyle + '.svg) no-repeat center',
45
- 'background-size': '100% 100%'
46
- });
47
- navText.css('color', '#666');
48
- nav.addClass(navClassName);
49
- } else {
50
- header.removeClass('headerUp');
51
- header.css({
52
- 'background-color': 'transparent',
53
- 'box-shadow': 'none'
54
- });
55
- logo.css({
56
- 'background': 'url(/assets/icons/logo.svg) no-repeat center',
57
- 'background-size': '100% 100%'
58
- });
59
- navText.css('color', '#fff');
60
- nav.removeClass(navClassName);
61
- }
62
-
63
- // scroll action
64
- if (scFlag > scrollTop) {
65
- header.addClass('headerDown');
66
- } else {
67
- header.removeClass('headerDown');
68
- }
69
- scFlag = scrollTop;
70
- });
71
- }
72
-
73
- /*
74
- * Post Cover Resize
75
- */
76
- function postCover(img, container) {
77
- var imgWidth = img.width();
78
- var containerWidth = container.width();
79
- var imgHeight = img.height();
80
- var containerHeight = container.height();
81
-
82
- if (imgHeight < containerHeight) {
83
- img.css({
84
- 'width': 'auto',
85
- 'height': '100%'
86
- });
87
- imgWidth = img.width(),
88
- containerWidth = container.width();
89
- var marginLeft = (imgWidth - containerWidth) / 2;
90
- img.css('margin-left', '-' + marginLeft + 'px');
91
- } else {
92
- var marginTop = (containerHeight - imgHeight) / 2;
93
- img.css('margin-top', marginTop + 'px');
94
- }
95
-
96
- img.fadeIn();
97
- }
98
-
99
- /**
100
- * The Post Navigator
101
- */
102
- $('.read-next-item section').each(function() {
103
- var n = $(this).height();
104
- var rn = $('.read-next-item').height();
105
- $(this).css('margin-top', (rn - n) / 2 + 'px');
106
- $(this).fadeIn();
107
- });
108
-
109
- $('.read-next-item img').each(function(){
110
- postCover($(this), $('.read-next-item'));
111
- });
112
-
113
- /**
114
- * Pagination
115
- */
116
- function pagination() {
117
- var total = parseInt($('#total_pages').val());
118
- var current = parseInt($('#current_pages').val());
119
- var baseUrl = $('#base_url').val();
120
- var limit = 3;
121
-
122
- var link_html = '';
123
-
124
- for (var i = current - limit; i < current; i++) {
125
- if (i > 0 && i !== 1) {
126
- link_html += '<a href="' + baseUrl + 'page' + i + '" class="page-link page-num">' + i + '</a>';
127
- } else if (i === 1) {
128
- link_html += '<a href="' + baseUrl + '" class="page-link page-num">' + i + '</a>';
129
- }
130
- }
131
-
132
- link_html += '<span class="page-link page-num active">' + current + '</span>';
133
-
134
- for (var j = current + 1; j <= current + limit; j++) {
135
- if (j <= total) {
136
- link_html += '<a href="' + baseUrl + 'page' + j + '" class="page-link page-num">' + j + '</a>';
137
- }
138
- }
139
-
140
- $('#page-link-container').html(link_html);
141
- }
142
- pagination();
143
-
144
- /**
145
- * Search
146
- */
147
- function Search() {
148
- var self = this;
149
- var input = $('#search_input');
150
- var result = $('.search_result');
151
-
152
- input.focus(function() {
153
- $('.icon-search').css('color', '#3199DB');
154
- result.show();
155
- });
156
-
157
- input.keyup(debounce(this.autoComplete));
158
-
159
- $(document).click(function(e) {
160
- if(e.target.id === 'search_input' || e.target.className === 'search_result' || e.target.className === 'search_item') {
161
- return;
162
- }
163
- $('.icon-search').css('color', '#CAD3DC');
164
- result.hide();
165
- });
166
- }
167
-
168
- Search.prototype.autoComplete = function() {
169
- var keywords = this.value.toLowerCase();
170
-
171
- if (keywords.length) {
172
- $('.icon-search').css('color', '#3199DB');
173
- } else {
174
- $('.icon-search').css('color', '#CAD3DC');
175
- }
176
-
177
- $.getJSON('search.json').done(function(data) {
178
- var html = '';
179
- for (var i in data) {
180
- var item = data[i];
181
- var title = item.title;
182
- var tags = item.tags;
183
- var url = item.url;
184
-
185
- var k = title + tags;
186
- if (keywords !== '' && k.toLowerCase().indexOf(keywords) >= 0) {
187
- html += '<a class="search_item" href="' + item.url + '">' + item.title + '</a>';
188
- }
189
- }
190
- $('.search_result').html(html);
191
- });
192
- };
193
-
194
- function debounce(fn, delay) {
195
- var timer;
196
- delay = delay || 120;
197
-
198
- return function () {
199
- var ctx = this;
200
- var args = arguments;
201
- var later = function() {
202
- fn.apply(ctx, args);
203
- };
204
- clearTimeout(timer);
205
- timer = setTimeout(later, delay);
206
- };
207
- }
208
-
209
- new Search();
210
-
211
- /**
212
- * Night mode
213
- */
214
- function nightMode() {
215
- var el = $('body');
216
- var className = 'night-mode';
217
-
218
- var date = new Date();
219
- var hour = date.getHours();
220
-
221
- if (hour <= 6 || hour >= 18) {
222
- el.addClass(className);
223
- }
224
- }
225
-
226
- if ($('#nm-switch').val() === 'true') {
227
- nightMode();
228
- }
229
-
230
- /**
231
- * Copy and copyright
232
- */
233
- function setClipboardData(str) {
234
- str += '\n\n著作权归作者所有。\n商业转载请联系作者获得授权,非商业转载请注明出处。\n原文: ' + location.href;
235
- $('.post-content').on('copy', function(e) {
236
- var data = window.clipboardData || e.originalEvent.clipboardData;
237
- data.setData('text/plain', str);
238
- e.preventDefault();
239
- });
240
- }
241
- $('.post-content').on('mouseup', function(e) {
242
- var txt = window.getSelection();
243
- if (txt.toString().length >= 30) {
244
- setClipboardData(txt);
245
- }
246
- });
247
-
248
- });