| HTML |
|---|
<link<h1 hrefstyle="https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v30.1.0/dist/font-face.css" rel="stylesheet" type="text/css" /> <style> @font-face { font-family: "IRANSans"; src: url("/download/attachments/85045416/IRANSansXVF.woff2") format("woff2"); } @font-face { font-family: "Vazir"; src: url("/download/attachments/85045416/Vazir-Regular.woff2") format("woff2"); } /* ============================================ پسزمینهی اصلی صفحه ============================================ */ body { background: radial-gradient(circle at 20% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 40%), radial-gradient(circle at 80% 60%, rgba(236, 72, 153, 0.06) 0%, transparent 40%), radial-gradient(circle at 50% 100%, rgba(59, 130, 246, 0.05) 0%, transparent 50%), #fafbff; min-height: 100vh; background-attachment: fixed; } /* ============================================ هدر زیبا با گرادیانت ============================================ */ .library-hero { max-width: 1100px; margin: 0 auto 25px; padding: 0 20px; } .hero-inner { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 35%, #ec4899 75%, #f43f5e 100%); border-radius: 28px; padding: 50px 40px; text-align: center; position: relative; overflow: hidden; box-shadow: 0 25px 50px -12px rgba(99, 102, 241, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset; } .hero-inner::before { content: ''; position: absolute; top: -50%; right: -20%; width: 500px; height: 500px; background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%); border-radius: 50%; animation: float 8s ease-in-out infinite; } .hero-inner::after { content: ''; position: absolute; bottom: -30%; left: -10%; width: 400px; height: 400px; background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%); border-radius: 50%; animation: float 10s ease-in-out infinite reverse; } @keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-20px, 20px) scale(1.05); } } .hero-content { position: relative; z-index: 2; } .hero-title { font-family: Vazir, Tahoma, sans-serif; font-size: 38px; font-weight: 800; color: #fff; margin: 0; text-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); letter-spacing: -0.5px; display: flex; align-items: center; justify-content: center; gap: 15px; } .hero-title-icon { font-size: 42px; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.2)); animation: bounce 2s ease-in-out infinite; display: inline-block; } @keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } } .hero-subtitle { font-family: Vazir, Tahoma, sans-serif; font-size: 15px; color: rgba(255, 255, 255, 0.95); margin: 14px 0 0; font-weight: 400; letter-spacing: 0.3px; } .hero-stats { display: flex; justify-content: center; gap: 30px; margin-top: 20px; flex-wrap: wrap; } .hero-stat { background: rgba(255, 255, 255, 0.18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.25); padding: 8px 20px; border-radius: 999px; font-family: Vazir, Tahoma, sans-serif; font-size: 13px; color: #fff; display: flex; align-items: center; gap: 6px; } /* ============================================ نوار جستجوی پیشرفته ============================================ */ #book-toolbar { width: 100%; max-width: 700px; margin: 0 auto 30px; padding: 0 20px; display: flex; justify-content: center; align-items: center; direction: rtl; } .search-wrapper { position: relative; width: 100%; } #book-search { width: 100%; height: 54px; padding: 0 60px 0 50px; border-radius: 999px; border: 2px solid transparent; background: #fff; font-family: Vazir, Tahoma, sans-serif; font-size: 14px; color: #2d3748; outline: none; box-shadow: 0 10px 40px rgba(99, 102, 241, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(99, 102, 241, 0.08); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); } #book-search::placeholder { color: #a0aec0; font-weight: 400; } #book-search:hover { box-shadow: 0 15px 50px rgba(99, 102, 241, 0.18), 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(99, 102, 241, 0.12); } #book-search:focus { border-color: #8b5cf6; box-shadow: 0 20px 60px rgba(139, 92, 246, 0.25), 0 0 0 4px rgba(139, 92, 246, 0.1); transform: translateY(-2px); } .search-icon { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: #8b5cf6; pointer-events: none; transition: transform 0.3s ease; } #book-search:focus + .search-icon { transform: translateY(-50%) scale(1.1); } .search-clear { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 50%; background: #f1f5f9; border: none; cursor: pointer; display: none; align-items: center; justify-content: center; color: #64748b; font-size: 14px; transition: all 0.2s ease; } .search-clear:hover { background: #e2e8f0; color: #1e293b; } .search-clear.visible { display: flex; } /* ============================================ گرید کتابها ============================================ */ #book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 0 40px 60px; direction: rtl; width: 100%; max-width: 1200px; margin: 0 auto; font-family: Vazir, Tahoma, sans-serif; } /* ============================================ کارت کتاب - طراحی مدرن ============================================ */ .card { background: #fff; border-radius: 22px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 10px 30px -5px rgba(99, 102, 241, 0.08); padding: 20px; min-height: 220px; display: flex; align-items: flex-start; justify-content: space-between; flex-direction: row-reverse; font-family: Vazir, Tahoma, sans-serif; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); position: relative; overflow: hidden; border: 1px solid rgba(99, 102, 241, 0.06); animation: cardEnter 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards; } @keyframes cardEnter { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } } /* خط رنگی بالای کارت */ .card::before { content: ''; position: absolute; top: 0; right: 0; left: 0; height: 4px; background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899); opacity: 0; transition: opacity 0.3s ease; } .card::after { content: ''; position: absolute; top: -50%; right: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(139, 92, 246, 0.04) 0%, transparent 50%); opacity: 0; transition: opacity 0.4s ease; pointer-events: none; } .card:hover { transform: translateY(-8px); box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.2), 0 10px 20px -5px rgba(0, 0, 0, 0.08); border-color: rgba(139, 92, 246, 0.2); } .card:hover::before { opacity: 1; } .card:hover::after { opacity: 1; } .card:hover .card-icon { background: linear-gradient(135deg, #ede9fe, #fce7f3); transform: rotate(-5deg) scale(1.05); } .card:hover .card-icon img { transform: scale(1.1); } .card:hover .download-btn { background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4); } /* ============================================ محتوای کارت ============================================ */ .card-content { flex: 1; min-width: 0; text-align: right; padding-right: 15px; direction: rtl; display: flex; flex-direction: column; } .card-content h3 { margin: 0 0 12px; font-family: Vazir, Tahoma, sans-serif; font-size: 15px; line-height: 1.65; font-weight: 700; color: #1e293b; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 50px; } .card-content .dot-line { font-family: Vazir, Tahoma, sans-serif; font-size: 12.5px; line-height: 1.9; color: #64748b; margin: 2px 0; word-break: break-word; display: flex; align-items: center; gap: 5px; } .card-content .dot-line::before { content: ''; width: 4px; height: 4px; background: #cbd5e1; border-radius: 50%; flex-shrink: 0; } .card-meta { margin-top: auto; padding-top: 10px; } /* ============================================ آیکون / تصویر کتاب ============================================ */ .card-icon { flex: 0 0 80px; width: 80px; height: 96px; background: linear-gradient(135deg, #f8fafc, #f1f5f9); border-radius: 16px; padding: 10px; display: flex; align-items: center; justify-content: center; margin-top: 0; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); position: relative; } .card-icon::before { content: ''; position: absolute; inset: 0; border-radius: 16px; border: 1px solid rgba(99, 102, 241, 0.08); } .card-icon img { width: 60px; height: 60px; object-fit: contain; display: block; transition: transform 0.4s ease; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08)); } /* ============================================ دکمهی دانلود ============================================ */ .download-btn { display: inline-flex; align-items: center; gap: 6px; background: linear-gradient(135deg, #08a9c5, #0891b2); color: #fff !important; border: none; border-radius: 25px; padding: 7px 18px; font-family: Vazir, Tahoma, sans-serif; font-size: 12px; font-weight: 500; line-height: 1.5; text-decoration: none !important; margin-top: 12px; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 4px 12px rgba(8, 169, 197, 0.25); align-self: flex-start; } .download-btn:hover { transform: translateY(-2px); background: linear-gradient(135deg, #0891b2, #0e7490) !important; box-shadow: 0 8px 20px rgba(8, 169, 197, 0.35); } .download-btn:active { transform: translateY(0); } .download-btn::before { content: '⬇'; font-size: 11px; } /* ===text-align:center; font-family:Vazir, Tahoma; color:#333;font-weight:600;"> 📚 کتابخانه </h1> <!-- نوار ابزار / جستجو --> <div id="book-toolbar" style="max-width:900px; margin:0 auto 10px; padding:0 20px; display:flex; justify-content:flex-start; align-items:center; gap:10px; direction:rtl;"> <input id="book-search" type="text" placeholder="جستجو در عنوان، حیطه، نویسنده یا سال..." style="flex:1; padding:8px 12px; border-radius:999px; border:1px solid #ddd; font-family:Vazir, Tahoma; font-size:13px; outline:none;"> </div> <div id="book-grid" style="display:grid; grid-template-columns:repeat(3, 1fr); gap:20px; padding:10px 40px 60px; direction:rtl;"></div> <style> @font-face { font-family: "IRANSans"; src: url("/download/attachments/85045416/IRANSansXVF.woff2") format("woff2"); } @font-face { font-family: "Vazir"; src: url("/download/attachments/85045416/Vazir-Regular.woff2") format("woff2"); } /* ========================================= حالتهای خالی / خطا / لودینگتنظیمات کلی ============================================ */ .state-message { grid-column: 1 / -1; text-align: center; font-family: Vazir, Tahoma, sans-serif !important; padding: 60px 30px !important; border-radius: 22px !important; animation: fadeIn 0.4s ease; } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .state-empty { background: linear-gradient(135deg, #fafbff, #f5f3ff) !important; border: 2px dashed #d8b4fe !important; color: #6b7280 !important; } .state-empty-icon { font-size: 56px; margin-bottom: 15px; display: block; opacity: 0.6; } .state-empty-title { font-size: 16px; font-weight: 600; color: #4b5563; margin-bottom: 6px; } .state-empty-sub { font-size: 13px; color: #9ca3af; } .state-error { background: linear-gradient(135deg, #fef2f2, #fee2e2) !important; border: 2px dashed #fca5a5 !important; color: #b91c1c !important; } .state-loading { background: #fff !important; border: 1px solid rgba(99, 102, 241, 0.1) !important; } .loading-spinner { width: 50px; height: 50px; margin: 0 auto 15px; border: 4px solid #f3f4f6; border-top: 4px solid #8b5cf6; border-right: 4px solid #ec4899; border-radius: 50%; animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } /* =========== #book-grid, #book-toolbar, #book-grid * , #book-toolbar * { box-sizing: border-box; } #book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding: 10px 40px 60px; direction: rtl; width: 100%; font-family: Vazir, Tahoma, sans-serif; } /* ========================= نوار جستجو ========================= */ #book-toolbar { width: 100%; max-width: 940px; margin: 0 auto 10px; padding: 0 20px; display: flex; justify-content: center; align-items: center; direction: rtl; } #book-search { width: 100%; height: 40px; padding: 8px 18px; border-radius: 999px; border: 1px solid #dedede; background: #fff; font-family: Vazir, Tahoma, sans-serif; font-size: 13px; color: #444; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; } #book-search::placeholder { color: #999; } #book-search:focus { border-color: #cfcfcf; box-shadow: 0 0 0 3px rgba(180, 0, 116, 0.05); } /* ================================= کارت ریسپانسیو ==================کتاب ========================== */ @media (max-width: 1100px) { #book-grid.card { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-left: 25px; padding-right: 25px; gap: 20px; } .hero-inner { padding: 40px 30px; } .hero-title { font-size: 32px; } } @media (max-width: 700px) { #book-toolbar { padding: 0 15px; margin-bottom: 20px; } #book-search { height: 48px; font-size: 13px; padding: 0 50px 0 45px; } .search-icon { right: 18px; width: 18px; height: 18px; } #book-grid { grid-template-columns: 1fr; padding: 0 15px 40px; gap: 16px; } .card { min-height: auto; padding: 16px; } .hero-inner { padding: 35px 20px; border-radius: 22px; } .hero-title { font-size: 26px; gap: 10px; } .hero-title-icon { font-size: 32px; } .hero-subtitle { font-size: 13px; } .hero-stats { gap: 10px; } .hero-stat { font-size: 12px; padding: 6px 14px; } } @media (max-width: 400px) { .card { padding: 14px; } .card-icon { flex: 0 0 70px; width: 70px; height: 84px; } .card-icon img { width: 50px; height: 50px; } .card-content h3 { font-size: 14px; } } </style> <!-- ==============background: #fff; border-radius: 18px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08); padding: 16px; min-height: 216px; display: flex; align-items: flex-start; justify-content: space-between; flex-direction: row-reverse; font-family: Vazir, Tahoma, sans-serif; transition: transform 0.2s ease, box-shadow 0.2s ease; } /* افکت بسیار ملایم هنگام رفتن موس روی کارت */ .card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.10); } /* ========================= بخش متن کارت ========================= */ .card-content { flex: 1; min-width: 0; text-align: right; padding-right: 15px; direction: rtl; } /* عنوان */ .card-content h3 { margin: 0 0 8px; font-family: Vazir, Tahoma, sans-serif; font-size: 14px; line-height: 1.65; font-weight: 700; color: #222; } /* خطوط اطلاعات */ .card-content .dot-line { font-family: Vazir, Tahoma, sans-serif; font-size: 12.5px; line-height: 1.8; color: #555; margin: 1px 0; word-break: break-word; } /* ============================== HTML ====================تصویر کتاب ======================== --> <!-- هدر زیبا --> <div class="library-hero"> <div class="hero-inner"> <div class="hero-content"> <h1 class="hero-title"> <span class="hero-title-icon">📚</span> <span>کتابخانه</span> </h1> <p class="hero-subtitle">دروازهای به دنیای دانش و مطالعه</p> <div class="hero-stats" id="hero-stats"></div> </div> </div> </div> <!-- نوار جستجو --> <div id="book-toolbar"> <div class="search-wrapper"> <input id="book-search" type="text" placeholder="جستجو در عنوان، حیطه، نویسنده یا سال..." autocomplete="off"> <svg class="search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="11" cy="11" r="8"/> <line x1="21" y1="21" x2="16.65" y2="16.65"/> </svg> <button class="search-clear" id="search-clear" type="button" aria-label="پاک کردن جستجو">✕</button> </div> </div> <div id="book-grid"></div> <script> (() => { /* ===== تنظیمات */ .card-icon { flex: 0 0 88px; width: 88px; height: 100px; background: #f7f7f7; border-radius: 16px; padding: 10px; display: flex; align-items: center; justify-content: center; margin-top: 0; } .card-icon img { width: 72px; height: 72px; object-fit: contain; display: block; } /* ========================= دکمه دانلود ========================= */ .download-btn { display: inline-block; background: #08a9c5; color: #fff !important; border: none; border-radius: 25px; padding: 5px 16px; min-width: 54px; text-align: center; font-family: Vazir, Tahoma, sans-serif; font-size: 11px; line-height: 1.5; text-decoration: none !important; margin-top: 8px; cursor: pointer; transition: background 0.2s ease, transform 0.2s ease; } .download-btn:hover { background: #0797af; transform: translateY(-1px); } /* ========================= پیامهای خالی / خطا ========================= */ #book-grid const LIB_ID = "nikan-west-library"; const FORCED_DATA_PAGE_ID = 85045416; const JSON_FILE_NAME = `library-${LIB_ID}.json`; > div[style*="grid-column"] { font-family: Vazir, Tahoma, sans-serif !important; border-radius: 18px !important; } /* =================== */ ====== function detectBase(){ try{ if (window.AJS && typeof AJS.contextPath==="function") return AJS.contextPath(); }catch(e){} const meta = document.querySelector('meta[name="ajs-context-path"]')?.content; if (meta) return metaتبلت ========================= */ @media (max-width: 1100px) { #book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-left: 25px; const m = location.pathname.match(/^(.*)\/(pages|display|download)\//); if (m) return m; return ''; } const BASE = detectBase(); const DATA_PAGE_ID = FORCED_DATA_PAGE_ID; const ENDPOINT_ATTACH_LIST = `${BASE}/rest/api/content/${DATA_PAGE_ID}/child/attachment`; const grid padding-right: 25px; gap: 18px; } } /* ========================= موبایل ========================= */ @media (max-width: 700px) { #book-toolbar { padding: 0 15px; } #book-grid { grid-template-columns: 1fr; padding: 10px = document.getElementById("book-grid");15px 40px; const searchInput = document.getElementById("book-search"); const searchClear = document.getElementById("search-clear"); const heroStats = document.getElementById("hero-stats"); let allBooks = []; /* ---------- نمایش لودینگ ----------gap: 15px; } .card { min-height: auto; } } </style> <script> (() => { /* ===== تنظیمات ===== */ function showLoading(){ const LIB_ID grid.innerHTML = ` <div class= "statenikan-message statewest-loadinglibrary"> ; // با <div class="loading-spinner"></div> صفحه ثبت یکی باشد const FORCED_DATA_PAGE_ID = 85045416; <div style="color:#6b7280; font-size:14px;">در حال بارگذاری کتابها...</div> </div>`; } /* ---------- آمار هدر ---------- */ function updateHeroStats(count // صفحهی فرم ثبت / ریشه دیتا const JSON_FILE_NAME = `library-${LIB_ID}.json`; /* =================== */ // تشخیص BASE (context path) function detectBase(){ try{ if (!heroStats) return; heroStats.innerHTML = ` <div class="hero-stat">📖 ${count} کتاب</div>window.AJS && typeof AJS.contextPath==="function") return AJS.contextPath(); }catch(e){} const meta <div class="hero-stat">✨ بروزرسانی شده</div> `= document.querySelector('meta[name="ajs-context-path"]')?.content; if (meta) return meta; } /* ---------- ساخت کارت ---------- */ function createBookCard(book, index){const m = location.pathname.match(/^(.*)\/(pages|display|download)\//); const authorsBlock =if (book.authors && book.authors.length)m) return m[1]; ? book.authors.map(a => `<div class="dot-line">${a}</div>`).join("") : `<div class="dot-line">بدون نویسنده</div>`; return ''; } const BASE const card = document.createElement("div"detectBase(); const card.className = "card"; card.style.animationDelay = `${Math.min(index * 0.05, 0.6)}s`; card.innerHTML = ` DATA_PAGE_ID = FORCED_DATA_PAGE_ID; // چون میدانیم دیتا روی صفحهی فرم ثبت است const ENDPOINT_ATTACH_LIST = `${BASE}/rest/api/content/${DATA_PAGE_ID}/child/attachment`; const grid <div class="card-content">= document.getElementById("book-grid"); const searchInput <h3>${book.title || "-"}</h3>= document.getElementById("book-search"); let allBooks <div class="dot-line">${book.category || "بدون دسته"}</div>= []; function createBookCard(book){ const authorsBlock = ${authorsBlock}(book.authors && book.authors.length) ? <div book.authors.map(a=>`<div class="dot-line">${book.year || "نامشخص"}</div>>• ${a}</div>`).join("") : <div`<div class="carddot-metaline"> >• بدون نویسنده</div>`; const card = ${book.fileUrl ? `<a href="${book.fileUrl}" target="_blank" rel="noopener" class="download-btn">دانلود</a>` : ""} document.createElement("div"); card.className = "card"; card.innerHTML = ` </div> <div class="card-content"> </div> <div class="card-icon"><h3>${book.title || "-"}</h3> <img<div srcclass="https://kb.h-soft.ir/download/thumbnails/85045416/12%20-%20Copy.png?api=v2&nonce=1787954132399" alt="کتاب" loading="lazy"> </div> `; return card; } /* ---------- رندر لیست ---------- */ function renderBooks(list){ grid.innerHTML = ""; if (!list.length){dot-line">• حیطه: ${book.category || "-"}</div> ${authorsBlock} <div class="dot-line">• تاریخ انتشار: ${book.year || "-"}</div> ${book.fileUrl ? `<a href="${book.fileUrl}" target="_blank" class="download-btn">دانلود</a>` : ""} </div> grid.innerHTML<div = `class="card-icon"> <div<img classsrc="state-message state-emptyhttps://kb.h-soft.ir/download/thumbnails/85045416/12%20-%20Copy.png?api=v2&nonce=1787954132399" alt="کتاب"> <span class="state-empty-icon">📭</span></div> `; return card; <div class="state-empty-title">کتابی پیدا نشد</div> } function renderBooks(list){ grid.innerHTML = ""; <div class="state-empty-sub">لطفاً عبارت دیگری جستجو کنید یا فیلتر را پاک کنید.</div> if (!list.length){ grid.innerHTML = ` </div>`; return; <div style="grid-column:1/-1; text-align:center; font-family:Vazir, Tahoma; color:#777; } list.forEach((b, i) => grid.appendChild(createBookCard(b, i))); } /* ---------- دریافت JSON ---------- */ async function getExistingAttachmentMeta() { background:#fafafa; border:1px dashed #e4e4e4; padding:14px; border-radius:18px;"> const urlکتابی = `${ENDPOINT_ATTACH_LIST}?filename=${encodeURIComponent(JSON_FILE_NAME)}&expand=results`; const res = await fetch(url, { credentials: "include" })با این فیلتر پیدا نشد. </div>`; if (!res.ok) return null; const data} list.forEach(b => await res.json()grid.appendChild(createBookCard(b))); } async iffunction (!data.results || !data.results.length) return null; return data.results; } async function loadJsonFromAttachment() {getExistingAttachmentMeta() { const url = `${ENDPOINT_ATTACH_LIST}?filename=${encodeURIComponent(JSON_FILE_NAME)}&expand=results`; const metares = await getExistingAttachmentMeta(fetch(url, { credentials: "include" }); if (!metares.ok) return { libId: LIB_ID, books: [] }null; const downloadLinkdata = meta._links && meta._links.downloadawait res.json(); if (!downloadLinkdata.results || !data.results.length) return { libId: LIB_ID, books: [] };null; return data.results[0]; } async function const res = await fetch(BASE + downloadLink, { credentials: "include" }loadJsonFromAttachment() { const meta = await getExistingAttachmentMeta(); if (!res.okmeta) throwreturn new Error("خطا در دانلود JSON: " + res.status); { libId: LIB_ID, books: [] }; const textdownloadLink = await res.text()meta._links && meta._links.download; if (!text.trim(downloadLink)) return { libId: LIB_ID, books: [] }; try { const parsedres = JSON.parse(text.replace(/^\uFEFF/, '').trim()); if (!parsed.books) parsed.books = []await fetch(BASE + downloadLink, { credentials: "include" }); if (!parsedres.libIdok) parsed.libIdthrow = LIB_ID; return parsednew Error("خطا در دانلود JSON: " + res.status); } catch(e) { console.error("JSON parse error:", econst text = await res.text(); if (!text.trim()) return { libId: LIB_ID, books: [] }; } } /* ---------- بارگذاری اولیه ---------- */ async function loadBooks() { showLoading(); try { const dataparsed = await loadJsonFromAttachment( JSON.parse(text.replace(/^\uFEFF/, '').trim()); allBooks = dataif (!parsed.books) parsed.books ||= []; updateHeroStats(allBooks.length)if (!parsed.libId) parsed.libId = LIB_ID; return parsed; } if (!allBooks.lengthcatch(e) { grid.innerHTML = ` <div class="state-message state-empty">console.error("JSON parse error:", e); return { libId: LIB_ID, books: <span class="state-empty-icon">📚</span>[] }; } } async function <div class="state-empty-title">کتابخانه خالی است</div>loadBooks() { try { const <divdata class="state-empty-sub">از طریق فرم ثبت، اولین کتاب را به کتابخانه اضافه کنید.</div> = await loadJsonFromAttachment(); allBooks = data.books || []; if </div>`;(!allBooks.length) { return; grid.innerHTML = ` } setTimeout(()<div => renderBooks(allBooks), 250)style="grid-column:1/-1; text-align:center; font-family:Vazir, Tahoma; color:#777; } catch (e) { console.error(e); grid.innerHTML = ` background:#fafafa; border:1px dashed #e4e4e4; <div class="state-message state-errorpadding:14px; border-radius:18px;"> <span class="state-empty-icon">⚠️</span> هنوز کتابی ثبت نشده است. <div class="state-empty-title">خطا در بارگذاری کتابها<</div>div>`; return; <div class="state-empty-sub">${e.message}</div> </div>`renderBooks(allBooks); } catch (e) { } console.error(e); /* ---------- جستجو ---------- */ function handleSearch(){ grid.innerHTML = ` const q = (searchInput.value || "").trim().toLowerCase(); <div style="grid-column:1/-1; text-align:center; font-family:Vazir, Tahoma; color:#c00; // نمایش/مخفی کردن دکمهی پاک کردن if (q) { searchClear.classList.add("visible"); } else {background:#fff5f5; border:1px dashed #f5b5b5; padding:14px; border-radius:18px;"> searchClear.classList.remove("visible"); } خطا در خواندن if (!q){کتابها: ${e.message} renderBooks(allBooks) </div>`; return; } } // سرچ روی constآرایهی allBooks filtered =function allBooks.filter(b => handleSearch(){ const title q = (b.title searchInput.value || "").trim().toLowerCase(); if (!q){ const category = (b.category || "").toLowerCase( renderBooks(allBooks); constreturn; year } = (b.year const filtered = || "").toLowerCase();allBooks.filter(b => { const authors = Array.isArray(b.authors) ? b.authors.join(" ") : title = (b.authorstitle || "").toLowerCase(); const authorsLcategory = authors(b.category || "").toLowerCase(); const haystack = `${title} ${category} ${year} ${authorsL}`; = (b.year return haystack.includes(q); || }); renderBooks(filtered"").toLowerCase(); } /* ---------- رویدادها ---------- */ let searchTimeout; searchInput.addEventListener("input", () => { clearTimeout(searchTimeout const authors = Array.isArray(b.authors) ? b.authors.join(" ") : (b.authors || ""); searchTimeout = setTimeout(handleSearch, 180); }const authorsL = authors.toLowerCase(); searchClear.addEventListener("click", () const haystack => `${ searchInput.value = ""; title} ${category} ${year} ${authorsL}`; return searchClearhaystack.classList.remove("visible"includes(q); searchInput.focus(}); renderBooks(allBooksfiltered); } searchInput.addEventListener("input", handleSearch); loadBooks(); })(); </script> |
Page History
Overview
Content Tools
Apps
Tasks