-
Notifications
You must be signed in to change notification settings - Fork 0
/
myposts.html
83 lines (77 loc) · 4.03 KB
/
myposts.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Posts</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<link rel="icon" href="Bloggerzz icon.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark">
<a href="home.html" class="navbar-brand"><img src="Bloggerzz icon.png" width="50"/></a>
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="home.html" aria-current="page">Feed</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="myposts.html" aria-current="page" >Your posts</a>
</li>
<li class="nav-item">
<a class="nav-link" href="blog.html" >Add blog</a>
</li>
</ul>
</div>
</div>
</nav>
<div style="margin-top: 140px;display: flex;">
<div class="myPosts me-5 mb-2 mb-lg-0">
</div>
<div>
<h1>Your blog details</h1>
<div class="card" style="width: 30vw;" id="card_status"></div>
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase.js"></script>
<script src="firebase.js"></script>
<script>
showPosts();
function showPosts(){
firebase.database().ref("blogs").once("value",function(snapshot){
let total=0;
let pu=0;
let pr=0;
snapshot.forEach(function(childSnapshot){
var childKey=childSnapshot.key;
var childValue=childSnapshot.val();
var sessusername=sessionStorage.getItem("username");
if(childValue["author"]==sessusername){
total=total+1;
let displayBlogPriv='<div class="card"><h1>'+childValue["heading"]+'</h1></br><h3>'+childValue["blogtext"]+'</h3>'+'<h6>Written By '+childValue["author"]+'</h6><h6>'+Date(childValue["date"]).slice(0,25)+`</h6><a class="ms-auto" href="posts.html?`+childKey+`">see more</a></div>`;
document.querySelector(".myPosts").innerHTML+=displayBlogPriv;
if(childValue["status"]=="private"){
pu=pu+1;
document.querySelector(".card").innerHTML+='<i class="fa fa-lock" style="color:#d0d00d"></i>';
}
else{
pr=pr+1;
}
}
});
document.querySelector("#card_status").innerHTML+='<h4>Total blogs: '+total+'</h4>';
document.querySelector("#card_status").innerHTML+='<h4>Public blogs: '+pu+'</h4>';
document.querySelector("#card_status").innerHTML+='<h4>Private blogs: '+pu+'</h4>';
});
}
</script>
</body>
</html>