jekyll-theme-h2o-ac 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/assets/js/app.min.js CHANGED
@@ -7,8 +7,8 @@
7
7
  \*************************/
8
8
  /***/ (() => {
9
9
 
10
- $(document).ready(function(){
11
- document.body.addEventListener('touchstart', function(){}, {passive: true});
10
+ $(document).ready(function () {
11
+ document.body.addEventListener('touchstart', function () {}, { passive: true });
12
12
 
13
13
  var nav = $('.g-nav');
14
14
  var baseurl = $("meta[property='og:baseurl']").attr('content');
@@ -23,53 +23,53 @@ $(document).ready(function(){
23
23
  * Cookie Tips
24
24
  */
25
25
  var cookieconsent_status = getCookie("cookieconsent_status");
26
- if(cookieconsent_status){
26
+ if (cookieconsent_status) {
27
27
  $('.cookie-tip').removeClass('active');
28
- }else{
28
+ } else {
29
29
  $('.cookie-tip').addClass('active');
30
30
  }
31
- $('#accept-tos').on('click', function() {
31
+ $('#accept-tos').on('click', function () {
32
32
  setCookie("cookieconsent_status", "allow", 365);
33
33
  $('.cookie-tip').removeClass('active');
34
- })
34
+ });
35
35
 
36
36
  /**
37
37
  * Fix table for small screens
38
38
  */
39
- $("table").wrap("<div class='table-area'></div>");
39
+ $("table").wrap("<div class='table-area'></div>");
40
40
 
41
41
 
42
42
  /**
43
43
  * Responsive Navigation
44
44
  */
45
- $('#menu-toggle').on('click', function(e) {
45
+ $('#menu-toggle').on('click', function (e) {
46
46
  var duration = 200;
47
47
  nav.slideToggle(duration);
48
- $(document).on('click', function() {
48
+ $(document).on('click', function () {
49
49
  nav.slideUp(duration);
50
50
  });
51
51
  e.stopPropagation();
52
52
  });
53
53
 
54
- nav.on('click', function(e) {
54
+ nav.on('click', function (e) {
55
55
  e.stopPropagation();
56
56
  });
57
57
 
58
- $(".g-nav li.dropdown").on("click", function(){
58
+ $(".g-nav li.dropdown").on("click", function () {
59
59
  $(".g-nav li.dropdown").not($(this)).children("ul.dropdown-menu").removeClass("show");
60
60
  $(".g-nav li.dropdown").not($(this)).children("a.dropdown-toggle").removeClass("show");
61
61
  $(this).children("a.dropdown-toggle").toggleClass("show");
62
62
  $(this).children("ul.dropdown-menu").toggleClass("show");
63
63
  });
64
- $(document).on("click", function(){
64
+ $(document).on("click", function () {
65
65
  $(".g-nav li.dropdown").children("a.dropdown-toggle").removeClass("show");
66
66
  $(".g-nav li.dropdown").children("ul.dropdown-menu").removeClass("show");
67
- })
67
+ });
68
68
 
69
69
  /**
70
70
  * Header Bar
71
71
  */
72
- if($(window).width() > 695) {
72
+ if ($(window).width() > 695) {
73
73
  var header = $('.g-header');
74
74
  var headerHeight = header.outerHeight();
75
75
  var navText = nav.find('a');
@@ -77,13 +77,11 @@ $(document).ready(function(){
77
77
  var logo = $('.g-logo');
78
78
  var themeStyle = $('.g-banner').attr('data-theme');
79
79
 
80
- $(document).scroll(function() {
80
+ $(document).scroll(function () {
81
81
  var scrollTop = $(this).scrollTop();
82
82
  var navClassName = 'nav-' + themeStyle;
83
-
84
-
85
83
  if (scrollTop > headerHeight) {
86
- if(scrollTop > 3 * headerHeight) {
84
+ if (scrollTop > 3 * headerHeight) {
87
85
  header.addClass('headerUp');
88
86
  }
89
87
  header.css({
@@ -94,7 +92,7 @@ $(document).ready(function(){
94
92
  'background': 'url(' + baseurl + '/assets/icons/' + themeStyle + '.svg) no-repeat center',
95
93
  'background-size': '100% 100%'
96
94
  });
97
- navText.css('color', '#666');
95
+ navText.addClass('color-f-gray');
98
96
  nav.addClass(navClassName);
99
97
  } else {
100
98
  header.removeClass('headerUp');
@@ -108,14 +106,14 @@ $(document).ready(function(){
108
106
  'background': 'url(' + baseurl + '/assets/icons/' + themeStyle + '.svg) no-repeat center',
109
107
  'background-size': '100% 100%'
110
108
  });
111
- navText.css('color', '#fff');
109
+ navText.removeClass('color-f-gray');
112
110
  nav.removeClass(navClassName);
113
111
  }
114
112
 
115
113
  // scroll action
116
114
  if (scFlag > scrollTop) {
117
115
  header.addClass('headerDown');
118
- if(header.hasClass('headerUp')){
116
+ if (header.hasClass('headerUp')) {
119
117
  $('#bttb').addClass("active");
120
118
  }
121
119
  } else {
@@ -124,14 +122,14 @@ $(document).ready(function(){
124
122
  }
125
123
  scFlag = scrollTop;
126
124
  });
127
- }else{
125
+ } else {
128
126
  var header = $('.g-header');
129
127
  var headerHeight = header.outerHeight();
130
128
  var scFlag = $(document).scrollTop();
131
- $(document).scroll(function() {
129
+ $(document).scroll(function () {
132
130
  var scrollTop = $(this).scrollTop();
133
131
 
134
- if (scrollTop < 100){
132
+ if (scrollTop < 100) {
135
133
  $('#bttb').removeClass("active");
136
134
  }
137
135
 
@@ -149,23 +147,23 @@ $(document).ready(function(){
149
147
  * List for contents
150
148
  */
151
149
 
152
- function clickMobileList(){
150
+ function clickMobileList() {
153
151
  $('.table-of-contents').toggleClass("active");
154
152
  var mode = getCookie("mode");
155
- if(mode == "night"){
153
+ if (mode == "night") {
156
154
  $('.mobile-list .icon.list.night').toggleClass('active');
157
155
  $('.mobile-list .icon.exit.night').toggleClass('active');
158
- }else{
156
+ } else {
159
157
  $('.mobile-list .icon.list.day').toggleClass('active');
160
158
  $('.mobile-list .icon.exit.day').toggleClass('active');
161
159
  }
162
160
  }
163
161
 
164
- $('.mobile-list').bind('click', function(){
162
+ $('.mobile-list').bind('click', function () {
165
163
  clickMobileList();
166
164
  });
167
165
 
168
- $(".table-of-contents").on('click', function(){
166
+ $(".table-of-contents").on('click', function () {
169
167
  clickMobileList();
170
168
  });
171
169
 
@@ -173,8 +171,8 @@ $(document).ready(function(){
173
171
  /**
174
172
  * Back To Top Button
175
173
  */
176
- $('.bttb').bind('click', function(){
177
- $('html,body').animate({scrollTop:0}, function(){
174
+ $('.bttb').bind('click', function () {
175
+ $('html,body').animate({ scrollTop: 0 }, function () {
178
176
  $('#bttb').removeClass("active");
179
177
  });
180
178
  });
@@ -193,7 +191,7 @@ $(document).ready(function(){
193
191
  'width': 'auto',
194
192
  'height': '100%'
195
193
  });
196
- imgWidth = img.width(),
194
+ imgWidth = img.width();
197
195
  containerWidth = container.width();
198
196
  var marginLeft = (imgWidth - containerWidth) / 2;
199
197
  img.css('margin-left', '-' + marginLeft + 'px');
@@ -208,14 +206,14 @@ $(document).ready(function(){
208
206
  /**
209
207
  * The Post Navigator
210
208
  */
211
- $('.read-next-item section').each(function() {
209
+ $('.read-next-item section').each(function () {
212
210
  var n = $(this).height();
213
211
  var rn = $('.read-next-item').height();
214
212
  $(this).css('margin-top', (rn - n) / 2 + 'px');
215
213
  $(this).fadeIn();
216
214
  });
217
215
 
218
- $('.read-next-item img').each(function(){
216
+ $('.read-next-item img').each(function () {
219
217
  postCover($(this), $('.read-next-item'));
220
218
  // $(this).addClass("lazyload");
221
219
  $(this).attr('data-src', $(this).attr('src')).removeAttr('src').addClass("lazyload");
@@ -260,15 +258,15 @@ $(document).ready(function(){
260
258
  var input = $('#search_input');
261
259
  var result = $('.search_result');
262
260
 
263
- input.focus(function() {
261
+ input.focus(function () {
264
262
  $('.icon-search').css('color', '#3199DB');
265
263
  result.show();
266
264
  });
267
265
 
268
266
  input.keyup(debounce(this.autoComplete));
269
267
 
270
- $(document).click(function(e) {
271
- if(e.target.id === 'search_input' || e.target.className === 'search_result' || e.target.className === 'search_item') {
268
+ $(document).click(function (e) {
269
+ if (e.target.id === 'search_input' || e.target.className === 'search_result' || e.target.className === 'search_item') {
272
270
  return;
273
271
  }
274
272
  $('.icon-search').css('color', '#CAD3DC');
@@ -276,7 +274,7 @@ $(document).ready(function(){
276
274
  });
277
275
  }
278
276
 
279
- Search.prototype.autoComplete = function() {
277
+ Search.prototype.autoComplete = function () {
280
278
  var keywords = this.value.toLowerCase();
281
279
 
282
280
  if (keywords.length) {
@@ -285,8 +283,8 @@ $(document).ready(function(){
285
283
  $('.icon-search').css('color', '#CAD3DC');
286
284
  }
287
285
 
288
- var jsonfile = baseurl + '/assets/search.json';
289
- $.getJSON(jsonfile).done(function(data) {
286
+ var jsonfile = baseurl + '/assets/search.json';
287
+ $.getJSON(jsonfile).done(function (data) {
290
288
  var html = '';
291
289
  for (var i in data) {
292
290
  var item = data[i];
@@ -310,7 +308,7 @@ $(document).ready(function(){
310
308
  return function () {
311
309
  var ctx = this;
312
310
  var args = arguments;
313
- var later = function() {
311
+ var later = function () {
314
312
  fn.apply(ctx, args);
315
313
  };
316
314
  clearTimeout(timer);
@@ -332,9 +330,9 @@ $(document).ready(function(){
332
330
 
333
331
  var mode = getCookie("mode");
334
332
  if (mode == "") {
335
- console.log(mode);
336
- if (hour <= 6 || hour >= 18){
337
- console.log("Start night mode");
333
+ // console.log(mode);
334
+ if (hour <= 6 || hour >= 18) {
335
+ // console.log("Start night mode");
338
336
  setCookie("mode", "night", 1)
339
337
  }
340
338
  // el.addClass(className);
@@ -350,13 +348,13 @@ $(document).ready(function(){
350
348
  */
351
349
  function setClipboardData(str) {
352
350
  str += '\n\n著作权归作者所有。\n商业转载请联系作者获得授权,非商业转载请注明出处。\n原文: ' + location.href;
353
- $('.post-content').on('copy', function(e) {
351
+ $('.post-content').on('copy', function (e) {
354
352
  var data = window.clipboardData || e.originalEvent.clipboardData;
355
353
  data.setData('text/plain', str);
356
354
  e.preventDefault();
357
355
  });
358
356
  }
359
- $('.post-content').on('mouseup', function(e) {
357
+ $('.post-content').on('mouseup', function (e) {
360
358
  var txt = window.getSelection();
361
359
  if (txt.toString().length >= 30) {
362
360
  setClipboardData(txt);
@@ -366,20 +364,20 @@ $(document).ready(function(){
366
364
  /**
367
365
  * TOC highlight with the corresponding content
368
366
  */
369
- function locateCatelogList(){
367
+ function locateCatelogList() {
370
368
  /*获取文章目录集合,可通过:header过滤器*/
371
369
  var alis = $('article :header');
372
370
  /*获取侧边栏目录列表集合**/
373
371
  var sidebar_alis = $('.table-of-contents').find('a');
374
372
  /*获取滚动条到顶部的距离*/
375
373
  var scroll_height = $(window).scrollTop();
376
- if(scroll_height>0){
374
+ if (scroll_height > 0) {
377
375
  $('.g-header').addClass('headerUp');
378
376
  }
379
- for(var i =0;i<alis.length;i++){
377
+ for (var i = 0; i < alis.length; i++) {
380
378
  /*获取锚点集合中的元素分别到顶点的距离*/
381
379
  var a_height = $(alis[i]).offset().top - 100;
382
- if (a_height < scroll_height){
380
+ if (a_height < scroll_height) {
383
381
  /*高亮显示*/
384
382
  $(sidebar_alis).removeClass('active');
385
383
  $(sidebar_alis[i]).addClass('active');
@@ -388,43 +386,41 @@ $(document).ready(function(){
388
386
  }
389
387
 
390
388
  locateCatelogList();
391
- $(window).bind('scroll',locateCatelogList);
389
+ $(window).bind('scroll', locateCatelogList);
392
390
 
393
391
  /**
394
392
  * Day/Night mode switch button
395
393
  */
396
- function getCookie(cname)
397
- {
394
+ function getCookie(cname) {
398
395
  var name = cname + "=";
399
396
  var ca = document.cookie.split(';');
400
- for(var i=0; i<ca.length; i++)
401
- {
397
+ for (var i = 0; i < ca.length; i++) {
402
398
  var c = ca[i].trim();
403
- if (c.indexOf(name)==0) return c.substring(name.length,c.length);
399
+ if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
404
400
  }
405
401
  return "";
406
402
  }
407
403
 
408
- function setCookie(cname, cvalue, exdays){
404
+ function setCookie(cname, cvalue, exdays) {
409
405
  var d = new Date();
410
- d.setTime(d.getTime()+(exdays*24*60*60*1000));
411
- var expires = "expires="+d.toGMTString();
412
- if(!baseurl){
413
- document.cookie = cname+"="+cvalue+"; path=/; "+expires;
414
- }else {
415
- document.cookie = cname+"="+cvalue+"; path="+baseurl+"; "+expires;
406
+ d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
407
+ var expires = "expires=" + d.toGMTString();
408
+ if (!baseurl) {
409
+ document.cookie = cname + "=" + cvalue + "; path=/; " + expires;
410
+ } else {
411
+ document.cookie = cname + "=" + cvalue + "; path=" + baseurl + "; " + expires;
416
412
  }
417
413
  }
418
414
 
419
415
  var mode = getCookie("mode");
420
416
  // console.log(mode);
421
- if(mode == "night"){
417
+ if (mode == "night") {
422
418
  $(".g-nav li.mode .night").addClass("active");
423
419
  $("#mode-toggle .icon-night").addClass("active");
424
420
  $("body").addClass("night-mode");
425
421
  $(".icon.up.night").toggleClass("active");
426
422
  $(".icon.list.night").toggleClass("active");
427
- }else{
423
+ } else {
428
424
  $(".g-nav li.mode .day").addClass("active");
429
425
  $("#mode-toggle .icon-day").addClass("active");
430
426
  $("body").removeClass("night-mode");
@@ -432,20 +428,20 @@ $(document).ready(function(){
432
428
  $(".icon.list.day").toggleClass("active");
433
429
  }
434
430
 
435
- function changeMode(){
431
+ function changeMode() {
436
432
  var mode = getCookie("mode");
437
- if(mode == ""){
433
+ if (mode == "") {
438
434
  setCookie("mode", "night", 1)
439
435
  $("body").addClass("night-mode");
440
- }else if(mode == "day"){
436
+ } else if (mode == "day") {
441
437
  setCookie("mode", "night", 1)
442
438
  $("body").addClass("night-mode");
443
- }else{
439
+ } else {
444
440
  setCookie("mode", "day", 1)
445
441
  $("body").removeClass("night-mode");
446
442
  }
447
443
  // console.log(mode + "-->" + getCookie("mode"));
448
- if($("#disqus_thread").length > 0){
444
+ if ($("#disqus_thread").length > 0) {
449
445
  DISQUS.reset({
450
446
  reload: true
451
447
  });
@@ -454,20 +450,20 @@ $(document).ready(function(){
454
450
  $("#mode-toggle .icon").toggleClass("active");
455
451
  $(".icon.up.day").toggleClass("active");
456
452
  $(".icon.up.night").toggleClass("active");
457
- if($('.table-of-contents').css('visibility') == "visible"){
453
+ if ($('.table-of-contents').css('visibility') == "visible") {
458
454
  $(".icon.exit.day").toggleClass("active");
459
455
  $(".icon.exit.night").toggleClass("active");
460
- }else{
456
+ } else {
461
457
  $(".icon.list.day").toggleClass("active");
462
458
  $(".icon.list.night").toggleClass("active");
463
459
  }
464
460
  }
465
461
 
466
- $(".g-nav li.mode").click(function(){
462
+ $(".g-nav li.mode").click(function () {
467
463
  changeMode();
468
464
  });
469
465
 
470
- $("#mode-toggle").click(function(){
466
+ $("#mode-toggle").click(function () {
471
467
  changeMode();
472
468
  });
473
469
 
@@ -476,50 +472,50 @@ $(document).ready(function(){
476
472
  */
477
473
  // get all <code> elements
478
474
  var allCodeBlocksElements = $("pre");
479
- allCodeBlocksElements.each(function(i) {
475
+ allCodeBlocksElements.each(function (i) {
480
476
  // add different id for each code block
481
- // target
477
+ // target
482
478
  var currentId = "codeblock" + (i + 1);
483
479
  $(this).attr('id', currentId);
484
- var lang = $(this).attr("class").split(" ")[1].substring(9).toUpperCase();
480
+ var lang = $(this).attr("class").split(" ")[1].substring(9).toUpperCase();
485
481
 
486
- if(lang == "ERS"){
482
+ if (lang == "ERS") {
487
483
  lang = $(this).attr("class").split(" ")[0].substring(9).toUpperCase();
488
- if(lang == "MERMAID2") {
484
+ if (lang == "MERMAID2") {
489
485
  text = $(this).text();
490
486
  $(this).before('<summary class="render-expand" aria-haspopup="dialog" role="button"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" class="octicon" style="display:inline-block;vertical-align:text-bottom"><path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 1.06L2.56 7h10.88l-2.22-2.22a.75.75 0 011.06-1.06l3.5 3.5a.75.75 0 010 1.06l-3.5 3.5a.75.75 0 11-1.06-1.06l2.22-2.22H2.56l2.22 2.22a.75.75 0 11-1.06 1.06l-3.5-3.5a.75.75 0 010-1.06l3.5-3.5z"></path></svg></summary>');
491
487
  $(this).after('<div class="mermaid2">' + text + '</div>');
492
- }else {
488
+ } else {
493
489
  $(this).wrap('<div class="highlight"></div>');
494
- $(this).parent().wrap('<div class="'+ $(this).attr("class").split(" ")[0] +' highlighter-rouge"></div>');
490
+ $(this).parent().wrap('<div class="' + $(this).attr("class").split(" ")[0] + ' highlighter-rouge"></div>');
495
491
  $(this).addClass("highlight");
496
492
  //trigger
497
493
  var clipButton = '<div class="copy-container"><span class="lang">' + lang + '</span><button class="btn" data-bs-original-title="Copy" aria-label="Copy" data-clipboard-target="#' + currentId + '"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-copy"></use></svg><span class="tooltip unfinish">Copy</span><span class="tooltip finish">Copied</span></button></div>';
498
494
  $(this).before(clipButton);
499
495
  }
500
- }else {
496
+ } else {
501
497
  //trigger
502
498
  var clipButton = '<div class="copy-container"><span class="lang">' + lang + '</span><button class="btn" data-bs-original-title="Copy" aria-label="Copy" data-clipboard-target="#' + currentId + '"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-copy"></use></svg><span class="tooltip unfinish">Copy</span><span class="tooltip finish">Copied</span></button></div>';
503
499
  $(this).before(clipButton);
504
- }
500
+ }
505
501
  });
506
502
 
507
503
  var clipboard = new ClipboardJS('.btn');
508
- clipboard.on('success', function(e) {
504
+ clipboard.on('success', function (e) {
509
505
  e.clearSelection();
510
506
  });
511
507
 
512
- $(".markdown-body .btn").hover(function(){
508
+ $(".markdown-body .btn").hover(function () {
513
509
  $(this).find(".tooltip.unfinish").addClass("active");
514
- },function(){
510
+ }, function () {
515
511
  $(this).find(".tooltip.unfinish").removeClass("active");
516
512
  });
517
513
 
518
- $(".markdown-body .btn").click(function(){
514
+ $(".markdown-body .btn").click(function () {
519
515
  $(this).find(".tooltip.unfinish").removeClass("active");
520
516
  var finish = $(this).find(".tooltip.finish")
521
517
  finish.addClass("active");
522
- setTimeout(function () {
518
+ setTimeout(function () {
523
519
  finish.removeClass("active");
524
520
  }, 500);
525
521
  });
@@ -527,35 +523,35 @@ $(document).ready(function(){
527
523
  /**
528
524
  * Expand the mermaid figure
529
525
  */
530
- $("summary").click(function(event){
526
+ $("summary").click(function (event) {
531
527
  var text = $(this).next().children().text();
532
528
  $(".modal .modal-content .container").html('<div class="mermaid2">' + text + '</div>')
533
529
  mermaid.init(undefined, $('.modal .modal-content .mermaid2'));
534
- $('.modal').css("visibility","visible");
535
- $(".modal .modal-content").click(function(event){
536
- if(event.target.classList.contains("close")){
537
- $(".modal").css("visibility","hidden");
530
+ $('.modal').css("visibility", "visible");
531
+ $(".modal .modal-content").click(function (event) {
532
+ if (event.target.classList.contains("close")) {
533
+ $(".modal").css("visibility", "hidden");
538
534
  }
539
535
  event.stopPropagation();
540
536
  });
541
537
  event.stopPropagation();
542
538
  });
543
-
544
- $(document).click(function(){
545
- $(".modal").css("visibility","hidden");
539
+
540
+ $(document).click(function () {
541
+ $(".modal").css("visibility", "hidden");
546
542
  });
547
543
 
548
544
  /**
549
545
  * Error image loading
550
546
  */
551
- document.addEventListener('error', function(e){
552
- if(e.target.nodeName == 'IMG'){e.target.src = baseurl + '/assets/img/placeholder.webp';}
547
+ document.addEventListener('error', function (e) {
548
+ if (e.target.nodeName == 'IMG') { e.target.src = baseurl + '/assets/img/placeholder.webp'; }
553
549
  }, true);
554
550
 
555
551
  /**
556
552
  * Alive time
557
553
  */
558
-
554
+
559
555
  var alivetime_days = $(".alivetime_days")
560
556
  var alivetime_hours = $(".alivetime_hours")
561
557
  var alivetime_minutes = $(".alivetime_minutes")
@@ -567,22 +563,22 @@ $(document).ready(function(){
567
563
  BirthDay = new Date(alivestart);
568
564
  // Now at
569
565
  today = new Date();
570
- timeold = (today.getTime() - BirthDay.getTime());
571
- secondsold = Math.floor(timeold / 1000);
566
+ timeold = (today.getTime() - BirthDay.getTime());
567
+ secondsold = Math.floor(timeold / 1000);
572
568
  e_daysold = timeold / (24 * 60 * 60 * 1000);
573
- daysold = Math.floor(e_daysold);
569
+ daysold = Math.floor(e_daysold);
574
570
  e_hrsold = (e_daysold - daysold) * 24;
575
- hrsold = Math.floor(e_hrsold);
571
+ hrsold = Math.floor(e_hrsold);
576
572
  e_minsold = (e_hrsold - hrsold) * 60;
577
- minsold= Math.floor(e_minsold)
578
- seconds = Math.floor((e_minsold - minsold) * 60);
573
+ minsold = Math.floor(e_minsold)
574
+ seconds = Math.floor((e_minsold - minsold) * 60);
579
575
  alivetime_days.html(daysold)
580
576
  alivetime_hours.html(hrsold)
581
577
  alivetime_minutes.html(minsold)
582
578
  alivetime_seconds.html(seconds)
583
579
  // alivetime.html(daysold + " 天 " + hrsold + " 小时 " + minsold + " 分 " + seconds + " 秒");
584
- }
585
- alive_time();
580
+ }
581
+ alive_time();
586
582
 
587
583
  });
588
584