-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
111 lines (97 loc) · 3.14 KB
/
index.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Github Pages Website</title>
<style>
/* Reset default margin and padding */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Set container to full width and height */
.container {
max-width: 1366px;
margin: 0 auto;
height: 100%;
}
</style>
</head>
<body>
<div class="container">
<div class="header">This is my Header<br />
<h1>My Links</h1>
<ul id="links-list"></ul>
</div>
<script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.21.1/firebase-database.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<div class="content">This is my Content <br />
<h1>My Posts</h1>
<table>
<thead>
<tr>
<th>Title</th>
<th>Author</th>
<th>Content</th>
<th>Date</th>
<th>Category</th>
</tr>
</thead>
<tbody id="post-table-body"></tbody>
</table>
</div>
<script>
// Initialize Firebase
var firebaseConfig = {
apiKey: "AIzaSyBB00grLIfvhq7EEQV6qiZUZuayP4-GoAg",
authDomain: "blog-25253.firebaseapp.com",
databaseURL: "https://blog-25253-default-rtdb.europe-west1.firebasedatabase.app",
projectId: "blog-25253",
storageBucket: "blog-25253.appspot.com",
messagingSenderId: "906101390805",
appId: "1:906101390805:web:871c51f2486921f443115c",
measurementId: "G-MY3P2TWN4L"
};
firebase.initializeApp(firebaseConfig);
// Reference to the links in the Firebase Database
var linksRef = firebase.database().ref("links");
// Read the links from the Firebase Database
linksRef.on("value", function(snapshot) {
// Get the links data
var links = snapshot.val();
// Loop through the links and add them to the list
$.each(links, function(key, link) {
$("#links-list").append("<li><a href='" + link.url + "'>" + key + "</a></li>");
});
});
// Reference to the posts in the Firebase Database
var postsRef = firebase.database().ref("posts");
// Read the posts from the Firebase Database
postsRef.on("value", function(snapshot) {
// Get the posts data
var posts = snapshot.val();
// Loop through the posts and add them to the table
var tableBody = document.getElementById("post-table-body");
for (var postId in posts) {
if (posts.hasOwnProperty(postId)) {
var post = posts[postId];
var row = tableBody.insertRow(-1);
var titleCell = row.insertCell(0);
var authorCell = row.insertCell(1);
var contentCell = row.insertCell(2);
var dateCell = row.insertCell(3);
var categoryCell = row.insertCell(4);
titleCell.innerText = post.postTitle;
authorCell.innerText = post.postAuthor;
contentCell.innerText = post.postContent;
dateCell.innerText = post.postDate;
categoryCell.innerText = post.categories.category1;
}
}
});
</script>
</div>
</body>
</html>