-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
46 lines (33 loc) · 1.33 KB
/
scripts.js
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
let scheduledPosts = [];
document.addEventListener('DOMContentLoaded', function() {
displayScheduledPosts();
});
const postForm = document.getElementById('post-form');
postForm.addEventListener('submit', function(event) {
event.preventDefault();
const postContent = document.getElementById('post-content').value;
const postTime = document.getElementById('post-time').value;
const newPost = {
content: postContent,
time: postTime
};
scheduledPosts.push(newPost);
document.getElementById('post-content').value = '';
document.getElementById('post-time').value = '';
displayScheduledPosts();
});
function displayScheduledPosts() {
const scheduledPostsContainer = document.getElementById('scheduled-posts');
scheduledPostsContainer.innerHTML = '';
scheduledPosts.forEach((post, index) => {
const card = document.createElement('div');
card.classList.add('scheduled-post');
const content = document.createElement('p');
content.textContent = `content: ${post.content}`;
card.appendChild(content);
const time = document.createElement('p');
time.textContent = `scheduled time: ${post.time}`;
card.appendChild(time);
scheduledPostsContainer.appendChild(card);
});
}