{"id":276,"date":"2025-04-25T08:09:38","date_gmt":"2025-04-25T08:09:38","guid":{"rendered":"https:\/\/fpsiyarsi.info\/?page_id=276"},"modified":"2025-09-16T02:08:31","modified_gmt":"2025-09-16T02:08:31","slug":"katalogbukuteks","status":"publish","type":"page","link":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/pendidikan\/katalogbukuteks\/","title":{"rendered":"Katalog Buku Teks"},"content":{"rendered":"\n<!-- Tambahkan kode ini ke halaman WordPress menggunakan Custom HTML block atau di theme template -->\n\n<div class=\"book-catalogue-container\">\n  <header class=\"catalogue-header\">\n    <div class=\"header-content\">\n      <h1 class=\"catalogue-title\">Katalog Buku<\/h1>\n      <div class=\"search-container\">\n  \t\t<input type=\"text\" id=\"bookSearch\" placeholder=\"Cari buku (judul atau penulis)...\">\n  \t\t<div id=\"autocomplete-list\" class=\"autocomplete-items\"><\/div>\n  \t\t<button class=\"search-button\">Cari<\/button>\n\t  <\/div>\n    <\/div>\n  <\/header>\n  \n  <div class=\"controls-container\">\n    <div class=\"filters-section\">\n      <div class=\"filter-item\">\n        <label for=\"category-filter\">Mata Kuliah:<\/label>\n        <select id=\"category-filter\">\n          <option value=\"all\">Semua Mata Kuliah<\/option>\n          <!-- Kategori akan diisi otomatis dari Google Sheet -->\n        <\/select>\n      <\/div>\n      <div class=\"filter-item\">\n        <label for=\"sort-filter\">Urutkan:<\/label>\n        <select id=\"sort-filter\">\n          <option value=\"newest\">Terbaru<\/option>\n          <option value=\"title\">Judul (A-Z)<\/option>\n          <option value=\"title-desc\">Judul (Z-A)<\/option>\n          <option value=\"author\">Penulis<\/option>\n        <\/select>\n      <\/div>\n    <\/div>\n    \n    <!-- Layout Toggle Buttons -->\n    <div class=\"layout-toggle\">\n      <button id=\"grid-view\" class=\"layout-btn active\" aria-label=\"Grid View\">\n        <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n          <rect x=\"3\" y=\"3\" width=\"7\" height=\"7\"><\/rect>\n          <rect x=\"14\" y=\"3\" width=\"7\" height=\"7\"><\/rect>\n          <rect x=\"14\" y=\"14\" width=\"7\" height=\"7\"><\/rect>\n          <rect x=\"3\" y=\"14\" width=\"7\" height=\"7\"><\/rect>\n        <\/svg>\n      <\/button>\n      <button id=\"list-view\" class=\"layout-btn\" aria-label=\"List View\">\n        <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n          <line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"><\/line>\n          <line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"><\/line>\n          <line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"><\/line>\n          <line x1=\"3\" y1=\"6\" x2=\"3.01\" y2=\"6\"><\/line>\n          <line x1=\"3\" y1=\"12\" x2=\"3.01\" y2=\"12\"><\/line>\n          <line x1=\"3\" y1=\"18\" x2=\"3.01\" y2=\"18\"><\/line>\n        <\/svg>\n      <\/button>\n    <\/div>\n  <\/div>\n  \n  <!-- Loading Indicator -->\n  <div id=\"loading-indicator\" class=\"loading-indicator\">\n    <div class=\"spinner\"><\/div>\n    <p>Memuat katalog buku&#8230;<\/p>\n  <\/div>\n  \n  <!-- Error Message -->\n  <div id=\"error-message\" class=\"error-message\" style=\"display: none;\">\n    <p>Gagal memuat data buku. Silakan coba lagi nanti.<\/p>\n    <button id=\"retry-button\" class=\"retry-button\">Coba Lagi<\/button>\n  <\/div>\n  \n  <!-- Books Container - will be filled dynamically -->\n  <div class=\"books-container grid-view\" id=\"books-container\"><\/div>\n  \n  <div class=\"pagination\" id=\"pagination\">\n    <!-- Pagination will be generated dynamically -->\n  <\/div>\n<\/div>\n\n<style>\n\/* Katalog Buku CSS *\/\n.book-catalogue-container {\n  max-width: 1200px;\n  margin: 0 auto;\n  padding: 20px;\n  font-family: 'Helvetica Neue', Arial, sans-serif;\n}\n\n.catalogue-header {\n  background-color: #f8f9fa;\n  padding: 24px;\n  margin-bottom: 30px;\n  border-radius: 8px;\n  box-shadow: 0 2px 4px rgba(0,0,0,0.05);\n}\n\n.header-content {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  flex-wrap: wrap;\n}\n\n.catalogue-title {\n  font-size: 28px;\n  color: #333;\n  margin: 0;\n}\n\n.search-container {\n  display: flex;\n  gap: 10px;\n}\n\n#bookSearch {\n  padding: 10px 15px;\n  border: 1px solid #ddd;\n  border-radius: 4px;\n  width: 250px;\n  font-size: 16px;\n}\n\n.search-button {\n  background-color: #0073aa;\n  color: white;\n  border: none;\n  border-radius: 4px;\n  padding: 10px 20px;\n  cursor: pointer;\n  font-size: 16px;\n  transition: background-color 0.3s;\n}\n\n.search-button:hover {\n  background-color: #005d8c;\n}\n\n\/* Loading Indicator *\/\n.loading-indicator {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  padding: 50px 0;\n}\n\n.spinner {\n  border: 4px solid rgba(0, 0, 0, 0.1);\n  width: 40px;\n  height: 40px;\n  border-radius: 50%;\n  border-left-color: #0073aa;\n  animation: spin 1s linear infinite;\n  margin-bottom: 20px;\n}\n\n@keyframes spin {\n  0% { transform: rotate(0deg); }\n  100% { transform: rotate(360deg); }\n}\n\n\/* Error Message *\/\n.error-message {\n  text-align: center;\n  padding: 30px;\n  background-color: #fff0f0;\n  border-radius: 8px;\n  margin: 20px 0;\n}\n\n.retry-button {\n  background-color: #0073aa;\n  color: white;\n  border: none;\n  border-radius: 4px;\n  padding: 10px 20px;\n  cursor: pointer;\n  font-size: 16px;\n  margin-top: 15px;\n}\n\n\/* Controls Container *\/\n.controls-container {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  margin-bottom: 30px;\n  flex-wrap: wrap;\n  gap: 20px;\n}\n\n.filters-section {\n  display: flex;\n  gap: 20px;\n  flex-wrap: wrap;\n}\n\n.filter-item {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n}\n\n.filter-item label {\n  font-weight: 500;\n  color: #555;\n}\n\n.filter-item select {\n  padding: 8px 12px;\n  border: 1px solid #ddd;\n  border-radius: 4px;\n  background-color: white;\n  font-size: 14px;\n}\n\n\/* Layout Toggle *\/\n.layout-toggle {\n  display: flex;\n  gap: 8px;\n  align-items: center;\n}\n\n.layout-btn {\n  background-color: #f0f0f0;\n  border: 1px solid #ddd;\n  border-radius: 4px;\n  width: 40px;\n  height: 40px;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  cursor: pointer;\n  transition: all 0.2s;\n  color: #555;\n}\n\n.layout-btn:hover {\n  background-color: #e0e0e0;\n}\n\n.layout-btn.active {\n  background-color: #0073aa;\n  color: white;\n  border-color: #0073aa;\n}\n\n\/* Books Container *\/\n.books-container {\n  margin-bottom: 40px;\n  min-height: 300px;\n}\n\n\/* Book Type - BARU *\/\n.book-type {\n  font-size: 12px;\n  color: #777;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  margin: 0 0 5px 0;\n  font-weight: 500;\n}\n\n\/* Info rows styling *\/\n.book-info-row {\n  font-size: 14px;\n  color: #666;\n  margin: 5px 0;\n  line-height: 1.4;\n}\n\n.book-info-row strong {\n  color: #444;\n  font-weight: 600;\n}\n\n\/* Grid View Styles *\/\n.books-container.grid-view {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));\n  gap: 30px;\n}\n\n.grid-view .book-item {\n  flex-direction: column;\n  border-radius: 8px;\n  overflow: hidden;\n  background-color: white;\n  box-shadow: 0 3px 8px rgba(0,0,0,0.1);\n  transition: transform 0.3s, box-shadow 0.3s;\n  height: 100%;\n  display: flex;\n}\n\n.grid-view .book-item:hover {\n  transform: translateY(-5px);\n  box-shadow: 0 5px 15px rgba(0,0,0,0.15);\n}\n\n.grid-view .book-cover {\n  height: 200px;\n  overflow: hidden;\n  background-color: #f5f5f5;\n}\n\n.grid-view .book-cover img {\n  width: 100%;\n  height: 100%;\n  object-fit: cover;\n  transition: transform 0.3s;\n}\n\n.grid-view .book-item:hover .book-cover img {\n  transform: scale(1.05);\n}\n\n.grid-view .book-info {\n  padding: 16px;\n  flex-grow: 1;\n  display: flex;\n  flex-direction: column;\n}\n\n.grid-view .book-description-full {\n  display: none; \/* Hide full description in grid view *\/\n}\n\n.grid-view .book-description-short {\n  display: block;\n  margin: 12px 0;\n  color: #666;\n  line-height: 1.4;\n  font-size: 13px;\n  display: -webkit-box;\n  -webkit-line-clamp: 2; \/* Show only 2 lines in grid view *\/\n  -webkit-box-orient: vertical;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n\/* List View Styles - UPDATED *\/\n.books-container.list-view {\n  display: flex;\n  flex-direction: column;\n  gap: 20px;\n}\n\n.list-view .book-item {\n  display: flex;\n  border-radius: 8px;\n  overflow: hidden;\n  background-color: white;\n  box-shadow: 0 3px 8px rgba(0,0,0,0.1);\n  transition: transform 0.2s, box-shadow 0.2s;\n  min-height: 220px; \/* Set minimum height for consistency *\/\n}\n\n.list-view .book-item:hover {\n  transform: translateY(-3px);\n  box-shadow: 0 5px 15px rgba(0,0,0,0.15);\n}\n\n.list-view .book-cover {\n  flex: 0 0 290px; \/* Fixed width for cover *\/\n  background-color: #f5f5f5;\n}\n\n.list-view .book-cover img {\n  width: 100%;\n  height: 100%;\n  object-fit: cover;\n  object-position: center;\n}\n\n.list-view .book-info {\n  flex: 1;\n  padding: 20px;\n  display: flex;\n  flex-direction: column;\n}\n\n.list-view .book-description-short {\n  display: none; \/* Hide short description in list view *\/\n}\n\n.list-view .book-description-full {\n  display: block;\n  margin: 12px 0;\n  color: #666;\n  line-height: 1.5;\n  font-size: 14px;\n  flex-grow: 1;\n  display: -webkit-box;\n  -webkit-line-clamp: 4; \/* Show up to 4 lines in list view *\/\n  -webkit-box-orient: vertical;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n\/* Common Book Item Styles *\/\n.book-title {\n  font-size: 18px;\n  margin: 0 0 8px 0;\n  color: #333;\n  line-height: 1.3;\n}\n\n.book-author {\n  font-size: 14px;\n  color: #666;\n  margin: 0 0 12px 0;\n}\n\n.book-link {\n  display: inline-block;\n  color: #0073aa;\n  text-decoration: none;\n  font-weight: 500;\n  font-size: 14px;\n  padding: 5px 0;\n  border-bottom: 2px solid transparent;\n  transition: border-color 0.2s;\n  margin-top: auto;\n}\n\n.book-link:hover {\n  border-color: #0073aa;\n}\n\n.pagination {\n  display: flex;\n  justify-content: center;\n  gap: 8px;\n  margin-top: 30px;\n}\n\n.page-link {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  width: 40px;\n  height: 40px;\n  border-radius: 50%;\n  background-color: white;\n  color: #333;\n  text-decoration: none;\n  font-weight: 500;\n  box-shadow: 0 2px 5px rgba(0,0,0,0.1);\n  transition: all 0.2s;\n  cursor: pointer;\n}\n\n.page-link:hover {\n  background-color: #f5f5f5;\n}\n\n.page-link.active {\n  background-color: #0073aa;\n  color: white;\n}\n\n.page-link.next, .page-link.prev {\n  width: auto;\n  padding: 0 15px;\n  border-radius: 20px;\n}\n\n\/* No Results Message *\/\n.no-results {\n  text-align: center;\n  padding: 40px 20px;\n  font-size: 16px;\n  color: #666;\n}\n\n\/* Responsif *\/\n@media (max-width: 768px) {\n  .header-content {\n    flex-direction: column;\n    align-items: flex-start;\n    gap: 15px;\n  }\n  \n  .search-container {\n    width: 100%;\n  }\n  \n  #bookSearch {\n    flex-grow: 1;\n  }\n  \n  .controls-container {\n    flex-direction: column;\n    align-items: flex-start;\n  }\n  \n  .layout-toggle {\n    margin-top: 10px;\n  }\n  \n  .list-view .book-item {\n    flex-direction: column;\n  }\n  \n  .list-view .book-cover {\n    height: 220px; \/* Fixed height on mobile *\/\n    flex: auto;\n    width: 100%;\n  }\n}\n\n@media (max-width: 480px) {\n  .filters-section {\n    flex-direction: column;\n    gap: 15px;\n  }\n  \n  .books-container.grid-view {\n    grid-template-columns: 1fr;\n  }\n}\n\n\/* Autocomplete Styles FINAL *\/\n.autocomplete-items {\n  position: absolute;\n  background: white;\n  border: 1px solid #ddd;\n  border-top: none;\n  max-height: 250px;\n  overflow-y: auto;\n  width: 100%;\n  z-index: 1000;\n  margin-top: 2px;\n  border-radius: 0 0 8px 8px;\n  box-shadow: 0 2px 5px rgba(0,0,0,0.1);\n}\n\n.autocomplete-item {\n  padding: 10px 15px;\n  cursor: pointer;\n  border-bottom: 1px solid #eee;\n  font-size: 14px;\n  color: #333;\n  background: white;\n}\n\n.autocomplete-item:hover, .autocomplete-active {\n  background-color: #0073aa;\n  color: white;\n}\n\n.highlight-match {\n  background-color: yellow;\n  font-weight: bold;\n}\n\n@media (max-width: 480px) {\n  .autocomplete-items {\n    max-height: 200px;\n    font-size: 13px;\n  }\n}\n<\/style>\n\n<script>\ndocument.addEventListener('DOMContentLoaded', function() {\n  \/\/ CONFIG - GANTI URL DENGAN GOOGLE SHEETS ANDA\n  const GOOGLE_SHEET_URL = 'https:\/\/docs.google.com\/spreadsheets\/d\/e\/2PACX-1vSnDpA40sttcFKTe52J4aInZdNvTH3iyb66fYZrQeBRTDFkaJUWZqsL3u7EhtA3idHjSZJrxhDzIHGq\/pub?output=csv';\n  \n  \/\/ Elemen DOM\n  const booksContainer = document.getElementById('books-container');\n  const loadingIndicator = document.getElementById('loading-indicator');\n  const errorMessage = document.getElementById('error-message');\n  const retryButton = document.getElementById('retry-button');\n  const categoryFilter = document.getElementById('category-filter');\n  const sortFilter = document.getElementById('sort-filter');\n  const searchInput = document.getElementById('bookSearch');\n  const searchButton = document.querySelector('.search-button');\n  const paginationContainer = document.getElementById('pagination');\n  const gridBtn = document.getElementById('grid-view');\n  const listBtn = document.getElementById('list-view');\n  \n  \/\/ Variabel state\n  let allBooks = [];\n  let filteredBooks = [];\n  let categories = new Set();\n  let currentPage = 1;\n  const booksPerPage = 15;\n  \n  \/\/ Set default layout to 'list-view' on page load\n  booksContainer.classList.remove('grid-view');\n  booksContainer.classList.add('list-view');\n  listBtn.classList.add('active');\n  gridBtn.classList.remove('active');\n\n  \/\/ Layout toggle functionality\n  gridBtn.addEventListener('click', function() {\n    booksContainer.classList.remove('list-view');\n    booksContainer.classList.add('grid-view');\n    gridBtn.classList.add('active');\n    listBtn.classList.remove('active');\n    localStorage.setItem('bookLayout', 'grid');\n  });\n  \n  listBtn.addEventListener('click', function() {\n    booksContainer.classList.remove('grid-view');\n    booksContainer.classList.add('list-view');\n    listBtn.classList.add('active');\n    gridBtn.classList.remove('active');\n    localStorage.setItem('bookLayout', 'list');\n  });\n  \n  \/\/ Check if user has a saved preference\n  const savedLayout = localStorage.getItem('bookLayout');\n  if (savedLayout === 'list') {\n    booksContainer.classList.remove('grid-view');\n    booksContainer.classList.add('list-view');\n    listBtn.classList.add('active');\n    gridBtn.classList.remove('active');\n  }\n  \n  \/\/ Fungsi untuk mengambil data dari Google Sheets\n  async function fetchBooksFromGoogleSheets() {\n    try {\n      loadingIndicator.style.display = 'flex';\n      errorMessage.style.display = 'none';\n      booksContainer.innerHTML = '';\n      \n      const response = await fetch(GOOGLE_SHEET_URL);\n      if (!response.ok) {\n        throw new Error('Gagal mengambil data');\n      }\n      \n      const csvData = await response.text();\n      const books = parseCSV(csvData);\n      \n      \/\/ Process data\n      allBooks = books;\n      processCategories(books);\n      filteredBooks = [...books];\n      \n      \/\/ Display books\n      currentPage = 1;\n      displayBooks(books);\n      setupPagination(books);\n      \n      loadingIndicator.style.display = 'none';\n    } catch (error) {\n      console.error('Error fetching data:', error);\n      loadingIndicator.style.display = 'none';\n      errorMessage.style.display = 'block';\n    }\n  }\n  \n  \/\/ Parse CSV to JSON\n  function parseCSV(csvText) {\n    const lines = csvText.split('\\n');\n    const headers = lines[0].split(',').map(header => header.trim());\n    \n    return lines.slice(1).map(line => {\n      if (!line.trim()) return null; \/\/ Skip empty lines\n      \n      \/\/ Handle commas within quoted fields\n      const values = [];\n      let currentValue = '';\n      let insideQuotes = false;\n      \n      for (let char of line) {\n        if (char === '\"') {\n          insideQuotes = !insideQuotes;\n        } else if (char === ',' && !insideQuotes) {\n          values.push(currentValue);\n          currentValue = '';\n        } else {\n          currentValue += char;\n        }\n      }\n      \n      values.push(currentValue); \/\/ Add the last value\n      \n      \/\/ Create object from headers and values\n      const bookData = {};\n      headers.forEach((header, index) => {\n        \/\/ Clean up values from potential quotes\n        const value = values[index] ? values[index].replace(\/^\"(.*)\"$\/, '$1').trim() : '';\n        bookData[header] = value;\n      });\n      \n      return bookData;\n    }).filter(book => book !== null); \/\/ Remove empty entries\n  }\n  \n  \/\/ Process categories for filter - Updated for multiple categories\n  function processCategories(books) {\n    categories = new Set();\n    books.forEach(book => {\n      if (book.category) {\n        book.category.split('|').forEach(cat => {\n          const trimmedCat = cat.trim();\n          if (trimmedCat) categories.add(trimmedCat);\n        });\n      }\n    });\n    \n    \/\/ Populate category filter\n    categoryFilter.innerHTML = '<option value=\"all\">Semua Mata Kuliah<\/option>';\n    Array.from(categories).sort().forEach(category => {\n      const option = document.createElement('option');\n      option.value = category.toLowerCase();\n      option.textContent = category;\n      categoryFilter.appendChild(option);\n    });\n  }\n  \n  \/\/ Format tanggal publikasi\n  function formatDate(dateString) {\n    if (!dateString) return '';\n    \n    try {\n      const date = new Date(dateString);\n      \/\/ Periksa apakah tanggal valid\n      if (isNaN(date.getTime())) return dateString;\n      \n      \/\/ Format tanggal: DD-MM-YYYY\n      return date.toLocaleDateString('id-ID', {\n        day: '2-digit',\n        month: '2-digit',\n        year: 'numeric'\n      });\n    } catch (error) {\n      return dateString; \/\/ Kembalikan string asli jika ada kesalahan\n    }\n  }\n  \n  \/\/ Display books with pagination - Updated with new fields\n  \/\/ Display books with pagination - Updated with Publisher and ISBN\/ISSN fields\nfunction displayBooks(books) {\n  booksContainer.innerHTML = '';\n  \n  if (books.length === 0) {\n    booksContainer.innerHTML = '<div class=\"no-results\">Tidak ada buku yang cocok dengan kriteria pencarian<\/div>';\n    paginationContainer.innerHTML = '';\n    return;\n  }\n  \n  \/\/ Calculate page range\n  const startIndex = (currentPage - 1) * booksPerPage;\n  const endIndex = Math.min(startIndex + booksPerPage, books.length);\n  const booksToShow = books.slice(startIndex, endIndex);\n  \n  \/\/ Create book elements\n  booksToShow.forEach(book => {\n    const bookElement = document.createElement('div');\n    bookElement.className = 'book-item';\n    \n    \/\/ Format tanggal publikasi\n    const formattedDate = formatDate(book.publishDate);\n    \n    \/\/ Persiapkan informasi meta yang berbeda untuk Book Chapter vs tipe buku lainnya\n    let metaInfo = '';\n    \n    if (book.type && book.type.toLowerCase() === 'book chapter') {\n      const bookParent = book.bookParent || 'Tidak tersedia';\n      const editor = book.editor || 'Tidak tersedia';\n      \n      metaInfo += `\n        <p class=\"book-info-row\"><strong>Judul Buku:<\/strong> ${bookParent}<\/p>\n        <p class=\"book-info-row\"><strong>Editor:<\/strong> ${editor}<\/p>\n      `;\n    }\n    \n    \/\/ Informasi Kategori\n    let categoryInfo = '';\n    if (book.category) {\n      const categories = book.category.split('|').map(cat => cat.trim()).join(', ');\n      categoryInfo = `<p class=\"book-info-row\"><strong>Mata Kuliah:<\/strong> ${categories}<\/p>`;\n    }\n    \n    \/\/ Informasi Tanggal Publikasi\n    let publishDateInfo = '';\n    if (formattedDate) {\n      publishDateInfo = `<p class=\"book-info-row\"><strong>Tanggal Publikasi:<\/strong> ${formattedDate}<\/p>`;\n    }\n\n    \/\/ Deskripsi\n    const shortDesc = book.shortDescription || (book.description?.substring(0, 100) + '...') || 'Tidak ada deskripsi tersedia.';\n    const fullDesc = book.description || 'Tidak ada deskripsi tersedia.';\n    \n    \/\/ Build inner HTML\n    bookElement.innerHTML = `\n      <div class=\"book-cover\">\n        <img decoding=\"async\" src=\"${book.coverUrl || '\/api\/placeholder\/200\/300'}\" alt=\"${book.title} Cover\">\n      <\/div>\n      <div class=\"book-info\">\n        <p class=\"book-type\">${book.type || 'Buku'}<\/p>\n        <h3 class=\"book-title\">${book.title}<\/h3>\n        <p class=\"book-author\"><strong>Penulis:<\/strong> ${book.author}<\/p>\n        \n        ${metaInfo}\n        ${categoryInfo}\n        ${publishDateInfo}\n        \n        ${book.publisher ? `<p class=\"book-info-row\"><strong>Penerbit:<\/strong> ${book.publisher}<\/p>` : ''}\n        \n        ${\n          book.isbn \n          ? `<p class=\"book-info-row\"><strong>ISBN:<\/strong> ${book.isbn}<\/p>` \n          : book.issn \n            ? `<p class=\"book-info-row\"><strong>ISSN:<\/strong> ${book.issn}<\/p>` \n            : ''\n        }\n        \n        <p class=\"book-description-short\">${shortDesc}<\/p>\n        <p class=\"book-description-full\">${fullDesc}<\/p>\n        <a href=\"${book.detailUrl || '#'}\" class=\"book-link\">Lihat Detail<\/a>\n      <\/div>\n    `;\n    \n    booksContainer.appendChild(bookElement);\n  });\n  \n  \/\/ Setup pagination\n  setupPagination(books);\n}\n\n  \n  \/\/ Setup pagination\n  function setupPagination(books) {\n    const totalPages = Math.ceil(books.length \/ booksPerPage);\n    paginationContainer.innerHTML = '';\n    \n    if (totalPages <= 1) {\n      return;\n    }\n    \n    \/\/ Add prev button if not on first page\n    if (currentPage > 1) {\n      paginationContainer.innerHTML += `\n        <a class=\"page-link prev\" data-page=\"${currentPage - 1}\">&laquo;<\/a>\n      `;\n    }\n    \n    \/\/ Add page numbers\n    for (let i = 1; i <= totalPages; i++) {\n      if (\n        i === 1 || \n        i === totalPages || \n        (i >= currentPage - 1 && i <= currentPage + 1)\n      ) {\n        paginationContainer.innerHTML += `\n          <a class=\"page-link ${i === currentPage ? 'active' : ''}\" data-page=\"${i}\">${i}<\/a>\n        `;\n      } else if (i === currentPage - 2 || i === currentPage + 2) {\n        paginationContainer.innerHTML += `<span class=\"page-ellipsis\">...<\/span>`;\n      }\n    }\n    \n    \/\/ Add next button if not on last page\n    if (currentPage < totalPages) {\n      paginationContainer.innerHTML += `\n        <a class=\"page-link next\" data-page=\"${currentPage + 1}\">&raquo;<\/a>\n      `;\n    }\n    \n    \/\/ Add click handlers\n    document.querySelectorAll('.page-link').forEach(link => {\n      link.addEventListener('click', function() {\n        currentPage = parseInt(this.getAttribute('data-page'));\n        displayBooks(filteredBooks);\n        window.scrollTo({ top: 0, behavior: 'smooth' });\n      });\n    });\n  }\n  \n  \/\/ Filter and search functionality - Updated for multiple categories\n  function applyFilters() {\n    const searchTerm = searchInput.value.toLowerCase();\n    const selectedCategory = categoryFilter.value.toLowerCase();\n    const sortOption = sortFilter.value;\n    \n    \/\/ Filter books\n    filteredBooks = allBooks.filter(book => {\n      \/\/ Category filter\n      const categoryMatch = selectedCategory === 'all' || \n                           (book.category && book.category.toLowerCase().split('|').some(cat => \n                              cat.trim().toLowerCase() === selectedCategory));\n      \n      \/\/ Search filter\n      const searchMatch = !searchTerm || \n                         (book.title && book.title.toLowerCase().includes(searchTerm)) ||\n                         (book.author && book.author.toLowerCase().split('|').some(author => author.trim().includes(searchTerm))) ||\n                         (book.description && book.description.toLowerCase().includes(searchTerm)) ||\n                         (book.type && book.type.toLowerCase().includes(searchTerm)) ||\n                         (book.category && book.category.toLowerCase().includes(searchTerm)) ||\n                         (book.bookParent && book.bookParent.toLowerCase().includes(searchTerm)) ||\n                         (book.editor && book.editor.toLowerCase().includes(searchTerm));\n      \n      return categoryMatch && searchMatch;\n    });\n    \n    \/\/ Sort books\n    filteredBooks.sort((a, b) => {\n      switch(sortOption) {\n        case 'title':\n          return a.title.localeCompare(b.title);\n        case 'title-desc':\n          return b.title.localeCompare(a.title);\n        case 'author':\n          return a.author.localeCompare(b.author);\n        case 'newest':\n        default:\n          return (b.publishDate || '').localeCompare(a.publishDate || '');\n      }\n    });\n    \n    \/\/ Reset to first page and display\n    currentPage = 1;\n    displayBooks(filteredBooks);\n  }\n  \n  \/\/ Event listeners for filters and search\n  categoryFilter.addEventListener('change', applyFilters);\n  sortFilter.addEventListener('change', applyFilters);\n  \n  searchButton.addEventListener('click', applyFilters);\n  searchInput.addEventListener('keyup', function(event) {\n    if (event.key === 'Enter') {\n      applyFilters();\n    }\n  });\n  \n  \/\/ Retry button\n  retryButton.addEventListener('click', fetchBooksFromGoogleSheets);\n  \n  \/\/ Initial data load\n  fetchBooksFromGoogleSheets();\n});\n\n\/\/ AUTOCOMPLETE FUNCTIONALITY FINAL\ndocument.addEventListener('DOMContentLoaded', function() {\n  \/\/ Memastikan searchInput sudah terdefinisi\n  const searchInput = document.getElementById('bookSearch');\n  const autocompleteList = document.getElementById('autocomplete-list');\n  let currentFocus = -1;\n  \n  \/\/ Fungsi untuk menampilkan autocomplete\n  function showAutocomplete() {\n    const val = searchInput.value.toLowerCase().trim();\n    autocompleteList.innerHTML = '';\n    currentFocus = -1;\n    \n    \/\/ Hanya tampilkan saran jika sudah mengetik minimal 3 karakter\n    if (!val || val.length < 3) {\n      return false;\n    }\n    \n    let suggestions = new Set();\n    let count = 0;\n    const maxSuggestions = 10;\n    \n    \/\/ Pastikan allBooks sudah tersedia\n    if (!window.allBooks || !window.allBooks.length) {\n      console.log('Data buku belum tersedia untuk autocomplete');\n      return false;\n    }\n    \n    window.allBooks.forEach(book => {\n      \/\/ Jika sudah mencapai batas maksimum saran\n      if (count >= maxSuggestions) return;\n      \n      \/\/ Judul\n      if (book.title && book.title.toLowerCase().includes(val)) {\n        suggestions.add(book.title);\n        count++;\n      }\n      \n      \/\/ Penulis\n      if (book.author && count < maxSuggestions) {\n        book.author.split('|').forEach(author => {\n          if (count >= maxSuggestions) return;\n          if (author.trim().toLowerCase().includes(val)) {\n            suggestions.add(author.trim());\n            count++;\n          }\n        });\n      }\n      \n      \/\/ Kategori\n      if (book.category && count < maxSuggestions) {\n        book.category.split('|').forEach(cat => {\n          if (count >= maxSuggestions) return;\n          if (cat.trim().toLowerCase().includes(val)) {\n            suggestions.add(cat.trim());\n            count++;\n          }\n        });\n      }\n    });\n    \n    \/\/ Tampilkan saran\n    Array.from(suggestions).forEach(suggestion => {\n      const item = document.createElement('div');\n      item.classList.add('autocomplete-item');\n      \n      \/\/ Highlight teks yang cocok dengan pencarian\n      item.innerHTML = suggestion.replace(\n        new RegExp(val, 'gi'), \n        match => `<span class=\"highlight-match\">${match}<\/span>`\n      );\n      \n      \/\/ Event ketika item diklik\n      item.addEventListener('click', function() {\n        searchInput.value = suggestion;\n        autocompleteList.innerHTML = '';\n        \n        \/\/ Pastikan fungsi applyFilters tersedia\n        if (typeof window.applyFilters === 'function') {\n          window.applyFilters();\n        } else {\n          \/\/ Fallback jika fungsi tidak tersedia\n          document.querySelector('.search-button').click();\n        }\n      });\n      \n      autocompleteList.appendChild(item);\n    });\n    \n    \/\/ Tampilkan pesan jika tidak ada saran\n    if (suggestions.size === 0) {\n      const noResult = document.createElement('div');\n      noResult.classList.add('autocomplete-item');\n      noResult.textContent = 'Tidak ada saran yang cocok';\n      autocompleteList.appendChild(noResult);\n    }\n  }\n  \n  \/\/ Event listener untuk input pencarian\n  if (searchInput) {\n    searchInput.addEventListener('input', showAutocomplete);\n    \n    \/\/ Keyboard navigation\n    searchInput.addEventListener('keydown', function(e) {\n      const items = autocompleteList.querySelectorAll('.autocomplete-item');\n      \n      if (e.key === 'ArrowDown') {\n        currentFocus++;\n        addActiveItem(items);\n        e.preventDefault();\n      } else if (e.key === 'ArrowUp') {\n        currentFocus--;\n        addActiveItem(items);\n        e.preventDefault();\n      } else if (e.key === 'Enter') {\n        e.preventDefault();\n        if (currentFocus > -1 && items[currentFocus]) {\n          items[currentFocus].click();\n        }\n      } else if (e.key === 'Escape') {\n        autocompleteList.innerHTML = '';\n      }\n    });\n  } else {\n    console.error('Search input element not found!');\n  }\n  \n  \/\/ Fungsi untuk menandai item aktif\n  function addActiveItem(items) {\n    if (!items || items.length === 0) return false;\n    \n    \/\/ Hapus semua class active terlebih dahulu\n    items.forEach(item => item.classList.remove('autocomplete-active'));\n    \n    \/\/ Atur index dan tambahkan class active\n    if (currentFocus >= items.length) currentFocus = 0;\n    if (currentFocus < 0) currentFocus = items.length - 1;\n    \n    items[currentFocus].classList.add('autocomplete-active');\n    \n    \/\/ Scroll ke item yang aktif jika perlu\n    items[currentFocus].scrollIntoView({ block: 'nearest' });\n  }\n  \n  \/\/ Tutup autocomplete ketika klik di luar\n  document.addEventListener('click', function(e) {\n    if (!e.target.closest('.search-container')) {\n      autocompleteList.innerHTML = '';\n    }\n  });\n  \n  \/\/ Expose fungsi applyFilters ke scope global\n  window.applyFilters = function() {\n    const searchTerm = searchInput.value.toLowerCase();\n    const selectedCategory = document.getElementById('category-filter').value.toLowerCase();\n    const sortOption = document.getElementById('sort-filter').value;\n    \n    \/\/ Filter books\n    window.filteredBooks = window.allBooks.filter(book => {\n      \/\/ Category filter\n      const categoryMatch = selectedCategory === 'all' || \n                           (book.category && book.category.toLowerCase().split('|').some(cat => \n                              cat.trim().toLowerCase() === selectedCategory));\n      \n      \/\/ Search filter\n      const searchMatch = !searchTerm || \n                         (book.title && book.title.toLowerCase().includes(searchTerm)) ||\n                         (book.author && book.author.toLowerCase().split('|').some(author => author.trim().includes(searchTerm))) ||\n                         (book.description && book.description.toLowerCase().includes(searchTerm)) ||\n                         (book.type && book.type.toLowerCase().includes(searchTerm)) ||\n                         (book.category && book.category.toLowerCase().includes(searchTerm)) ||\n                         (book.bookParent && book.bookParent.toLowerCase().includes(searchTerm)) ||\n                         (book.editor && book.editor.toLowerCase().includes(searchTerm));\n      \n      return categoryMatch && searchMatch;\n    });\n    \n    \/\/ Sort books\n    window.filteredBooks.sort((a, b) => {\n      switch(sortOption) {\n        case 'title':\n          return a.title.localeCompare(b.title);\n        case 'title-desc':\n          return b.title.localeCompare(a.title);\n        case 'author':\n          return a.author.localeCompare(b.author);\n        case 'newest':\n        default:\n          return (b.publishDate || '').localeCompare(a.publishDate || '');\n      }\n    });\n    \n    \/\/ Reset to first page and display\n    window.currentPage = 1;\n    window.displayBooks(window.filteredBooks);\n  };\n  \n  \/\/ Tambahkan fungsi displayBooks ke scope global jika belum ada\n  if (typeof window.displayBooks !== 'function') {\n    window.displayBooks = function(books) {\n      \/\/ Implementasi displayBooks jika diperlukan\n      console.log('displayBooks function needs to be defined globally');\n    };\n  }\n});\n\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Katalog Buku Cari Mata Kuliah: Semua Mata Kuliah Urutkan: TerbaruJudul (A-Z)Judul (Z-A)Penulis Memuat katalog buku&#8230; Gagal memuat data buku. Silakan coba lagi nanti. Coba Lagi<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":259,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-276","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/pages\/276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/comments?post=276"}],"version-history":[{"count":10,"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/pages\/276\/revisions"}],"predecessor-version":[{"id":485,"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/pages\/276\/revisions\/485"}],"up":[{"embeddable":true,"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/pages\/259"}],"wp:attachment":[{"href":"https:\/\/www.yarsi.ac.id\/fakultas-psikologi\/wp-json\/wp\/v2\/media?parent=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}