-
Notifications
You must be signed in to change notification settings - Fork 0
/
myblogs.html
90 lines (65 loc) · 3.57 KB
/
myblogs.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
<!--After Post Area-->
<hr>
<br>
<div class="text-center bg-light text-dark">
<h3>My Promotions</h3>
</div>
<hr>
<br>
<div class="row container-fluid bg-3">
<div class="col-sm-12" id="blogs">
</div>
</div>
<br>
<!--After Post Area End here -->
<!--Validations and uploading of post blogs -->
<script>
var user = firebase.auth().currentUser;
var dblogs = firebase.database().ref().child("Promotions").orderByChild("uid").equalTo(user.uid);
dblogs.on("value", function (blogs) {
if (blogs.exists()) {
var blogsHtml = "";
blogs.forEach(function (singleBlog) {
counter = counter + 1;
blogsHtml += "<div class='jumbotron bg-light text-dark border border-dark'>";
blogsHtml += "<div> <img width='1000px' height='550px' src='";
blogsHtml += singleBlog.val().image;
blogsHtml += "'/></div><br>";
blogsHtml += "<div class='row'>";
blogsHtml += "<div class='col-sm-5'> <p style='grey';>"
+ "published by: " + singleBlog.val().userName
+ "</p></div>" +
"<div class='col-sm-3'> <p style='grey';>"
+ "Time : " + singleBlog.val().time
+ "</p></div>" +
"<div class='col-sm-4'> <p style='grey; margin-left: 15px;'>"
+ "Date : " + singleBlog.val().date
+ "</p></div>"
;
blogsHtml += "</div><br>";
blogsHtml += "<div style='text-align: justify; color: black;'>";
blogsHtml += singleBlog.val().desc;
blogsHtml += "</div><br>";
blogsHtml += "<div class ='form-group' style='text-align: justify; color: black;'>";
blogsHtml += "<button class='form-control btn btn-light bg-dark text-white' onclick=deleterecord('"+singleBlog.key+"')>Delete this Promotion</button>";
blogsHtml += "</div><br>";
blogsHtml += "</div>";
});
$("#blogs").html(blogsHtml);
}
});
function deleterecord(key)
{
var deleteRef = firebase.database().ref().child("Promotions").child(key);
return deleteRef.remove()
.then(function()
{
console.log("Remove Successfully.");
})
.catch(function()
{
console.log("Error Occured.");
});
}
//end recieve data from the database
</script>