forked from kitian616/jekyll-TeXt-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall.html
117 lines (113 loc) · 5.16 KB
/
all.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
---
layout: blog-default
title: All Posts
---
<div class="m-all">
<div class="main">
<h1 class="js-page-heading">{{ page.title }}</h1>
{% include blog/tags.html %}
<!--group by year: http://stackoverflow.com/questions/19086284/jekyll-liquid-templating-how-to-group-blog-posts-by-year-->
<section class="js-year-wrapper">
{% for post in site.posts %}
{% assign currentdate = post.date | date: "%Y" %}
{% if currentdate != date %}
{% unless forloop.first %}</ul></section>{% endunless %}
<section id="{{ post.date | date: "%Y" }}">
<h2 class="year-title" id="year-{{ post.date | date: "%Y" }}">{{ currentdate }}</h2>
<ul class="year-list">
{% assign date = currentdate %}
{% endif %}
{% assign _tags = "" %}
{% for tag in post.tags %}
{% assign _tag = tag | strip | url_encode %}
{% assign _tags = _tags | append: ","" | append: _tag %}
{% endfor %}
{% assign last = _tags | size | minus: 1 %}
{% assign _tags = _tags | slice: 1, last %}
<li class="js-post-block" data-tag="{{ _tags }}">
{% assign locale_ALDF = site.data.locale.ARTICLE_LIST_DATA_FORMAT } %}
<span class="post-date">
{% if locale_ALDF[site.lang] %}{{ post.date | date: locale_ALDF[site.lang] }}{% else %}{{ post.date | date: locale_ALDF.en }}{% endif %}
</span><a class="post-link" href="{{ post.url | prepend: site.baseurl | replace: '//', '/' }}">{{ post.title }}</a>
</li>
{% if forloop.last %}</ul></section>{% endif %}
{% endfor %}
</section>
</div>
</div>
<script type="text/javascript">
// function queryString is copied from
// http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter#answer-979995
function queryString() {
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var i = 0, queryObj = {}, pair;
var queryStr = window.location.search.substring(1);
var queryArr = queryStr.split('&');
for (i = 0; i < queryArr.length; i++) {
pair = queryArr[i].split('=');
// If first entry with this name
if (typeof queryObj[pair[0]] === 'undefined') {
queryObj[pair[0]] = pair[1];
// If second entry with this name
} else if (typeof queryObj[pair[0]] === 'string') {
queryObj[pair[0]] = [queryObj[pair[0]], pair[1]];
// If third or later entry with this name
} else {
queryObj[pair[0]].push(pair[1]);
}
}
return queryObj;
}
$(function() {
var $pageHeading = $('.js-page-heading');
var $articleTag = $('.js-article-tag');
var $tagShowAll = $('.js-tag-show-all');
var $postBlock = $('.js-post-block');
var $yearSection = $('.js-year-wrapper section');
window.tagSelect = function(tag) {
var i = 0, flag = false, cur, tagStr = '',
tags = [], _tag = '', lis = [];
if (tag === undefined || tag === '') {
$pageHeading.text('{{ page.title }}'); $tagShowAll.focus(); $postBlock.show();
} else {
tag = tag.trim();
// $articleTag.filter('.tag-' + tag).focus();
for (i = 0; i < $articleTag.length; i++) {
cur = $articleTag.eq(i); _tag = cur.data('tag');
if (typeof _tag === 'string' && _tag.trim() === tag) {
cur.focus(); tagStr = cur.children('span').text();
(typeof tagStr === 'string') && (tagStr = tagStr.trim());
$pageHeading.text('Tag: ' + tagStr); break;
}
}
$postBlock.each(function() {
flag = false, cur = $(this);
tags = cur.data('tag').split(',');
for (i = 0; i < tags.length; i++) {
_tag = tags[i].trim();
if (_tag === tag) {
flag = true; cur.show(); break;
}
}
flag || (cur.hide());
});
}
$yearSection.each(function() {
flag = false, cur = $(this);
lis = cur.find('li');
for (i = 0; i < lis.length; i++) {
if(lis.eq(i).css('display') !== 'none') {
flag = true; break;
}
}
flag ? cur.show() : cur.hide();
});
tag === undefined || window.history.replaceState(null, '', window.location.href.split('?')[0] + '?tag=' + tag);
}
var query = queryString();
var tag = undefined;
query.tag === undefined || (tag = query.tag);
tagSelect(tag);
});
</script>