-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog.html
87 lines (79 loc) · 3.64 KB
/
blog.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
<!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>Blog</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 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" >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 active" href="blog.html" aria-current="page" >Add blog</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="blogwriting me-auto ms-auto " style="margin-top:20px">
<h4 style="text-align:center;font-weight:bold">Happy Blogging!!</h4>
<input type="text" placeholder="Blog name" id="heading" class="form-control"/>
<textarea placeholder="Start writing....." id="blogtext" class="form-control" rows="14"></textarea>
<input type="checkbox" value="private" id="checkbox" class="form-check-input"/><label class="form-check-label"> Make this blog private</label></br></br>
<div style="display: flex;justify-content: end; margin-right:10px">
<button id="postBlog" onclick="postBlog()" class="btn btn-primary" >Post</button>
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase.js"></script>
<script src="firebase.js"></script>
<script>
function postBlog(){
let heading=document.getElementById("heading").value;
let blogtext=document.getElementById("blogtext").value;
let checkbox=document.getElementById("checkbox");
let status="";
if(checkbox.checked==true){
status="private"
}
else{
status="public"
}
if(heading!="" && blogtext!=""){
function blogSubmit(){
let newBlogs=blogs.push();
newBlogs.set({
heading:heading,
date:Date.now(),
blogtext:blogtext,
status:status,
author:sessionStorage.getItem("username")
});
alert("You blog is saved successfully");
}
blogSubmit();
}
else{
alert("You need to enter something");
}
}
</script>
</body>
</html>