Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +722 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: hackernews
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,722 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Hacker News Clone</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.story:hover .story-title {
|
| 11 |
+
color: #ff6600;
|
| 12 |
+
}
|
| 13 |
+
.upvote:hover {
|
| 14 |
+
color: #ff6600;
|
| 15 |
+
transform: scale(1.2);
|
| 16 |
+
}
|
| 17 |
+
.comment-count:hover, .comment-link:hover {
|
| 18 |
+
color: #ff6600;
|
| 19 |
+
}
|
| 20 |
+
.fade-in {
|
| 21 |
+
animation: fadeIn 0.3s ease-in;
|
| 22 |
+
}
|
| 23 |
+
.slide-in {
|
| 24 |
+
animation: slideIn 0.3s ease-out;
|
| 25 |
+
}
|
| 26 |
+
@keyframes fadeIn {
|
| 27 |
+
from { opacity: 0; }
|
| 28 |
+
to { opacity: 1; }
|
| 29 |
+
}
|
| 30 |
+
@keyframes slideIn {
|
| 31 |
+
from { transform: translateX(20px); opacity: 0; }
|
| 32 |
+
to { transform: translateX(0); opacity: 1; }
|
| 33 |
+
}
|
| 34 |
+
.loading-spinner {
|
| 35 |
+
border: 3px solid rgba(255, 102, 0, 0.3);
|
| 36 |
+
border-radius: 50%;
|
| 37 |
+
border-top: 3px solid #ff6600;
|
| 38 |
+
width: 20px;
|
| 39 |
+
height: 20px;
|
| 40 |
+
animation: spin 1s linear infinite;
|
| 41 |
+
}
|
| 42 |
+
@keyframes spin {
|
| 43 |
+
0% { transform: rotate(0deg); }
|
| 44 |
+
100% { transform: rotate(360deg); }
|
| 45 |
+
}
|
| 46 |
+
.comment {
|
| 47 |
+
position: relative;
|
| 48 |
+
}
|
| 49 |
+
.comment::before {
|
| 50 |
+
content: '';
|
| 51 |
+
position: absolute;
|
| 52 |
+
left: -15px;
|
| 53 |
+
top: 0;
|
| 54 |
+
bottom: 0;
|
| 55 |
+
width: 2px;
|
| 56 |
+
background-color: #e5e7eb;
|
| 57 |
+
}
|
| 58 |
+
.comment:hover::before {
|
| 59 |
+
background-color: #ff6600;
|
| 60 |
+
}
|
| 61 |
+
.comment-content {
|
| 62 |
+
position: relative;
|
| 63 |
+
}
|
| 64 |
+
.comment-content::after {
|
| 65 |
+
content: '';
|
| 66 |
+
position: absolute;
|
| 67 |
+
left: -15px;
|
| 68 |
+
top: 20px;
|
| 69 |
+
width: 15px;
|
| 70 |
+
height: 2px;
|
| 71 |
+
background-color: #e5e7eb;
|
| 72 |
+
}
|
| 73 |
+
.comment:hover .comment-content::after {
|
| 74 |
+
background-color: #ff6600;
|
| 75 |
+
}
|
| 76 |
+
.highlight-new {
|
| 77 |
+
animation: highlight 2s ease-out;
|
| 78 |
+
}
|
| 79 |
+
@keyframes highlight {
|
| 80 |
+
0% { background-color: rgba(255, 102, 0, 0.1); }
|
| 81 |
+
100% { background-color: transparent; }
|
| 82 |
+
}
|
| 83 |
+
</style>
|
| 84 |
+
</head>
|
| 85 |
+
<body class="bg-gray-100 font-sans">
|
| 86 |
+
<header class="bg-orange-600 py-2 px-4 shadow-md">
|
| 87 |
+
<div class="max-w-5xl mx-auto flex items-center">
|
| 88 |
+
<div class="flex items-center">
|
| 89 |
+
<div class="mr-2">
|
| 90 |
+
<i class="fas fa-newspaper text-white text-xl"></i>
|
| 91 |
+
</div>
|
| 92 |
+
<h1 class="text-white font-bold text-xl mr-4">Hacker News</h1>
|
| 93 |
+
</div>
|
| 94 |
+
<nav class="flex space-x-4 text-sm">
|
| 95 |
+
<a href="#" class="text-white hover:underline">new</a>
|
| 96 |
+
<a href="#" class="text-white hover:underline">past</a>
|
| 97 |
+
<a href="#" class="text-white hover:underline">comments</a>
|
| 98 |
+
<a href="#" class="text-white hover:underline">ask</a>
|
| 99 |
+
<a href="#" class="text-white hover:underline">show</a>
|
| 100 |
+
<a href="#" class="text-white hover:underline">jobs</a>
|
| 101 |
+
<a href="#" class="text-white hover:underline">submit</a>
|
| 102 |
+
</nav>
|
| 103 |
+
<div class="ml-auto">
|
| 104 |
+
<a href="#" class="text-white text-sm hover:underline">login</a>
|
| 105 |
+
</div>
|
| 106 |
+
</div>
|
| 107 |
+
</header>
|
| 108 |
+
|
| 109 |
+
<main class="max-w-5xl mx-auto bg-white shadow-sm mt-4 rounded-md overflow-hidden">
|
| 110 |
+
<div id="news-view" class="">
|
| 111 |
+
<div class="p-4 border-b border-gray-200">
|
| 112 |
+
<div class="flex items-center">
|
| 113 |
+
<h2 class="font-semibold text-gray-800">Top Stories</h2>
|
| 114 |
+
<div class="ml-4 flex space-x-2">
|
| 115 |
+
<button id="refresh-btn" class="px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded text-sm flex items-center">
|
| 116 |
+
<i class="fas fa-sync-alt mr-1 text-gray-600"></i> Refresh
|
| 117 |
+
</button>
|
| 118 |
+
<div class="relative">
|
| 119 |
+
<select id="filter-select" class="appearance-none px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded text-sm pr-8">
|
| 120 |
+
<option value="top">Top</option>
|
| 121 |
+
<option value="new">New</option>
|
| 122 |
+
<option value="best">Best</option>
|
| 123 |
+
<option value="ask">Ask HN</option>
|
| 124 |
+
<option value="show">Show HN</option>
|
| 125 |
+
<option value="jobs">Jobs</option>
|
| 126 |
+
</select>
|
| 127 |
+
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
|
| 128 |
+
<i class="fas fa-chevron-down text-xs"></i>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
<div id="stories-container" class="divide-y divide-gray-100">
|
| 136 |
+
<!-- Stories will be loaded here -->
|
| 137 |
+
<div class="p-4 flex items-center justify-center">
|
| 138 |
+
<div class="loading-spinner"></div>
|
| 139 |
+
</div>
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<div class="p-4 border-t border-gray-200 text-center">
|
| 143 |
+
<button id="load-more" class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded text-sm font-medium">
|
| 144 |
+
Load More
|
| 145 |
+
</button>
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
|
| 149 |
+
<div id="comments-view" class="hidden">
|
| 150 |
+
<div class="p-4 border-b border-gray-200 flex items-center">
|
| 151 |
+
<button id="back-btn" class="mr-4 text-gray-600 hover:text-orange-600">
|
| 152 |
+
<i class="fas fa-arrow-left"></i>
|
| 153 |
+
</button>
|
| 154 |
+
<h2 class="font-semibold text-gray-800">Comments</h2>
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<div id="story-header" class="p-4 border-b border-gray-200 bg-gray-50">
|
| 158 |
+
<!-- Story details will be loaded here -->
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
<div id="comments-container" class="divide-y divide-gray-100">
|
| 162 |
+
<!-- Comments will be loaded here -->
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<div class="p-4 border-t border-gray-200">
|
| 166 |
+
<div class="flex items-start mb-4">
|
| 167 |
+
<div class="mr-3 mt-1">
|
| 168 |
+
<div class="w-8 h-8 rounded-full bg-gray-300 flex items-center justify-center">
|
| 169 |
+
<i class="fas fa-user text-gray-500"></i>
|
| 170 |
+
</div>
|
| 171 |
+
</div>
|
| 172 |
+
<div class="flex-1">
|
| 173 |
+
<textarea id="comment-input" class="w-full border border-gray-300 rounded p-2 text-sm" rows="3" placeholder="Add your comment..."></textarea>
|
| 174 |
+
<div class="mt-2 flex justify-end">
|
| 175 |
+
<button id="submit-comment" class="px-4 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded text-sm">
|
| 176 |
+
Submit
|
| 177 |
+
</button>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
</main>
|
| 184 |
+
|
| 185 |
+
<footer class="max-w-5xl mx-auto mt-4 py-4 border-t border-gray-200 text-center text-xs text-gray-500">
|
| 186 |
+
<div class="mb-2">
|
| 187 |
+
<a href="#" class="hover:underline">Guidelines</a> |
|
| 188 |
+
<a href="#" class="hover:underline">FAQ</a> |
|
| 189 |
+
<a href="#" class="hover:underline">Lists</a> |
|
| 190 |
+
<a href="#" class="hover:underline">API</a> |
|
| 191 |
+
<a href="#" class="hover:underline">Security</a> |
|
| 192 |
+
<a href="#" class="hover:underline">Legal</a> |
|
| 193 |
+
<a href="#" class="hover:underline">Apply to YC</a> |
|
| 194 |
+
<a href="#" class="hover:underline">Contact</a>
|
| 195 |
+
</div>
|
| 196 |
+
<div>
|
| 197 |
+
<form class="inline-flex items-center">
|
| 198 |
+
<label for="search" class="mr-2">Search:</label>
|
| 199 |
+
<input type="text" id="search" class="border border-gray-300 px-2 py-1 rounded text-xs w-64">
|
| 200 |
+
<button type="submit" class="ml-2 px-2 py-1 bg-gray-200 hover:bg-gray-300 rounded text-xs">
|
| 201 |
+
<i class="fas fa-search"></i>
|
| 202 |
+
</button>
|
| 203 |
+
</form>
|
| 204 |
+
</div>
|
| 205 |
+
</footer>
|
| 206 |
+
|
| 207 |
+
<script>
|
| 208 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 209 |
+
let currentPage = 1;
|
| 210 |
+
let currentFilter = 'top';
|
| 211 |
+
let isLoading = false;
|
| 212 |
+
let currentStoryId = null;
|
| 213 |
+
const storiesContainer = document.getElementById('stories-container');
|
| 214 |
+
const loadMoreBtn = document.getElementById('load-more');
|
| 215 |
+
const refreshBtn = document.getElementById('refresh-btn');
|
| 216 |
+
const filterSelect = document.getElementById('filter-select');
|
| 217 |
+
const newsView = document.getElementById('news-view');
|
| 218 |
+
const commentsView = document.getElementById('comments-view');
|
| 219 |
+
const backBtn = document.getElementById('back-btn');
|
| 220 |
+
const storyHeader = document.getElementById('story-header');
|
| 221 |
+
const commentsContainer = document.getElementById('comments-container');
|
| 222 |
+
const commentInput = document.getElementById('comment-input');
|
| 223 |
+
const submitComment = document.getElementById('submit-comment');
|
| 224 |
+
|
| 225 |
+
// Mock data for stories
|
| 226 |
+
const mockStories = [
|
| 227 |
+
{
|
| 228 |
+
id: 1,
|
| 229 |
+
title: 'Rust 1.70.0 Released',
|
| 230 |
+
url: 'https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html',
|
| 231 |
+
score: 287,
|
| 232 |
+
by: 'steveklabnik',
|
| 233 |
+
time: Date.now() - 3600000 * 3,
|
| 234 |
+
descendants: 54,
|
| 235 |
+
text: 'The Rust team is happy to announce a new version of Rust, 1.70.0. Rust is a programming language empowering everyone to build reliable and efficient software.'
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
id: 2,
|
| 239 |
+
title: 'The future of TypeScript is JavaScript',
|
| 240 |
+
url: 'https://dev.to/this-is-learning/the-future-of-typescript-is-javascript-2o5e',
|
| 241 |
+
score: 156,
|
| 242 |
+
by: 'tldrews',
|
| 243 |
+
time: Date.now() - 3600000 * 5,
|
| 244 |
+
descendants: 42,
|
| 245 |
+
text: 'With the new features coming to JavaScript, TypeScript might become less necessary in the future. Here are my thoughts on why.'
|
| 246 |
+
},
|
| 247 |
+
{
|
| 248 |
+
id: 3,
|
| 249 |
+
title: 'Show HN: I built a tool that helps you find remote jobs',
|
| 250 |
+
url: 'https://remotejobs.com',
|
| 251 |
+
score: 98,
|
| 252 |
+
by: 'remoteworker',
|
| 253 |
+
time: Date.now() - 3600000 * 7,
|
| 254 |
+
descendants: 23,
|
| 255 |
+
text: 'After struggling to find good remote jobs myself, I built this tool to aggregate the best remote job listings from across the web. Would love your feedback!'
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
id: 4,
|
| 259 |
+
title: 'Ask HN: What books changed the way you think about programming?',
|
| 260 |
+
url: '',
|
| 261 |
+
score: 210,
|
| 262 |
+
by: 'bookworm',
|
| 263 |
+
time: Date.now() - 3600000 * 9,
|
| 264 |
+
descendants: 187,
|
| 265 |
+
text: 'I\'m looking to expand my programming knowledge and would love to hear about books that had a significant impact on how you think about software development.'
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
id: 5,
|
| 269 |
+
title: 'The hidden cost of technical debt',
|
| 270 |
+
url: 'https://medium.com/tech-debt/the-hidden-cost-of-technical-debt-3895e59a9d5e',
|
| 271 |
+
score: 176,
|
| 272 |
+
by: 'debtfree',
|
| 273 |
+
time: Date.now() - 3600000 * 12,
|
| 274 |
+
descendants: 63,
|
| 275 |
+
text: 'Technical debt is often discussed, but the hidden costs are rarely quantified. This article explores the real impact of accumulated tech debt on productivity and morale.'
|
| 276 |
+
}
|
| 277 |
+
];
|
| 278 |
+
|
| 279 |
+
// Mock data for comments
|
| 280 |
+
const mockComments = {
|
| 281 |
+
1: [
|
| 282 |
+
{
|
| 283 |
+
id: 101,
|
| 284 |
+
by: 'rustfan',
|
| 285 |
+
time: Date.now() - 3600000 * 2,
|
| 286 |
+
text: 'This is a great release! The performance improvements are significant.',
|
| 287 |
+
score: 45,
|
| 288 |
+
kids: [
|
| 289 |
+
{
|
| 290 |
+
id: 1011,
|
| 291 |
+
by: 'rustnewbie',
|
| 292 |
+
time: Date.now() - 3600000 * 1,
|
| 293 |
+
text: 'I agree! The new error messages are much clearer.',
|
| 294 |
+
score: 12,
|
| 295 |
+
kids: []
|
| 296 |
+
}
|
| 297 |
+
]
|
| 298 |
+
},
|
| 299 |
+
{
|
| 300 |
+
id: 102,
|
| 301 |
+
by: 'programmer123',
|
| 302 |
+
time: Date.now() - 3600000 * 2.5,
|
| 303 |
+
text: 'I\'ve been waiting for these features. The async improvements are game-changing.',
|
| 304 |
+
score: 32,
|
| 305 |
+
kids: [
|
| 306 |
+
{
|
| 307 |
+
id: 1021,
|
| 308 |
+
by: 'asyncdev',
|
| 309 |
+
time: Date.now() - 3600000 * 1.5,
|
| 310 |
+
text: 'Yes! Finally we can do X without workarounds.',
|
| 311 |
+
score: 8,
|
| 312 |
+
kids: []
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
id: 1022,
|
| 316 |
+
by: 'perfexpert',
|
| 317 |
+
time: Date.now() - 3600000 * 1,
|
| 318 |
+
text: 'The benchmarks show a 15% improvement in my use case.',
|
| 319 |
+
score: 5,
|
| 320 |
+
kids: []
|
| 321 |
+
}
|
| 322 |
+
]
|
| 323 |
+
}
|
| 324 |
+
],
|
| 325 |
+
2: [
|
| 326 |
+
{
|
| 327 |
+
id: 201,
|
| 328 |
+
by: 'jsdev',
|
| 329 |
+
time: Date.now() - 3600000 * 4,
|
| 330 |
+
text: 'I think TypeScript will still be relevant for large codebases.',
|
| 331 |
+
score: 28,
|
| 332 |
+
kids: [
|
| 333 |
+
{
|
| 334 |
+
id: 2011,
|
| 335 |
+
by: 'tslover',
|
| 336 |
+
time: Date.now() - 3600000 * 3,
|
| 337 |
+
text: 'Exactly! Type safety is crucial for team development.',
|
| 338 |
+
score: 10,
|
| 339 |
+
kids: []
|
| 340 |
+
}
|
| 341 |
+
]
|
| 342 |
+
}
|
| 343 |
+
],
|
| 344 |
+
4: [
|
| 345 |
+
{
|
| 346 |
+
id: 401,
|
| 347 |
+
by: 'classiccoder',
|
| 348 |
+
time: Date.now() - 3600000 * 8,
|
| 349 |
+
text: 'Structure and Interpretation of Computer Programs changed everything for me.',
|
| 350 |
+
score: 56,
|
| 351 |
+
kids: [
|
| 352 |
+
{
|
| 353 |
+
id: 4011,
|
| 354 |
+
by: 'lisper',
|
| 355 |
+
time: Date.now() - 3600000 * 7,
|
| 356 |
+
text: 'Same here! It teaches you to think differently about problems.',
|
| 357 |
+
score: 22,
|
| 358 |
+
kids: []
|
| 359 |
+
}
|
| 360 |
+
]
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
id: 402,
|
| 364 |
+
by: 'pragmatic',
|
| 365 |
+
time: Date.now() - 3600000 * 7.5,
|
| 366 |
+
text: 'Clean Code by Robert Martin is a must-read for any professional developer.',
|
| 367 |
+
score: 42,
|
| 368 |
+
kids: []
|
| 369 |
+
}
|
| 370 |
+
]
|
| 371 |
+
};
|
| 372 |
+
|
| 373 |
+
// Format time as "X hours ago"
|
| 374 |
+
function formatTime(timestamp) {
|
| 375 |
+
const seconds = Math.floor((Date.now() - timestamp) / 1000);
|
| 376 |
+
|
| 377 |
+
let interval = Math.floor(seconds / 31536000);
|
| 378 |
+
if (interval >= 1) return `${interval} year${interval === 1 ? '' : 's'} ago`;
|
| 379 |
+
|
| 380 |
+
interval = Math.floor(seconds / 2592000);
|
| 381 |
+
if (interval >= 1) return `${interval} month${interval === 1 ? '' : 's'} ago`;
|
| 382 |
+
|
| 383 |
+
interval = Math.floor(seconds / 86400);
|
| 384 |
+
if (interval >= 1) return `${interval} day${interval === 1 ? '' : 's'} ago`;
|
| 385 |
+
|
| 386 |
+
interval = Math.floor(seconds / 3600);
|
| 387 |
+
if (interval >= 1) return `${interval} hour${interval === 1 ? '' : 's'} ago`;
|
| 388 |
+
|
| 389 |
+
interval = Math.floor(seconds / 60);
|
| 390 |
+
if (interval >= 1) return `${interval} minute${interval === 1 ? '' : 's'} ago`;
|
| 391 |
+
|
| 392 |
+
return `${Math.floor(seconds)} second${seconds === 1 ? '' : 's'} ago`;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
// Get domain from URL
|
| 396 |
+
function getDomain(url) {
|
| 397 |
+
if (!url) return '';
|
| 398 |
+
try {
|
| 399 |
+
const domain = new URL(url).hostname.replace('www.', '');
|
| 400 |
+
return domain;
|
| 401 |
+
} catch {
|
| 402 |
+
return '';
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
// Render stories
|
| 407 |
+
function renderStories(stories) {
|
| 408 |
+
storiesContainer.innerHTML = '';
|
| 409 |
+
|
| 410 |
+
stories.forEach(story => {
|
| 411 |
+
const storyElement = document.createElement('div');
|
| 412 |
+
storyElement.className = 'story p-4 hover:bg-gray-50 transition-colors duration-150 fade-in';
|
| 413 |
+
storyElement.innerHTML = `
|
| 414 |
+
<div class="flex items-start">
|
| 415 |
+
<div class="text-gray-500 text-xs mr-2 mt-1 flex flex-col items-center">
|
| 416 |
+
<button class="upvote text-gray-400 hover:text-orange-600 transition-all duration-200">
|
| 417 |
+
<i class="fas fa-caret-up"></i>
|
| 418 |
+
</button>
|
| 419 |
+
<span class="text-gray-700 font-medium">${story.score}</span>
|
| 420 |
+
</div>
|
| 421 |
+
<div class="flex-1">
|
| 422 |
+
<div class="flex items-baseline flex-wrap">
|
| 423 |
+
<a href="${story.url || `#item?id=${story.id}`}" target="_blank" class="story-title text-base font-medium text-gray-900 hover:text-orange-600 mr-1">${story.title}</a>
|
| 424 |
+
${story.url ? `<span class="text-xs text-gray-500">(${getDomain(story.url)})</span>` : ''}
|
| 425 |
+
</div>
|
| 426 |
+
<div class="mt-1 text-xs text-gray-500">
|
| 427 |
+
by <a href="#" class="hover:underline">${story.by}</a> ${formatTime(story.time)} |
|
| 428 |
+
<a href="#" class="comment-link hover:underline ml-1" data-story-id="${story.id}">${story.descendants} comment${story.descendants !== 1 ? 's' : ''}</a>
|
| 429 |
+
</div>
|
| 430 |
+
</div>
|
| 431 |
+
</div>
|
| 432 |
+
`;
|
| 433 |
+
storiesContainer.appendChild(storyElement);
|
| 434 |
+
});
|
| 435 |
+
|
| 436 |
+
// Add click handlers to comment links
|
| 437 |
+
document.querySelectorAll('.comment-link').forEach(link => {
|
| 438 |
+
link.addEventListener('click', function(e) {
|
| 439 |
+
e.preventDefault();
|
| 440 |
+
showComments(parseInt(this.getAttribute('data-story-id')));
|
| 441 |
+
});
|
| 442 |
+
});
|
| 443 |
+
|
| 444 |
+
// Add click handlers to upvote buttons
|
| 445 |
+
document.querySelectorAll('.upvote').forEach(btn => {
|
| 446 |
+
btn.addEventListener('click', function() {
|
| 447 |
+
const scoreElement = this.nextElementSibling;
|
| 448 |
+
if (!this.classList.contains('text-orange-600')) {
|
| 449 |
+
this.classList.add('text-orange-600');
|
| 450 |
+
scoreElement.textContent = parseInt(scoreElement.textContent) + 1;
|
| 451 |
+
} else {
|
| 452 |
+
this.classList.remove('text-orange-600');
|
| 453 |
+
scoreElement.textContent = parseInt(scoreElement.textContent) - 1;
|
| 454 |
+
}
|
| 455 |
+
});
|
| 456 |
+
});
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
// Render comments recursively
|
| 460 |
+
function renderComments(comments, level = 0) {
|
| 461 |
+
let html = '';
|
| 462 |
+
|
| 463 |
+
comments.forEach(comment => {
|
| 464 |
+
html += `
|
| 465 |
+
<div class="comment pl-${level > 0 ? level * 4 : 4} py-3 fade-in highlight-new" data-comment-id="${comment.id}">
|
| 466 |
+
<div class="comment-content pl-2">
|
| 467 |
+
<div class="text-xs text-gray-500 mb-1">
|
| 468 |
+
<button class="upvote text-gray-400 hover:text-orange-600 transition-all duration-200 mr-1">
|
| 469 |
+
<i class="fas fa-caret-up"></i>
|
| 470 |
+
</button>
|
| 471 |
+
<a href="#" class="hover:underline font-medium">${comment.by}</a> ${formatTime(comment.time)} |
|
| 472 |
+
<span class="text-gray-700">${comment.score} point${comment.score !== 1 ? 's' : ''}</span>
|
| 473 |
+
</div>
|
| 474 |
+
<div class="text-sm text-gray-800 mb-2">
|
| 475 |
+
${comment.text}
|
| 476 |
+
</div>
|
| 477 |
+
<div class="text-xs">
|
| 478 |
+
<a href="#" class="text-gray-500 hover:underline reply-link" data-comment-id="${comment.id}">reply</a>
|
| 479 |
+
</div>
|
| 480 |
+
</div>
|
| 481 |
+
</div>
|
| 482 |
+
`;
|
| 483 |
+
|
| 484 |
+
if (comment.kids && comment.kids.length > 0) {
|
| 485 |
+
html += renderComments(comment.kids, level + 1);
|
| 486 |
+
}
|
| 487 |
+
});
|
| 488 |
+
|
| 489 |
+
return html;
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
// Show comments for a story
|
| 493 |
+
function showComments(storyId) {
|
| 494 |
+
currentStoryId = storyId;
|
| 495 |
+
newsView.classList.add('hidden');
|
| 496 |
+
commentsView.classList.remove('hidden');
|
| 497 |
+
|
| 498 |
+
// Find the story
|
| 499 |
+
const story = mockStories.find(s => s.id === storyId);
|
| 500 |
+
if (!story) return;
|
| 501 |
+
|
| 502 |
+
// Render story header
|
| 503 |
+
storyHeader.innerHTML = `
|
| 504 |
+
<div class="flex items-start">
|
| 505 |
+
<div class="text-gray-500 text-xs mr-2 mt-1 flex flex-col items-center">
|
| 506 |
+
<button class="upvote text-gray-400 hover:text-orange-600 transition-all duration-200">
|
| 507 |
+
<i class="fas fa-caret-up"></i>
|
| 508 |
+
</button>
|
| 509 |
+
<span class="text-gray-700 font-medium">${story.score}</span>
|
| 510 |
+
</div>
|
| 511 |
+
<div class="flex-1">
|
| 512 |
+
<div class="flex items-baseline flex-wrap">
|
| 513 |
+
<a href="${story.url || `#item?id=${story.id}`}" target="_blank" class="text-base font-medium text-gray-900 hover:text-orange-600 mr-1">${story.title}</a>
|
| 514 |
+
${story.url ? `<span class="text-xs text-gray-500">(${getDomain(story.url)})</span>` : ''}
|
| 515 |
+
</div>
|
| 516 |
+
<div class="mt-1 text-xs text-gray-500">
|
| 517 |
+
by <a href="#" class="hover:underline">${story.by}</a> ${formatTime(story.time)}
|
| 518 |
+
</div>
|
| 519 |
+
${story.text ? `<div class="mt-2 text-sm text-gray-800">${story.text}</div>` : ''}
|
| 520 |
+
</div>
|
| 521 |
+
</div>
|
| 522 |
+
`;
|
| 523 |
+
|
| 524 |
+
// Add upvote handler
|
| 525 |
+
storyHeader.querySelector('.upvote').addEventListener('click', function() {
|
| 526 |
+
const scoreElement = this.nextElementSibling;
|
| 527 |
+
if (!this.classList.contains('text-orange-600')) {
|
| 528 |
+
this.classList.add('text-orange-600');
|
| 529 |
+
scoreElement.textContent = parseInt(scoreElement.textContent) + 1;
|
| 530 |
+
} else {
|
| 531 |
+
this.classList.remove('text-orange-600');
|
| 532 |
+
scoreElement.textContent = parseInt(scoreElement.textContent) - 1;
|
| 533 |
+
}
|
| 534 |
+
});
|
| 535 |
+
|
| 536 |
+
// Load and render comments
|
| 537 |
+
commentsContainer.innerHTML = '<div class="p-4 flex items-center justify-center"><div class="loading-spinner"></div></div>';
|
| 538 |
+
|
| 539 |
+
setTimeout(() => {
|
| 540 |
+
const comments = mockComments[storyId] || [];
|
| 541 |
+
|
| 542 |
+
if (comments.length === 0) {
|
| 543 |
+
commentsContainer.innerHTML = `
|
| 544 |
+
<div class="p-4 text-center text-gray-500">
|
| 545 |
+
No comments yet. Be the first to comment!
|
| 546 |
+
</div>
|
| 547 |
+
`;
|
| 548 |
+
} else {
|
| 549 |
+
commentsContainer.innerHTML = renderComments(comments);
|
| 550 |
+
|
| 551 |
+
// Add upvote handlers
|
| 552 |
+
commentsContainer.querySelectorAll('.upvote').forEach(btn => {
|
| 553 |
+
btn.addEventListener('click', function() {
|
| 554 |
+
const scoreElement = this.nextElementSibling.nextElementSibling;
|
| 555 |
+
if (!this.classList.contains('text-orange-600')) {
|
| 556 |
+
this.classList.add('text-orange-600');
|
| 557 |
+
const currentScore = parseInt(scoreElement.textContent);
|
| 558 |
+
scoreElement.textContent = (currentScore || 0) + 1 + ' point' + ((currentScore + 1) !== 1 ? 's' : '');
|
| 559 |
+
} else {
|
| 560 |
+
this.classList.remove('text-orange-600');
|
| 561 |
+
const currentScore = parseInt(scoreElement.textContent);
|
| 562 |
+
scoreElement.textContent = (currentScore - 1) + ' point' + ((currentScore - 1) !== 1 ? 's' : '');
|
| 563 |
+
}
|
| 564 |
+
});
|
| 565 |
+
});
|
| 566 |
+
|
| 567 |
+
// Add reply handlers
|
| 568 |
+
commentsContainer.querySelectorAll('.reply-link').forEach(link => {
|
| 569 |
+
link.addEventListener('click', function(e) {
|
| 570 |
+
e.preventDefault();
|
| 571 |
+
const commentId = parseInt(this.getAttribute('data-comment-id'));
|
| 572 |
+
commentInput.focus();
|
| 573 |
+
commentInput.placeholder = `Replying to comment #${commentId}...`;
|
| 574 |
+
});
|
| 575 |
+
});
|
| 576 |
+
}
|
| 577 |
+
}, 800);
|
| 578 |
+
}
|
| 579 |
+
|
| 580 |
+
// Simulate loading stories from API
|
| 581 |
+
function loadStories(page = 1, filter = 'top') {
|
| 582 |
+
isLoading = true;
|
| 583 |
+
|
| 584 |
+
// Show loading spinner
|
| 585 |
+
storiesContainer.innerHTML = `
|
| 586 |
+
<div class="p-4 flex items-center justify-center">
|
| 587 |
+
<div class="loading-spinner"></div>
|
| 588 |
+
</div>
|
| 589 |
+
`;
|
| 590 |
+
|
| 591 |
+
// Simulate API delay
|
| 592 |
+
setTimeout(() => {
|
| 593 |
+
// Filter mock stories based on selection
|
| 594 |
+
let filteredStories = [...mockStories];
|
| 595 |
+
|
| 596 |
+
if (filter === 'new') {
|
| 597 |
+
filteredStories.sort((a, b) => b.time - a.time);
|
| 598 |
+
} else if (filter === 'best') {
|
| 599 |
+
filteredStories.sort((a, b) => b.score - a.score);
|
| 600 |
+
} else if (filter === 'ask') {
|
| 601 |
+
filteredStories = filteredStories.filter(story => story.title.startsWith('Ask HN:'));
|
| 602 |
+
} else if (filter === 'show') {
|
| 603 |
+
filteredStories = filteredStories.filter(story => story.title.startsWith('Show HN:'));
|
| 604 |
+
} else if (filter === 'jobs') {
|
| 605 |
+
filteredStories = filteredStories.filter(story => story.title.includes('hiring') || story.title.includes('job'));
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
// Pagination simulation
|
| 609 |
+
const startIdx = (page - 1) * 5;
|
| 610 |
+
const endIdx = startIdx + 5;
|
| 611 |
+
const paginatedStories = filteredStories.slice(0, endIdx);
|
| 612 |
+
|
| 613 |
+
renderStories(paginatedStories);
|
| 614 |
+
isLoading = false;
|
| 615 |
+
|
| 616 |
+
// Show/hide load more button
|
| 617 |
+
if (endIdx >= filteredStories.length) {
|
| 618 |
+
loadMoreBtn.style.display = 'none';
|
| 619 |
+
} else {
|
| 620 |
+
loadMoreBtn.style.display = 'inline-block';
|
| 621 |
+
}
|
| 622 |
+
}, 800);
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
// Back to news view
|
| 626 |
+
backBtn.addEventListener('click', function() {
|
| 627 |
+
commentsView.classList.add('hidden');
|
| 628 |
+
newsView.classList.remove('hidden');
|
| 629 |
+
commentInput.value = '';
|
| 630 |
+
commentInput.placeholder = 'Add your comment...';
|
| 631 |
+
});
|
| 632 |
+
|
| 633 |
+
// Submit comment
|
| 634 |
+
submitComment.addEventListener('click', function() {
|
| 635 |
+
const commentText = commentInput.value.trim();
|
| 636 |
+
if (!commentText) return;
|
| 637 |
+
|
| 638 |
+
// Create new comment
|
| 639 |
+
const newComment = {
|
| 640 |
+
id: Math.floor(Math.random() * 10000),
|
| 641 |
+
by: 'currentuser',
|
| 642 |
+
time: Date.now(),
|
| 643 |
+
text: commentText,
|
| 644 |
+
score: 1,
|
| 645 |
+
kids: []
|
| 646 |
+
};
|
| 647 |
+
|
| 648 |
+
// In a real app, you would send this to your backend
|
| 649 |
+
if (!mockComments[currentStoryId]) {
|
| 650 |
+
mockComments[currentStoryId] = [];
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
mockComments[currentStoryId].unshift(newComment);
|
| 654 |
+
|
| 655 |
+
// Update the story's comment count
|
| 656 |
+
const story = mockStories.find(s => s.id === currentStoryId);
|
| 657 |
+
if (story) {
|
| 658 |
+
story.descendants += 1;
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
// Clear input
|
| 662 |
+
commentInput.value = '';
|
| 663 |
+
|
| 664 |
+
// Re-render comments
|
| 665 |
+
showComments(currentStoryId);
|
| 666 |
+
|
| 667 |
+
// Scroll to new comment
|
| 668 |
+
setTimeout(() => {
|
| 669 |
+
const newCommentElement = document.querySelector(`[data-comment-id="${newComment.id}"]`);
|
| 670 |
+
if (newCommentElement) {
|
| 671 |
+
newCommentElement.scrollIntoView({ behavior: 'smooth' });
|
| 672 |
+
}
|
| 673 |
+
}, 100);
|
| 674 |
+
});
|
| 675 |
+
|
| 676 |
+
// Initial load
|
| 677 |
+
loadStories(currentPage, currentFilter);
|
| 678 |
+
|
| 679 |
+
// Load more stories
|
| 680 |
+
loadMoreBtn.addEventListener('click', function() {
|
| 681 |
+
if (isLoading) return;
|
| 682 |
+
currentPage++;
|
| 683 |
+
loadStories(currentPage, currentFilter);
|
| 684 |
+
});
|
| 685 |
+
|
| 686 |
+
// Refresh stories
|
| 687 |
+
refreshBtn.addEventListener('click', function() {
|
| 688 |
+
if (isLoading) return;
|
| 689 |
+
currentPage = 1;
|
| 690 |
+
loadStories(currentPage, currentFilter);
|
| 691 |
+
|
| 692 |
+
// Add rotation animation to refresh button
|
| 693 |
+
refreshBtn.querySelector('i').classList.add('fa-spin');
|
| 694 |
+
setTimeout(() => {
|
| 695 |
+
refreshBtn.querySelector('i').classList.remove('fa-spin');
|
| 696 |
+
}, 800);
|
| 697 |
+
});
|
| 698 |
+
|
| 699 |
+
// Filter stories
|
| 700 |
+
filterSelect.addEventListener('change', function() {
|
| 701 |
+
currentFilter = this.value;
|
| 702 |
+
currentPage = 1;
|
| 703 |
+
loadStories(currentPage, currentFilter);
|
| 704 |
+
});
|
| 705 |
+
|
| 706 |
+
// Keyboard shortcuts
|
| 707 |
+
document.addEventListener('keydown', function(e) {
|
| 708 |
+
// Press 'r' to refresh
|
| 709 |
+
if (e.key === 'r' && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
| 710 |
+
e.preventDefault();
|
| 711 |
+
refreshBtn.click();
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
// Press Escape to clear reply
|
| 715 |
+
if (e.key === 'Escape') {
|
| 716 |
+
commentInput.placeholder = 'Add your comment...';
|
| 717 |
+
}
|
| 718 |
+
});
|
| 719 |
+
});
|
| 720 |
+
</script>
|
| 721 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=sexyfrad/hackernews" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
| 722 |
+
</html>
|