1const hamburger = document.getElementById("hamburger-container"); 2const menu = document.getElementById("menu"); 3const bar2 = document.querySelector(".bar2"); 4const bar3 = document.querySelector(".bar3"); 5 6// Toggle menu visibility 7hamburger.addEventListener("click", () => { 8 if (menu.classList.contains("active")) { 9 menu.classList.remove("active"); 10 bar2.classList.add("bar2"); 11 bar3.classList.add("bar3"); 12 setTimeout(() => menu.classList.add("hidden"), 300); 13 } else { 14 menu.classList.remove("hidden"); 15 bar2.classList.remove("bar2"); 16 bar3.classList.remove("bar3"); 17 requestAnimationFrame(() => menu.classList.add("active")); 18 } 19}); 20 21// JWT token handling 22const getAuthToken = () => document.cookie.split("; ").find(row => row.startsWith("token="))?.split("=")[1] || null; 23const token = getAuthToken(); 24 25function parseJwt(token) { 26 const base64Url = token.split('.')[1]; 27 const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); 28 const jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) { 29 return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); 30 }).join('')); 31 32 return JSON.parse(jsonPayload); 33} 34 35const payload = parseJwt(token); 36const reg_num = payload.data.reg_num; 37const email = payload.data.email; 38 39// Extract courseCode from URL 40const params = new URLSearchParams(window.location.search); 41const course_c = params.get('course'); 42 43// API endpoint 44const apiEndpoint4 = `../FA3/get_reviews?course_code=${course_c}`; 45 46// Fetch, display, and compile reviews 47function fetchReview() { 48 fetch(apiEndpoint4, { 49 method: "GET", 50 headers: { "Authorization": `${token}` } 51 }) 52 .then(response => response.json()) 53 .then(data => { 54 if (data.status_code === 200) { 55 const results = data.result; 56 const commentContainer = document.querySelector('.right-body'); 57 let commentString = "const comments = [\n"; 58 59 results.forEach(result => { 60 const name = result.full_name.replace(/"/g, '\\"'); 61 const comment = result.review.replace(/"/g, '\\"'); 62 63 // Append to DOM 64 const div = document.createElement('div'); 65 div.className = 'comment-box'; 66 67 const h4 = document.createElement('h4'); 68 h4.textContent = name; 69 70 const p = document.createElement('p'); 71 p.textContent = comment; 72 73 div.appendChild(h4); 74 div.appendChild(p); 75 commentContainer.appendChild(div); 76 77 commentString += ` { name: "${name}", comment: "${comment}" },\n`; 78 }); 79 80 commentString += "];"; 81 console.log(commentString); 82 } 83 }) 84 .catch(error => console.error("Error fetching data:", error)); 85} 86 87fetchReview();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.