-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.html
78 lines (72 loc) · 3.91 KB
/
home.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="styles.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feed</title>
<link rel="icon" href="Bloggerzz icon.png">
<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 active" href="home.html" aria-current="page">Feed</a>
</li>
<li class="nav-item">
<a class="nav-link" href="myposts.html" >Your posts</a>
</li>
<li class="nav-item">
<a class="nav-link" href="blog.html" >Add blog</a>
</li>
</ul>
<a href="login.html" class="btn btn-light">Logout</a>
</div>
</div>
</nav>
<div style="display: flex; margin-top: 140px;" id="flex_home">
<div class="posts me-5 mb-2 mb-lg-0">
</div>
<div class="private_posts_home">
<h1>Your private posts</h1>
<div class="private-card"></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){
snapshot.forEach(function(childSnapshot){
var childKey=childSnapshot.key;
var childValue=childSnapshot.val();
if(childValue["status"]=="public"){
let displayBlog='<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(".posts").innerHTML+=displayBlog;
}
else if(childValue["status"]=="private"){
var sessusername=sessionStorage.getItem("username");
if(childValue["author"]==sessusername){
newDate=Date((childValue["date"]));
let displayBlogPriv='<div class="card" style="width:30vw"><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(".private-card").innerHTML+=displayBlogPriv;
}
else{
document.querySelector(".private-card").innerHTML="<h3>No blogs available</h3>";
}
}
});
});
}
</script>
</body>
</html>