templates/mainContent/pdfContent.html.twig line 1

Open in your IDE?
  1. </html>
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5.     <meta charset="UTF-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <link rel="stylesheet" href="{{ asset('hatlone/assets_preview/css/Elearn/Newsidebar.css')}}">
  8.     <link rel="stylesheet" href="{{ asset('hatlone/assets_preview/css/Elearn/mainContent.css')}}">
  9.     <link rel="stylesheet" href="{{ asset('hatlone/assets_preview/css/Elearn/purpleFrame.css')}}">
  10.     <link rel="stylesheet" href="{{ asset('hatlone/assets_preview/css/Elearn/pdfContent.css')}}">
  11.     <link rel="stylesheet" href="{{ asset('hatlone/assets_preview/css/Elearn/mediaQueries.css')}}">
  12.     <link href="https://cdn.jsdelivr.net/npm/tailwindcss@^2.2/dist/tailwind.min.css" rel="stylesheet">
  13.     <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
  14.     <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  15.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
  16.     <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.4.0/jspdf.umd.min.js"></script>
  17. <!-- Load PDF.js library -->
  18. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.10.377/pdf.min.js"></script>
  19. <!-- Load PDF.js worker -->
  20. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.10.377/pdf.worker.min.js"></script>
  21. <script>
  22.     // Set the workerSrc to point to the correct worker file
  23.     pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.10.377/pdf.worker.min.js';
  24. </script>
  25.   <style>
  26.     #popupQuestion select , #popupQuestion input{
  27.      box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
  28.      margin-top:10px;
  29.      margin-bottom:20px !important;
  30.     
  31.     }
  32.     #popupNote input , #popup input , #popupText input{ 
  33.      box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
  34.      width:100% !important;
  35.     }
  36.      #popupNote textarea{
  37.      box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
  38.      width:100% !important;
  39.     }
  40.    </style> 
  41. </head>
  42. <body >
  43.     
  44.     <div id="pdfContent" >
  45.         
  46.         <div id="targetDiv" >
  47.             <span class="titleContent" style="font-weight: 500;color: var(--blue-purple-color);">{{title}}</span>
  48.             <hr class="hr_underContent">
  49.             <div class="content_Icons">
  50.                 <div class="Rightspace">
  51.                     <div class="tooltip-container">
  52.                         <span class="tooltip">Ask Question</span>
  53.                         <span class="material-symbols-outlined content_Icon"  onclick="openQuestionPopup()" style="margin-right: 1vw;" >chat_bubble</span>
  54.                     </div>
  55.                       <div class="tooltip-container">
  56.                         <span class="tooltip">favourite</span>
  57.                         <span class="material-symbols-outlined content_Icon"  onclick="togglePinkColor(event)">favorite</span>
  58.                     </div>
  59.                   
  60.                 </div>
  61.                 <div class="Icons2" style="display: flex;">
  62.                  <div class="tooltip-container disabled hidden">
  63.                    <span class="tooltip">Highlight text</span>
  64.                <span class="material-symbols-outlined ink_highlighter">ink_highlighter</span>
  65.                    </div>
  66.                     <div class="tooltip-container ">
  67.                         <span class="tooltip">Mark text</span>
  68.                         <span id="sellIcon" class="material-symbols-outlined content_Icon" onclick="openPopupText() " style="margin-right: 0.5vw;">sell</span>
  69.                     </div>
  70.                     <div class="tooltip-container">
  71.                         <span class="tooltip">Add Note</span>
  72.                         <span class="material-symbols-outlined content_Icon edit-note" id="editNoteIcon" onclick="openNotePopup()" style="margin-right: 0.5vw;">edit_note</span>
  73.                     </div>
  74.                     <div class="tooltip-container">
  75.                         <span class="tooltip">Download</span>
  76.                         <span class="material-symbols-outlined content_Icon downloadBtn">download_for_offline</span>
  77.                     </div>
  78.                    
  79.                 </div>
  80.             </div>
  81.                <style>
  82.                         body{
  83.                             overflow-x:hidden !important;
  84.                         }
  85.         .pdf-viewer {
  86.             width: 100%;
  87.             height: 100%; /* Set the height to full viewport */
  88.             border: none;
  89.         }
  90.         .noteHidden{
  91.             display:none;
  92.         }
  93.     </style>
  94.             <div id="pdf-content" style="box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;border:none !important;border-radius:20px;">
  95.                 <div class="header" >
  96.                     <div style="margin-left: auto;">
  97.                           <span class="material-symbols-outlined zoom_out_pdf ink_highlighter mx-1  disabled hidden"  onclick="waitForTextSelection()" style="color:transparent !important;">ink_highlighter</span>
  98.                         <span class="material-symbols-outlined  zoom_out_pdf  edit-note noteHidden mx-1" id="editNoteIcon" onclick="openNotePopup()" >edit_note</span>
  99.                         <span id="sellIcon" class="material-symbols-outlined zoom_out_pdf tagHidden mx-1" onclick="openPopupText() ">sell</span>
  100.                         
  101.                         <span class="material-symbols-outlined zoom_out_pdf mx-1" onclick="toggleFullscreen()">zoom_out_map</span>
  102.                     </div>
  103.                     
  104.                 </div>
  105.                 
  106.                   
  107.                    <!-- Use an iframe to display the PDF -->
  108.                  <iframe  src="{{ asset('hatlone/assets_preview/PHP_intro.pdf')}}" class="pdf-viewer"  id="pdfFrame" width="100%" height="600px" style="border:none;"></iframe>
  109.                  
  110.              <!-- Popup for adding tags -->
  111.     <div id="popupNote" class="fixed inset-0 flex items-center justify-center hidden z-50">
  112.         <div class="absolute inset-0 bg-black bg-opacity-50 backdrop-filter backdrop-blur-sm flex items-center justify-center">
  113.             <div class="bg-white rounded-lg p-4 sm:p-6 md:p-8 shadow-lg relative max-w-full xs:max-w-xs sm:max-w-sm md:max-w-md lg:max-w-lg xl:max-w-xl">
  114.                 <!-- Close icon -->
  115.                 <span class="material-icons absolute top-2 right-2 text-gray-600 cursor-pointer" onclick="closeNotePopup()">close</span>
  116.                 <!-- Popup content -->
  117.                 <h3 class="text-lg font-bold mb-4" style="color: var(--main-color-title);">Create a Note</h3>
  118.                 <hr>
  119.                 <pre class="text-xs text-gray-800 my-4 whitespace-pre-wrap" style="font-family: 'Poppins', sans-serif;">
  120.                    The note feature empowers you to jot down key points and insights
  121.                    effortlessly while participating in the lecture, facilitating effective and
  122.                   organized note-taking.
  123.                   </pre>
  124.                 <input type="text" id="NoteTitleInput" placeholder="Note Title..." class="border-gray-300 border-solid border rounded-md px-3 py-2 mb-4 w-80">
  125.                  <textarea id="NoteDescription" placeholder="Description..." class="border-gray-300 border-solid border rounded-md px-3 py-2 mb-4 w-80"></textarea>
  126.                 <hr>
  127.                 <button onclick="addNote()" class="text-white px-4 py-1 rounded-md" style="background-color: var(--blue-purple-color); margin-top: 1vw;">Confirm</button>
  128.             </div>
  129.         </div>
  130.     </div>       
  131.     <div id="popupText" class="fixed inset-0 flex items-center justify-center hidden z-50">
  132.         <div class="absolute inset-0 bg-black bg-opacity-50 backdrop-filter backdrop-blur-sm flex items-center justify-center">
  133.             <div class="bg-white rounded-lg p-4 sm:p-6 md:p-8 shadow-lg relative max-w-full xs:max-w-xs sm:max-w-sm md:max-w-md lg:max-w-lg xl:max-w-xl">
  134.                 <!-- Close icon -->
  135.                 <span class="material-icons absolute top-2 right-2 text-gray-600 cursor-pointer" onclick="closePopupText()">close</span>
  136.                 <!-- Popup content -->
  137.                 <h3 class="text-lg font-bold mb-4" style="color: var(--main-color-title);">Create a Tag</h3>
  138.                 <hr>
  139.                 <pre class="text-xs text-gray-800 my-4 whitespace-pre-wrap" style="font-family: 'Poppins', sans-serif;">
  140.                  The tag feature enables you to seamlessly return to any specific text
  141.                   in the script, providing a convenient way to revisit and review particular
  142.                   text .</pre>
  143.                 <input type="text" id="tagTitleInput" placeholder="text..." class="border-gray-300 border-solid border rounded-md px-3 py-2 mb-4 w-80">
  144.                 <hr>
  145.                 <button onclick="addTagPDF()" class="text-white px-4 py-2 rounded-md" style="background-color: var(--blue-purple-color); margin-top: 1vw;">Confirm</button>
  146.             </div>
  147.         </div>
  148.     </div>
  149.                 <div class="content" id="contentContainer" hidden>
  150.                     <p id="contentParagraph">
  151.                         1Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  152.                         Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  153.                         Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  154.                         Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  155.                     </p>
  156.                 </div>
  157.             </div>
  158.            <div class="container" style="box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;border:none !important;padding-bottom:60px;border-radius:20px;padding-top:5px;padding-left:10px;padding-right:10px;margin-top:10px;margin-bottom:5px;">
  159.                 <div style="align-items: center; display: flex; margin-top: 3vh; margin-bottom: 3vh; font-weight: 500;color: var(--blue-color);">
  160.                     <span class="material-symbols-outlined content_Icon edit-note" id="editNoteIcon" style="margin-right: 0.5vw;color:var(--blue-purple-color);">edit_note</span>
  161.                     <h1 style="font-weight: bold;color:var(--blue-purple-color) !important;">Your Notes</h1>
  162.                 </div>
  163.                 <hr style="width: 90%; margin: 2vh auto;">
  164.                 <div class="notesDiv" style="align-items: center; display: block; color: var(--blue-color);">
  165.                     
  166.                 </div>
  167.             </div>
  168.         </div>
  169.          <div id="tagsContainer" style="box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;border:none !important;margin-bottom:10px;padding-bottom:10px;padding-left:10px;">
  170.             <div style="display: flex; justify-content: center; color:var(--blue-purple-color); margin-top: 2vh;">
  171.                 <span class="material-symbols-outlined content_Icon_filled" style="margin-right: 0.5vw;">sell</span>
  172.                 <p style="margin: 0; font-weight: bold;">Your tags</p>
  173.             </div>
  174.             <hr style="width: 10vw; margin: 2vh auto;">
  175.         </div>
  176.     </div>
  177.    
  178.     <!-- Popup for adding tags -->
  179.     <div id="popupQuestion" class="fixed inset-0 flex items-center justify-center hidden z-50">
  180.         <div class="absolute inset-0 bg-black bg-opacity-50 backdrop-filter backdrop-blur-sm flex items-center justify-center">
  181.             <div class="bg-white rounded-lg p-4 sm:p-6 md:p-8 shadow-lg relative max-w-full xs:max-w-xs sm:max-w-sm md:max-w-md lg:max-w-lg xl:max-w-xl" style="display: block;">
  182.                 <!-- Close icon -->
  183.                 <span class="material-icons absolute top-2 right-2 text-gray-600 cursor-pointer" onclick="closeQuestionPopup()">close</span>
  184.                 <!-- Popup content -->
  185.                 <h3 class="text-lg font-bold mb-4" style="color: var(--main-color-title);">You have a Question?</h3>
  186.                 <hr style=" margin: 2vh auto;">
  187.                 <select id="NoteTypeSelect" class="border-gray-300 border-solid border rounded-md px-3 py-2 mb-4 w-80">
  188.                     <option value="" disabled selected>Select a Question</option>
  189.                     <option value="a">aaaaa</option>
  190.                     <option value="b">bbbbbb</option>
  191.                     <option value="c">ccccc</option>
  192.                     <option value="d">ddddd</option>
  193.                   </select>
  194.                   
  195.                   <div style="display: flex; align-items: center; margin-bottom: 1vh;">
  196.                     <p style="color: var(--main-text-color);">You didn't find a question in the list ?</p>
  197.                     <label class="switch">
  198.                       <input type="checkbox" id="toggleInput">
  199.                       <span class="slider"></span>
  200.                     </label>
  201.                   </div>
  202.                   
  203.                   <input type="text" id="Question" placeholder="Write a question here" class="border-gray-300 border-solid border rounded-md px-3 py-2 mb-4 w-80" disabled>
  204.                   
  205.                 <hr>
  206.                 <button onclick="closeQuestionPopup()" class="text-white px-4 py-2 rounded-md" style="background-color: var(--blue-purple-color); margin-top: 1vw;">Confirm</button>
  207.             </div>
  208.         </div>
  209.     </div>
  210.  
  211. <style>
  212.              #popupNote , #popupText {
  213.     z-index: 9999; /* Une valeur très élevée pour s'assurer que les pop-ups apparaissent en plein écran */
  214. }
  215. </style>
  216.     <script>
  217.            function waitForTextSelection() {
  218.     const inkHighlighter = document.querySelector('.material-symbols-outlined.ink_highlighter');
  219.     // Add a class when the ink_highlighter icon is clicked
  220.     inkHighlighter.classList.add('waitSelection');
  221.     // Function to handle the selection and apply highlighting
  222.     function handleSelection(event) {
  223.         event.preventDefault(); // Prevent default selection behavior
  224.         highlightSelectedText(); // Highlight selected text
  225.         // Remove the class after handling the selection
  226.         inkHighlighter.classList.remove('waitSelection');
  227.         // Remove the event listener after handling the selection
  228.         document.removeEventListener('mouseup', handleSelection);
  229.     }
  230.     // Add event listener for mouseup to wait for text selection
  231.     document.addEventListener('mouseup', handleSelection);
  232. }
  233. function waitForPDFToLoad() {
  234.     const iframe = document.getElementById('pdfFrame');
  235.     iframe.onload = function () {
  236.         const checkPDFLoaded = setInterval(() => {
  237.             const pdfViewerApp = iframe.contentWindow.PDFViewerApplication;
  238.            
  239.                 clearInterval(checkPDFLoaded);
  240.             
  241.         }, 500); // Check every 500ms
  242.     };
  243. }
  244. function highlightSelectedText() {
  245.     const selection = window.getSelection();
  246.     if (selection.rangeCount > 0) {
  247.         const range = selection.getRangeAt(0);
  248.         // Get page number
  249.         const pageNumber = getPageNumber();
  250.         if (!pageNumber) {
  251.             console.error('Could not retrieve page number.');
  252.             return;
  253.         }
  254.         // Get line number approximation
  255.         const lineNumber = getLineNumber(range);
  256.         // Call addTagPDF with page number and line number
  257.         addTagPDF(pageNumber, lineNumber);
  258.     } else {
  259.         console.error('No text selected.');
  260.     }
  261. }
  262. /*function addTagPDF() {
  263.     const tagTitleInput = document.getElementById('tagTitleInput').value.trim();
  264.     if (tagTitleInput) {
  265.         const tagElement = document.createElement('div');
  266.         tagElement.classList.add("tag");
  267.         tagElement.style.cursor = "pointer";
  268.         tagElement.style.fontWeight = 'bold';
  269.         tagElement.style.color = 'var(--blue-purple-color)';
  270.         tagElement.style.wordBreak = 'break-word'; 
  271.         tagElement.style.whiteSpace = 'normal';
  272.         tagElement.style.textAlign = 'center';
  273.         // Display the tag with the page number and line number
  274.         tagElement.textContent = `${tagTitleInput}`;
  275.         document.getElementById('tagsContainer').appendChild(tagElement);
  276.         closePopupText();
  277.     }
  278. }*/
  279. // Load and parse the PDF
  280. // Charger et analyser le PDF
  281. async function loadPDF() {
  282.     const url = "{{ asset('hatlone/assets_preview/PHP_intro.pdf') }}"; // Chemin vers votre fichier PDF
  283.     const pdf = await pdfjsLib.getDocument(url).promise;
  284.     const textByPage = [];
  285.     for (let pageNum = 1; pageNum <= pdf.numPages; pageNum++) {
  286.         const page = await pdf.getPage(pageNum);
  287.         const textContent = await page.getTextContent();
  288.         // Extraire le texte de la page et le normaliser
  289.         const pageText = textContent.items.map(item => item.str).join(' ').replace(/\s+/g, ' ').trim();
  290.         textByPage.push({ pageNum, pageText });
  291.     }
  292.     return textByPage;
  293. }
  294. // Rechercher un terme dans le texte du PDF
  295. function searchTermInPDF(term, textByPage) {
  296.     const termLower = term.toLowerCase();
  297.     for (const { pageNum, pageText } of textByPage) {
  298.         const termIndex = pageText.toLowerCase().indexOf(termLower);
  299.         if (termIndex !== -1) {
  300.             // Calculer la ligne approximative où le terme apparaît
  301.             const estimatedLine = Math.floor(termIndex / 100) + 1; // Estimation du numéro de ligne
  302.             return { page: pageNum, line: estimatedLine };
  303.         }
  304.     }
  305.     return null;
  306. }
  307. // Afficher le résultat de la recherche dans le conteneur des tags
  308. function displaySearchResult(term, result) {
  309.     const tagsContainer = document.getElementById('tagsContainer');
  310.     const tagElement = document.createElement('div');
  311.     tagElement.classList.add("tag");
  312.     tagElement.style.fontWeight = 'bold';
  313.     tagElement.style.color = 'var(--blue-purple-color)';
  314.     tagElement.style.marginBottom = '1vh';
  315.     tagElement.style.cursor = 'pointer';
  316.     if (result) {
  317.         tagElement.textContent = `${term} (Page: ${result.page}, Ligne: ${result.line})`;
  318.         tagElement.setAttribute('data-page', result.page); // Stocker le numéro de la page dans un attribut
  319.         // Ajouter un événement clic pour naviguer vers la page correspondante lors du clic
  320.         tagElement.addEventListener('click', function () {
  321.             goToPage(result.page); // Appeler la fonction pour aller à la page spécifique
  322.         });
  323.     } else {
  324.         tagElement.textContent = `${term} non trouvé dans le PDF`;
  325.     }
  326.     tagsContainer.appendChild(tagElement);
  327. }
  328. async function addTagPDF() {
  329.     const tagTitleInput = document.getElementById('tagTitleInput').value.trim();
  330.     if (tagTitleInput) {
  331.         const textByPage = await loadPDF(); // Charger et analyser le PDF
  332.         // Limiter la recherche aux premiers mots du paragraphe (ex. : les 5 premiers mots)
  333.         const firstFewWords = tagTitleInput.split(' ').slice(0, 5).join(' ');
  334.         
  335.         const searchResult = searchTermInPDF(firstFewWords, textByPage); // Rechercher le terme
  336.         displaySearchResult(firstFewWords, searchResult); // Afficher le résultat
  337.     }
  338.     closePopupText(); // Fermer la popup d'entrée de tag
  339. }
  340. // Function to navigate to a specific page in the PDF
  341. function goToPage(pageNumber) {
  342.     const iframe = document.getElementById('pdfFrame');
  343.     const pdfViewerApp = iframe.contentWindow.PDFViewerApplication;
  344.     if (pdfViewerApp && pdfViewerApp.page) {
  345.         pdfViewerApp.page = pageNumber; // Set the PDF viewer to the specified page
  346.     }
  347. }
  348.             function openPopupText() {
  349.                 //toggleFullscreen();
  350.                 //if (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) {
  351.                     document.getElementById('popupText').classList.remove('hidden');
  352.                     document.getElementById('tagTitleInput').value = ''; // Clear input field
  353.             // }
  354.             }
  355.             function closePopupText() {
  356.                 document.getElementById('popupText').classList.add('hidden');
  357.             }
  358.             function highlightSelectedTextPink() {
  359.             var selection = window.getSelection();
  360.             
  361.             if (selection.rangeCount > 0) {
  362.                 var range = selection.getRangeAt(0);
  363.                 
  364.                 // Check if the selection is within a single text node
  365.                 if (range.startContainer === range.endContainer && range.startContainer.nodeType === Node.TEXT_NODE) {
  366.                     var span = document.createElement('span');
  367.                     span.style.backgroundColor = 'rgb(255, 141, 179)'; // Change to green or desired color
  368.                     range.surroundContents(span);
  369.                 } else {
  370.                     console.error('Cannot highlight: Selection spans multiple nodes or non-text nodes.');
  371.                 }
  372.             } else {
  373.                 console.error('No text selected.');
  374.             }
  375.         }
  376.         function highlightText(text) {
  377.             const content = document.querySelector('#pdf-content .content');
  378.             const regex = new RegExp(`(${text})`, 'gi');
  379.             // Replace only the text nodes, preserving existing HTML structure
  380.             const walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT, null, false);
  381.             const textNodes = [];
  382.             while (walker.nextNode()) {
  383.                 textNodes.push(walker.currentNode);
  384.             }
  385.             textNodes.forEach(node => {
  386.                 const nodeText = node.nodeValue;
  387.                 const newHTML = nodeText.replace(regex, '<span class="highlight">$1</span>');
  388.                 if (newHTML !== nodeText) {
  389.                     const tempDiv = document.createElement('div');
  390.                     tempDiv.innerHTML = newHTML;
  391.                     while (tempDiv.firstChild) {
  392.                         node.parentNode.insertBefore(tempDiv.firstChild, node);
  393.                     }
  394.                     node.parentNode.removeChild(node);
  395.                 }
  396.             });
  397.         }
  398.         function removeHighlight(text) {
  399.             const content = document.querySelector('#pdf-content .content');
  400.             const regex = new RegExp(`<span class="highlight">(${text})</span>`, 'gi');
  401.             // Replace only the text nodes, preserving existing HTML structure
  402.             const walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT, null, false);
  403.             const textNodes = [];
  404.             while (walker.nextNode()) {
  405.                 textNodes.push(walker.currentNode);
  406.             }
  407.             textNodes.forEach(node => {
  408.                 const nodeText = node.nodeValue;
  409.                 const newHTML = nodeText.replace(regex, '$1');
  410.                 if (newHTML !== nodeText) {
  411.                     const tempDiv = document.createElement('div');
  412.                     tempDiv.innerHTML = newHTML;
  413.                     while (tempDiv.firstChild) {
  414.                         node.parentNode.insertBefore(tempDiv.firstChild, node);
  415.                     }
  416.                     node.parentNode.removeChild(node);
  417.                 }
  418.             });
  419.             // Remove all highlight spans
  420.             const spans = content.querySelectorAll('span.highlight');
  421.             spans.forEach(span => {
  422.                 const parent = span.parentNode;
  423.                 parent.replaceChild(document.createTextNode(span.textContent), span);
  424.                 parent.normalize(); // Merges adjacent text nodes into one
  425.             });
  426.         }
  427.         
  428.         function enterFullscreen(element) {
  429.             if (element.requestFullscreen) {
  430.                 element.requestFullscreen();
  431.             } else if (element.mozRequestFullScreen) { // Firefox
  432.                 element.mozRequestFullScreen();
  433.             } else if (element.webkitRequestFullscreen) { // Chrome, Safari and Opera
  434.                 element.webkitRequestFullscreen();
  435.             } else if (element.msRequestFullscreen) { // IE/Edge
  436.                 element.msRequestFullscreen();
  437.             }
  438.         }
  439.         function exitFullscreen() {
  440.             if (document.exitFullscreen) {
  441.                 document.exitFullscreen();
  442.             } else if (document.mozCancelFullScreen) { // Firefox
  443.                 document.mozCancelFullScreen();
  444.             } else if (document.webkitExitFullscreen) { // Chrome, Safari and Opera
  445.                 document.webkitExitFullscreen();
  446.             } else if (document.msExitFullscreen) { // IE/Edge
  447.                 document.msExitFullscreen();
  448.             }
  449.         }
  450.         function toggleFullscreen() {
  451.             const element = document.getElementById('pdf-content');
  452.             const highlighterIcon = document.querySelector('.material-symbols-outlined.zoom_out_pdf.ink_highlighter');
  453.             const tagHidden=document.querySelector(".material-symbols-outlined.zoom_out_pdf.tagHidden");
  454.             const noteHidden=document.querySelector(".material-symbols-outlined.zoom_out_pdf.noteHidden");
  455.             if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
  456.                 enterFullscreen(element);
  457.                 highlighterIcon.style.display = 'inline-block'; // Or any other display value you prefer
  458.                 tagHidden.style.display = 'inline-block';
  459.                 noteHidden.style.display = 'inline-block';
  460.             } else {
  461.                 exitFullscreen();
  462.                 highlighterIcon.style.display = 'none';
  463.                 tagHidden.style.display = 'none';
  464.                 noteHidden.style.display = 'none';
  465.             }
  466.         }
  467.     </script>
  468.     <style>
  469.         .disabled {
  470.     pointer-events: none; /* Prevents clicking */
  471.     opacity: 0.5;         /* Makes the icon look disabled */
  472.     cursor: not-allowed;  /* Shows the "not allowed" cursor */
  473. }
  474.     </style>
  475.     <script>
  476.         document.querySelectorAll('.downloadBtn').forEach(button => {
  477.     button.addEventListener('click', function () {
  478.         // Create a temporary link element
  479.         var link = document.createElement('a');
  480.         link.href = "{{ asset('hatlone/assets_preview/PHP_intro.pdf') }}"; // Path to the PDF file
  481.         link.download = 'PHP_intro.pdf'; // The name of the file to be downloaded
  482.         link.click(); // Simulate the click to download the file
  483.     });
  484. });
  485.  // Function to open note popup
  486.     function openNotePopup() {
  487.         document.getElementById('popupNote').classList.remove('hidden');
  488.         document.getElementById('NoteTitleInput').value = ''; // Clear input field
  489.         document.getElementById('NoteDescription').value = ''; // Clear input field
  490.     }
  491.       // Function to add note
  492.     function addNote() {
  493.         const noteTitle = document.getElementById('NoteTitleInput').value.trim();
  494.         const noteDescription = document.getElementById('NoteDescription').value.trim();
  495.         if (noteTitle !== '' && noteDescription !== '') {
  496.             displayNote(noteTitle, noteDescription);
  497.             closeNotePopup();
  498.                // Show the SweetAlert success message
  499.     Swal.fire({
  500.         icon: 'success',
  501.         title: 'Success!',
  502.         text: 'Your note has been added successfully.',
  503.     });
  504.         }
  505.      
  506.     }
  507.     function displayNote(title, description) {
  508.     const notesDiv = document.querySelector('.notesDiv');
  509.     const noteContainer = document.createElement('div');
  510.     noteContainer.style.flexDirection = 'column';
  511.     noteContainer.style.marginBottom = '1vh';
  512.     const titleSpan = document.createElement('span');
  513.     titleSpan.innerHTML = (title || "No Title") + "&nbsp;:&nbsp;";
  514.     titleSpan.style.fontWeight = 'bold';
  515.     const descriptionSpan = document.createElement('span');
  516.     descriptionSpan.textContent = description || "No Description";
  517.     noteContainer.appendChild(titleSpan);
  518.     noteContainer.appendChild(descriptionSpan);
  519.     notesDiv.appendChild(noteContainer);
  520. }
  521.     </script>
  522. </body>
  523. </html>