Spaces:
Running

archive / static /index.html
tuka1's picture
Server-side OG/Twitter meta tags for rich link previews on shared URLs
4c2adc3 verified
Raw History Blame Contribute Delete
128 kB
<!doctype html> <html lang="he" dir="rtl"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> <title>Gamer Forums Archive</title> <!--OG_TAGS--> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet"> <script src="https://cdn.tailwindcss.com"></script> <script> tailwind.config = { darkMode: 'class', theme: { extend: { fontFamily: { sans: ['Heebo', 'ui-sans-serif', 'system-ui'], mono: ['JetBrains Mono', 'ui-monospace', 'monospace'], }, colors: { ink: { // Dark-mode foreground tones (50-500). 300/400/500 brightened // ~+15 over the original muted look for better legibility. 50:'#f7f7f8',100:'#ececef',200:'#d8d8e0',300:'#c4c4d0', 400:'#9a9aa8',500:'#787886', // Surface/background tones (600-950). Untouched — these define // the dark theme's layered card hierarchy. 600:'#48485a',700:'#363645', 800:'#272735',850:'#1d1d28',900:'#13131c',950:'#0a0a12', }, accent: { DEFAULT: '#7c5cff', soft: '#a591ff', glow: '#9a7bff', } }, boxShadow: { 'glow-sm': '0 0 0 1px rgba(124,92,255,0.35), 0 8px 24px -8px rgba(124,92,255,0.25)', 'float': '0 30px 80px -20px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.06)', } } } } </script> <style> html { color-scheme: dark; } /* Hard bound: nothing — long URLs, oversized post images, code blocks, any single CJK/long-word — may horizontally escape the viewport. Mobile especially: page scroll must only ever be vertical. */ html, body { overflow-x: hidden; max-width: 100vw; } body { background: radial-gradient(1200px 600px at 15% -10%, rgba(124,92,255,0.10), transparent 60%), radial-gradient(1000px 500px at 90% 110%, rgba(80,140,255,0.07), transparent 60%), #0a0a12; } /* Force every image inside post bodies (rich HTML from baked content OR rendered preview snippets) to fit. Some original posts embed huge screenshots that would otherwise blow out the layout. */ .post-rich img, .post-body img, #modal-body img { max-width: 100%; height: auto; } /* Break long URLs and unbroken strings inside post text. */ .post-rich, .post-body, #modal-body p, #modal-body div, #modal-body span { overflow-wrap: anywhere; } /* `.hover-fade` = invisible until parent .group is hovered, but only on devices with hover support (desktop). Touch devices keep it visible. */ @media (hover: hover) and (pointer: fine) { .hover-fade { opacity: 0; transition: opacity 120ms; } .group:hover .hover-fade { opacity: 1; } } /* Sticky-actions / collapsible-title pattern for the modal: once the user starts scrolling the post/thread body, the title row folds away so the action buttons (which stay) get a bigger reading area. The header re-appears as soon as scroll returns to the top. max-height upper bound is set via the --modal-header-h CSS var (measured in JS on modal open) so the transition covers ONLY the actual header range — not a generous 200px guess that wastes most of the animation budget on invisible space. */ #modal-header { transition: max-height 180ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 120ms ease-out, padding-top 180ms cubic-bezier(0.22, 0.61, 0.36, 1), padding-bottom 180ms cubic-bezier(0.22, 0.61, 0.36, 1), border-color 120ms ease-out; max-height: var(--modal-header-h, 120px); overflow: hidden; will-change: max-height, opacity; } #modal.header-collapsed #modal-header { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; border-bottom-color: transparent; } /* font-size scale via body[data-font] */ body[data-font="s"] { --post-fs: 12px; --meta-fs: 10px; } body[data-font="m"], body:not([data-font]) { --post-fs: 14px; --meta-fs: 12px; } body[data-font="l"] { --post-fs: 17px; --meta-fs: 13px; } body[data-font="xl"] { --post-fs: 20px; --meta-fs: 14px; } .post-rich, .post-body { font-size: var(--post-fs, 14px); } /* light theme overrides — rank colors (inline-style hex) stay original */ html.theme-light { color-scheme: light; } html.theme-light body { background: #f4f5f7; color: #0b0b14; } html.theme-light .bg-ink-950\/70 { background: rgba(244,245,247,0.9) !important; } /* hide the purple/blue radial gradient overlay in light mode */ html.theme-light .grid-bg { display: none; } /* Card hierarchy in light mode: body #f4f5f7 (page bg) ink-850 #ffffff (container card — welcome, inputs) ink-900 #fbfbfd (slightly off-white — post/thread items inside container) ink-800 #f4f5f8 (hover state, slightly tinted) */ html.theme-light .bg-ink-850\/80, html.theme-light .bg-ink-850\/60, html.theme-light .bg-ink-850\/50, html.theme-light .bg-ink-850 { background: #ffffff !important; } html.theme-light .bg-ink-900\/80, html.theme-light .bg-ink-900\/60, html.theme-light .bg-ink-900\/50, html.theme-light .bg-ink-900 { background: #f8f9fc !important; } html.theme-light .bg-ink-800 { background: #ebecf0 !important; } html.theme-light .border-white\/5 { border-color: rgba(0,0,0,0.10) !important; } html.theme-light .border-white\/10 { border-color: rgba(0,0,0,0.15) !important; } html.theme-light .border-white\/15 { border-color: rgba(0,0,0,0.20) !important; } html.theme-light .rank-bar-track { background: rgba(0,0,0,0.06) !important; border-color: rgba(0,0,0,0.25) !important; } html.theme-light .bg-white\/5 { background: rgba(0,0,0,0.05) !important; } html.theme-light .bg-white\/10 { background: rgba(0,0,0,0.12) !important; } /* the rating/rank bar tracks — ensure visible on any theme */ .rank-bar-track { background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.18); } html.theme-light .rank-bar-track { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.22); } /* Light-theme text scale — mirror dark scale: brightest in dark = darkest in light, etc. Tuned for high contrast on the white card surfaces. */ html.theme-light .text-ink-100, html.theme-light .text-ink-200 { color: #0b0b14 !important; } html.theme-light .text-ink-300 { color: #1f1f2b !important; } html.theme-light .text-ink-400 { color: #2c2c38 !important; } html.theme-light .text-ink-500 { color: #404048 !important; } html.theme-light .text-ink-600 { color: #5e5e6a !important; } html.theme-light .text-ink-700 { color: #80808d !important; } html.theme-light .placeholder\:text-ink-400::placeholder { color: #45454f !important; } html.theme-light .placeholder\:text-ink-500::placeholder { color: #565660 !important; } html.theme-light .placeholder\:text-ink-600::placeholder { color: #6c6c78 !important; } html.theme-light .post-rich blockquote { background: rgba(124,92,255,0.07); color: #363645; } html.theme-light .post-rich blockquote > div:first-child { color: #5b3df5; } html.theme-light .hover\:bg-white\/5:hover { background: rgba(0,0,0,0.04) !important; } html.theme-light mark { background: rgba(255,210,0,0.40); color: #5a4500; } html.theme-light .post-rich a { color: #5b3df5; } mark { background: rgba(255,221,87,0.22); color: #ffd95c; padding: 0 2px; border-radius: 3px; font-weight: 500; } .scrollbar::-webkit-scrollbar { width: 10px; height: 10px; } .scrollbar::-webkit-scrollbar-thumb { background: rgba(124,92,255,0.25); border-radius: 6px; } .scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(124,92,255,0.45); } .scrollbar::-webkit-scrollbar-track { background: transparent; } .kbd { font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); color: #d4d4db; } .post-body { white-space: pre-wrap; word-break: break-word; } .grid-bg { background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px); background-size: 32px 32px; mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 30%, transparent 80%); } .shimmer { background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.08), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; } @keyframes shimmer { 0%{background-position:0% 0} 100%{background-position:-200% 0} } .avatar { width: 50px; height: 55px; border-radius: 5px; object-fit: cover; flex-shrink: 0; background: linear-gradient(135deg, #2a2438, #1a1a24); border: 1px solid rgba(255,255,255,0.08); } .avatar-lg { width: 72px; height: 80px; border-radius: 6px; } /* forum-style quote blocks */ .post-rich blockquote { margin: 8px 0; padding: 10px 12px; background: rgba(124,92,255,0.06); border-right: 3px solid rgba(124,92,255,0.45); border-radius: 6px; font-size: 13px; color: #aeaebd; } .post-rich blockquote > .quote-head { /* "ציטוט של X מתוך הודעה מ..." header */ font-size: 11px; color: #a591ff; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,0.08); } .post-rich blockquote > .quote-body { /* body content of the quote */ } .post-rich blockquote[data-quote-author] > .quote-head { cursor: pointer; user-select: none; } .post-rich blockquote[data-quote-author] > .quote-head:hover { color: #c2b3ff; } .post-rich blockquote[data-quote-author] > .quote-head::after { content: " ↗"; color: #a591ff; opacity: 0.6; } .post-rich blockquote hr { display: none; } .post-rich blockquote blockquote { background: rgba(124,92,255,0.10); opacity: 0.92; } .post-rich p { margin: 6px 0; } .post-rich img { max-width: 100%; height: auto; border-radius: 4px; } /* Placeholder swapped in by the global img onerror handler when an embedded post image 404s — gamer.co.il is gone, so this happens a lot. Looks like a small inline pill with the alt text + an icon. */ .broken-img { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; padding: 4px 10px; border: 1px dashed rgba(255,255,255,0.12); border-radius: 6px; color: var(--ink-500, #787886); background: rgba(255,255,255,0.02); font-size: 12px; vertical-align: middle; max-width: 100%; text-decoration: none; transition: border-color 120ms, color 120ms; } .broken-img:hover { border-color: rgba(255,255,255,0.25); color: var(--ink-300, #c4c4d0); } .broken-img svg { flex: 0 0 auto; opacity: 0.7; } .broken-img .broken-img-status { font-weight: 500; white-space: nowrap; flex: 0 0 auto; } .broken-img .broken-img-sep { opacity: 0.4; flex: 0 0 auto; } .broken-img .broken-img-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; min-width: 0; opacity: 0.7; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; } /* Mobile: stack the URL onto its own line — keeps the pill to 2 clean rows instead of wrapping every word independently. */ @media (max-width: 640px) { .broken-img .broken-img-label { flex: 1 1 100%; max-width: 100%; } .broken-img .broken-img-sep { display: none; } } html.theme-light .broken-img { border-color: rgba(0,0,0,0.12); background: rgba(0,0,0,0.02); color: #7a7a85; } html.theme-light .broken-img:hover { border-color: rgba(0,0,0,0.3); color: #4a4a55; } .post-rich a { color: #a591ff; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; word-break: break-word; /* break long URLs */ } .post-rich hr { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 8px 0; } .post-rich font[color] { color: inherit !important; } /* old inline colors look bad on dark bg */ /* spoilers: any <span> with an inline background-color (the original forum's spoiler convention) — hide text until hover or click */ .post-rich span[style*="background-color"] { color: transparent !important; background: rgba(255,255,255,0.10) !important; cursor: pointer; border-radius: 3px; padding: 0 3px; transition: color 0.15s ease, background-color 0.15s ease; } .post-rich span[style*="background-color"]:hover, .post-rich span[style*="background-color"].spoiler-revealed { color: inherit !important; background: rgba(255,221,87,0.18) !important; } html.theme-light .post-rich span[style*="background-color"] { background: rgba(0,0,0,0.08) !important; } html.theme-light .post-rich span[style*="background-color"]:hover, html.theme-light .post-rich span[style*="background-color"].spoiler-revealed { background: rgba(255,200,0,0.30) !important; } .avatar-fallback { display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; color: white; } @keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } } .modal-in { animation: modal-in 0.16s ease-out; } @keyframes fade-in { from { opacity: 0 } to { opacity: 1 } } .fade-in { animation: fade-in 0.16s ease-out; } </style> </head> <body class="font-sans text-ink-100 antialiased min-h-screen"> <div class="grid-bg fixed inset-0 -z-10 pointer-events-none"></div> <!-- top bar --> <header class="sticky top-0 z-20 backdrop-blur-xl bg-ink-950/70 border-b border-white/5"> <div class="max-w-7xl mx-auto px-3 sm:px-5 h-14 flex items-center gap-2 sm:gap-4"> <button id="home-link" type="button" class="flex items-center gap-2 text-ink-200 hover:text-white transition min-w-0" title="חזרה לראש העמוד"> <svg width="22" height="22" viewBox="0 0 24 24" fill="none" class="text-accent shrink-0"> <path d="M4 5h16M4 12h10M4 19h7" stroke="currentColor" stroke-width="2" stroke-linecap="round"/> </svg> <span class="font-semibold tracking-tight truncate">gamer<span class="text-accent">.co.il</span></span> <span class="text-ink-500 text-xs hidden sm:inline">archive search</span> </button> <div class="flex-1"></div> <div id="stats-pill" class="text-xs text-ink-400 hidden md:flex items-center gap-3"> <span class="shimmer rounded-md h-4 w-44"></span> </div> <div class="relative"> <button id="settings-btn" class="p-2 rounded-lg hover:bg-white/5 text-ink-300 hover:text-white transition" title="הגדרות"> <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="3"/> <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/> </svg> </button> <div id="settings-popover" class="hidden absolute left-0 top-full mt-2 bg-ink-850 border border-white/10 rounded-xl shadow-2xl shadow-black/40 p-3 min-w-[220px] z-30"> <div class="text-xs text-ink-500 mb-1.5">ערכת נושא</div> <div class="flex bg-ink-900 rounded-lg p-1 mb-3"> <button data-theme="dark" class="theme-btn flex-1 px-3 py-1.5 rounded-md text-xs transition">כהה</button> <button data-theme="light" class="theme-btn flex-1 px-3 py-1.5 rounded-md text-xs transition">בהירה</button> </div> <div class="text-xs text-ink-500 mb-1.5">גודל גופן</div> <div class="flex bg-ink-900 rounded-lg p-1 mb-3"> <button data-font="s" class="font-btn flex-1 px-2 py-1.5 rounded-md text-xs transition">קטן</button> <button data-font="m" class="font-btn flex-1 px-2 py-1.5 rounded-md text-xs transition">בינוני</button> <button data-font="l" class="font-btn flex-1 px-2 py-1.5 rounded-md text-xs transition">גדול</button> <button data-font="xl" class="font-btn flex-1 px-2 py-1.5 rounded-md text-xs transition">ענק</button> </div> <div class="text-xs text-ink-500 mb-1.5">תצוגת תוצאות</div> <div class="flex bg-ink-900 rounded-lg p-1 mb-3"> <button data-view="compact" class="view-btn flex-1 px-3 py-1.5 rounded-md text-xs transition">מצומצמת</button> <button data-view="detailed" class="view-btn flex-1 px-3 py-1.5 rounded-md text-xs transition">מורחבת</button> </div> <div class="text-xs text-ink-500 mb-1.5">תצוגת דיון</div> <div class="flex bg-ink-900 rounded-lg p-1"> <button data-thread-view="paged" class="thread-view-btn flex-1 px-3 py-1.5 rounded-md text-xs transition">עמודים</button> <button data-thread-view="full" class="thread-view-btn flex-1 px-3 py-1.5 rounded-md text-xs transition">מלאה</button> </div> </div> </div> </div> </header> <!-- toast --> <div id="toast" class="fixed bottom-6 left-1/2 -translate-x-1/2 bg-ink-850 border border-accent/40 text-ink-100 text-sm px-4 py-2 rounded-lg shadow-2xl shadow-black/40 z-50 transition-all opacity-0 translate-y-2 pointer-events-none">הקישור הועתק</div> <!-- search-help modal --> <div id="help-bg" class="hidden fixed inset-0 z-30 bg-black/70 backdrop-blur-sm fade-in"></div> <div id="help-wrap" class="hidden fixed inset-0 z-40 flex items-stretch sm:items-center justify-center p-0 sm:p-4 pointer-events-none"> <div class="modal-in pointer-events-auto bg-ink-900 rounded-none sm:rounded-2xl shadow-float w-full max-w-full sm:max-w-2xl h-full max-h-[100dvh] sm:max-h-[88vh] flex flex-col overflow-hidden"> <div class="px-5 py-3 border-b border-white/5 flex items-center gap-3 shrink-0"> <div class="flex-1"> <div class="text-xs text-accent-soft">עזרה</div> <div class="font-semibold">תחביר חיפוש מתקדם</div> </div> <button id="help-close" class="text-ink-300 hover:text-white text-2xl leading-none px-2">×</button> </div> <div class="p-5 overflow-y-auto scrollbar text-sm"> <p class="text-ink-300 leading-relaxed mb-4"> אפשר לשלב מספר מילים-מפתח בתוך החיפוש הרגיל. הן יסוננו והשאר ייחפש כטקסט חופשי. </p> <div class="space-y-3"> <div> <div class="text-xs text-ink-500 mb-1">חיפוש מדויק</div> <div class="space-y-1"> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">"red dead"</code><span class="text-ink-400 text-xs">ביטויים בתוך גרשיים נמצאים בדיוק כפי שהוקלדו, ללא הטיות</span></div> </div> </div> <div> <div class="text-xs text-ink-500 mb-1">דירוג הודעה (אחוז מילוי בר הכוכבים)</div> <div class="space-y-1"> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">דירוג>80</code><span class="text-ink-400 text-xs">הודעות עם דירוג של מעל 80%</span></div> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">דירוג<10</code><span class="text-ink-400 text-xs">דירוג נמוך מ-10%</span></div> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">דירוג=100</code><span class="text-ink-400 text-xs">דירוג מקסימלי</span></div> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">דירוג>=50 דירוג<=70</code><span class="text-ink-400 text-xs">בטווח</span></div> </div> </div> <div> <div class="text-xs text-ink-500 mb-1">סדר תוצאות מיוחד</div> <div class="space-y-1"> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">הכי:אהובים</code><span class="text-ink-400 text-xs">ההודעות עם הדירוג הגבוה ביותר תחילה</span></div> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">הכי:שנואים</code><span class="text-ink-400 text-xs">ההודעות עם הדירוג הנמוך ביותר תחילה</span></div> </div> </div> <div> <div class="text-xs text-ink-500 mb-1">סינון לפי שנה / פורום / מיקום בדיון</div> <div class="space-y-1"> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">שנה:2014</code><span class="text-ink-400 text-xs">רק הודעות מהשנה הזאת</span></div> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">פורום:13</code><span class="text-ink-400 text-xs">לפי מספר פורום</span></div> <div class="flex items-baseline gap-3"><code class="bg-ink-850 px-2 py-0.5 rounded font-mono text-xs">הודעה:1</code><span class="text-ink-400 text-xs">רק הודעת הפתיחה של הדיון</span></div> </div> </div> <div> <div class="text-xs text-ink-500 mb-1">דוגמאות מעניינות</div> <div class="space-y-1"> <div class="flex items-baseline gap-3"><button data-help-try="הכי:אהובים" class="help-try bg-ink-850 hover:bg-accent/20 px-2 py-0.5 rounded font-mono text-xs">הכי:אהובים</button><span class="text-ink-400 text-xs">ההודעות שאי-פעם זכו בדירוג הגבוה ביותר</span></div> <div class="flex items-baseline gap-3"><button data-help-try="הכי:שנואים שנה:2010" class="help-try bg-ink-850 hover:bg-accent/20 px-2 py-0.5 rounded font-mono text-xs">הכי:שנואים שנה:2010</button><span class="text-ink-400 text-xs">ההודעות הכי שנואות של 2010</span></div> <div class="flex items-baseline gap-3"><button data-help-try="דירוג=100 הודעה:1" class="help-try bg-ink-850 hover:bg-accent/20 px-2 py-0.5 rounded font-mono text-xs">דירוג=100 הודעה:1</button><span class="text-ink-400 text-xs">הודעות פתיחה שזכו בדירוג מושלם</span></div> <div class="flex items-baseline gap-3"><button data-help-try="חצי-גמר דירוג>80" class="help-try bg-ink-850 hover:bg-accent/20 px-2 py-0.5 rounded font-mono text-xs">חצי-גמר דירוג>80</button><span class="text-ink-400 text-xs">הודעות מעולות שמזכירות "חצי-גמר"</span></div> </div> <p class="text-[11px] text-ink-500 mt-2">לחיצה על דוגמה תפעיל אותה.</p> </div> </div> </div> </div> </div> <main class="max-w-7xl mx-auto px-3 sm:px-5 pt-4 sm:pt-6 pb-6"> <!-- hero search --> <section class="pb-6 sm:pb-8"> <form id="search-form" class="max-w-6xl mx-auto group" autocomplete="off"> <div class="relative"> <div class="absolute left-2 sm:left-3 top-1/2 -translate-y-1/2 flex items-center gap-1 sm:gap-2"> <button id="q-help" type="button" title="תחביר חיפוש מתקדם" class="text-ink-300 hover:text-accent-soft hover:bg-white/5 w-7 h-7 rounded-md transition text-xl font-semibold flex items-center justify-center leading-none">?</button> <svg class="text-ink-300 group-focus-within:text-accent transition" width="20" height="20" viewBox="0 0 24 24" fill="none"> <circle cx="11" cy="11" r="7" stroke="currentColor" stroke-width="2"/> <path d="m20 20-3.5-3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/> </svg> </div> <input id="q" type="text" placeholder="חפשו מילים, ביטויים, שמות…" class="w-full bg-ink-850 border border-white/15 rounded-xl pl-16 sm:pl-20 pr-10 sm:pr-12 py-3 sm:py-4 text-base sm:text-lg text-right placeholder:text-ink-400 outline-none transition focus:border-accent/70 focus:shadow-glow-sm" dir="rtl" /> <button id="q-clear" type="button" title="נקה (Esc)" class="hidden absolute right-2 sm:right-3 top-1/2 -translate-y-1/2 text-ink-400 hover:text-ink-100 w-7 h-7 rounded-md hover:bg-white/10 transition flex items-center justify-center text-xl leading-none">×</button> </div> <div class="mt-3 flex flex-wrap items-center gap-2 sm:gap-2.5 text-sm"> <!-- scope tabs (Posts | Threads) --> <div class="h-9 inline-flex bg-ink-850 border border-white/15 rounded-lg overflow-hidden shrink-0"> <button type="button" data-scope="posts" class="scope-btn h-full px-2.5 text-xs flex items-center gap-1 transition"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M4 6h16M4 12h16M4 18h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg> הודעות </button> <button type="button" data-scope="threads" class="scope-btn h-full px-2.5 text-xs flex items-center gap-1 transition border-r border-white/15"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><rect x="3" y="4" width="18" height="6" rx="1.5" stroke="currentColor" stroke-width="2"/><rect x="3" y="14" width="18" height="6" rx="1.5" stroke="currentColor" stroke-width="2"/></svg> דיונים </button> </div> <select id="forum" dir="rtl" class="h-9 bg-ink-850 border border-white/15 rounded-lg pr-3 pl-2 outline-none focus:border-accent/70 transition flex-1 sm:flex-none min-w-[140px] sm:min-w-[160px] max-w-full sm:max-w-[280px] shrink"> <option value="">כל הפורומים</option> </select> <div class="h-9 flex items-center gap-1 bg-ink-850 border border-white/15 rounded-lg px-2 relative flex-1 sm:flex-none sm:shrink-0 min-w-[150px]"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-ink-400 shrink-0"><circle cx="12" cy="8" r="4"/><path d="M4 22c0-4 4-7 8-7s8 3 8 7"/></svg> <input id="author-q" placeholder="משתמש…" class="bg-transparent outline-none flex-1 sm:w-44 min-w-0 text-sm placeholder:text-ink-400"> <input id="author" type="hidden"> <button id="author-clear" type="button" class="text-ink-400 hover:text-ink-100 w-3 text-center invisible shrink-0">×</button> </div> <!-- Date range popover trigger --> <div class="relative shrink-0"> <button id="date-toggle" type="button" class="h-9 flex items-center gap-1.5 bg-ink-850 border border-white/15 rounded-lg px-3 hover:border-white/25 transition"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-ink-400"><rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18"/></svg> <span id="date-label" class="text-xs text-ink-300">תאריכים</span> </button> <div id="date-popover" class="hidden absolute end-0 top-full mt-1 bg-ink-850 border border-white/15 rounded-lg p-3 shadow-2xl shadow-black/40 z-30 flex flex-col gap-2 w-[260px] max-w-[calc(100vw-1.5rem)]"> <label class="flex items-center gap-2 text-xs text-ink-400"> <span class="w-16 shrink-0 whitespace-nowrap text-left">מתאריך</span> <input id="date-from" type="date" class="bg-ink-900 border border-white/10 rounded px-2 py-1 outline-none text-sm flex-1 min-w-0" style="color-scheme: dark;"> </label> <label class="flex items-center gap-2 text-xs text-ink-400"> <span class="w-16 shrink-0 whitespace-nowrap text-left">עד תאריך</span> <input id="date-to" type="date" class="bg-ink-900 border border-white/10 rounded px-2 py-1 outline-none text-sm flex-1 min-w-0" style="color-scheme: dark;"> </label> <div class="flex justify-end mt-1"> <button type="button" data-date-preset="all" class="date-preset text-[11px] px-3 py-1 rounded-md bg-ink-900 border border-white/10 hover:border-accent/40 text-ink-300 hover:text-ink-100 transition">נקה</button> </div> </div> </div> <div class="h-9 bg-ink-850 border border-white/15 rounded-lg overflow-hidden flex shrink-0"> <button type="button" data-sort="newest" class="sort-btn h-full px-2.5 text-xs hover:bg-white/10 transition">חדש</button> <button type="button" data-sort="oldest" class="sort-btn h-full px-2.5 text-xs hover:bg-white/10 transition border-r border-white/15">ישן</button> </div> <button id="reset" type="button" class="h-9 ml-auto text-xs text-ink-400 hover:text-ink-100 transition px-2 shrink-0">איפוס</button> </div> <div id="author-dropdown" class="hidden absolute z-30 mt-1 bg-ink-850 border border-white/10 rounded-lg shadow-2xl shadow-black/40 max-h-64 overflow-auto scrollbar"></div> </form> </section> <section> <div id="profile-card" class="hidden mt-6 mb-6"></div> <div id="result-meta" class="flex items-center justify-between text-xs text-ink-500 mb-3 px-1 h-4"> <div id="result-count"></div> <div id="result-time" class="font-mono"></div> </div> <div id="pager-top" class="mb-4 flex items-center justify-center flex-wrap gap-2 min-h-[0]"></div> <div id="welcome" class="hidden mt-6 mb-6"></div> <div id="results" class="space-y-2 min-h-[420px]"></div> <div id="pager" class="mt-6 flex items-center justify-center flex-wrap gap-2 min-h-[36px]"></div> <div id="empty" class="hidden text-center py-20 text-ink-500"> <div class="text-5xl mb-3 opacity-50">∅</div> <div>אין תוצאות. נסה חיפוש אחר.</div> </div> </section> </main> <!-- footer --> <footer class="max-w-7xl mx-auto px-5 pb-10 pt-4 text-center text-xs text-ink-300 leading-relaxed"> הארכיון המקורי הועלה ל-<a href="https://archive.org/details/forums.gamer.co.il" target="_blank" rel="noopener" class="text-accent-soft hover:text-accent transition"><span dir="ltr">archive.org</span></a> ב-2018 ע״י <a href="https://archive.org/details/@sheppsh" target="_blank" rel="noopener" class="text-accent-soft hover:text-accent transition">sheppsh</a>. </footer> <!-- floating modal --> <div id="modal-bg" class="hidden fixed inset-0 z-30 bg-black/70 backdrop-blur-sm fade-in"></div> <div id="modal-wrap" class="hidden fixed inset-0 z-40 flex items-stretch sm:items-center justify-center p-0 sm:p-4 pointer-events-none"> <div id="modal" class="modal-in pointer-events-auto bg-ink-900 rounded-none sm:rounded-2xl shadow-float w-full max-w-full sm:max-w-5xl h-full max-h-[100dvh] sm:max-h-[88vh] flex flex-col overflow-hidden"> <div id="modal-header" class="bg-ink-900 border-b border-white/5 px-3 sm:px-5 py-3 flex items-center gap-2 sm:gap-3 shrink-0"> <div class="flex-1 min-w-0"> <div id="modal-forum" class="text-xs text-accent-soft truncate"></div> <div id="modal-title" class="font-semibold truncate"></div> </div> <!-- meta hidden on mobile — it's already shown in the actions bar below --> <div id="modal-meta" class="hidden sm:block text-xs text-ink-500 shrink-0"></div> <!-- star/copy/close: visible on desktop in the header; on mobile they get re-rendered inside the actions bar to save a header row. --> <span id="modal-star" class="hidden sm:inline text-base shrink-0"></span> <button id="modal-copy" class="hidden sm:flex text-ink-300 hover:text-accent-soft text-sm p-1.5 rounded hover:bg-white/5 transition items-center shrink-0" title="העתק קישור"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/> <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/> </svg> </button> <button id="modal-close" class="hidden sm:inline-flex text-ink-300 hover:text-white text-2xl leading-none px-2 shrink-0" title="סגור (Esc)">×</button> </div> <div id="modal-actions" class="hidden px-5 py-2 bg-ink-850/50 border-b border-white/5 flex items-center gap-3 text-sm shrink-0"></div> <div id="modal-body" class="p-5 space-y-3 overflow-y-auto scrollbar flex-1"></div> </div> </div> <script> 'use strict'; const state = { q: '', scope: 'posts', forum: '', author: '', authorNick: '', dateFrom: '', dateTo: '', sort: 'newest', offset: 0, limit: 30, forums: [], openItem: null, // ['post'|'thread', id] currently in the modal viewMode: 'compact', // 'compact' | 'detailed' threadView: 'paged', // 'paged' | 'full' threadPageSize: 20, // posts per page in 'paged' mode // When all filters are empty we show a welcome card instead of dumping the // global feed. Setting browseAll=true overrides that (the user explicitly // asked to see the newest/oldest of everything). browseAll: false, stats: null, // cached /api/stats response for the welcome card // Cursor pagination: prevCursors is a stack of cursors used to reach the // current page; currentCursor is what we used to fetch this page. nextCursor // is the cursor for the NEXT page, taken from the last result row. Reset // whenever the search query/filters change. prevCursors: [], currentCursor: null, nextCursor: null, totalCached: null, pageIndex: 0, // zero-based page number for display }; // Retry-on-5xx wrapper around the global fetch. The Space rolls deploys // by stopping the old container before the new one is fully ready, so a // brief 502/503 window is normal for ~30 s after every push. Without this // wrapper, the user sees raw "Unexpected token" JSON-parse errors when // the frontend tries to parse an HTML error page. With it, we wait and // re-try transparently. (() => { const _origFetch = window.fetch.bind(window); const isApi = (u) => { try { return new URL(u, location.href).pathname.startsWith('/api/'); } catch { return false; } }; window.fetch = async function patchedFetch(input, init) { const url = typeof input === 'string' ? input : (input && input.url) || ''; if (!isApi(url)) return _origFetch(input, init); const delays = [500, 1500, 3500]; let lastErr; for (let attempt = 0; attempt <= delays.length; attempt++) { try { const r = await _origFetch(input, init); // 5xx is transient (deploy swap, container restart). Retry. if (r.status >= 500 && r.status < 600 && attempt < delays.length) { await new Promise(res => setTimeout(res, delays[attempt])); continue; } return r; } catch (e) { lastErr = e; if (attempt < delays.length) { await new Promise(res => setTimeout(res, delays[attempt])); continue; } throw e; } } throw lastErr || new Error('fetch failed after retries'); }; })(); const $ = (s) => document.querySelector(s); const FALLBACK_COLORS = [ '#7c5cff','#5cc4ff','#ff6e8a','#ffa84d','#3ed6b5','#c87bff','#ffe066','#5cffae','#ff5c8a','#7d9bff' ]; function rankPillHTML(u) { if (!u.rank_desc && u.rank_dsize == null) return ''; const color = u.rank_color != null ? '#' + Number(u.rank_color).toString(16).padStart(6,'0').toUpperCase() : '#7c5cff'; const w = Math.max(0, Math.min(100, u.rank_dsize ?? 0)); return ` <div class="flex items-center gap-1.5 text-xs text-ink-400"> ${u.rank_desc ? `<span>${escapeHTML(u.rank_desc)}</span>` : ''} ${u.rank_dsize != null ? ` <span class="inline-block w-16 h-2 rounded-full overflow-hidden rank-bar-track"> <span class="block h-full" style="width:${w}%;background:${color}"></span> </span> `:''} </div> `; } function postRatingHTML(p) { if (p.dsize == null && p.color == null) return ''; const color = p.color != null ? '#' + Number(p.color).toString(16).padStart(6,'0').toUpperCase() : '#7c5cff'; const w = Math.max(0, Math.min(100, p.dsize ?? 0)); return ` <span class="inline-flex items-center gap-1 text-xs text-ink-500" title="דירוג: ${w}%"> <span class="inline-block w-12 h-2 rounded-full overflow-hidden rank-bar-track"> <span class="block h-full" style="width:${w}%;background:${color}"></span> </span> </span> `; } // Build the alternation regex used by both the snippet highlighter and // the in-DOM highlighter. Mirrors escape_fts() server-side so highlights // land on the same tokens FTS actually matched. const HE_PREFIXES = ['ה','ב','ו','ל','מ','ש','כ']; function _buildHighlightRegex(q) { if (!q) return null; const tokens = q.replace(/"/g, ' ').split(/\s+/).filter(Boolean); if (!tokens.length) return null; const variants = new Set(); for (const tok of tokens) { if (!tok) continue; const isHebrew = /[֐-׿]/.test(tok); variants.add(tok); if (isHebrew) { for (const p of HE_PREFIXES) if (!tok.startsWith(p)) variants.add(p + tok); } } if (!variants.size) return null; const escapedVars = [...variants] .sort((a,b) => b.length - a.length) .map(v => v.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')); return new RegExp('(' + escapedVars.join('|') + ')[\\u0590-\\u05FFa-zA-Z0-9]*', 'g'); } // Walk text nodes inside an already-rendered DOM subtree and wrap matches // in <mark>. Use this on `.post-rich` after injecting post HTML — applied // only when the user opened the post from a search result, so navigating // within a thread doesn't keep the marks. function highlightInElement(rootEl, q) { if (!rootEl || !q) return; const re = _buildHighlightRegex(q); if (!re) return; const nodes = []; const walker = document.createTreeWalker(rootEl, NodeFilter.SHOW_TEXT); let n; while (n = walker.nextNode()) { const p = n.parentNode; if (!p) continue; const tag = p.nodeName; if (tag === 'MARK' || tag === 'SCRIPT' || tag === 'STYLE') continue; nodes.push(n); } for (const node of nodes) { const text = node.nodeValue; const matches = [...text.matchAll(re)]; if (!matches.length) continue; const parent = node.parentNode; let last = 0; for (const m of matches) { if (m.index > last) parent.insertBefore(document.createTextNode(text.slice(last, m.index)), node); const mark = document.createElement('mark'); mark.textContent = m[0]; parent.insertBefore(mark, node); last = m.index + m[0].length; } if (last < text.length) parent.insertBefore(document.createTextNode(text.slice(last)), node); parent.removeChild(node); } } // Client-side highlighter: wraps occurrences of query terms (and common // Hebrew-prefix variants) in <mark> within a plain-text snippet. function highlightSnippet(snippet, q) { if (!snippet) return ''; if (!q) return escapeHTML(snippet); // Strip the "..." quoting that signals exact-phrase search — for highlight // purposes we still want every word in the phrase to light up. After that, // split on whitespace as before. const tokens = q.replace(/"/g, ' ').split(/\s+/).filter(Boolean); // Build a single alternation regex of all variants const variants = new Set(); for (const tok of tokens) { if (!tok) continue; const isHebrew = /[֐-׿]/.test(tok); variants.add(tok); if (isHebrew) { for (const p of HE_PREFIXES) if (!tok.startsWith(p)) variants.add(p + tok); } } if (!variants.size) return escapeHTML(snippet); const escapedVars = [...variants] .sort((a,b) => b.length - a.length) // longest first .map(v => v.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')); // Match each variant + any suffix word chars (so גומל also catches גומלים) const re = new RegExp('(' + escapedVars.join('|') + ')[\\u0590-\\u05FFa-zA-Z0-9]*', 'g'); // Escape the rest, but inject <mark> around matches let result = ''; let last = 0; for (const m of snippet.matchAll(re)) { result += escapeHTML(snippet.slice(last, m.index)); result += '<mark>' + escapeHTML(m[0]) + '</mark>'; last = m.index + m[0].length; } result += escapeHTML(snippet.slice(last)); return result; } function avatarHTML(userId, nick, sizeClass='avatar') { // Always return an element with the avatar dimensions so neighbouring // layout (post snippet, meta row) doesn't shift when the file is missing // or the user has no id. if (!userId) return `<span class="${sizeClass}" aria-hidden="true"></span>`; const safeNick = (nick || '?').trim() || '?'; const url = `/avatars/user${userId}.jpg`; const onerror = "this.style.visibility='hidden'"; return `<img loading="lazy" class="${sizeClass}" src="${url}" alt="${escapeHTML(safeNick)}" onerror="${onerror}">`; } async function init() { applyTheme(localStorage.getItem('theme') || 'dark'); applyFont(localStorage.getItem('font') || 'm'); applyView(localStorage.getItem('viewMode') || 'compact'); applyThreadView(localStorage.getItem('threadView') || 'paged'); try { const [stats, forums] = await Promise.all([ fetch('/api/stats').then(r => r.json()), fetch('/api/forums').then(r => r.json()), ]); state.stats = stats; renderStats(stats); state.forums = forums.forums; renderForumSelect(forums.forums); } catch (e) { $('#stats-pill').innerHTML = '<span class="text-red-400">DB לא מוכן עדיין</span>'; } bindEvents(); syncFromURL(); applySortUI(); applyScopeUI(); updateDateLabel(); // capture ?open=... BEFORE doSearch (which rewrites the URL via pushURL) const openParam = new URL(location.href).searchParams.get('open'); await doSearch(); if (openParam) maybeOpenFromURL(openParam); } // ---------- theme / font ---------- function applyTheme(t) { document.documentElement.classList.toggle('theme-light', t === 'light'); for (const b of document.querySelectorAll('.theme-btn')) { const active = b.dataset.theme === t; b.classList.toggle('bg-accent/20', active); b.classList.toggle('text-accent-soft', active); b.classList.toggle('text-ink-400', !active); } localStorage.setItem('theme', t); } function applyFont(f) { document.body.dataset.font = f; for (const b of document.querySelectorAll('.font-btn')) { const active = b.dataset.font === f; b.classList.toggle('bg-accent/20', active); b.classList.toggle('text-accent-soft', active); b.classList.toggle('text-ink-400', !active); } localStorage.setItem('font', f); } function applyView(v) { state.viewMode = v; for (const b of document.querySelectorAll('.view-btn')) { const active = b.dataset.view === v; b.classList.toggle('bg-accent/20', active); b.classList.toggle('text-accent-soft', active); b.classList.toggle('text-ink-400', !active); } localStorage.setItem('viewMode', v); } function applyThreadView(v) { state.threadView = v; for (const b of document.querySelectorAll('.thread-view-btn')) { const active = b.dataset.threadView === v; b.classList.toggle('bg-accent/20', active); b.classList.toggle('text-accent-soft', active); b.classList.toggle('text-ink-400', !active); } localStorage.setItem('threadView', v); } // ---------- toast + copy ---------- let toastT; function toast(msg) { const el = $('#toast'); el.textContent = msg; el.classList.remove('opacity-0','translate-y-2'); el.classList.add('opacity-100','translate-y-0'); clearTimeout(toastT); toastT = setTimeout(() => { el.classList.add('opacity-0','translate-y-2'); el.classList.remove('opacity-100','translate-y-0'); }, 1600); } async function copyToClipboard(text, msg='הקישור הועתק') { try { await navigator.clipboard.writeText(text); toast(msg); } catch (e) { // fallback for non-secure contexts const ta = document.createElement('textarea'); ta.value = text; document.body.appendChild(ta); ta.select(); try { document.execCommand('copy'); toast(msg); } catch {} ta.remove(); } } function linkForPost(id) { const u = new URL(location.href); u.search=''; u.searchParams.set('open', 'post:' + id); return u.toString(); } function linkForThread(id) { const u = new URL(location.href); u.search=''; u.searchParams.set('open', 'thread:' + id); return u.toString(); } function maybeOpenFromURL(p) { if (!p) p = new URL(location.href).searchParams.get('open'); if (!p) return; const m = /^(post|thread):(\d+)$/.exec(p); if (!m) return; // A shared deep link to a post can carry the search context too — when // ?q=… is in the URL we treat the post as if opened from that search and // highlight matches inside it. const hl = state.q || ''; if (m[1] === 'post') openPostModal(parseInt(m[2]), null, hl); if (m[1] === 'thread') openThreadModal(parseInt(m[2])); } function renderStats(s) { const fmt = (n) => Number(n).toLocaleString('he-IL'); const fmtDate = (d) => { if (!d) return '?'; const dt = new Date(d); const dd = String(dt.getDate()).padStart(2,'0'); const mm = String(dt.getMonth()+1).padStart(2,'0'); return `${dd}/${mm}/${dt.getFullYear()}`; }; $('#stats-pill').innerHTML = ` <span><span class="text-ink-200">${fmt(s.posts)}</span> הודעות</span> <span class="text-ink-700">·</span> <span><span class="text-ink-200">${fmt(s.threads)}</span> דיונים</span> <span class="text-ink-700">·</span> <span><span class="text-ink-200">${fmt(s.users)}</span> משתמשים</span> ${s.date_min ? ` <span class="text-ink-700">·</span> <span dir="ltr" class="font-mono text-ink-300" title="טווח תאריכים בארכיון">${fmtDate(s.date_min)} – ${fmtDate(s.date_max)}</span> ` : ''} `; } function renderForumSelect(forums) { const sel = $('#forum'); for (const f of forums) { if (!f.thread_count) continue; const opt = document.createElement('option'); opt.value = f.id; opt.textContent = (f.name || `פורום ${f.id}`) + ` (${f.thread_count})`; sel.appendChild(opt); } sel.value = state.forum; } function applySortUI() { for (const btn of document.querySelectorAll('.sort-btn')) { btn.classList.toggle('bg-accent/20', btn.dataset.sort === state.sort); btn.classList.toggle('text-accent-soft', btn.dataset.sort === state.sort); } } function updateDateLabel() { const lbl = $('#date-label'); if (!lbl) return; const f = state.dateFrom, t = state.dateTo; const shortYear = (s) => s ? s.slice(0, 4) : ''; if (!f && !t) { lbl.textContent = 'תאריכים'; lbl.classList.remove('text-accent-soft'); lbl.classList.add('text-ink-300'); } else if (f && t && shortYear(f) === shortYear(t.replace(/-12-31/, '').replace(/-(\d{2})-(\d{2})/, '-$1-$2'))) { lbl.textContent = shortYear(f); lbl.classList.add('text-accent-soft'); lbl.classList.remove('text-ink-300'); } else if (f && t) { lbl.textContent = `${shortYear(f)}–${shortYear(t) - 1 || shortYear(t)}`; lbl.classList.add('text-accent-soft'); lbl.classList.remove('text-ink-300'); } else { lbl.textContent = f ? `מ-${shortYear(f)}` : `עד ${shortYear(t)}`; lbl.classList.add('text-accent-soft'); lbl.classList.remove('text-ink-300'); } } function applyScopeUI() { for (const btn of document.querySelectorAll('.scope-btn')) { const active = btn.dataset.scope === state.scope; btn.classList.toggle('bg-accent/20', active); btn.classList.toggle('text-accent-soft', active); btn.classList.toggle('text-ink-400', !active); } const ph = state.scope === 'threads' ? 'חפשו בשמות דיונים…' : 'חפשו מילים, ביטויים, שמות, צירופים…'; $('#q').placeholder = ph; } function bindEvents() { // Collapse the modal title row once the user scrolls the body; restore // when they return to (near) the top. The actions bar stays visible // throughout — it sits between the (now-collapsing) header and the // (scrolling) body, so the buttons remain pinned at the top edge of // the post content. (() => { const body = $('#modal-body'); if (!body) return; let lastCollapsed = false; body.addEventListener('scroll', () => { const collapsed = body.scrollTop > 24; if (collapsed === lastCollapsed) return; lastCollapsed = collapsed; $('#modal').classList.toggle('header-collapsed', collapsed); }, { passive: true }); })(); // Replace failed embedded images inside post bodies with a small inline // placeholder pill (alt text + icon) instead of the browser's default // broken-image glyph. We render the pill as an <a href={original src}> // so the browser's link context menu (open in new tab / copy link // address) preserves the original URL — handy as a history breadcrumb // even when the target is long gone. // We listen in capture phase because `error` events don't bubble, and // only swap images inside `.post-rich` so avatars and other UI imagery // use their own fallback. document.addEventListener('error', (e) => { const t = e.target; if (!t || t.tagName !== 'IMG') return; if (!t.closest('.post-rich')) return; if (t.dataset.brokenHandled) return; t.dataset.brokenHandled = '1'; const src = t.src || ''; const detail = (t.alt || t.title || '').trim() || src; const a = document.createElement('a'); a.className = 'broken-img'; a.href = src; a.target = '_blank'; a.rel = 'noopener noreferrer'; a.title = src; a.innerHTML = ` <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <rect x="3" y="3" width="18" height="18" rx="2"/> <circle cx="9" cy="9" r="1.5"/> <path d="m21 15-5-5L5 21"/> <line x1="3" y1="3" x2="21" y2="21" stroke-opacity="0.6"/> </svg> <span class="broken-img-status">תמונה לא זמינה</span> ${detail ? `<span class="broken-img-sep">·</span><span class="broken-img-label" dir="ltr">${escapeHTML(detail)}</span>` : ''}`; t.replaceWith(a); }, true); // Browser back/forward: pull the new URL into state and replay the page — // close/open the modal to match ?open=… and re-run the search if the // query/filters differ. _replayingHistory suppresses pushURL during this // so we don't push a new entry on top of the one the user just navigated to. window.addEventListener('popstate', async () => { _replayingHistory = true; try { const wasOpen = state.openItem; syncFromURL(); applySortUI(); applyScopeUI(); updateDateLabel(); const openParam = new URL(location.href).searchParams.get('open'); // Modal state: close if the URL no longer has ?open=, open if it does // and we're either closed or pointing at a different item. if (!openParam && wasOpen) { closeModal(true); } await doSearch(); if (openParam) { const [kind, idStr] = openParam.split(':'); const id = parseInt(idStr, 10); if (!wasOpen || wasOpen[0] !== kind || wasOpen[1] !== id) { if (kind === 'post') openPostModal(id, null, state.q || ''); if (kind === 'thread') openThreadModal(id); } } } finally { _replayingHistory = false; _lastPushedURL = location.href; } }); let t; $('#q').addEventListener('input', (e) => { state.q = e.target.value; $('#q-clear').classList.toggle('hidden', !state.q); resetCursor(); clearTimeout(t); t = setTimeout(doSearch, 180); }); $('#q-clear').addEventListener('click', () => { state.q = ''; $('#q').value = ''; $('#q-clear').classList.add('hidden'); resetCursor(); doSearch(); $('#q').focus(); }); $('#search-form').addEventListener('submit', (e) => { e.preventDefault(); resetCursor(); doSearch(); }); $('#forum').addEventListener('change', (e) => { state.forum = e.target.value; resetCursor(); doSearch(); }); $('#date-from').addEventListener('change', (e) => { state.dateFrom = e.target.value; resetCursor(); updateDateLabel(); doSearch(); }); $('#date-to').addEventListener('change', (e) => { state.dateTo = e.target.value; resetCursor(); updateDateLabel(); doSearch(); }); $('#date-toggle').addEventListener('click', (e) => { e.stopPropagation(); const pop = $('#date-popover'); const wasHidden = pop.classList.contains('hidden'); pop.classList.toggle('hidden'); if (wasHidden) { // Position the popover within the viewport. The .relative parent is // somewhere mid-filter-row, so static `right-0` / `end-0` would let // a 260px popover bleed off the screen edge on narrow mobile. We // switch to fixed positioning, anchor below the toggle, and clamp // horizontal placement to a 12px margin from each viewport side. const trig = $('#date-toggle').getBoundingClientRect(); const margin = 12; const popWidth = Math.min(260, window.innerWidth - 2 * margin); // Prefer aligning popover's RIGHT edge under the trigger's right // edge (matches the RTL "drop from start" intuition), then clamp. let right = window.innerWidth - trig.right; right = Math.max(margin, Math.min(right, window.innerWidth - popWidth - margin)); pop.style.position = 'fixed'; pop.style.top = (trig.bottom + 4) + 'px'; pop.style.right = right + 'px'; pop.style.left = 'auto'; pop.style.width = popWidth + 'px'; } }); // Date range preset buttons (inside the popover) for (const btn of document.querySelectorAll('.date-preset')) { btn.addEventListener('click', () => { const p = btn.dataset.datePreset; let from = '', to = ''; const dmax = state.stats?.date_max ? state.stats.date_max.slice(0, 10) : '2014-12-31'; const dmin = state.stats?.date_min ? state.stats.date_min.slice(0, 10) : '2004-01-01'; const maxYear = parseInt(dmax.slice(0, 4), 10); const minYear = parseInt(dmin.slice(0, 4), 10); if (p === 'all') { from = ''; to = ''; } else if (/^\d{4}-\d{4}$/.test(p)) { const [a, b] = p.split('-'); from = `${a}-01-01`; to = `${parseInt(b,10) + 1}-01-01`; } else if (p === 'last-year') { from = `${maxYear}-01-01`; to = `${maxYear + 1}-01-01`; } else if (p === 'first-year') { from = `${minYear}-01-01`; to = `${minYear + 1}-01-01`; } state.dateFrom = from; state.dateTo = to; $('#date-from').value = from; $('#date-to').value = to; updateDateLabel(); resetCursor(); doSearch(); }); } document.addEventListener('click', (e) => { if (!e.target.closest('#date-popover') && !e.target.closest('#date-toggle')) { $('#date-popover').classList.add('hidden'); } }); $('#home-link').addEventListener('click', () => { // Reset all filters back to the welcome state and scroll to top resetAll(); window.scrollTo({top: 0, behavior: 'instant'}); }); // Search help modal const openHelp = () => { $('#help-bg').classList.remove('hidden'); $('#help-wrap').classList.remove('hidden'); document.body.style.overflow='hidden'; }; const closeHelp = () => { $('#help-bg').classList.add('hidden'); $('#help-wrap').classList.add('hidden'); document.body.style.overflow=''; }; $('#q-help').addEventListener('click', (e) => { e.preventDefault(); openHelp(); }); $('#help-close').addEventListener('click', closeHelp); $('#help-bg').addEventListener('click', closeHelp); // Click on an example token → put it in the search box and run it document.addEventListener('click', (e) => { const t = e.target.closest('[data-help-try]'); if (!t) return; closeHelp(); state.q = t.dataset.helpTry; $('#q').value = state.q; $('#q-clear').classList.remove('hidden'); resetCursor(); doSearch(); }); // Spoiler reveal — click any inline-bg span inside post-rich to keep it shown document.addEventListener('click', (e) => { const sp = e.target.closest('.post-rich span[style*="background-color"]'); if (sp) sp.classList.toggle('spoiler-revealed'); }); for (const btn of document.querySelectorAll('.sort-btn')) { btn.addEventListener('click', () => { state.sort = btn.dataset.sort; resetCursor(); applySortUI(); doSearch(); }); } for (const btn of document.querySelectorAll('.scope-btn')) { btn.addEventListener('click', () => { state.scope = btn.dataset.scope; resetCursor(); applyScopeUI(); doSearch(); }); } $('#reset').addEventListener('click', resetAll); let at; $('#author-q').addEventListener('input', (e) => { clearTimeout(at); const v = e.target.value.trim(); if (!v) { hideAuthorDropdown(); state.author=''; state.authorNick=''; $('#author').value=''; updateAuthorClear(); resetCursor(); doSearch(); return; } at = setTimeout(() => fetchAuthors(v), 200); }); $('#author-clear').addEventListener('click', () => { state.author=''; state.authorNick=''; $('#author').value=''; $('#author-q').value=''; updateAuthorClear(); hideAuthorDropdown(); resetCursor(); doSearch(); }); document.addEventListener('click', (e) => { if (!e.target.closest('#author-q') && !e.target.closest('#author-dropdown')) hideAuthorDropdown(); }); $('#modal-close').addEventListener('click', closeModal); $('#modal-bg').addEventListener('click', closeModal); $('#modal-copy').addEventListener('click', () => { if (!state.openItem) return; const [kind, id] = state.openItem; copyToClipboard(kind === 'post' ? linkForPost(id) : linkForThread(id), kind === 'post' ? 'קישור להודעה הועתק' : 'קישור לדיון הועתק'); }); document.addEventListener('keydown', (e) => { if (e.key === 'Escape') { if (!$('#help-wrap').classList.contains('hidden')) { $('#help-close').click(); } else if (document.activeElement === $('#q') && state.q) { // Esc while focused on search clears the term instead of closing modals $('#q-clear').click(); } else { closeModal(); } } if (e.key === '/' && document.activeElement !== $('#q')) { e.preventDefault(); $('#q').focus(); } }); // settings popover $('#settings-btn').addEventListener('click', (e) => { e.stopPropagation(); $('#settings-popover').classList.toggle('hidden'); }); document.addEventListener('click', (e) => { if (!e.target.closest('#settings-popover') && !e.target.closest('#settings-btn')) { $('#settings-popover').classList.add('hidden'); } }); for (const b of document.querySelectorAll('.theme-btn')) { b.addEventListener('click', () => applyTheme(b.dataset.theme)); } for (const b of document.querySelectorAll('.font-btn')) { b.addEventListener('click', () => applyFont(b.dataset.font)); } for (const b of document.querySelectorAll('.view-btn')) { b.addEventListener('click', () => { applyView(b.dataset.view); doSearch(); }); } for (const b of document.querySelectorAll('.thread-view-btn')) { b.addEventListener('click', () => { applyThreadView(b.dataset.threadView); }); } // per-post copy buttons (event delegation, since posts are re-rendered) document.addEventListener('click', (e) => { const btn = e.target.closest('[data-copy-post], [data-copy-thread]'); if (!btn) return; e.stopPropagation(); const pid = btn.getAttribute('data-copy-post'); const tid = btn.getAttribute('data-copy-thread'); if (pid) copyToClipboard(linkForPost(parseInt(pid)), 'קישור להודעה הועתק'); else if (tid) copyToClipboard(linkForThread(parseInt(tid)), 'קישור לדיון הועתק'); }); // star toggles (event delegation) document.addEventListener('click', (e) => { const btn = e.target.closest('[data-star]'); if (!btn) return; e.stopPropagation(); const [kind, id] = btn.dataset.star.split(':'); const nowOn = toggleStar(kind, id); // update *all* visible stars for this id (search hit + modal header etc.) for (const b of document.querySelectorAll(`[data-star="${kind}:${id}"]`)) { b.outerHTML = starButton(kind, id, b.classList.contains('text-xl') ? 'text-xl' : 'text-base'); } // If the welcome card's favorites list is shown, also refresh it so // unstarred items disappear immediately (and new ones appear). if (!$('#welcome').classList.contains('hidden')) { renderStarredInWelcome(); } toast(nowOn ? '★ נוסף למועדפים' : 'הוסר מהמועדפים'); }); // click on username → filter the search by this author and close the modal document.addEventListener('click', (e) => { const u = e.target.closest('.user-link'); if (!u) return; e.stopPropagation(); const uid = u.dataset.uid; const nick = u.dataset.nick; if (!uid) return; state.author = uid; state.authorNick = nick; $('#author').value = uid; $('#author-q').value = nick; updateAuthorClear(); resetCursor(); closeModal(); doSearch(); // Wait for the profile card to render, then scroll it into view (just // below the sticky header) so it isn't tucked under the filter row. setTimeout(() => { const card = $('#profile-card'); if (!card || card.classList.contains('hidden')) return; const headerH = document.querySelector('header').offsetHeight || 56; const y = card.getBoundingClientRect().top + window.scrollY - headerH - 16; window.scrollTo({top: Math.max(0, y), behavior: 'smooth'}); }, 50); }); // click on a quote header (blockquote with data-quote-author/time) → jump to source post document.addEventListener('click', async (e) => { const head = e.target.closest('.post-rich blockquote[data-quote-author][data-quote-time] > .quote-head'); if (!head) return; const bq = head.parentElement; e.stopPropagation(); const nick = bq.dataset.quoteAuthor; const time = bq.dataset.quoteTime; const res = await fetch(`/api/find_post_by_quote?nick=${encodeURIComponent(nick)}&time=${encodeURIComponent(time)}`).then(r => r.json()); if (res.found) { openPostModal(res.post_id, res.thread_id); } else { toast('לא נמצאה ההודעה המצוטטת בארכיון'); } }); } function resetAll() { state.q=''; state.forum=''; state.author=''; state.authorNick=''; state.dateFrom=''; state.dateTo=''; state.sort='newest'; $('#q').value=''; $('#forum').value=''; $('#author').value=''; $('#author-q').value=''; $('#date-from').value=''; $('#date-to').value=''; resetCursor(); updateAuthorClear(); applySortUI(); doSearch(); } async function fetchAuthors(q) { const res = await fetch(`/api/users/search?q=${encodeURIComponent(q)}&limit=8`).then(r=>r.json()); const dd = $('#author-dropdown'); if (!res.users.length) { hideAuthorDropdown(); return; } const anchor = $('#author-q').getBoundingClientRect(); dd.style.top = (anchor.bottom + window.scrollY + 4) + 'px'; dd.style.right = (window.innerWidth - anchor.right) + 'px'; dd.style.minWidth = anchor.width + 'px'; dd.innerHTML = res.users.map(u => ` <button type="button" data-id="${u.id}" data-nick="${escapeHTML(u.nick||'')}" class="author-pick block w-full text-right px-3 py-2 hover:bg-white/5 border-b border-white/5 last:border-b-0"> <div class="flex items-center gap-2"> ${avatarHTML(u.id, u.nick)} <div class="min-w-0 flex-1 space-y-0.5"> <div class="text-ink-100 text-sm truncate">${escapeHTML(u.nick||'?')}</div> ${u.location ? `<div class="text-xs text-ink-500 truncate">מ: ${escapeHTML(u.location)}</div>` : ''} ${u.messagecount != null ? `<div class="text-xs text-ink-500 truncate">הודעות: ${u.messagecount.toLocaleString('he-IL')}</div>` : ''} </div> </div> </button> `).join(''); dd.classList.remove('hidden'); for (const b of dd.querySelectorAll('.author-pick')) { b.addEventListener('click', () => { state.author = b.dataset.id; state.authorNick = b.dataset.nick; $('#author').value = b.dataset.id; $('#author-q').value = b.dataset.nick; updateAuthorClear(); hideAuthorDropdown(); resetCursor(); doSearch(); }); } } function hideAuthorDropdown() { $('#author-dropdown').classList.add('hidden'); } function updateAuthorClear() { $('#author-clear').classList.toggle('invisible', !state.author); } // ---------- profile card ---------- // Track which user the card currently shows, so paginating through the same // user's posts doesn't trigger a refetch + layout shimmer. let profileShownFor = null; async function refreshProfileCard() { const card = $('#profile-card'); if (!state.author) { if (profileShownFor !== null) { card.classList.add('hidden'); card.innerHTML = ''; profileShownFor = null; } return; } if (profileShownFor === state.author) return; // already showing this user card.classList.remove('hidden'); card.innerHTML = ` <div class="rounded-xl border border-white/5 bg-ink-900/60 p-4 flex gap-4 animate-pulse"> <div class="avatar avatar-lg shimmer"></div> <div class="flex-1 space-y-2"><div class="shimmer h-4 w-32 rounded"></div><div class="shimmer h-3 w-48 rounded"></div></div> </div>`; const wantId = state.author; try { const p = await fetch(`/api/user/${wantId}`).then(r => r.json()); if (state.author !== wantId) return; // user changed mid-fetch renderProfileCard(p); profileShownFor = wantId; } catch (e) { card.innerHTML = `<div class="text-red-400 text-sm p-3">פרופיל לא זמין</div>`; } } function renderProfileCard(p) { const fmt = (n) => Number(n).toLocaleString('he-IL'); const u = p.user; const s = p.stats; const fmtDate = (d) => { if (!d) return '—'; const dt = new Date(d); return `${String(dt.getDate()).padStart(2,'0')}/${String(dt.getMonth()+1).padStart(2,'0')}/${dt.getFullYear()}`; }; const years = (() => { if (!s.first_post || !s.last_post) return null; const dy = (new Date(s.last_post) - new Date(s.first_post)) / (1000*60*60*24*365.25); return dy >= 1 ? `${dy.toFixed(1)} שנים` : (dy*12).toFixed(0) + ' חודשים'; })(); const rank_color_hex = p.latest_rank?.rank_color != null ? '#' + Number(p.latest_rank.rank_color).toString(16).padStart(6,'0').toUpperCase() : '#7c5cff'; const rank_w = p.latest_rank?.rank_dsize != null ? Math.max(0, Math.min(100, p.latest_rank.rank_dsize)) : null; const stat = (val, label) => ` <div class="flex flex-col items-start"> <div class="text-[11px] text-ink-500 leading-tight">${label}</div> <div class="text-base font-semibold text-ink-100 leading-tight mt-0.5">${val}</div> </div>`; $('#profile-card').innerHTML = ` <div class="rounded-xl border border-accent/30 bg-ink-900/60 p-4 relative"> <button id="profile-clear" class="absolute top-2 left-2 text-ink-500 hover:text-ink-100 text-xl leading-none w-7 h-7 rounded-md hover:bg-white/5 transition flex items-center justify-center" title="הסר סינון משתמש">×</button> <div class="flex items-start gap-4"> <!-- left: avatar + identity --> <div class="shrink-0 flex flex-col items-center gap-2 w-28"> ${avatarHTML(u.id, u.nick, 'avatar avatar-lg')} <div class="text-center"> <div class="text-base font-semibold text-ink-100 leading-tight break-words">${escapeHTML(u.nick || 'אנונימי')}</div> ${u.location ? `<div class="text-xs text-ink-400 leading-tight mt-0.5">מ: ${escapeHTML(u.location)}</div>` : ''} </div> </div> <!-- right: stats grid, forums --> <div class="flex-1 min-w-0"> <div class="flex flex-wrap gap-x-5 gap-y-3 items-start"> ${stat(fmt(s.post_count), 'הודעות')} ${stat(fmt(s.thread_count), 'דיונים')} ${years ? stat(years, 'פעיל') : ''} ${stat('<span dir="ltr">' + fmtDate(s.first_post) + ' → ' + fmtDate(s.last_post) + '</span>', 'טווח')} ${p.latest_rank ? stat(` <span class="flex items-center gap-1.5"> ${p.latest_rank.rank_desc ? `<span>${escapeHTML(p.latest_rank.rank_desc)}</span>` : ''} ${rank_w != null ? ` <span class="inline-block w-16 h-2 rounded-full overflow-hidden rank-bar-track"> <span class="block h-full" style="width:${rank_w}%;background:${rank_color_hex}"></span> </span>` : ''} </span>`, 'דרגה אחרונה') : ''} </div> ${p.top_forums.length ? ` <div class="mt-4"> <div class="text-[11px] text-ink-500 mb-1.5">פורומים פעילים</div> <div class="flex flex-wrap gap-1.5"> ${p.top_forums.map(f => ` <button class="forum-jump text-xs px-2 py-1 rounded-md bg-ink-850 hover:bg-accent/20 hover:text-accent-soft border border-white/10 transition flex items-center gap-1.5" data-forum="${f.id}"> <span>${escapeHTML(f.name)}</span> <span class="text-ink-500 font-mono">${fmt(f.posts)}</span> </button>`).join('')} </div> </div>` : ''} </div> </div> </div>`; $('#profile-clear')?.addEventListener('click', () => { state.author = ''; state.authorNick = ''; $('#author').value = ''; $('#author-q').value = ''; updateAuthorClear(); resetCursor(); doSearch(); }); for (const b of document.querySelectorAll('.forum-jump')) { b.addEventListener('click', () => { state.forum = b.dataset.forum; $('#forum').value = b.dataset.forum; resetCursor(); doSearch(); }); } } // ---------- search ---------- // Any search-input change (q, scope, forum, author, dates, sort) must reset // cursor state so we start at page 1 for the new query, and also leave // "browse all" mode. function resetCursor() { state.prevCursors = []; state.currentCursor = null; state.nextCursor = null; state.totalCached = null; state.pageIndex = 0; state.offset = 0; state.browseAll = false; } function hasAnyFilter() { return !!(state.q || state.forum || state.author || state.dateFrom || state.dateTo); } // ---------- special-query parser ---------- // Extracts tokens like `דירוג>80`, `שנה:2014`, `הכי:מדורגים` out of the // search text. Returns an object with `text` (remaining FTS text) and any // extra API params to send. function parseSpecialQuery(q) { if (!q) return { text: '', params: {} }; const out = { text: '', params: {} }; const tokens = q.split(/\s+/); const remaining = []; for (const tok of tokens) { if (!tok) continue; // numeric comparator: דירוג>80, דירוג<=10, דירוג=100 let m = tok.match(/^דירוג(>=|<=|>|<|=)(\d+)$/); if (m) { const op = m[1], n = parseInt(m[2], 10); if (op === '>') out.params.rating_min = Math.min(100, n + 1); else if (op === '<') out.params.rating_max = Math.max(0, n - 1); else if (op === '>=') out.params.rating_min = n; else if (op === '<=') out.params.rating_max = n; else if (op === '=') { out.params.rating_min = n; out.params.rating_max = n; } continue; } // key:value tokens m = tok.match(/^(שנה|פורום|הודעה|הכי):(.+)$/); if (m) { const k = m[1], v = m[2].replace(/^"|"$/g, ''); if (k === 'שנה') { if (/^\d{4}$/.test(v)) { out.params.date_from = `${v}-01-01`; out.params.date_to = `${parseInt(v,10)+1}-01-01`; } } else if (k === 'פורום') { if (/^\d+$/.test(v)) out.params.forum = v; } else if (k === 'הודעה') { if (/^\d+$/.test(v)) out.params.idx = parseInt(v, 10); } else if (k === 'הכי') { if (v === 'אהובים' || v === 'אהוב' || v === 'מדורגים' || v === 'מדורג') out.params.sort = 'top_rated'; else if (v === 'שנואים' || v === 'שנוא') out.params.sort = 'top_hated'; } continue; } remaining.push(tok); } out.text = remaining.join(' '); return out; } function renderWelcome() { const fmt = (n) => n != null ? Number(n).toLocaleString('he-IL') : '?'; const fmtDate = (d) => { if (!d) return '?'; const dt = new Date(d); return `${String(dt.getDate()).padStart(2,'0')}/${String(dt.getMonth()+1).padStart(2,'0')}/${dt.getFullYear()}`; }; const s = state.stats || {}; $('#welcome').classList.remove('hidden'); $('#welcome').innerHTML = ` <div class="rounded-2xl border border-white/15 bg-ink-850 p-5 sm:p-8 md:p-10 text-center max-w-full overflow-hidden"> <img src="/static/logo.png" alt="gamer" class="mx-auto mb-5 h-12 sm:h-16 md:h-20 w-auto max-w-full"> <h2 class="text-xl sm:text-2xl md:text-3xl font-bold text-ink-100 tracking-tight">ארכיון הפורומים</h2> <p class="mt-3 text-ink-400 mx-auto leading-relaxed text-sm break-words"> חיפוש פנים-טקסטואלי על פני <span class="text-ink-100 font-semibold">${fmt(s.posts)}</span> הודעות מתוך <span class="text-ink-100 font-semibold">${fmt(s.threads)}</span> דיונים של <span class="text-ink-100 font-semibold">${fmt(s.users)}</span> משתמשים, בין <span dir="ltr" class="font-mono text-ink-300">${fmtDate(s.date_min)}</span> ל-<span dir="ltr" class="font-mono text-ink-300">${fmtDate(s.date_max)}</span>. </p> <div id="welcome-stars" class="hidden mt-5 pt-5 border-t border-white/5 text-right"></div> <div class="mt-5 pt-5 border-t border-white/5"> <div class="flex flex-wrap items-center justify-center gap-2 text-xs"> <button id="discover-random" type="button" class="h-9 px-3 rounded-lg bg-white/5 hover:bg-white/10 border border-white/15 text-ink-200 transition inline-flex items-center justify-center gap-1.5 leading-none"> 🎲 דיון אקראי </button> <button id="discover-hot" type="button" class="h-9 px-3 rounded-lg bg-white/5 hover:bg-white/10 border border-white/15 text-ink-200 transition inline-flex items-center justify-center gap-1.5 leading-none"> 🔥 הדיונים הפעילים ביותר </button> <button id="discover-top-msg" type="button" class="h-9 px-3 rounded-lg bg-white/5 hover:bg-white/10 border border-white/15 text-ink-200 transition inline-flex items-center justify-center gap-1.5 leading-none"> 👑 כותבי-העל </button> <button id="discover-top-thr" type="button" class="h-9 px-3 rounded-lg bg-white/5 hover:bg-white/10 border border-white/15 text-ink-200 transition inline-flex items-center justify-center gap-1.5 leading-none"> ✍️ פותחי-הדיונים הגדולים </button> </div> <div id="discover-result" class="mt-4"></div> </div> </div>`; // Discovery actions // Render starred items if any renderStarredInWelcome(); $('#discover-random').addEventListener('click', async () => { $('#discover-result').innerHTML = `<div class="text-ink-500 text-xs text-center">טוען…</div>`; try { const r = await fetch('/api/discovery/random_thread').then(r => r.json()); openThreadModal(r.id); $('#discover-result').innerHTML = ''; } catch (e) { $('#discover-result').innerHTML = `<div class="text-red-400 text-xs">שגיאה</div>`; } }); $('#discover-hot').addEventListener('click', () => loadDiscovery('hot')); $('#discover-top-msg').addEventListener('click', () => loadDiscovery('top_messages')); $('#discover-top-thr').addEventListener('click', () => loadDiscovery('top_threads_started')); } async function renderStarredInWelcome() { const box = $('#welcome-stars'); const starredThreads = getStars('thread').slice(0, 8); const starredPosts = getStars('post').slice(0, 8); if (!starredThreads.length && !starredPosts.length) { box.classList.add('hidden'); box.innerHTML = ''; return; } box.classList.remove('hidden'); box.innerHTML = ` <div class="text-base font-semibold text-ink-100 mb-4 text-center">מועדפים</div> ${starredPosts.length ? `<div class="text-[11px] text-ink-500 mb-1.5 text-right">הודעות</div><div id="star-posts" class="space-y-2 mb-4"></div>` : ''} ${starredThreads.length ? `<div class="text-[11px] text-ink-500 mb-1.5 text-right">דיונים</div><div id="star-threads" class="grid sm:grid-cols-2 gap-1.5"></div>` : ''} `; // Posts: fetch + transform into the shape renderPostHit expects, then reuse it if (starredPosts.length) { const target = $('#star-posts'); const posts = await Promise.all(starredPosts.map(async (id) => { try { const p = await fetch('/api/post/' + id + '?bare=1').then(r => r.json()); return { post_id: p.id, thread_id: p.thread_id, author_id: p.author_id, idx: p.idx, created_at: p.created_at, post_color: p.post_color, post_dsize: p.post_dsize, rank_desc: p.rank_desc, rank_color: p.rank_color, rank_dsize: p.rank_dsize, thread_name: p.thread_name, forum_id: p.forum_id, forum_name: p.forum_name, author_nick: p.author_nick, author_location: p.author_location, author_messagecount: p.author_messagecount, snippet: (p.content || '').slice(0, 280), title_snippet: p.thread_name, }; } catch { return null; } })); target.innerHTML = posts.filter(Boolean).map(renderPostHit).join(''); // wire clicks for (const el of target.querySelectorAll('[data-open-post]')) { el.addEventListener('click', (e) => { if (e.target.closest('[data-star], [data-copy-post], .user-link')) return; openPostModal(parseInt(el.dataset.openPost), parseInt(el.dataset.openThread)); }); } } // Threads: lightweight cards (same as before) if (starredThreads.length) { const target = $('#star-threads'); const items = await Promise.all(starredThreads.map(async (id) => { try { const r = await fetch('/api/thread/' + id + '?bare=1').then(r => r.json()); return { id, name: r.thread?.name || `(דיון ${id})`, forum: r.thread?.forum_name, post_count: r.thread?.total_posts }; } catch { return { id, name: `(דיון ${id})` }; } })); target.innerHTML = items.map(it => ` <button data-open-thread="${it.id}" class="text-xs text-right bg-ink-900 hover:bg-accent/15 border border-white/10 hover:border-accent/40 rounded-md px-3 py-2 transition flex items-start gap-2"> <span class="text-yellow-400 shrink-0">★</span> <span class="min-w-0 flex-1"> <span class="block text-[11px] text-ink-300">${it.forum ? escapeHTML(it.forum) : 'דיון'}${it.post_count ? ' · ' + it.post_count.toLocaleString('he-IL') + ' הודעות' : ''}</span> <span class="block truncate text-ink-100">${escapeHTML(it.name)}</span> </span> </button>`).join(''); for (const el of target.querySelectorAll('[data-open-thread]')) { el.addEventListener('click', () => openThreadModal(parseInt(el.dataset.openThread))); } } } async function loadDiscovery(kind) { const target = $('#discover-result'); target.innerHTML = `<div class="text-ink-500 text-xs text-center py-4">טוען…</div>`; const fmt = (n) => Number(n).toLocaleString('he-IL'); try { if (kind === 'hot') { const r = await fetch('/api/discovery/hot_threads?limit=20').then(r => r.json()); target.innerHTML = ` <div class="text-xs text-ink-500 mb-1.5">הדיונים עם הכי הרבה הודעות:</div> <div class="grid sm:grid-cols-2 gap-1.5 text-right"> ${r.results.map(t => ` <button data-open-thread="${t.id}" class="text-xs bg-ink-900 hover:bg-accent/15 border border-white/10 hover:border-accent/40 rounded-md px-3 py-2 transition flex items-start gap-2"> <span class="font-mono text-accent-soft shrink-0">${fmt(t.post_count)}</span> <span class="min-w-0 flex-1"> <span class="block truncate text-ink-100">${escapeHTML(t.name || '(ללא כותרת)')}</span> <span class="block truncate text-ink-500 text-[10px]">${escapeHTML(t.forum_name)}${t.first_author_nick ? ' · נפתח ע״י ' + escapeHTML(t.first_author_nick) : ''}</span> </span> </button>`).join('')} </div>`; } else if (kind === 'top_messages' || kind === 'top_threads_started') { const by = kind === 'top_messages' ? 'messages' : 'threads_started'; const r = await fetch(`/api/discovery/top_users?by=${by}&limit=24`).then(r => r.json()); const label = by === 'messages' ? 'הודעות' : 'דיונים שנפתחו'; target.innerHTML = ` <div class="text-xs text-ink-500 mb-1.5">${by === 'messages' ? 'המשתמשים הכי פרודוקטיביים:' : 'מי פתחו הכי הרבה דיונים:'}</div> <div class="grid sm:grid-cols-3 gap-1.5"> ${r.results.map((u,i) => ` <button class="user-link bg-ink-900 hover:bg-accent/15 border border-white/10 hover:border-accent/40 rounded-md px-3 py-2 transition flex items-center gap-2 text-right" data-uid="${u.id}" data-nick="${escapeHTML(u.nick||'')}"> <span class="text-ink-600 font-mono w-5 shrink-0">${i+1}</span> <span class="min-w-0 flex-1"> <span class="block truncate text-ink-100 text-xs font-semibold">${escapeHTML(u.nick||'?')}</span> ${u.location ? `<span class="block truncate text-ink-500 text-[10px]">מ: ${escapeHTML(u.location)}</span>` : ''} </span> <span class="text-accent-soft font-mono text-xs shrink-0" title="${label}">${fmt(u.metric)}</span> </button>`).join('')} </div>`; } // Wire any newly-rendered open-thread buttons for (const el of target.querySelectorAll('[data-open-thread]')) { el.addEventListener('click', () => openThreadModal(parseInt(el.dataset.openThread))); } } catch (e) { target.innerHTML = `<div class="text-red-400 text-xs">שגיאה: ${escapeHTML(e.message)}</div>`; } } function hideWelcome() { $('#welcome').classList.add('hidden'); $('#welcome').innerHTML = ''; } let inflight = 0; async function doSearch() { const myToken = ++inflight; pushURL(); refreshProfileCard(); // No filters and no explicit browse → show the welcome panel instead of // dumping the global feed. if (!hasAnyFilter() && !state.browseAll) { $('#results').innerHTML = ''; $('#results').classList.add('!min-h-0'); $('#pager').innerHTML = ''; $('#pager-top').innerHTML = ''; $('#result-count').innerHTML = ''; $('#result-time').textContent = ''; $('#empty').classList.add('hidden'); // Collapse the reserved heights of result-meta / pager-top while the // welcome card is on so there's no gap between it and the filter row. $('#result-meta').classList.add('hidden'); $('#pager-top').classList.add('hidden'); renderWelcome(); return; } $('#results').classList.remove('!min-h-0'); $('#result-meta').classList.remove('hidden'); $('#pager-top').classList.remove('hidden'); hideWelcome(); // Parse special tokens out of the search box (דירוג>80, שנה:2014, etc.) const parsed = parseSpecialQuery(state.q || ''); const effSort = parsed.params.sort || state.sort; const effForum = parsed.params.forum || state.forum; const effDateF = parsed.params.date_from || state.dateFrom; const effDateT = parsed.params.date_to || state.dateTo; const params = new URLSearchParams(); if (parsed.text) params.set('q', parsed.text); params.set('scope', state.scope); if (effForum) params.set('forum', effForum); if (state.author) params.set('author', state.author); if (effDateF) params.set('date_from', effDateF); if (effDateT) params.set('date_to', effDateT); if (parsed.params.rating_min != null) params.set('rating_min', parsed.params.rating_min); if (parsed.params.rating_max != null) params.set('rating_max', parsed.params.rating_max); if (parsed.params.idx != null) params.set('idx', parsed.params.idx); params.set('sort', effSort); params.set('limit', state.limit); // Use cursor when we have one (next/prev nav). Otherwise use offset // (first page, or jump-to-last). if (state.currentCursor) { params.set('cursor', state.currentCursor); } else if (state.offset) { params.set('offset', state.offset); } $('#results').innerHTML = loadingSkeletons(6); $('#empty').classList.add('hidden'); const t0 = performance.now(); try { const res = await fetch('/api/search?' + params).then(r => r.json()); if (myToken !== inflight) return; const dt = (performance.now() - t0).toFixed(0); // Update cursor info from the response state.nextCursor = res.next_cursor || null; // Carry the total from page 1; subsequent cursor pages return total=-1 if (res.total >= 0) state.totalCached = res.total; renderResults(res, dt); } catch (e) { $('#results').innerHTML = `<div class="text-red-400 p-6">שגיאה: ${escapeHTML(e.message)}</div>`; } } function loadingSkeletons(n) { return Array.from({length:n}).map(() => ` <div class="bg-ink-900/60 border border-white/5 rounded-xl p-4 space-y-2"> <div class="shimmer h-3 w-1/3 rounded"></div> <div class="shimmer h-4 w-3/4 rounded"></div> <div class="shimmer h-3 w-full rounded"></div> <div class="shimmer h-3 w-5/6 rounded"></div> </div> `).join(''); } function renderResults(res, dtMs) { const fmt = (n) => Number(n).toLocaleString('he-IL'); const totalShown = state.totalCached != null ? state.totalCached : (res.total > 0 ? res.total : 0); // Server caps the count at 10001 to avoid full-scan COUNT on common terms const totalLabel = totalShown >= 10001 ? '+10,000' : fmt(totalShown); $('#result-count').innerHTML = totalShown ? `<span class="text-ink-200">${totalLabel}</span> ${res.scope === 'threads' ? 'דיונים' : 'הודעות'}` : ''; $('#result-time').textContent = res.results.length ? `${dtMs}ms` : ''; if (!res.results.length) { $('#results').innerHTML = ''; $('#results').classList.add('!min-h-0'); $('#empty').classList.remove('hidden'); // If user is searching threads and found nothing, hint that posts scope // may have hits (thread title search only matches titles, not bodies). const hint = state.scope === 'threads' ? `<button id="empty-try-posts" class="mt-3 text-sm text-accent-soft hover:text-accent transition underline underline-offset-4">חפש את "${escapeHTML(state.q || '')}" בתוך ההודעות עצמן</button>` : ''; $('#empty').innerHTML = ` <div class="text-5xl mb-3 opacity-50">∅</div> <div>אין תוצאות. נסה חיפוש אחר.</div> ${hint}`; if (hint) { $('#empty-try-posts').addEventListener('click', () => { state.scope = 'posts'; resetCursor(); applyScopeUI(); doSearch(); }); } renderPager(res); return; } $('#results').classList.remove('!min-h-0'); $('#empty').classList.add('hidden'); const renderer = res.scope === 'threads' ? renderThreadHit : (state.viewMode === 'detailed' ? renderPostHitDetailed : renderPostHit); // Within each page, only push *confirmed* quote-only matches to the // bottom; body matches and unknown/unbaked rows keep their server order // (which respects sort=newest etc). Stable sort preserves ranking within // each group. The server already did the equivalent over a wider window; // this is a safety pass for the visible page. const ordered = [...res.results].sort((a, b) => (a.match_in_body === false ? 1 : 0) - (b.match_in_body === false ? 1 : 0) ); $('#results').innerHTML = ordered.map(renderer).join(''); // Capture the query used for *this* page of results so the post modal // can highlight matches inside the opened post. We snapshot rather than // reading state.q at click time, because the user may have typed something // else by then. const hlQuery = state.q || ''; for (const el of document.querySelectorAll('[data-open-post]')) { el.addEventListener('click', () => openPostModal(parseInt(el.dataset.openPost), parseInt(el.dataset.openThread), hlQuery)); } for (const el of document.querySelectorAll('[data-open-thread]:not([data-open-post])')) { el.addEventListener('click', () => openThreadModal(parseInt(el.dataset.openThread))); } renderPager(res); } function quoteOnlyBadge(r) { if (r.match_in_body !== false) return ''; return `<span class="inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-300 text-[10px] font-medium" title="המילה מופיעה רק בציטוט בתוך ההודעה, לא בגוף ההודעה עצמה"> <svg width="10" height="10" viewBox="0 0 24 24" fill="currentColor"><path d="M7 7h4v4H7zM13 7h4v4h-4zM7 13c0 3 2 4 4 4v-2c-1 0-2-1-2-2zM13 13c0 3 2 4 4 4v-2c-1 0-2-1-2-2z"/></svg> תוצאה בציטוט </span>`; } function renderPostHit(r) { const date = r.created_at ? new Date(r.created_at).toLocaleString('he-IL', {year:'numeric', month:'short', day:'numeric'}) : ''; const forumName = r.forum_name || (r.forum_id ? `פורום ${r.forum_id}` : '—'); const userForRank = { rank_desc: r.rank_desc, rank_color: r.rank_color, rank_dsize: r.rank_dsize }; const postForRating = { color: r.post_color, dsize: r.post_dsize }; return ` <article data-open-post="${r.post_id}" data-open-thread="${r.thread_id}" class="group bg-ink-900 hover:bg-ink-850 border border-white/10 hover:border-accent/50 rounded-xl p-4 cursor-pointer transition-all duration-150 flex gap-3"> <div class="pt-0.5">${avatarHTML(r.author_id, r.author_nick)}</div> <div class="min-w-0 flex-1"> <div class="flex items-center gap-2 text-xs text-ink-300 mb-1.5 flex-wrap"> ${starButton('post', r.post_id)} <span class="user-link cursor-pointer text-ink-200 font-medium hover:text-accent-soft" data-uid="${r.author_id||''}" data-nick="${escapeHTML(r.author_nick||'')}">${escapeHTML(r.author_nick || 'אנונימי')}</span> ${r.author_location ? `<span class="text-ink-700">·</span><span>מ: ${escapeHTML(r.author_location)}</span>` : ''} ${r.author_messagecount != null ? `<span class="text-ink-700">·</span><span>הודעות: ${r.author_messagecount.toLocaleString('he-IL')}</span>` : ''} ${rankPillHTML(userForRank)} <span class="text-ink-700">·</span> <span class="text-accent-soft">${escapeHTML(forumName)}</span> ${quoteOnlyBadge(r)} <span class="ml-auto flex items-center gap-2"> ${postRatingHTML(postForRating)} <span class="font-mono">${date}</span> <span class="text-ink-700">·</span> <span>#${r.idx ?? '?'}</span> </span> </div> <h3 class="font-semibold text-ink-100 group-hover:text-white truncate mb-1"> ${highlightSnippet(r.title_snippet || r.thread_name || '(ללא כותרת)', state.q)} </h3> <p class="post-body text-ink-300 leading-relaxed line-clamp-3">${highlightSnippet(r.snippet || '', state.q)}</p> </div> </article> `; } function renderPostHitDetailed(r) { // Forum-post layout for search hits: user column on right, message body on // left with thread-context line + meta + snippet stacked inside. const date = r.created_at ? new Date(r.created_at).toLocaleString('he-IL', {year:'numeric', month:'short', day:'numeric'}) : ''; const forumName = r.forum_name || (r.forum_id ? `פורום ${r.forum_id}` : '—'); const rank_color_hex = r.rank_color != null ? '#' + Number(r.rank_color).toString(16).padStart(6,'0').toUpperCase() : null; const rank_w = r.rank_dsize != null ? Math.max(0, Math.min(100, r.rank_dsize)) : null; const rankBar = rank_w != null ? ` <div class="w-20 h-2 rounded-full overflow-hidden rank-bar-track"> <div class="h-full" style="width:${rank_w}%;background:${rank_color_hex || '#7c5cff'}"></div> </div>` : ''; const nickEl = `<span class="user-link cursor-pointer font-semibold text-ink-100 hover:text-accent-soft leading-tight break-words" data-uid="${r.author_id||''}" data-nick="${escapeHTML(r.author_nick||'')}">${escapeHTML(r.author_nick || 'אנונימי')}</span>`; const userColumn = ` <aside class="w-full sm:w-36 sm:shrink-0 bg-ink-900/60 border-b sm:border-b-0 sm:border-l border-white/10"> <div class="flex sm:hidden items-center gap-3 p-3"> ${avatarHTML(r.author_id, r.author_nick, 'avatar')} <div class="min-w-0 flex-1"> <div class="text-sm">${nickEl}</div> <div class="text-xs text-ink-400 mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5"> ${r.rank_desc ? `<span>${escapeHTML(r.rank_desc)}</span>` : ''} ${rankBar ? `<span class="inline-flex">${rankBar}</span>` : ''} </div> </div> </div> <div class="hidden sm:flex flex-col items-center gap-1.5 text-center p-3"> <span class="text-sm">${nickEl}</span> ${r.rank_desc ? `<div class="text-xs text-ink-300 leading-tight">${escapeHTML(r.rank_desc)}</div>` : ''} ${rankBar ? `<div class="mt-0.5">${rankBar}</div>` : ''} <div class="mt-1.5">${avatarHTML(r.author_id, r.author_nick, 'avatar avatar-lg')}</div> ${r.author_location ? `<div class="text-xs text-ink-400 mt-1.5 leading-tight">מ: ${escapeHTML(r.author_location)}</div>` : ''} ${r.author_messagecount != null ? `<div class="text-xs text-ink-500 leading-tight">הודעות: ${r.author_messagecount.toLocaleString('he-IL')}</div>` : ''} </div> </aside> `; const postRatingBar = (r.post_color != null || r.post_dsize != null) ? ` <span class="inline-flex items-center gap-1.5"> <span class="text-ink-600">·</span> <span class="text-xs text-ink-500">דירוג</span> <span class="inline-block w-14 h-2 rounded-full overflow-hidden rank-bar-track"> <span class="block h-full" style="width:${Math.max(0,Math.min(100,r.post_dsize ?? 0))}%;background:${r.post_color != null ? '#'+Number(r.post_color).toString(16).padStart(6,'0').toUpperCase() : '#7c5cff'}"></span> </span> </span>` : ''; return ` <article data-open-post="${r.post_id}" data-open-thread="${r.thread_id}" class="group rounded-xl border border-white/10 bg-ink-850 hover:bg-ink-800 hover:border-accent/50 cursor-pointer transition-all duration-150 overflow-hidden"> <div class="flex flex-col sm:flex-row"> ${userColumn} <div class="min-w-0 flex-1 p-4"> <div class="flex items-center gap-2 text-xs text-ink-300 mb-2 flex-wrap"> <span class="text-accent-soft truncate">${escapeHTML(forumName)}</span> <span class="text-ink-700">·</span> <span class="font-mono">${date}</span> <span class="text-ink-700">·</span> <span>#${r.idx ?? '?'}</span> ${postRatingBar} ${quoteOnlyBadge(r)} </div> <h3 class="font-semibold text-ink-100 group-hover:text-white truncate mb-2"> ${highlightSnippet(r.title_snippet || r.thread_name || '(ללא כותרת)', state.q)} </h3> <p class="post-body text-ink-300 leading-relaxed line-clamp-3">${highlightSnippet(r.snippet || '', state.q)}</p> </div> </div> </article> `; } function renderThreadHit(r) { const fmt = (n) => Number(n).toLocaleString('he-IL'); const firstDate = r.first_post ? new Date(r.first_post).toLocaleDateString('he-IL', {year:'numeric', month:'short', day:'numeric'}) : ''; const lastDate = r.last_post ? new Date(r.last_post ).toLocaleDateString('he-IL', {year:'numeric', month:'short', day:'numeric'}) : ''; const dateRange = firstDate === lastDate ? firstDate : `${firstDate} → ${lastDate}`; const forumName = r.forum_name || (r.forum_id ? `פורום ${r.forum_id}` : '—'); return ` <article data-open-thread="${r.id}" class="group bg-ink-900 hover:bg-ink-850 border border-white/10 hover:border-accent/50 rounded-xl p-4 cursor-pointer transition-all duration-150 flex gap-3"> <div class="pt-0.5">${avatarHTML(r.first_author_id, r.first_author_nick)}</div> <div class="min-w-0 flex-1"> <div class="flex items-center gap-2 text-xs text-ink-300 mb-1.5 flex-wrap"> <span class="text-accent-soft">${escapeHTML(forumName)}</span> <span class="text-ink-700">·</span> <span class="font-mono">${dateRange}</span> <span class="text-ink-700">·</span> <span>${fmt(r.post_count)} הודעות</span> ${r.first_author_nick ? `<span class="text-ink-700">·</span><span>נפתח ע״י ${escapeHTML(r.first_author_nick)}</span>` : ''} </div> <h3 class="font-semibold text-ink-100 group-hover:text-white mb-1"> ${escapeHTML(r.name || '(ללא כותרת)')} </h3> ${r.first_excerpt ? `<p class="post-body text-ink-400 leading-relaxed line-clamp-2">${escapeHTML(r.first_excerpt)}</p>` : ''} </div> </article> `; } function renderPager(res) { const pagerTop = $('#pager-top'); const pager = $('#pager'); const total = state.totalCached != null ? state.totalCached : res.total; // total = -1 means the server skipped COUNT for performance (top_rated/ // top_hated). Fall back to offset-style pagination with no known last // page — we infer "there's more" from getting a full page back. const totalKnown = total >= 0; const fullPage = res.results.length >= state.limit; if (!res.results.length) { pager.innerHTML = ''; pagerTop.innerHTML = ''; return; } if (totalKnown && total <= state.limit) { pager.innerHTML = ''; pagerTop.innerHTML = ''; return; } const pages = totalKnown ? Math.ceil(total / state.limit) : null; const page = state.pageIndex + 1; const lastOffset = totalKnown ? (pages - 1) * state.limit : null; const atFirst = state.pageIndex === 0; const atLast = totalKnown ? (!res.next_cursor && !fullPage) || page >= pages : !fullPage; // unknown-total mode: more pages exist iff we got a full page const cls = "px-2 sm:px-3 py-1.5 rounded-lg bg-ink-850 border border-white/15 hover:border-accent/50 disabled:opacity-30 disabled:hover:border-white/15 text-sm transition whitespace-nowrap shrink-0"; // Jump-to-first/last are visually secondary — tighter padding + slightly // smaller text on mobile so they don't dominate the row. const jumpCls = "px-1.5 sm:px-3 py-1.5 text-xs sm:text-sm rounded-lg bg-ink-850 border border-white/15 hover:border-accent/50 disabled:opacity-30 disabled:hover:border-white/15 transition whitespace-nowrap shrink-0"; // Inline-block whole label so RTL bidi never splits "X מתוך Y" across lines. const pageLabel = totalKnown ? `<span class="whitespace-nowrap" dir="rtl">עמוד <span class="text-ink-100">${page}</span> מתוך ${pages.toLocaleString('he-IL')}</span>` : `<span class="whitespace-nowrap" dir="rtl">עמוד <span class="text-ink-100">${page}</span></span>`; // Hide first/last only when total is unknown (no last-page to jump to). const showJumpButtons = totalKnown; const html = () => ` ${showJumpButtons ? `<button data-pg="first" ${atFirst?'disabled':''} class="${jumpCls}" title="עמוד ראשון">««</button>` : ''} <button data-pg="prev" ${atFirst?'disabled':''} class="${cls}">‹ הקודם</button> <span class="text-sm text-ink-400 px-2 sm:px-3 shrink-0">${pageLabel}</span> <button data-pg="next" ${atLast?'disabled':''} class="${cls}">הבא ›</button> ${showJumpButtons ? `<button data-pg="last" ${atLast?'disabled':''} class="${jumpCls}" title="עמוד אחרון">»»</button>` : ''} `; pager.innerHTML = html(); pagerTop.innerHTML = html(); const goFirst = () => { state.prevCursors = []; state.currentCursor = null; state.nextCursor = null; state.offset = 0; state.pageIndex = 0; doSearch(); window.scrollTo({top:0, behavior:'smooth'}); }; const goNext = () => { if (state.nextCursor) { state.prevCursors.push(state.currentCursor); // may be null for page 1 state.currentCursor = state.nextCursor; state.pageIndex += 1; state.offset = 0; // not used while cursor is set } else { // offset-based fallback (top_rated/top_hated etc — no cursor) state.offset = (state.offset || 0) + state.limit; state.pageIndex += 1; } doSearch(); window.scrollTo({top:0, behavior:'smooth'}); }; const goPrev = () => { if (state.prevCursors.length > 0) { state.currentCursor = state.prevCursors.pop(); state.pageIndex = Math.max(0, state.pageIndex - 1); state.offset = 0; } else if (state.offset > 0) { // offset-based fallback state.offset = Math.max(0, state.offset - state.limit); state.pageIndex = Math.max(0, state.pageIndex - 1); } else { goFirst(); return; } doSearch(); window.scrollTo({top:0, behavior:'smooth'}); }; const goLast = () => { // Cursor doesn't help for arbitrary jumps; fall back to OFFSET. One-shot // cost (the user explicitly asked to jump to the end). state.prevCursors = []; state.currentCursor = null; state.nextCursor = null; state.offset = lastOffset; state.pageIndex = pages - 1; doSearch(); window.scrollTo({top:0, behavior:'smooth'}); }; for (const btn of document.querySelectorAll('[data-pg]')) { btn.addEventListener('click', () => { switch (btn.dataset.pg) { case 'first': goFirst(); break; case 'prev': goPrev(); break; case 'next': goNext(); break; case 'last': goLast(); break; } }); } } // ---------- modal ---------- function openModalShell() { $('#modal-bg').classList.remove('hidden'); $('#modal-wrap').classList.remove('hidden'); $('#modal').classList.remove('modal-in'); $('#modal').classList.remove('header-collapsed'); void $('#modal').offsetWidth; $('#modal').classList.add('modal-in'); $('#modal-actions').classList.add('hidden'); $('#modal-actions').innerHTML = ''; $('#modal-body').innerHTML = loadingSkeletons(3); $('#modal-body').scrollTop = 0; document.body.style.overflow = 'hidden'; // Measure the header's natural height once it has content; we use this // as the max-height upper bound so the collapse animation transitions // across the actual range (otherwise max-height: 200px → 0 stutters // because most of the range is invisible empty space). requestAnimationFrame(() => { requestAnimationFrame(() => { const h = $('#modal-header').getBoundingClientRect().height; if (h > 0) $('#modal').style.setProperty('--modal-header-h', h + 'px'); }); }); // star for the open item — re-render whenever state changes if (state.openItem) { const [k, id] = state.openItem; $('#modal-star').innerHTML = starButton(k, id, 'text-xl'); } else { $('#modal-star').innerHTML = ''; } } function refreshModalStar() { if (!state.openItem) return; const [k, id] = state.openItem; $('#modal-star').innerHTML = starButton(k, id, 'text-xl'); } // Mobile-only cluster for the actions bar — duplicates the close/copy/star // header controls so they don't need their own row on narrow viewports. // The hidden desktop buttons (modal-close, modal-copy, modal-star) still // live in the DOM, so we delegate via click(). // `ms-auto` pushes the cluster to the visual-left edge of the row, // matching where these controls sit in the desktop header. function mobileModalActionsHTML() { if (!state.openItem) return ''; const [k, id] = state.openItem; // Identical 32×32 flex-centered square per glyph — guarantees the three // (★, link-icon, ×, each with very different intrinsic heights) sit on // the same horizontal baseline. No wrapper around the star: the star // button itself takes the slot classes. const slot = "h-8 w-8 inline-flex items-center justify-center shrink-0 rounded hover:bg-white/5 transition leading-none"; return ` <span class="sm:hidden flex items-center gap-1 shrink-0 ms-auto"> ${starButton(k, id, 'text-xl', slot)} <button id="m-modal-copy" class="${slot} text-ink-300 hover:text-accent-soft" title="העתק קישור"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/> <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/> </svg> </button> <button id="m-modal-close" class="${slot} text-ink-300 hover:text-white text-2xl" title="סגור">×</button> </span>`; } function wireMobileModalActions() { const close = document.getElementById('m-modal-close'); if (close) close.addEventListener('click', () => $('#modal-close').click()); const copy = document.getElementById('m-modal-copy'); if (copy) copy.addEventListener('click', () => $('#modal-copy').click()); // star uses the global [data-star] delegation, no per-instance wiring. } function closeModal(skipHistory=false) { $('#modal-bg').classList.add('hidden'); $('#modal-wrap').classList.add('hidden'); document.body.style.overflow = ''; state.openItem = null; if (!skipHistory) pushURL(); } async function openPostModal(postId, threadId, highlightQuery = null) { state.openItem = ['post', postId]; pushURL(); openModalShell(); $('#modal-title').textContent = '…'; $('#modal-forum').textContent = ''; $('#modal-meta').textContent = ''; try { const p = await fetch(`/api/post/${postId}`).then(r => r.json()); $('#modal-forum').textContent = p.forum_name || (p.forum_id ? `פורום ${p.forum_id}` : ''); $('#modal-title').textContent = p.thread_name || `(דיון ${threadId})`; $('#modal-meta').textContent = `הודעה #${p.idx ?? '?'} מתוך ${p.thread_post_count}`; $('#modal-actions').classList.remove('hidden'); $('#modal-actions').innerHTML = ` <button id="jump-thread" class="px-3 py-1.5 rounded-lg bg-accent/15 hover:bg-accent/25 text-accent-soft text-xs transition flex items-center gap-1.5" title="קפיצה להודעה זו בתוך הדיון"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M4 12h16M4 12l6-6M4 12l6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> להודעה </button> <button id="jump-thread-start" class="px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/15 text-ink-200 text-xs transition flex items-center gap-1.5" title="פתח את הדיון מההתחלה"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M12 19V5M5 12l7-7 7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> לדיון </button> <div class="text-xs text-ink-500 mr-auto hidden sm:block">${p.thread_post_count} הודעות בדיון</div> ${mobileModalActionsHTML()} `; wireMobileModalActions(); $('#modal-body').innerHTML = renderSinglePost(p, true); decorateExternalLinks($('#modal-body')); if (highlightQuery) highlightInElement($('#modal-body'), highlightQuery); // Jumping into the thread is a navigation away from the search hit, so // we don't carry the highlight over — the thread view shows the post // in its native context. $('#jump-thread').addEventListener('click', () => openThreadModal(p.thread_id, postId)); $('#jump-thread-start').addEventListener('click', () => openThreadModal(p.thread_id)); } catch (e) { $('#modal-body').innerHTML = `<div class="text-red-400 p-4">שגיאה: ${escapeHTML(e.message)}</div>`; } } // Open any <a href> inside the given root in a new tab. Used on rendered // post HTML — links in post bodies come from the original forum and we // don't want them hijacking the SPA navigation. function decorateExternalLinks(rootEl) { if (!rootEl) return; for (const a of rootEl.querySelectorAll('a[href]')) { if (!a.target) a.target = '_blank'; if (!a.rel) a.rel = 'noopener noreferrer'; } } async function openThreadModal(threadId, highlightPost = null) { state.openItem = ['thread', threadId]; state.openThreadId = threadId; state.openThreadHighlight = highlightPost; pushURL(); openModalShell(); $('#modal-actions').classList.remove('hidden'); $('#modal-actions').innerHTML = ` <button id="thread-top" class="px-2 sm:px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/15 text-ink-200 text-xs transition flex items-center gap-1.5" title="ראש העמוד"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M12 19V5M5 12l7-7 7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> <span class="hidden sm:inline">ראש העמוד</span> </button> <button id="thread-bottom" class="px-2 sm:px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/15 text-ink-200 text-xs transition flex items-center gap-1.5" title="סוף העמוד"> <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12l7 7 7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg> <span class="hidden sm:inline">סוף העמוד</span> </button> ${mobileModalActionsHTML()} `; wireMobileModalActions(); $('#thread-top').addEventListener('click', () => { $('#modal-body').scrollTo({top: 0, behavior: 'smooth'}); }); $('#thread-bottom').addEventListener('click', () => { const b = $('#modal-body'); b.scrollTo({top: b.scrollHeight, behavior: 'smooth'}); }); $('#modal-title').textContent = '…'; $('#modal-forum').textContent = ''; $('#modal-meta').textContent = ''; try { // Paged mode: fetch only the page we need from the server (huge win for // multi-page threads — we don't pull 1000 posts of JSON just to show 20). // Full mode: fetch all at once (legacy). let url, page = 0; if (state.threadView === 'paged') { // If highlight requested, look up its idx to find the right page if (highlightPost) { try { const meta = await fetch('/api/post/' + highlightPost + '?bare=1').then(r => r.json()); if (meta.idx) page = Math.floor((meta.idx - 1) / state.threadPageSize); } catch {} } state.threadPage = page; url = `/api/thread/${threadId}?page=${page}&page_size=${state.threadPageSize}`; } else { url = `/api/thread/${threadId}`; } const res = await fetch(url).then(r => r.json()); $('#modal-forum').textContent = res.thread.forum_name || (res.thread.forum_id ? `פורום ${res.thread.forum_id}` : ''); $('#modal-title').textContent = res.thread.name || `(דיון ${threadId})`; const total = res.thread.total_posts || res.posts.length; $('#modal-meta').textContent = `${total.toLocaleString('he-IL')} הודעות`; state.openThreadTotal = total; if (state.threadView === 'paged') { state.openThreadPosts = res.posts; // just this page renderThreadPage(highlightPost); } else { state.openThreadPosts = res.posts; $('#modal-body').innerHTML = res.posts.map(p => renderSinglePost(p, false, p.id === highlightPost)).join(''); decorateExternalLinks($('#modal-body')); if (highlightPost) { requestAnimationFrame(() => { const el = document.getElementById('p-' + highlightPost); if (el) el.scrollIntoView({behavior:'instant', block:'start'}); }); } } } catch (e) { $('#modal-body').innerHTML = `<div class="text-red-400 p-4">שגיאה: ${escapeHTML(e.message)}</div>`; } } // ---------- favorites (localStorage) ---------- const STAR_KEY = 'gamer_archive_starred'; const STAR_CAP = 500; function _starsAll() { try { return JSON.parse(localStorage.getItem(STAR_KEY) || '{}'); } catch { return {}; } } function getStars(kind) { return _starsAll()[kind] || []; } function isStarred(kind, id) { return getStars(kind).includes(Number(id)); } function toggleStar(kind, id) { id = Number(id); const all = _starsAll(); if (!all[kind]) all[kind] = []; const i = all[kind].indexOf(id); if (i >= 0) all[kind].splice(i, 1); else all[kind].unshift(id); all[kind] = all[kind].slice(0, STAR_CAP); localStorage.setItem(STAR_KEY, JSON.stringify(all)); return all[kind].includes(id); } function starButton(kind, id, sizeCls='text-base', extraCls='') { const on = isStarred(kind, id); const base = extraCls ? extraCls : 'leading-none px-1'; return `<button data-star="${kind}:${id}" class="star-btn ${on?'text-yellow-400':'text-ink-500'} hover:text-yellow-400 transition ${sizeCls} ${base}" title="${on?'הסר מהמועדפים':'הוסף למועדפים'}">${on?'★':'☆'}</button>`; } function copyLinkButton(kind, id, label='העתק קישור') { // Always visible on touch (mobile), reveal-on-hover on pointer:fine // (desktop) so it doesn't add visual noise next to the per-row meta. return ` <button data-copy-${kind}="${id}" class="copy-btn opacity-100 hover-fade text-ink-500 hover:text-accent-soft text-xs flex items-center gap-1 transition" title="${label}"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/> <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/> </svg> </button>`; } function renderThreadPage(highlightPost = null) { const posts = state.openThreadPosts || []; if (!posts.length) return; const size = state.threadPageSize; const total = state.openThreadTotal || posts.length; const pages = Math.max(1, Math.ceil(total / size)); state.threadPage = Math.max(0, Math.min(state.threadPage || 0, pages - 1)); const pagerCls = "px-2 sm:px-3 py-1.5 rounded-lg bg-ink-850 border border-white/15 hover:border-accent/50 disabled:opacity-30 disabled:hover:border-white/15 text-sm transition whitespace-nowrap shrink-0"; const atFirst = state.threadPage === 0; const atLast = state.threadPage >= pages - 1; // Glyphs only — labels were forcing the row to wrap onto two lines on // mobile; the chevrons alone are universally understood here. const pagerHTML = pages > 1 ? ` <div class="flex items-center justify-center flex-wrap gap-2 py-3"> <button data-tpg="first" ${atFirst?'disabled':''} class="${pagerCls}" title="עמוד ראשון">««</button> <button data-tpg="prev" ${atFirst?'disabled':''} class="${pagerCls}" title="עמוד קודם">‹</button> <span class="text-sm text-ink-400 px-2 sm:px-3 whitespace-nowrap shrink-0" dir="rtl">עמוד <span class="text-ink-100">${state.threadPage + 1}</span> / ${pages}</span> <button data-tpg="next" ${atLast?'disabled':''} class="${pagerCls}" title="עמוד הבא">›</button> <button data-tpg="last" ${atLast?'disabled':''} class="${pagerCls}" title="עמוד אחרון">»»</button> </div>` : ''; $('#modal-body').innerHTML = pagerHTML + posts.map(p => renderSinglePost(p, false, p.id === highlightPost)).join('') + pagerHTML; decorateExternalLinks($('#modal-body')); // Capture page index at render time so the handler never depends on // state.threadPage being current at click time (eliminates races with // pending fetches that may have stomped it). const currentPage = state.threadPage; const goToPage = async (n) => { n = Math.max(0, Math.min(pages - 1, n)); state.threadPage = n; const url = `/api/thread/${state.openThreadId}?page=${n}&page_size=${size}`; $('#modal-body').innerHTML = loadingSkeletons(3); try { const res = await fetch(url).then(r => r.json()); state.openThreadPosts = res.posts; renderThreadPage(); $('#modal-body').scrollTo({top: 0, behavior: 'smooth'}); } catch (e) { $('#modal-body').innerHTML = `<div class="text-red-400 p-4">שגיאה: ${escapeHTML(e.message)}</div>`; } }; for (const btn of $('#modal-body').querySelectorAll('[data-tpg]')) { btn.addEventListener('click', () => { switch (btn.dataset.tpg) { case 'first': goToPage(0); break; case 'prev': goToPage(currentPage - 1); break; case 'next': goToPage(currentPage + 1); break; case 'last': goToPage(pages - 1); break; } }); } if (highlightPost) { requestAnimationFrame(() => { const el = document.getElementById('p-' + highlightPost); if (el) el.scrollIntoView({behavior:'instant', block:'start'}); }); } } function renderSinglePost(p, isolated, highlighted=false) { const date = p.created_at ? new Date(p.created_at).toLocaleString('he-IL') : ''; const wrapperClass = isolated ? 'rounded-xl border border-accent/40 bg-accent/5' : `rounded-xl border ${highlighted?'border-accent/60 bg-accent/10':'border-white/10 bg-ink-850'}`; // user column: vertical sidebar on sm+; horizontal strip on mobile so we // keep the post body wide on narrow screens. const rank_color_hex = p.rank_color != null ? '#' + Number(p.rank_color).toString(16).padStart(6,'0').toUpperCase() : null; const rank_w = p.rank_dsize != null ? Math.max(0, Math.min(100, p.rank_dsize)) : null; const rankBar = rank_w != null ? ` <div class="w-20 h-2 rounded-full overflow-hidden rank-bar-track"> <div class="h-full" style="width:${rank_w}%;background:${rank_color_hex || '#7c5cff'}"></div> </div>` : ''; const nickEl = `<span class="user-link cursor-pointer font-semibold text-ink-100 hover:text-accent-soft leading-tight break-words" data-uid="${p.author_id||''}" data-nick="${escapeHTML(p.author_nick||'')}">${escapeHTML(p.author_nick || 'אנונימי')}</span>`; const userColumn = ` <aside class="w-full sm:w-36 sm:shrink-0 bg-ink-900/60 border-b sm:border-b-0 sm:border-l border-white/5"> <!-- mobile: horizontal strip — star/copy live on the meta row below so this row stays clean (avatar + nick + ranks). --> <div class="flex sm:hidden items-center gap-3 p-3"> ${avatarHTML(p.author_id, p.author_nick, 'avatar')} <div class="min-w-0 flex-1"> <div class="text-sm">${nickEl}</div> <div class="text-xs text-ink-400 mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5"> ${p.rank_desc ? `<span>${escapeHTML(p.rank_desc)}</span>` : ''} ${rankBar ? `<span class="inline-flex">${rankBar}</span>` : ''} ${p.author_location ? `<span>· מ: ${escapeHTML(p.author_location)}</span>` : ''} ${p.author_messagecount != null ? `<span>· ${p.author_messagecount.toLocaleString('he-IL')} הודעות</span>` : ''} </div> </div> </div> <!-- desktop: vertical column --> <div class="hidden sm:flex flex-col items-center gap-1.5 text-center p-3"> <span class="text-sm">${nickEl}</span> ${p.rank_desc ? `<div class="text-xs text-ink-300 leading-tight">${escapeHTML(p.rank_desc)}</div>` : ''} ${rankBar ? `<div class="mt-0.5">${rankBar}</div>` : ''} <div class="mt-1.5">${avatarHTML(p.author_id, p.author_nick, 'avatar avatar-lg')}</div> ${p.author_location ? `<div class="text-xs text-ink-400 mt-1.5 leading-tight">מ: ${escapeHTML(p.author_location)}</div>` : ''} ${p.author_messagecount != null ? `<div class="text-xs text-ink-500 leading-tight">הודעות: ${p.author_messagecount.toLocaleString('he-IL')}</div>` : ''} </div> </aside> `; // post meta bar (above message): #idx · date · rating const postRatingBar = (p.post_color != null || p.post_dsize != null) ? ` <span class="inline-flex items-center gap-1.5"> <span class="text-ink-600">·</span> <span class="text-xs text-ink-500">דירוג</span> <span class="inline-block w-14 h-2 rounded-full overflow-hidden rank-bar-track"> <span class="block h-full" style="width:${Math.max(0,Math.min(100,p.post_dsize ?? 0))}%;background:${p.post_color != null ? '#'+Number(p.post_color).toString(16).padStart(6,'0').toUpperCase() : '#7c5cff'}"></span> </span> </span>` : ''; const body = p.content_html ? `<div class="post-rich text-ink-200 leading-relaxed">${p.content_html}</div>` : `<div class="post-body text-ink-200 leading-relaxed">${escapeHTML(p.content || '')}</div>`; return ` <div id="p-${p.id}" class="${wrapperClass} overflow-hidden group"> <div class="flex flex-col sm:flex-row"> ${userColumn} <div class="min-w-0 flex-1 p-4"> <div class="flex items-center gap-2 text-xs text-ink-500 mb-3 pb-2 border-b border-white/5 flex-wrap"> <span class="font-mono text-ink-300">#${p.idx ?? '?'}</span> <span class="text-ink-700">·</span> <span class="font-mono">${date}</span> ${postRatingBar} <!-- star + copy pinned to the visual-left edge of the meta row (mr-auto in an RTL flex row pushes the item toward inline- end = visual-left). Matches the controls' placement in other UI surfaces. --> <span class="mr-auto flex items-center gap-1"> ${starButton('post', p.id)} ${copyLinkButton('post', p.id, 'העתק קישור להודעה')} </span> </div> ${body} </div> </div> </div> `; } // ---------- url state ---------- // Track the last URL we pushed so we can decide push-vs-replace heuristically: // the search box mutates the URL on every debounced keystroke — those should // collapse into a single history entry — but distinct filter/scope changes // (and modal open/close) each get their own entry so back/forward steps // through them one at a time. let _lastPushedURL = location.href; // While replaying a popstate event, suppress pushURL — otherwise the // re-render side-effects would push redundant entries on top of the entry // the user just navigated to. let _replayingHistory = false; function pushURL() { if (_replayingHistory) return; pushURL._impl(); } pushURL._impl = function _pushURLImpl() { const u = new URL(location.href); u.search = ''; if (state.q) u.searchParams.set('q', state.q); if (state.scope !== 'posts') u.searchParams.set('scope', state.scope); if (state.forum) u.searchParams.set('forum', state.forum); if (state.author) { u.searchParams.set('author', state.author); u.searchParams.set('author_nick', state.authorNick); } if (state.dateFrom) u.searchParams.set('from', state.dateFrom); if (state.dateTo) u.searchParams.set('to', state.dateTo); if (state.sort !== 'newest') u.searchParams.set('sort', state.sort); if (state.offset) u.searchParams.set('offset', state.offset); if (state.browseAll && !hasAnyFilter()) u.searchParams.set('browse', '1'); if (state.openItem) u.searchParams.set('open', `${state.openItem[0]}:${state.openItem[1]}`); const newURL = u.toString(); if (newURL === location.href) return; // Heuristic: if only the q param changed compared to the last pushed URL, // assume this is a typing-debounced search and just overwrite the current // entry instead of creating a new one for each keystroke session. const cmp = (urlA, urlB) => { try { const a = new URL(urlA).searchParams, b = new URL(urlB).searchParams; const ka = [...a.keys()].filter(k => k !== 'q').sort(); const kb = [...b.keys()].filter(k => k !== 'q').sort(); if (ka.length !== kb.length || ka.some((k,i) => k !== kb[i])) return false; return ka.every(k => a.get(k) === b.get(k)); } catch { return false; } }; if (cmp(newURL, _lastPushedURL)) { history.replaceState(null, '', u); } else { history.pushState(null, '', u); } _lastPushedURL = newURL; } function syncFromURL() { const p = new URL(location.href).searchParams; state.q = p.get('q') || ''; state.scope = p.get('scope') === 'threads' ? 'threads' : 'posts'; state.forum = p.get('forum') || ''; state.author = p.get('author') || ''; state.authorNick = p.get('author_nick') || ''; state.dateFrom = p.get('from') || ''; state.dateTo = p.get('to') || ''; state.sort = p.get('sort') || 'newest'; state.offset = parseInt(p.get('offset') || '0', 10) || 0; state.browseAll = p.get('browse') === '1'; $('#q').value = state.q; $('#date-from').value = state.dateFrom; $('#date-to').value = state.dateTo; $('#author-q').value = state.authorNick; $('#author').value = state.author; updateAuthorClear(); } function escapeHTML(s) { return String(s).replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c])); } init(); </script> </body> </html>
<!doctype html>
<html lang="he" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<title>Gamer Forums Archive</title>
<!--OG_TAGS-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Heebo', 'ui-sans-serif', 'system-ui'],
mono: ['JetBrains Mono', 'ui-monospace', 'monospace'],
},
colors: {
ink: {
// Dark-mode foreground tones (50-500). 300/400/500 brightened
// ~+15 over the original muted look for better legibility.
50:'#f7f7f8',100:'#ececef',200:'#d8d8e0',300:'#c4c4d0',
400:'#9a9aa8',500:'#787886',
// Surface/background tones (600-950). Untouched — these define
// the dark theme's layered card hierarchy.
600:'#48485a',700:'#363645',
800:'#272735',850:'#1d1d28',900:'#13131c',950:'#0a0a12',
},
accent: {
DEFAULT: '#7c5cff', soft: '#a591ff', glow: '#9a7bff',
}
},
boxShadow: {
'glow-sm': '0 0 0 1px rgba(124,92,255,0.35), 0 8px 24px -8px rgba(124,92,255,0.25)',
'float': '0 30px 80px -20px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.06)',
}
}
}
}
</script>
<style>
html { color-scheme: dark; }
/* Hard bound: nothing — long URLs, oversized post images, code blocks,
any single CJK/long-word — may horizontally escape the viewport.
Mobile especially: page scroll must only ever be vertical. */
html, body { overflow-x: hidden; max-width: 100vw; }
body {
background:
radial-gradient(1200px 600px at 15% -10%, rgba(124,92,255,0.10), transparent 60%),
radial-gradient(1000px 500px at 90% 110%, rgba(80,140,255,0.07), transparent 60%),
#0a0a12;
}
/* Force every image inside post bodies (rich HTML from baked content
OR rendered preview snippets) to fit. Some original posts embed
huge screenshots that would otherwise blow out the layout. */
.post-rich img,
.post-body img,
#modal-body img { max-width: 100%; height: auto; }
/* Break long URLs and unbroken strings inside post text. */
.post-rich, .post-body, #modal-body p,
#modal-body div, #modal-body span { overflow-wrap: anywhere; }
/* `.hover-fade` = invisible until parent .group is hovered, but only on
devices with hover support (desktop). Touch devices keep it visible. */
@media (hover: hover) and (pointer: fine) {
.hover-fade { opacity: 0; transition: opacity 120ms; }
.group:hover .hover-fade { opacity: 1; }
}
/* Sticky-actions / collapsible-title pattern for the modal: once the
user starts scrolling the post/thread body, the title row folds away
so the action buttons (which stay) get a bigger reading area. The
header re-appears as soon as scroll returns to the top.
max-height upper bound is set via the --modal-header-h CSS var
(measured in JS on modal open) so the transition covers ONLY the
actual header range — not a generous 200px guess that wastes most
of the animation budget on invisible space. */
#modal-header {
transition:
max-height 180ms cubic-bezier(0.22, 0.61, 0.36, 1),
opacity 120ms ease-out,
padding-top 180ms cubic-bezier(0.22, 0.61, 0.36, 1),
padding-bottom 180ms cubic-bezier(0.22, 0.61, 0.36, 1),
border-color 120ms ease-out;
max-height: var(--modal-header-h, 120px);
overflow: hidden;
will-change: max-height, opacity;
}
#modal.header-collapsed #modal-header {
max-height: 0;
opacity: 0;
padding-top: 0;
padding-bottom: 0;
border-bottom-color: transparent;
}
/* font-size scale via body[data-font] */
body[data-font="s"] { --post-fs: 12px; --meta-fs: 10px; }
body[data-font="m"], body:not([data-font]) { --post-fs: 14px; --meta-fs: 12px; }