-
Notifications
You must be signed in to change notification settings - Fork 0
/
post2.html
235 lines (206 loc) · 7.22 KB
/
post2.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Thoughts on thing</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
:root {
--neon-green: #0f0;
}
body {
margin: 0;
padding: 0;
font-family: 'Orbitron', sans-serif;
background-color: #000;
color: var(--neon-green);
line-height: 1.6;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
header {
background: #000;
padding: 20px;
text-align: center;
border-bottom: 2px solid var(--neon-green);
}
header h1 {
margin: 0;
font-size: 2.5rem;
color: var(--neon-green);
}
.post-meta {
margin-bottom: 20px;
color: var(--neon-green);
}
.post-content {
margin-bottom: 40px;
padding: 20px;
border: 1px solid var(--neon-green);
border-radius: 5px;
}
.post-navigation {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.post-navigation a {
color: var(--neon-green);
text-decoration: none;
}
.post-navigation a:hover {
text-decoration: underline;
}
.like-button button {
padding: 5px 10px;
font-family: 'Orbitron', sans-serif;
background-color: #000;
color: var(--neon-green);
border: 1px solid var(--neon-green);
cursor: pointer;
}
.like-button button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.comments-section h3 {
color: var(--neon-green);
}
.comment {
border: 1px solid var(--neon-green);
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
}
.comment-form textarea,
.reply-form textarea {
width: 100%;
height: 100px;
margin-top: 10px;
margin-bottom: 10px;
padding: 10px;
font-family: 'Orbitron', sans-serif;
background-color: #000;
color: var(--neon-green);
border: 1px solid var(--neon-green);
}
.comment-form button,
.reply-form button,
.reply-button {
padding: 5px 10px;
font-family: 'Orbitron', sans-serif;
background-color: #000;
color: var(--neon-green);
border: 1px solid var(--neon-green);
cursor: pointer;
}
.replies {
margin-left: 20px;
border-left: 1px solid var(--neon-green);
padding-left: 10px;
}
</style>
</head>
<body>
<div class="container">
<article>
<header>
<h1>Thoughts on thing</h1>
</header>
<div class="post-meta">
<p>Posted on 2021-01-01 | By: Author</p>
</div>
<div class="post-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam scelerisque leo nec magna varius, a tincidunt nulla facilisis. Phasellus vehicula justo eget diam posuere sollicitudin eu tincidunt nulla. Integer vitae justo nec mi facilisis fermentum.</p>
</div>
<div class="post-navigation">
<a href="Blog_User.html">Back to Blog</a>
<a href="post3.html">Previous Post</a>
<a href="post1.html">Next Post</a>
</div>
<div class="like-button">
<button onclick="likePost()" id="likeButton">Like</button> <span id="like-count">0</span> Likes
</div>
<div class="comments-section">
<h3>Comments</h3>
<div id="comments">
<!-- Comments will be dynamically added here -->
</div>
<div class="comment-form">
<label for="comment-input"></label><textarea id="comment-input" placeholder="Add a comment..."></textarea>
<button onclick="addComment()">Post Comment</button>
</div>
</div>
</article>
</div>
<script>
// The JavaScript remains the same as in the original code
let likeCount = 0;
let hasLiked = false;
function likePost() {
if (!hasLiked) {
likeCount++;
document.getElementById('like-count').innerText = likeCount;
hasLiked = true;
document.getElementById('likeButton').disabled = true;
}
}
function addComment() {
const commentInput = document.getElementById('comment-input');
const commentText = commentInput.value.trim();
if (commentText !== "") {
const commentDiv = createCommentElement(commentText);
document.getElementById('comments').appendChild(commentDiv);
commentInput.value = "";
}
}
function createCommentElement(text, isReply = false) {
const commentDiv = document.createElement('div');
commentDiv.classList.add('comment');
if (isReply) commentDiv.classList.add('reply');
const commentText = document.createElement('p');
commentText.textContent = text;
commentDiv.appendChild(commentText);
if (!isReply) {
const replyButton = document.createElement('button');
replyButton.textContent = 'Reply';
replyButton.classList.add('reply-button');
replyButton.onclick = function() {
const replyForm = createReplyForm(commentDiv);
commentDiv.appendChild(replyForm);
replyButton.style.display = 'none';
};
commentDiv.appendChild(replyButton);
}
const repliesDiv = document.createElement('div');
repliesDiv.classList.add('replies');
commentDiv.appendChild(repliesDiv);
return commentDiv;
}
function createReplyForm(parentComment) {
const replyForm = document.createElement('div');
replyForm.classList.add('reply-form');
const replyInput = document.createElement('textarea');
replyInput.placeholder = 'Write a reply...';
replyForm.appendChild(replyInput);
const replyButton = document.createElement('button');
replyButton.textContent = 'Post Reply';
replyButton.onclick = function() {
const replyText = replyInput.value.trim();
if (replyText !== "") {
const replyElement = createCommentElement(replyText, true);
parentComment.querySelector('.replies').appendChild(replyElement);
replyForm.remove();
parentComment.querySelector('.reply-button').style.display = 'inline-block';
}
};
replyForm.appendChild(replyButton);
return replyForm;
}
</script>
</body>
</html>