-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathblogHeader.php
155 lines (137 loc) · 6.51 KB
/
blogHeader.php
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
<script>
// ====================================================Header Three bLogs==========================================
let urlThree = './admin/blogAdmin/api.php/?q=readHome';
var threePosts = document.getElementById("row2");
threePosts.innerHTML = "";
$(document).ready(function() {
$.ajax({
url: urlThree,
method: 'GET',
dataType: 'JSON',
success: function(data) {
//console.log(data);
data.forEach(myThreeBlogs);
function myThreeBlogs(row, index) {
let spanTag = "";
row.Category.forEach((element) => {
spanTag += "<p><span>" + element + "</span></p>"
})
threePosts.innerHTML += "<div class='col-md-4 col-lg-4'>\
<div id=" + row.Sno + "_image onClick = redirectHeaderThree(" + row.Sno + ") class='effect-layla figure'>\
<img src='" + row.Image + "' />\
<div class='figcaption'>\
<h2><span>" + row.Title + "</span></h2>" + spanTag + "\
<p>" + row.Date.split(' ')[0] + "</p>\
</div>\
</div>\
</div>";
// threePosts.innerHTML += "<div class=col-md-4 col-lg-4>\
// <div id=" + row.Sno + "_image onClick = redirectHeaderThree(" + row.Sno + ") class='a-block d-flex align-items-center height-md'" + " style= background-repeat: no-repeat; background-size: cover;>\
// <div class=text>\
// <div class=post-meta>\
// <span id=blogHeader" + index + "_category class='category'>" + row.Category + "</span>\
// <span id=blogHeader" + index + "_date class='mr-2'>" + row.Date + " </span>\
// </div>\
// <h3 id=blogHeader" + index + "_title>" + row.Title + "</h3>\
// </div>\
// </div>\
// </div>";
// document.getElementById(row.Sno + "_image").style.backgroundImage = "url(./admin/blogAdmin/" + row.Image + ")"
}
// ===============================================right side three blogs================================================
var rightThreePost = document.getElementById("row4");
rightThreePost.innerHTML = "";
data.forEach(rightThreeBlogs);
function rightThreeBlogs(row, index) {
rightThreePost.innerHTML += "<div id=" + row.Sno + " class='row rightCard' onClick = redirectRightThree(" + row.Sno + ")>\
<div class='col-5'>\
<div class='rightImage'>\
<img id=rightBlog" + index + "_image src='" + row.Image + "' alt= />\
</div>\
</div>\
<div class='col-7 rightText'>\
<h5 id= rightBlog" + index + "_title>" + row.Title + "</h5>\
<span id=rightBlog" + index + "_date class='card-span cardDown'>" + row.Date.split(' ')[0] + "</span>\
<span class='card-span card-span-dot'><i class='fas fa-circle'></i>\
</span>\
<span class='card-span cardDown'><i class='fas fa-comments'></i></span>\
</div>\
</div>";
}
}
});
});
// ==================================================show Category==============================================
let categoryUrl = './admin/blogAdmin/api.php/?q=showCategory';
var categories = document.getElementById("row3");
// categories.innerHTML = " ";
//console.log(categories, "categories");
$(document).ready(function() {
$.ajax({
url: categoryUrl,
method: 'GET',
dataType: 'JSON',
success: function(data) {
//console.log(data, "category");
data.forEach(categoryCountShow);
function categoryCountShow(row, index) {
categories.innerHTML += "<div class= 'row categories'>\
<div id=" + row.Category + " class= 'col-6 categoryLeft' onClick = setCategory(" + row.Category + ")>" + row.Category + "</div>\
<div class= 'col-6 categoryRight' >(" + row.catCount + ")</div>\
</div> \
<hr style= 'width: 100%; text-align: centre' />";
}
},
});
});
function setCategory(cat) {
console.log(cat);
let showCategoryURL = "./admin/blogAdmin/api.php/?q=getPostByCategory&id='" + cat.innerHTML + "'";
posts.innerHTML = "";
$(document).ready(function() {
$.ajax({
url: showCategoryURL,
method: 'GET',
dataType: 'JSON',
success: function(data) {
// console.log(data);
data.forEach(getpostcategory);
function getpostcategory(row, index) {
var desc = row.Content;
var descSub = desc.substring(0, 70) + "...";
posts.innerHTML += "<div class=col-md-6 col-lg-6 col-12>\
<div class=card id=" + row.Sno + " onClick = redirec(" + row.Sno + ") >\
<img\
src = '" + row.Image + "'\
id=blog" + index + "_image\
class=card-img-top\
alt=Card image cap\
/>\
<div class=card-body>\
<div class=post-meta>\
<span id=blog" + index + "_category class=category>" + row.Category + "</span>\
<span id=blog" + index + "_date class=mx-2 card-span>" + row.Date.split(' ')[0] + "</span>\
<span class=mx-2 card-span card-span-dot\
><i class=fas fa-circle></i>\
</span>\
<span class=mx-2 card-span\
><i class=fas fa-comments></i\
></span>\
</div>\
<p id=blog" + index + "_content class=card-text>" + descSub + "</p>\
</div>\
</div>\
</div>"
}
},
});
});
}
function redirectHeaderThree(id) {
window.document.location = "./singleBlog.php?Id=" + id; //Connecting Second page
}
function redirectRightThree(id) {
window.document.location = "./singleBlog.php?Id=" + id; //Connecting Second page
}
</script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>