{"id":31674,"date":"2025-11-10T10:49:46","date_gmt":"2025-11-10T09:49:46","guid":{"rendered":"https:\/\/www.univ-djelfa.dz\/?page_id=31674"},"modified":"2025-11-10T11:18:12","modified_gmt":"2025-11-10T10:18:12","slug":"elementor-31674","status":"publish","type":"page","link":"https:\/\/www.univ-djelfa.dz\/?page_id=31674","title":{"rendered":"Recherche bibliographique"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"31674\" class=\"elementor elementor-31674\" data-elementor-post-type=\"page\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-284b9ec elementor-section-boxed elementor-section-height-default elementor-section-height-default exad-sticky-section-no\" data-id=\"284b9ec\" data-element_type=\"section\" data-settings=\"{&quot;ekit_has_onepagescroll_dot&quot;:&quot;yes&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-07ea5f0 exad-sticky-section-no\" data-id=\"07ea5f0\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f93b90a exad-sticky-section-no elementor-widget elementor-widget-html\" data-id=\"f93b90a\" data-element_type=\"widget\" data-settings=\"{&quot;ekit_we_effect_on&quot;:&quot;none&quot;}\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div dir=\"ltr\" style=\"font-family:'Cairo',sans-serif; background:#fff; padding:25px; border-radius:12px; border:1px solid #e0e0e0;\">\n  <h2 style=\"text-align:center; color:#333; margin-bottom:10px;\">\ud83d\udcda Recherche de R\u00e9f\u00e9rences<\/h2>\n  <div style=\"height:2px; background:#ccc; margin-bottom:15px;\"><\/div> <!-- s\u00e9parateur -->\n\n  <div id=\"searchSection\" style=\"display:flex; flex-wrap:wrap; gap:10px; justify-content:center; margin-bottom:15px;\">\n    <input id=\"titleInput\" placeholder=\"\ud83d\udd0d Recherche par Titre\" style=\"padding:10px;border:1px solid #ccc;border-radius:8px;min-width:220px;\">\n    <input id=\"authorInput\" placeholder=\"\ud83d\udc64 Recherche par Auteur\" style=\"padding:10px;border:1px solid #ccc;border-radius:8px;min-width:220px;\">\n    <input id=\"publisherInput\" placeholder=\"\ud83c\udfe2 Recherche par \u00c9diteur\" style=\"padding:10px;border:1px solid #ccc;border-radius:8px;min-width:220px;\">\n    <button id=\"searchBtn\" style=\"background:#666;color:#fff;border:none;border-radius:8px;padding:10px 18px;cursor:pointer;\">Rechercher<\/button>\n    <button id=\"resetBtn\" style=\"background:#ccc;color:#333;border:none;border-radius:8px;padding:10px 18px;cursor:pointer;\">R\u00e9initialiser<\/button>\n    <button id=\"showAllBtn\" style=\"background:#888;color:#fff;border:none;border-radius:8px;padding:10px 18px;cursor:pointer;\">Afficher toutes les r\u00e9f\u00e9rences<\/button>\n  <\/div>\n\n  <p id=\"noResults\" style=\"display:none; color:#a33; text-align:center;\">\u274c Aucun r\u00e9sultat<\/p>\n  <div id=\"resultsContainer\" style=\"display:none; margin-top:20px; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:12px; display:grid;\"><\/div>\n  <div id=\"tableContainer\" style=\"display:none; margin-top:20px; width:100%;\">\n    <table id=\"allRefsTable\" style=\"width:100%; border-collapse:collapse; text-align:left; background:#fff;\">\n      <thead style=\"background:#f0f0f0; color:#333;\"><\/thead>\n      <tbody><\/tbody>\n    <\/table>\n  <\/div>\n  <div id=\"pagination\" style=\"text-align:center; margin-top:15px;\"><\/div>\n<\/div>\n\n<script>\nconst csvUrl = 'https:\/\/www.univ-djelfa.dz\/\/wp-content\/uploads\/libray.csv';\nlet headers = [];\nlet data = [];\nlet currentPage = 1;\nconst itemsPerPage = 9;\nconst tableItemsPerPage = 10;\n\nfunction detectDelimiter(line){\n  const semis=(line.match(\/;\/g)||[]).length;\n  const commas=(line.match(\/,\/g)||[]).length;\n  return semis>commas?';':',';\n}\n\nfunction parseCSV(text){\n  text=text.replace(\/^\\uFEFF\/, '');\n  const lines=text.split(\/\\r?\\n\/).filter(l=>l.trim()!=='');\n  if(!lines.length)return{headers:[],rows:[]};\n  const delim=detectDelimiter(lines[0]);\n  const headers=lines[0].split(delim).map(h=>h.trim());\n  const rows=lines.slice(1).map(line=>{\n    const parts=[];let cur='',inQuotes=false;\n    for(let ch of line){\n      if(ch==='\"') inQuotes=!inQuotes;\n      else if(ch===delim&&!inQuotes){parts.push(cur.trim());cur='';}\n      else cur+=ch;\n    }\n    parts.push(cur.trim());\n    return parts;\n  });\n  return {headers,rows};\n}\n\nfunction createCard(row){\n  let card = `<div style=\"background:#fff;border:1px solid #e0e0e0;border-radius:10px;padding:12px;box-shadow:0 1px 3px rgba(0,0,0,0.05);\">`;\n  for(let i=0;i<headers.length;i++){\n    if(!headers[i]) continue;\n    card += `<p><strong>${headers[i]}:<\/strong> ${row[i]||''}<\/p>`;\n  }\n  card += `<\/div>`;\n  return card;\n}\n\nfunction paginateResults(filtered){\n  const totalPages = Math.ceil(filtered.length \/ itemsPerPage);\n  if (currentPage > totalPages) currentPage = totalPages;\n  const start = (currentPage - 1) * itemsPerPage;\n  const end = start + itemsPerPage;\n  const paginated = filtered.slice(start, end);\n\n  const res = document.getElementById('resultsContainer');\n  const no = document.getElementById('noResults');\n  const paginationDiv = document.getElementById('pagination');\n\n  if (!filtered.length){\n    res.style.display='none';\n    paginationDiv.innerHTML='';\n    no.style.display='block';\n    return;\n  }\n\n  no.style.display='none';\n  res.style.display='grid';\n  res.innerHTML = paginated.map(createCard).join('');\n\n  renderShortPagination(totalPages, gotoPage);\n}\n\nfunction gotoPage(page){\n  currentPage = page;\n  performSearch();\n}\n\nfunction renderShortPagination(totalPages, callback){\n  const pagination=document.getElementById('pagination');\n  pagination.innerHTML='';\n  const delta=3;\n  let range = [];\n  for(let i=1;i<=totalPages;i++){\n    if(i===1 || i===totalPages || (i>=currentPage-delta && i<=currentPage+delta)){\n      range.push(i);\n    }\n  }\n  let last = 0;\n  range.forEach(i=>{\n    if(i-last>1) pagination.innerHTML+=' ... ';\n    pagination.innerHTML += `<button onclick=\"(${callback.name})(${i})\" style=\"margin:3px; padding:6px 12px; border-radius:6px; border:1px solid #e0e0e0; background:${i===currentPage?'#666':'#fff'}; color:${i===currentPage?'#fff':'#333'}; cursor:pointer;\">${i}<\/button>`;\n    last=i;\n  });\n}\n\nfunction performSearch(){\n  const t=document.getElementById('titleInput').value.trim().toLowerCase();\n  const a=document.getElementById('authorInput').value.trim().toLowerCase();\n  const p=document.getElementById('publisherInput').value.trim().toLowerCase();\n  if(!data.length)return;\n\n  const ti=headers.findIndex(h=>h.replace(\/\\s|_|-\/g,'').toLowerCase().includes('titre'));\n  const ai=headers.findIndex(h=>h.replace(\/\\s|_|-\/g,'').toLowerCase().includes('auteur'));\n  const pi=headers.findIndex(h=>h.replace(\/\\s|_|-\/g,'').toLowerCase().includes('\u00e9diteur'));\n\n  const filtered=data.filter(r=>(!t||(r[ti]||'').toLowerCase().includes(t))&&(!a||(r[ai]||'').toLowerCase().includes(a))&&(!p||(r[pi]||'').toLowerCase().includes(p)));\n  paginateResults(filtered);\n}\n\nfunction resetSearch(){\n  document.getElementById('titleInput').value='';\n  document.getElementById('authorInput').value='';\n  document.getElementById('publisherInput').value='';\n  document.getElementById('resultsContainer').style.display='none';\n  document.getElementById('noResults').style.display='none';\n  document.getElementById('pagination').innerHTML='';\n  currentPage = 1;\n}\n\nasync function loadCSV(){\n  try{\n    const res=await fetch(csvUrl);\n    if(!res.ok){throw new Error('file not found');}\n    const text=await res.text();\n    const utf8Text = new TextDecoder('utf-8', {fatal:false}).decode(new TextEncoder().encode(text));\n    const parsed=parseCSV(utf8Text);\n    headers=parsed.headers;\n    data=parsed.rows;\n  }catch(e){\n    alert('\u26a0\ufe0f Impossible de lire le fichier CSV. V\u00e9rifiez le chemin ou l\u2019encodage.');\n    console.error(e);\n  }\n}\n\nfunction showAllReferences(){\n  const tableContainer=document.getElementById('tableContainer');\n  const resultsContainer=document.getElementById('resultsContainer');\n  const btn=document.getElementById('showAllBtn');\n\n  if(tableContainer.style.display==='none'){\n    resultsContainer.style.display='none';\n    renderTable(1);\n    tableContainer.style.display='block';\n    btn.textContent='Masquer le tableau';\n  } else {\n    tableContainer.style.display='none';\n    btn.textContent='Afficher toutes les r\u00e9f\u00e9rences';\n  }\n}\n\nfunction renderTable(page){\n  const table=document.getElementById('allRefsTable');\n  const totalPages=Math.ceil(data.length\/tableItemsPerPage);\n  const start=(page-1)*tableItemsPerPage;\n  const end=start+tableItemsPerPage;\n  const rows=data.slice(start,end);\n\n  table.querySelector('thead').innerHTML='<tr>'+headers.map(h=>`<th style=\"padding:8px;border:1px solid #ccc;\">${h}<\/th>`).join('')+'<\/tr>';\n  table.querySelector('tbody').innerHTML=rows.map(r=>'<tr style=\"background:#fff;\">'+r.map(c=>`<td style=\"padding:6px;border:1px solid #eee;\">${c}<\/td>`).join('')+'<\/tr>').join('');\n\n  currentPage=page;\n  renderShortPagination(totalPages, renderTable);\n}\n\ndocument.addEventListener('DOMContentLoaded',()=>{\n  loadCSV();\n  document.getElementById('searchBtn').onclick=()=>{currentPage=1;performSearch();};\n  document.getElementById('resetBtn').onclick=resetSearch;\n  document.getElementById('showAllBtn').onclick=showAllReferences;\n});\n<\/script>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\ud83d\udcda Recherche de R\u00e9f\u00e9rences Rechercher R\u00e9initialiser Afficher toutes les r\u00e9f\u00e9rences \u274c Aucun r\u00e9sultat<\/p>\n","protected":false},"author":2,"featured_media":31660,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_post_transparent":"","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_kad_post_feature":"default","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"class_list":["post-31674","page","type-page","status-publish","has-post-thumbnail","hentry"],"lang":"fr","translations":{"fr":31674,"ar":31653},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=\/wp\/v2\/pages\/31674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31674"}],"version-history":[{"count":10,"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=\/wp\/v2\/pages\/31674\/revisions"}],"predecessor-version":[{"id":31691,"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=\/wp\/v2\/pages\/31674\/revisions\/31691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=\/wp\/v2\/media\/31660"}],"wp:attachment":[{"href":"https:\/\/www.univ-djelfa.dz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}