-
Notifications
You must be signed in to change notification settings - Fork 0
/
10433304.html
685 lines (582 loc) · 27.8 KB
/
10433304.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
<!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en">
<![endif]-->
<!--[if IE 7]>
<html class="no-js lt-ie9 lt-ie8" lang="en">
<![endif]-->
<!--[if IE 8]>
<html class="no-js lt-ie9" lang="en">
<![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<!--[if IE]>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<![endif]-->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" name="viewport">
<meta content="HGNULB,数据库" name="keywords"/>
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>LeetCode 1084. 销售分析III | 走在修行的大街上</title>
<meta name="generator" content="Jekyll v4.3.4" />
<meta property="og:title" content="LeetCode 1084. 销售分析III" />
<meta name="author" content="HGNULB" />
<meta property="og:locale" content="en" />
<meta name="description" content="小兵的 BLOG" />
<meta property="og:description" content="小兵的 BLOG" />
<link rel="canonical" href="https://hgnulb.github.io/blog/2024/10433304" />
<meta property="og:url" content="https://hgnulb.github.io/blog/2024/10433304" />
<meta property="og:site_name" content="走在修行的大街上" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2024-09-23T21:23:46+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="LeetCode 1084. 销售分析III" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"HGNULB"},"dateModified":"2024-09-23T21:23:46+08:00","datePublished":"2024-09-23T21:23:46+08:00","description":"小兵的 BLOG","headline":"LeetCode 1084. 销售分析III","mainEntityOfPage":{"@type":"WebPage","@id":"https://hgnulb.github.io/blog/2024/10433304"},"url":"https://hgnulb.github.io/blog/2024/10433304"}</script>
<!-- End Jekyll SEO tag -->
<link href="https://cdn.jsdelivr.net/gh/hgnulb/blog@gh-pages/assets/images/theme/favicon.svg" rel="shortcut icon" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/gh/hgnulb/blog@gh-pages/assets/images/theme/favicon.svg" rel="icon" type="image/x-icon">
<link href='/blog/assets/libs/stylesheets/blog.css' rel="stylesheet" type="text/css">
<title>LeetCode 1084. 销售分析III</title>
<!--jquery插件-->
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<!--字体图标-->
<link href="https://cdn.jsdelivr.net/gh/hgnulb/blog@gh-pages/assets/libs/fontawesome/css/all.min.css" rel="stylesheet">
<!--Tippy.js插件-->
<link href="https://cdn.jsdelivr.net/npm/tippy.js/animations/shift-away.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/tippy.js/themes/translucent.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tippy.js/dist/tippy-bundle.umd.js"></script>
<!--其他插件-->
<script src="https://cdn.jsdelivr.net/npm/npm-modernizr/modernizr.min.js"></script>
<!--顶部进度条-->
<script src="https://cdn.jsdelivr.net/npm/pace-js@latest/pace.min.js"></script>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script>
if (window.location.pathname === '/blog') {
window.location.replace('/blog/');
}
function getPropertyValue(propertyName) {
let style = window.getComputedStyle(document.documentElement);
return style.getPropertyValue(propertyName);
}
const setProperty = (propertyName, propertyValue) => {
document.documentElement.style.setProperty(propertyName, propertyValue);
};
function typedEntryTitle() {
window.addEventListener("DOMContentLoaded", function () {
let entryTitle = document.querySelector(".entry-title");
let pageTitle = "LeetCode 1084. 销售分析III";
let index = 0;
function typedTitle() {
if (index <= pageTitle.length) {
entryTitle.innerText = `${pageTitle.slice(0, index++)}|`;
setTimeout(typedTitle, 100);
} else {
entryTitle.innerText = pageTitle;
}
}
typedTitle();
});
}
function changePoint(url, id) {
let target = document.getElementById(id.replace("#", ""));
if (null === target || target === undefined) {
document.location.href = url;
} else {
target.scrollIntoView(true);
}
sessionStorage.setItem("location", id.replace("#", ""));
}
const imgError = image => {
image.onerror = null;
if ("true" === "true") {
image.src = `https://cdn.jsdelivr.net/gh/hgnulb/blog@gh-pages/assets/images/theme/err-img.svg`;
} else {
image.src = `/blog/assets/images/theme/err-img.svg`;
}
$(image).css("width", "100px");
return true;
};
function tippyConfigure() {
tippy("[data-tippy-content]", {
theme: "translucent",
animation: "shift-away",
inertia: true,
allowHTML: true
});
}
function initContents() {
let markdownToc = $("#markdown-toc");
if (markdownToc.length) {
$("#sidebar-toc-content").append(markdownToc.html());
let toc = $("#markdown-toc, #sidebar-toc-content").find("a");
if (toc.length) {
toc.each(function () {
let id = $(this).attr("href");
$(this).attr("data-tippy-content", $(this).html());
$(this).on("click", function (e) {
e.preventDefault();
changePoint(id, id);
});
});
}
}
}
function generateContents() {
let markdownToc = $("#markdown-toc");
if (markdownToc.length) {
if ($(window).width() >= 1366) {
markdownToc.css("display", "none");
$("#page").css("margin-left", getPropertyValue("--sidebar-width"));
$(".sidebar").css("display", "block");
$(".nav-global .btn-contents").removeClass("hidden");
} else {
markdownToc.css("display", "inline-block");
$(".sidebar").css("display", "none");
$(".nav-global .btn-contents").addClass("hidden");
$("#page").css("margin-left", "0px");
}
}
}
function contentsToggle() {
initContents();
generateContents();
$(window).resize(generateContents);
$(".nav-global .btn-contents").on("click", function () {
let click = $(this).data("clicks");
if (click) {
$(this).find("i").removeClass("fa-arrow-right-long").addClass("fa-arrow-left-long");
$(".sidebar").css("display", "block");
$("#page").css("margin-left", getPropertyValue("--sidebar-width"));
} else {
$(this).find("i").removeClass("fa-arrow-left-long").addClass("fa-arrow-right-long");
$(".sidebar").css("display", "none");
$("#page").css("margin-left", "0px");
}
$(this).data("clicks", !click);
});
}
function themeToggle() {
let themeMode = $(".theme-mode");
if (localStorage.toggled === "light") {
document.documentElement.classList.add("light");
themeMode.find("i").removeClass("fa-toggle-off").addClass("fa-toggle-on");
} else {
document.documentElement.classList.remove("light");
themeMode.find("i").removeClass("fa-toggle-on").addClass("fa-toggle-off");
}
themeMode.on("click", function () {
document.documentElement.classList.toggle("light");
if (localStorage.toggled !== "light") {
localStorage.toggled = "light";
$(this).find("i").removeClass("fa-toggle-off").addClass("fa-toggle-on");
} else {
localStorage.toggled = "dark";
themeMode.find("i").removeClass("fa-toggle-on").addClass("fa-toggle-off");
}
});
}
function jumpLocation() {
let location = sessionStorage.getItem("location");
sessionStorage.removeItem("location");
if (location == null) {
return;
}
let target = document.getElementById(location);
if (target != null) {
target.scrollIntoView(true);
}
}
window.onload = function () {
jumpLocation();
};
$(function () {
themeToggle();
contentsToggle();
tippyConfigure();
});
</script>
</head>
<body>
<canvas id="universe"></canvas>
<!--[if IE]>
<p class="site-notice">您正在使用一个过时的网页浏览器。<a href="https://browsehappy.com/" target="_blank">请升级您的浏览器。</a></p>
<![endif]-->
<noscript>
<p class="site-notice">本网站需要 JavaScript。<a href="https://www.enable-javascript.com/" target="_blank">请查阅指南来给您的浏览器开启 JavaScript 功能。</a></p>
</noscript>
<div class="nav-wrapper overlay-wrapper">
<div class="nav-form overlay-form">
<span class="overlay-header menu">Menu</span>
<a class="btn-close"><i class="fas fa-times"></i></a>
<div class="results">
<ul>
<li><a href="/blog/categories/">Categories</a></li>
<li><a href="/blog/tags/">Tags</a></li>
<li><a href="/blog/home/">About</a></li>
</ul>
</div>
</div>
</div>
<div class="search-wrapper overlay-wrapper">
<div class="search-form overlay-form animate__animated animate__bounce">
<label><input class="overlay-header" id="search-input" placeholder="please enter keyword search" tabindex="-1" type="text"></label>
<a class="btn-close"><i class="fas fa-times"></i></a>
<ul id="results-container"></ul>
</div>
</div>
<div class="sidebar animate__animated animate__bounceInLeft">
<div class="sidebar-toc">
<div class="sidebar-toc-title">Table of contents</div>
<ul id="sidebar-toc-content"></ul>
</div>
</div>
<div id="page">
<header class="the-header">
<div class="unit-head">
<nav class="nav-global animate__animated animate__headShake">
<ul>
<li class="logo">
<button class="btn-menu" data-tippy-content="Menu"><i class="fas fa-bars"></i></button>
<a href="/blog/home/">走在修行的大街上</a>
<!--[if !IE]>-->
<button class="btn-search" data-tippy-content="Search"><i class="fas fa-search"></i></button>
<!--<![endif]-->
</li>
<li><a class="theme-mode"><i class="fa-solid fa-toggle-off"></i></a></li>
<li><a class="btn-contents hidden"><i class="fa-solid fa-arrow-left-long"></i></a></li>
<li><a href="/blog/categories/"><i class="fa-solid fa-bookmark"></i></a></li>
<li><a href="/blog/tags/"><i class="fa-solid fa-hashtag"></i></a></li>
<!--[if !IE]>-->
<li><a class="btn-search"><i class="fa-solid fa-magnifying-glass"></i></a></li>
<!--<![endif]-->
</ul>
</nav>
</div>
</header>
<div class="body animate__animated animate__bounceInLeft" role="main">
<div class="unit-body">
<div class="unit-inner">
<!--page start-->
<article class="unit-article layout-post">
<div class="unit-inner unit-article-inner">
<div class="content">
<header>
<div class="unit-head">
<div class="unit-inner">
<h1 class="entry-title">LeetCode 1084. 销售分析III</h1>
</div>
</div>
</header>
<div class="meta">
<section class="date-publish">
<button>
<i class="fas fa-calendar-alt article-icon"></i>Published:
<time class="date-pub updated"
data-tippy-content="2024-09-23 21:23:46" datetime="2024-09-23T21:23:46+08:00">2024-09-23
</time>
by
<a class="author" href="/blog/" rel="author">
HGNULB
</a>
</button>
</section>
<ul class="list-category list-linear">
<li class="list-head"><i class="fas fa-inbox article-icon"></i>Categories:</li>
<div>
<a onclick="changePoint('/blog/categories/', '#LeetCode')" data-tippy-content="LeetCode">
<button>LeetCode <span>1879</span></button>
</a>
</div>
<div>
<a onclick="changePoint('/blog/categories/', '#🟢-简单')" data-tippy-content="🟢 简单">
<button>🟢 简单 <span>491</span></button>
</a>
</div>
</ul>
<ul class="list-tag list-linear">
<li class="list-head"><i class="fas fa-tag article-icon"></i>Tags:</li>
<div>
<a onclick="changePoint('/blog/tags/', '#数据库')" data-tippy-content="数据库">
<button>数据库 <span>116</span></button>
</a>
</div>
</ul>
</div>
<ul id="markdown-toc">
<li><a href="#题目描述" id="markdown-toc-题目描述">题目描述</a></li>
<li><a href="#思路分析" id="markdown-toc-思路分析">思路分析</a></li>
<li><a href="#参考代码" id="markdown-toc-参考代码">参考代码</a></li>
</ul>
<h2 id="题目描述">题目描述</h2>
<blockquote>
<p>🔥 <a href="https://leetcode.cn/problems/sales-analysis-iii/">1084. 销售分析III</a></p>
</blockquote>
<h2 id="思路分析">思路分析</h2>
<blockquote>
<p>思路描述</p>
</blockquote>
<h2 id="参考代码">参考代码</h2>
<div class="language-go highlighter-rouge"><div class="highlight"><pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="n">write</span> <span class="n">your</span> <span class="n">code</span> <span class="n">here</span>
</pre></td></tr></tbody></table></code></pre></div></div>
<div class="language-go highlighter-rouge"><div class="highlight"><pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="n">write</span> <span class="n">your</span> <span class="n">code</span> <span class="n">here</span>
</pre></td></tr></tbody></table></code></pre></div></div>
<p><a class="button show-hidden">🍏 点击查看 Java 题解</a></p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="n">write</span> <span class="n">your</span> <span class="n">code</span> <span class="n">here</span>
</pre></td></tr></tbody></table></code></pre></div></div>
<footer class="unit-foot">
<div class="unit-inner">
<p>
<a class="go-top" data-tippy-content="Back to Top"><i class="fas fa-arrow-up"></i></a>
</p>
<nav class="pagination">
<div class="prev">
<span class="line line-top"></span>
<span class="line line-right"></span>
<span class="line line-bottom"></span>
<span class="line line-left"></span>
<a class="internal" data-tippy-content="LeetCode 1083. 销售分析 II" href="/blog/2024/41727497" rel="prev">🔥 上一篇</a>
</div>
<div class="next">
<span class="line line-top"></span>
<span class="line line-right"></span>
<span class="line line-bottom"></span>
<span class="line line-left"></span>
<a class="internal" data-tippy-content="LeetCode 1085. 最小元素各数位之和" href="/blog/2024/68165749" rel="next">下一篇 🔥</a>
</div>
</nav>
</div>
</footer>
<div class="post-copyright">
<div class="post-copyright-author"><span class="post-copyright-meta">本文作者: </span>
<a href="/blog/" rel="author">
HGNULB
</a>
</div>
<div class="post-copyright-type"><span class="post-copyright-meta">本文链接: </span>
<a href="https://hgnulb.github.io/blog/2024/10433304">https://hgnulb.github.io/blog/2024/10433304</a>
</div>
<div class="post-copyright-notice"><span class="post-copyright-meta">版权声明: </span>
本博客所有文章除特别声明外,均采用
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="license" target="_blank"> CC BY-NC-SA 4.0 </a>
许可协议,转载请注明出处!
</div>
</div>
</div>
</div>
</article>
<script>
typedEntryTitle();
</script>
<!--page end-->
</div>
</div>
</div>
<footer class="the-footer">
<div class="unit-inner">
<h4><a href="/blog/">About</a></h4>
<p>Copyright ©2017-2024 走在修行的大街上 All rights reserved</p>
<p id="sitetime"></p>
<p>
<span id="busuanzi_container_page_pv">本文阅读量 <span id="busuanzi_value_page_pv"></span> 次</span>
<span id="busuanzi_container_site_pv">本站访问量 <span id="busuanzi_value_site_pv"></span> 次</span>
<span id="busuanzi_container_site_uv">本站访客数 <span id="busuanzi_value_site_uv"></span> 人</span>
</p>
</div>
<div class="social-links">
<a class="ico-gmail" data-tippy-content="email" href="mailto:[email protected]" rel="me" target="_blank"></a>
<a class="ico-leetcode" data-tippy-content="leetcode" href="https://leetcode.cn/u/hgnulb/" rel="me" target="_blank"></a>
<a class="ico-github" data-tippy-content="github" href="https://github.com/hgnulb/" rel="me" target="_blank"></a>
<a class="ico-douban" data-tippy-content="douban" href="https://book.douban.com/people/257597606/" rel="me" target="_blank"></a>
<a class="ico-stackoverflow" data-tippy-content="stackoverflow" href="https://stackoverflow.com/users/10383025/" rel="me" target="_blank"></a>
<a class="ico-nowcoder" data-tippy-content="nowcoder" href="https://www.nowcoder.com/profile/8667211/" rel="me" target="_blank"></a>
</div>
<button class="back-to-top"><i class="fas fa-arrow-alt-circle-up fa-3x"></i></button>
</footer>
</div>
<!--图片懒加载插件-->
<script src="https://cdn.jsdelivr.net/npm/jquery-lazyload/jquery.lazyload.min.js"></script>
<!--其他插件-->
<script src="https://cdn.jsdelivr.net/npm/simple-jekyll-search/dest/simple-jekyll-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/hgnulb/blog@gh-pages/assets/libs/javascripts/canvas-bg.js"></script>
<script>
let pathPrefix = "/blog";
if ("true" === "true") {
pathPrefix = "https://cdn.jsdelivr.net/gh/hgnulb/blog@gh-pages";
}
let pygmentsThemes = JSON.parse(`["fruity","github-dark","zenburn","dracula","stata-dark","lightbulb","monokai"]`);
function loadRandomPygmentsTheme() {
const randomTheme = pygmentsThemes[Math.floor(Math.random() * pygmentsThemes.length)];
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = `${pathPrefix}/assets/libs/pygments_css/${randomTheme}.css`;
document.head.appendChild(link);
}
function overrideCheckbox() {
$(`input[type="checkbox"]`).each(function () {
if (this.checked) {
$(this).after(`<i class="fa-regular fa-square-check checkbox-icon checkbox-checked fa-lg"></i>`);
} else {
$(this).after(`<i class="fa-regular fa-square checkbox-icon fa-lg"></i>`);
}
});
}
function headerToggle() {
let header = $("h1, h2, h3");
header.filter(":not(.entry-title)").prepend(`<i class="title-icon fa-solid fa-caret-down" style="display: none;"></i>`);
header.filter(":not(.entry-title)").mouseenter(function () {
let titleIconChildren = $(this).find(".title-icon");
if (titleIconChildren.is(".title-icon.fa-caret-down")) {
titleIconChildren.attr("style", "display: inline-block;");
}
}).mouseleave(function () {
let titleIconChildren = $(this).find(".title-icon");
if (titleIconChildren.is(".title-icon.fa-caret-down")) {
titleIconChildren.attr("style", "display: none;");
}
});
$(".title-icon").on("click", function () {
let click = $(this).data("clicks");
if (click) {
$(this).parent().nextUntil(this.parentNode.tagName).slideDown();
$(this).removeClass("fa-caret-right").addClass("fa-caret-down");
$(this).parent().nextUntil(this.parentNode.tagName).find(".title-icon").removeClass("fa-caret-right").addClass("fa-caret-down").attr("style", "display: none;");
$(this).parent().nextUntil(this.parentNode.tagName).find(".title-icon").data("clicks", !click);
} else {
$(this).parent().nextUntil(this.parentNode.tagName).slideUp();
$(this).removeClass("fa-caret-down").addClass("fa-caret-right");
}
$(this).data("clicks", !click);
});
}
function lazyload() {
if ("true" !== "true") {
return;
}
$("img.lazyload").show().lazyload({
event: "scroll",
effect: "fadeIn"
});
$(window).bind("load", function () {
setTimeout(function () {
$("img.lazyload").trigger("scroll");
}, 1000);
});
}
function imgBoxFactory(imageUrl, imageName) {
return `<div class="img-box"><img src=${imageUrl} alt=${imageName}></div>`;
}
function goTop() {
let offset = 50, duration = 500, width = 960;
$(window).scroll(function () {
if ($(window).width() > width) {
if ($(this).scrollTop() > offset) {
$("footer").css("top", "20px");
$("footer .back-to-top").fadeIn(duration);
} else {
$("footer").css("top", "auto");
$("footer .back-to-top").fadeOut(duration);
}
}
});
$(window).resize(function () {
if ($(window).width() < width) {
$("footer").css("top", "auto");
$("footer .back-to-top").fadeOut(duration);
}
if ($(window).width() >= width && $(this).scrollTop() > offset) {
$("footer").css("top", "20px");
$("footer .back-to-top").fadeIn(duration);
}
});
$("footer .back-to-top, .go-top").on("click", function (event) {
event.preventDefault();
$("html, body").animate({
scrollTop: 0
}, duration);
return false;
});
}
function displayDetail() {
let showHidden = $(".show-hidden");
showHidden.each(function () {
if ($(this).parent().next()) {
$(this).parent().next().addClass("hidden");
}
});
showHidden.on("click", function () {
$(this).parent().next().slideToggle();
});
}
function closeOverlay() {
$(".nav-wrapper, .search-wrapper").removeAttr("style");
$(".nav-form, .search-form").removeClass("active");
$(".search-form").find("input").val("");
$("body").removeClass("nav-overlay search-overlay");
}
function searchMethod() {
$(".nav-global .btn-search").on("click", function () {
$(".search-wrapper").css({display: "block"});
let searchForm = $(".search-form");
searchForm.addClass("active");
searchForm.find("input").focus();
$("body").addClass("search-overlay");
});
$(".nav-global .btn-menu").on("click", function () {
$(".nav-wrapper").css({display: "block"});
$(".nav-form").addClass("active");
$(".nav-form #search-input").prop("disabled", true);
$("body").addClass("nav-overlay");
});
$(".nav-wrapper .btn-close, .search-wrapper .btn-close").on("click", function () {
closeOverlay();
});
new SimpleJekyllSearch({
searchInput: document.getElementById("search-input"),
resultsContainer: document.getElementById("results-container"),
json: "/blog/home/search.json",
searchResultTemplate: `<li><a href="{url}">{title}<time class="entry-date">{date}</time></a></li>`,
noResultsText: "<p><b>Not Found</b></p>",
limit: 15,
fuzzy: true
});
}
function pad(n) {
return (n < 10) ? ("0" + n) : n;
}
function siteTime() {
window.setTimeout("siteTime()", 1000);
let seconds = 1000;
let minutes = seconds * 60;
let hours = minutes * 60;
let days = hours * 24;
let years = days * 365;
let today = new Date();
let startDate = new Date("2017/12/26");
let diff = today - startDate;
let diffYears = Math.floor(diff / years);
let diffDays = Math.floor((diff / days) - diffYears * 365);
let diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
let diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) / minutes);
let diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours - diffMinutes * minutes) / seconds);
document.getElementById("sitetime").innerHTML = "本博客已稳定运行 " + diffYears + " 年 " + diffDays + " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + pad(diffSeconds) + " 秒";
}
$(function () {
lazyload();
loadRandomPygmentsTheme();
goTop();
overrideCheckbox();
headerToggle();
displayDetail();
searchMethod();
siteTime();
});
</script>
</body>
</html>