-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
853 lines (782 loc) · 27.9 KB
/
index.html
File metadata and controls
853 lines (782 loc) · 27.9 KB
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Swaga - Мемы, Роблокс, Приколы и Юмор | Лучший сайт про Swaga</title>
<meta name="keywords" content="swaga, свага, мемы, swaga мемы, свага мемы, swaga github, свага роблокс, swaga roblox, swaga приколы, swaga юмор, swaga видео, swaga картинки, swaga смешно, swaga 2026, swaga тренды">
<meta name="description" content="Swaga (Свага) - самый смешной сайт с мемами, приколами и юмором. Свежие мемы про Swaga, Swaga в Роблокс, Swaga мемы 2026. Автор сайта - Влад, лучший создатель контента про Swaga!">
<meta property="og:title" content="Swaga (Свага) - Смешные мемы и приколы 2026 | Лучший сайт про Swaga">
<meta property="og:description" content="Самые свежие и смешные мемы про Swaga. Swaga в Роблокс, Swaga мемы, Swaga приколы и многое другое. Заходи за порцией юмора!">
<meta property="og:image" content="images/swaga.png">
<meta property="og:url" content="https://forexample-u.github.io/swaga">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Swaga - Мемы и Приколы">
<meta property="og:locale" content="ru_RU">
<link rel="canonical" href="https://forexample-u.github.io/swaga">
<link rel="icon" href="images/swaga.png" type="image/png" />
<link rel="stylesheet" href="assets/menu.css" />
<style>
body {
margin: 0;
background-color: #0f0f0f;
color: #333;
}
.card {
background: #242424;
border-radius: 12px;
margin-bottom: 20px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
position: relative;
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
.card-header {
padding: 14px 16px;
display: flex;
align-items: center;
gap: 10px;
}
.avatar {
width: 36px;
height: 36px;
border-radius: 50%;
background-color: #e0e0e0;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
user-select: none;
}
.user-info {
flex: 1;
}
.username {
font-weight: 600;
font-size: 0.95rem;
color: #fff;
}
.timestamp {
font-size: 0.8rem;
color: #757575; /*#828282*/
user-select: none;
}
.card-content {
position: relative;
}
.media-container {
width: 100%;
max-height: 1200px;
overflow: hidden;
}
.media-container img,
.media-container video {
width: 100%;
height: auto;
display: block;
max-height: 70vh;
width: 100%;
object-fit: fill;
}
.text-content {
padding: 0px 16px;
margin-top: 8px;
background-color: #242424;
color: #fff;
}
.card-text {
font-size: 0.95rem;
color: #bfbfbf;
white-space: pre-line;
}
.card-actions {
padding: 0px 6px;
margin-bottom: 8px;
display: flex;
background-color: #242424;
}
.card-title {
font-weight: 600;
margin-bottom: 8px;
font-size: 1.1rem;
}
.action-btn {
display: flex;
align-items: center;
gap: 6px;
padding: 8px;
background: none;
border: none;
font-size: 0.95rem;
color: #f8f8f8;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.2s;
user-select: none;
}
.action-btn:hover {
background-color: #d0d0d0;
}
.action-btn.liked {
color: #66b2ff;
}
.action-btn.liked .like-icon {
animation: heartBeat 0.6s;
}
@keyframes heartBeat {
0% {
transform: scale(1);
}
14% {
transform: scale(1.2);
}
28% {
transform: scale(1);
}
42% {
transform: scale(1.2);
}
70% {
transform: scale(1);
}
}
.views-counter {
position: absolute;
top: 12px;
right: 16px;
display: flex;
align-items: center;
gap: 4px;
padding: 4px 8px;
border-radius: 12px;
font-size: 0.8rem;
color: #f8f8f8;
user-select: none;
}
.comment-form {
padding: 16px;
border-top: 1px solid #f0f2f5;
display: flex;
align-items: flex-start;
gap: 12px;
background: #f9f9f9;
border-radius: 0 0 12px 12px;
}
.comment-avatar-comment {
width: 40px;
height: 40px;
border-radius: 50%;
background: #f0f2f5;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 1.2rem;
color: #121212;
user-select: none;
}
.comment-input-container {
flex: 1;
display: flex;
flex-direction: column;
gap: 8px;
}
.username-in-comment {
font-weight: 600;
font-size: 0.9rem;
color: #f0f2f5;
margin-left: 4px;
}
.comment-textarea {
border: 2px solid #ccc;
border-radius: 24px;
padding: 10px 16px;
font-size: 0.9rem;
resize: none;
outline: none;
transition: border-color 0.2s;
background: #222222;
color: #fff;
min-height: 40px;
line-height: 1.4;
}
.comment-textarea:focus {
border-color: #1877f2;
box-shadow: 0 0 4px rgba(24, 119, 242, 0.2);
}
.comment-textarea::placeholder {
color: #aaa;
font-style: italic;
}
.comment-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
padding-top: 4px;
}
.comment-btn {
background: #1877f2;
color: white;
border: none;
border-radius: 24px;
padding: 8px 16px;
font-size: 0.85rem;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
}
.comment-btn:hover {
background: #166fe5;
}
.comment-btn:disabled {
background: #e0e0e0;
color: #999;
cursor: not-allowed;
}
.cancel-btn {
background: none;
color: #1877f2;
border: none;
font-size: 0.85rem;
cursor: pointer;
padding: 8px 16px;
border-radius: 24px;
transition: background 0.2s;
}
.cancel-btn:hover {
background: #f0f2f5;
}
.comments-section {
padding: 0 16px;
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease, padding 0.3s ease;
border-top: none;
}
.comments-section.expanded {
max-height: 50000px;
padding: 12px 16px;
border-top: 1px solid #545454;
}
.comment {
padding: 2px 0;
/*border-bottom: 1px solid #f0f2f5;*/
display: flex;
gap: 12px;
}
.comment:last-child {
border-bottom: none;
}
.comment-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.comment-avatar {
width: 24px;
height: 24px;
border-radius: 50%;
background-color: #e0e0e0;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.7rem;
font-weight: bold;
user-select: none;
}
.comment-username {
font-weight: 600;
font-size: 0.85rem;
color: #fff;
}
.comment-text {
font-size: 0.9rem;
color: #f8f8f8;
flex: 1;
padding-left: 0;
white-space: pre-line;
}
@media (max-width: 767px) {
.media-container img,
.media-container video {
max-height: 70vh;
width: 100%;
object-fit: fill;
}
.comment-form {
flex-direction: column;
padding: 12px;
gap: 8px;
}
.comment-input-container {
width: 100%;
gap: 6px;
}
.comment-actions {
justify-content: flex-end;
}
}
</style>
</head>
<body>
<nav class="sidebar" role="navigation" aria-label="Основное меню сайта">
<div class="logo" onclick="location.reload();" tabindex="0">Swaga</div>
<a href="?tag=" class="active" tabindex="0">
<span class="nav-icon">🏠</span>
<span>Главная</span>
</a>
<a href="?tag=deepweb" tabindex="0">
<span class="nav-icon">💀</span>
<span>Нижний интернет</span>
</a>
<a href="?tag=ai" tabindex="0">
<span class="nav-icon">🤖</span>
<span>Нейро-контент</span>
</a>
<a href="?tag=haha" tabindex="0">
<span class="nav-icon">😈</span>
<span>Хохотач</span>
</a>
</nav>
<main class="content-area">
<header class="header" role="banner">
<div class="header-left">
<div class="menu-toggle" onclick="this.nextElementSibling.classList.toggle('active')">
<span></span>
<span></span>
<span></span>
</div>
<div class="settings-menu">
<a href="./profile.html" class="menu-item">
<span class="menu-item-icon">👤</span>
<span>Профиль</span>
</a>
<a href="https://t.me/+_IvRIMc5cO9kZWQ6" target="_blank" class="menu-item">
<span class="menu-item-icon">🌵</span>
<span>Телеграмм</span>
</a>
<a href="./faq.html" class="menu-item">
<span class="menu-item-icon">📣</span>
<span>FAQ</span>
</a>
<a href="./graphics.html" class="menu-item">
<span class="menu-item-icon">📉</span>
<span>Смотреть на случайный график</span>
</a>
<a href="./allasearch.html" class="menu-item">
<span class="menu-item-icon">📡</span>
<span>Смотреть в скольки метрах от вас Алла Пугачёва</span>
</a>
<a href="#" class="menu-item">
<span class="menu-item-icon">🧩</span>
<span>Пройти качпу</span>
</a>
<a href="http://peer.infinityfreeapp.com/peer/indexx.php" target="_blank" class="menu-item">
<span class="menu-item-icon">📒</span>
<span>Золотая тетрадка смерти для избранных</span>
</a>
<a href="./games/kakasha/index.html" class="menu-item">
<span class="menu-item-icon">👾</span>
<span>Новая игра</span>
</a>
<a href="#" class="menu-item">
<span class="menu-item-icon">🚪</span>
<span>Дверь</span>
</a>
</div>
<a href="./index.html" class="logo-phone">Swaga</a>
</div>
<div class="header-right">
<a href="./upload.html" class="upload-btn">➕ Создать</a>
<a href="./register.html" class="login-btn">Войти</a>
</div>
</header>
<div class="content-container" role="main" tabindex="0" id="maincontent"></div>
</main>
<script src="./assets/content.js"></script>
<script src="./assets/translater.js"></script>
<script>
function getRelativeTime(dateString) {
const pastDate = new Date(dateString);
const now = new Date(new Date().toISOString());
const diffMs = now - pastDate;
const diffSec = Math.floor(diffMs / 1000);
const diffMin = Math.floor(diffSec / 60);
const diffHour = Math.floor(diffMin / 60);
const diffDay = Math.floor(diffHour / 24);
const diffWeek = Math.floor(diffDay / 7);
const diffMonth = Math.floor(diffDay / 30);
const diffYear = Math.floor(diffDay / 365);
if (diffSec < 60 && diffSec >= 0) {
return 'Только что';
} else if (diffMin < 60) {
return `${diffMin} минут назад`;
} else if (diffHour < 5) {
return `${diffHour} часа назад`;
} else if (diffHour < 24) {
return `${diffHour} часов назад`;
} else if (diffDay === 1) {
return `Вчера`;
} else if (diffDay < 5) {
return `${diffDay} дня назад`;
} else if (diffDay < 7) {
return `${diffDay} дней назад`;
} else if (diffDay < 30) {
return `${diffWeek} недели назад`;
} else if (diffMonth < 12) {
return `${diffMonth} месяцев назад`;
} else if (diffYear < 100) {
return `${diffYear} лет назад`;
}
return `${diffYear} век назад`;
}
function getLocalTime(utcDate) {
let addHours = -(new Date().getTimezoneOffset()) / 60;
let utcTime = new Date(utcDate).getTime();
let localDate = new Date(utcTime + addHours * 60 * 60 * 1000);
return localDate;
}
async function getJsonData() {
if (Math.random() < 0.18) {
try {
const response = await fetch('https://forexampleu.pythonanywhere.com/random');
let jsonServerData = "[]";
if (response.ok) {
jsonServerData = await response.json();
const hasTag = jsonServerData.some(item => item.tags === selectTag || selectTag === "");
if (hasTag) {
return jsonServerData;
}
}
} catch { }
}
return jsonStaticData;
}
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
function stringToColor(str) {
try {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
hash = hash & hash;
}
let color = '#';
for (let i = 0; i < 3; i++) {
let value = (hash >> (i * 8)) & 0xFF;
if (value < 128) value += 128;
color += ('00' + value.toString(16)).slice(-2);
}
return color;
} catch {
return "#000000";
}
}
function getRecommentJson(json, tags, take, is_extra_found, is_ignore_dublicate) {
let result = [];
let ids = [];
json.forEach((data, index) => {
if (data.tags == tags || tags == "") {
let dublicate = localStorage.getItem("p" + data.id);
if (dublicate == null || Math.random() < 0.5 || is_ignore_dublicate) {
result.push(data);
if (dublicate == null) {
localStorage.setItem("p" + data.id, '{}');
}
ids.push(data.id);
}
}
});
if (result.length < take && is_extra_found) {
json.forEach((data, index) => {
if (!ids.includes(data.id)) {
result.push(data);
let dublicate = localStorage.getItem("p" + data.id);
if (dublicate == null) {
localStorage.setItem("p" + data.id, '{}');
}
}
});
}
result = shuffle(result).slice(0, take);
let seen = new Set();
for (let i = result.length - 1; i >= 0; i--) {
let key = result[i].id + "|" + result[i].url;
if (seen.has(key)) {
result.splice(i, 1);
} else {
seen.add(key);
}
}
return result;
}
function escapeHtml(str) {
if (typeof str !== 'string') return '';
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
.replace(/"/g, '"').replace(/'/g, ''');
}
function generatePage(json) {
const container = document.getElementById('maincontent');
json.forEach((data, index) => {
const article = document.createElement('article');
const viewsCounter = document.createElement('div');
const cardHeader = document.createElement('div');
const emotions = data.emotions.match(/(\d+)/)[1] || 0;
try {
const usermessages = JSON.parse(localStorage.getItem("p" + data.id) || "{}").msg || [];
usermessages.forEach((comment, indexx) => {
const message = `{ "id": 5, "datetime": "2025-09-09T00:00", "username": "${localStorage.getItem("login") || "anon"}", "userpublickey": "", "usersign": "", "value": "${comment}", "emotions": "😁0" }`;
data.comments.push(JSON.parse(message));
});
} catch { }
article.className = 'card';
article.setAttribute('aria-labelledby', `post${data.id}-title`);
article.setAttribute('tabindex', '0');
viewsCounter.className = 'views-counter';
viewsCounter.innerHTML = `
<span class="views-icon">👁️🗨️</span>
<span class="view-count">${Number(data.views) + 1}</span>
`;
cardHeader.className = 'card-header';
const avatar = document.createElement('div');
avatar.className = 'avatar';
avatar.setAttribute('aria-hidden', 'true');
avatar.textContent = data.username.charAt(0).toUpperCase();
const userInfo = document.createElement('div');
userInfo.className = 'user-info';
const usernameDiv = document.createElement('div');
usernameDiv.className = 'username';
usernameDiv.style.color = stringToColor(data.username + "1");
usernameDiv.textContent = data.username;
const timeElem = document.createElement('time');
timeElem.className = 'timestamp';
timeElem.dateTime = getLocalTime(data.datetime);
timeElem.textContent = getRelativeTime(getLocalTime(data.datetime));
userInfo.appendChild(usernameDiv);
userInfo.appendChild(timeElem);
cardHeader.appendChild(avatar);
cardHeader.appendChild(userInfo);
const cardContent = document.createElement('div');
const mediaContainer = document.createElement('div');
cardContent.className = 'card-content';
mediaContainer.className = 'media-container';
const filetype = data.filetype.toLowerCase();
if (['mp4', 'mkv', 'webm', 'x-msvideo', 'mpeg', '3gp'].includes(filetype)) {
mediaContainer.innerHTML = `
<video playsinline controls poster="${escapeHtml(data.preview)}" aria-label="Видео">
<source src="${escapeHtml(data.fileurl)}" type="${escapeHtml(data.filetype) === 'mp4' ? 'video/mp4' : 'video/mkv'}">
Ваш браузер не поддерживает видео тег.
</video>
`;
} else if (["png", "jpg", "jpeg", "gif", "bmp"].includes(filetype)) {
const img = document.createElement('img');
img.src = data.fileurl;
mediaContainer.appendChild(img);
} else if (['mp3', 'wav', 'ogg', 'm4a', 'aac', 'flac', 'opus'].includes(filetype)) {
mediaContainer.innerHTML = `
<audio controls aria-label="Аудио">
<source src="${escapeHtml(data.fileurl)}" type="audio/mpeg">
Ваш браузер не поддерживает аудио тег.
</audio>
`;
}
const textContent = document.createElement('div');
textContent.className = 'text-content';
const title = document.createElement('h2');
title.className = 'card-title';
title.id = `post${data.id}-title`;
title.textContent = data.title;
const description = document.createElement('p');
description.className = 'card-text';
description.textContent = data.description;
textContent.appendChild(title);
textContent.appendChild(description);
let postdata = JSON.parse(localStorage.getItem("p" + data.id) || '{}');
let countlike = 0;
if (postdata.e) countlike = parseInt(postdata.e.replace(/\D/g, '')) || 0;
const cardActions = document.createElement('div');
cardActions.className = 'card-actions';
cardActions.innerHTML = `
<button class="action-btn like-btn${countlike == 0 ? "" : " liked"}" id="postlike${Number(data.id)}" onclick="updateLike(${Number(data.id)}, 1)" aria-label="Лайк">
<span class="like-icon">👍</span>
<span class="like-count">${parseInt(emotions) + countlike}</span>
</button>
<button class="action-btn comment-toggle" aria-expanded="false" aria-controls="comments${Number(data.id)}" aria-label="Показать комментарии">💬 <span class="comment-count">${Number(data.comments.length)}</span></button>
<button class="action-btn share-btn" aria-label="Поделиться">↗️</button>
`;
cardContent.appendChild(mediaContainer);
cardContent.appendChild(textContent);
article.appendChild(viewsCounter);
article.appendChild(cardHeader);
article.appendChild(cardContent);
article.appendChild(cardActions);
if (data.comments.length >= 0) {
const commentsSection = document.createElement('section');
commentsSection.className = 'comments-section';
commentsSection.id = `comments${data.id}`;
commentsSection.setAttribute('aria-hidden', 'true');
const comments = document.createElement('div');
comments.className = 'comment';
comments.innerHTML = `
<div class="comment-avatar-comment">Вы</div>
<div class="comment-input-container">
<div class="username-in-comment">${localStorage.getItem("login") || "anon"}</div>
<textarea class="comment-textarea" id="textarea${Number(data.id)}" placeholder="Добавить комментарий..."></textarea>
<div class="comment-actions">
<button class="cancel-btn">Отмена</button>
<button class="comment-btn" onclick="sendMessage(document.getElementById('textarea${Number(data.id)}').value, ${Number(data.id)})">Комментировать</button>
</div>
</div>
`;
commentsSection.appendChild(comments);
data.comments.forEach(comment => {
const commentDiv = document.createElement('div');
commentDiv.className = 'comment';
const commentHeader = document.createElement('div');
commentHeader.className = 'comment-header';
const commentAvatar = document.createElement('div');
commentAvatar.className = 'comment-avatar';
commentAvatar.setAttribute('aria-hidden', 'true');
commentAvatar.textContent = comment.username.charAt(0).toUpperCase();
const commentUsername = document.createElement('div');
commentUsername.className = 'comment-username';
commentUsername.style.color = stringToColor(comment.username);
commentUsername.textContent = comment.username;
commentHeader.appendChild(commentAvatar);
commentHeader.appendChild(commentUsername);
const commentText = document.createElement('p');
commentText.className = 'comment-text';
commentText.textContent = comment.value;
commentDiv.appendChild(commentHeader);
commentDiv.appendChild(commentText);
commentsSection.appendChild(commentDiv);
});
article.appendChild(commentsSection);
}
container.appendChild(article);
});
}
function updateLike(id, countLike) {
const json = JSON.parse(localStorage.getItem("p" + id));
const button = document.getElementById("postlike" + id);
const countElement = button.querySelector('.like-count');
if (!countElement) return;
if (json.e == null || json.e == undefined) {
json.e = "";
}
let userLike = countLike;
let count = parseInt(countElement.textContent);
if (json.e == "0👍" || json.e == "") {
count += userLike;
json.e = userLike + "👍";
button.classList.add('liked');
} else {
userLike = parseInt(json.e.replace(/\D/g, ''));
count -= userLike;
json.e = "0👍";
button.classList.remove('liked');
}
countElement.textContent = count;
localStorage.setItem("p" + id, JSON.stringify(json));
}
function submitDataOnServer() {
let result = "{";
for (let key in localStorage) {
if (key.startsWith('p') && !isNaN(key.slice(1)) && key.slice(1).length > 0) {
let value = localStorage.getItem(key);
result += `"${key}":${value},`;
}
}
result = result.substring(0, result.length - 1) + "}";
}
submitDataOnServer();
function setupEventDelegates() {
const container = document.getElementById('maincontent');
container.addEventListener('click', (event) => {
if (event.target.closest('.comment-toggle')) {
const button = event.target.closest('.comment-toggle');
const card = button.closest('.card');
const commentsSection = card.querySelector('.comments-section');
if (!commentsSection) return;
const expanded = commentsSection.classList.toggle('expanded');
const commentCount = button.querySelector('.comment-count')?.textContent || 0;
commentsSection.setAttribute('aria-hidden', !expanded);
button.setAttribute('aria-expanded', expanded);
button.innerHTML = '💬 <span class="comment-count">' + commentCount + '</span>';
}
});
}
function sendMessage(message, id) {
const json = JSON.parse(localStorage.getItem("p" + id)); // it's tmp message, delete message if send on server
if (json.msg == null || json.msg == undefined) {
json.msg = [];
}
json.msg.push(message);
localStorage.setItem("p" + id, JSON.stringify(json));
const username = localStorage.getItem("login") || "anon";
const commentDiv = document.createElement('div');
commentDiv.className = 'comment';
commentDiv.innerHTML = `
<div class="comment-header">
<div class="comment-avatar" aria-hidden="true">${username.charAt(0).toUpperCase()}</div>
<div class="comment-username">${username}</div>
</div>
<p class="comment-text">${message}</p>
`;
const comments = document.getElementById("comments" + id);
comments.appendChild(commentDiv);
document.getElementById("textarea" + id).value = "";
}
let selectTag = "";
async function init() {
const urlParams = new URLSearchParams(window.location.search);
const tagValue = urlParams.get('tag') || '';
const links = document.querySelectorAll('nav.sidebar a');
links.forEach(link => link.classList.remove('active'));
if (tagValue) {
const activeLink = document.querySelector(`nav.sidebar a[href="?tag=${tagValue}"]`);
if (activeLink) activeLink.classList.add('active');
} else {
const homeLink = document.querySelector('nav.sidebar a[href="?tag="]');
if (homeLink) homeLink.classList.add('active');
}
selectTag = tagValue == "deepweb" ? "" : tagValue;
setupEventDelegates();
let newJson = await getJsonData();
generatePage(getRecommentJson(newJson, selectTag, 10, false, newJson.length < 10));
let isLoading = false;
window.addEventListener('scroll', () => {
if (isLoading) return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 500) {
isLoading = true;
setTimeout(async () => {
newJson = await getJsonData();
generatePage(getRecommentJson(newJson, selectTag, 10, false, newJson.length < 10));
isLoading = false;
}, 1000);
}
});
}
document.addEventListener('DOMContentLoaded', async () => {
await init();
});
document.querySelectorAll('video').forEach(video => {
video.addEventListener('touchstart', function () {
if (video.paused) {
video.play();
} else {
video.pause();
}
});
});
</script>
</body>
</html>