forked from raml-org/raml-org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchives.html
138 lines (123 loc) · 6.47 KB
/
archives.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
---
layout: page
title: Blog Archives
permalink: /archives
---
<div class="wrapper">
<div class = "renderblog"></div>
<ul id="pagination-demo" class="paginationqw"></ul>
</div>
<script src="js/jquery.twbsPagination.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('h1.page-header').text("Blog Archive");
//console.log(queryStingval);
fetchJsonData();
function fetchJsonData() {
var dataarray =[];
var currentdate = new Date($.now());
//console.log(currentdate);
$.getJSON("/blog.json", function (data) {
$.each(data,function(l) {
var date = new Date(data[l].date);
var newDate = date.toString('dd-MM-yy');
if(date < currentdate) {
dataarray.push(data[l]);
}
});
if(dataarray.length >= 0) {
renderJsonData(dataarray)
}
});
}
function renderJsonData(data) {
//console.log(data);
var perpage = 5;
var datalimit = perpage;
var maxdatalength = data.length;
var totallinks = Math.ceil(maxdatalength/perpage);
var renderblog = $('div.renderblog');
console.log(totallinks);
$('#pagination-demo').twbsPagination({
totalPages: totallinks,
visiblePages: 5,
next: 'Next',
prev: 'Prev',
onPageClick: function (event, page) {
// var current_page = page;
datalimit = (page*perpage);
var start;
if(page == 1) {
start = 0;
} else {
start = (datalimit+perpage)-(2*perpage);
datalimit = (datalimit+perpage)-perpage;
}
// console.log( page + " start " + start + " limit " + datalimit );
renderblog.empty();
var regex = /\s+/gi;
for(var i = start; i < datalimit; i++ ) {
if(data[i] === undefined) {
continue;
}
var joinblogcategory;
if(data[i].categories.indexOf(',') > -1) {
var blogcategory = [];
var getblogcat = data[i].categories.split(",");
for(var j = 0; j < getblogcat.length; j++ ) {
var getcat;
var wordCounts = getblogcat[j].trim().replace(regex, " ").split(" ").length;
if(wordCounts > 1) {
getcat = getblogcat[j].trim().replace(" ", "+").toLowerCase();
} else {
getcat = getblogcat[j].trim().toLowerCase();
}
//blogcategory += '<a href="/blog-cat?cat=' + getblogcat[j].trim() + '">' + getblogcat[j] +'</a>' + ' , ';
blogcategory.push('<a href="/blog-cat?cat=' + getcat + '">' + getblogcat[j] +'</a>');
}
joinblogcategory = blogcategory.join(', ');
} else {
if(data[i].categories.trim().replace(regex, " ").split(" ").length > 1) {
joinblogcategory = '<a href="/blog-cat?cat=' + data[i].categories.trim().replace(" ", "+").toLowerCase() + '">' + data[i].categories +'</a>';
} else {
joinblogcategory = '<a href="/blog-cat?cat=' + data[i].categories.trim().toLowerCase() + '">' + data[i].categories +'</a>';
}
}
var blogtag;
if(data[i].tags.length >= 1) {
if(data[i].tags.indexOf(',') > 0) {
var blogtags = [];
var getblogtag = data[i].tags.split(",");
for(var k = 0; k < getblogtag.length; k++ ) {
if(getblogtag[k] != undefined) {
var getVal;
var wordCount = getblogtag[k].trim().replace(regex, " ").split(" ").length;
if(wordCount > 1) {
getVal = getblogtag[k].trim().replace(" ", "+").toLowerCase();
} else {
getVal = getblogtag[k].trim().toLowerCase();
}
blogtags.push('<a href="/blogtag?tag=' + getVal + '">' + getblogtag[k] +'</a>');
}
}
blogtag = blogtags.join(', ');
} else {
if(data[i].tags.trim().replace(regex, " ").split(" ").length > 1) {
blogtag = '<a href="/blogtag?tag=' + data[i].tags.trim().replace(" ", "+").toLowerCase() + '">' + data[i].tags +'</a>';
} else {
blogtag = '<a href="/blogtag?tag=' + data[i].tags.trim().toLowerCase() + '">' + data[i].tags +'</a>';
}
}
} else {
blogtag = '';
}
var blogDiv = '<div class="blog"><h2><a class="post-link" href="'+ data[i].url +'">'+ data[i].title +'</a></h2>' + '' +
'<div class="post_author">By: '+ data[i].author + '</div><div class="post_date">'+ data[i].date + '</div><div class="post_categories"> Category: ' + joinblogcategory + '</div><div class="post_tag"> Tags: ' + blogtag +'</div>' +
'<div class="post_content">' + data[i].content + '</div><div class="read_more"><a href="' + data[i].url + '" class="btn btn-default">Read More</a></div></div>';
renderblog.append(blogDiv);
}
}
});
}
});
</script>