${playlist.description} ${playlist.title} `; playlistSection.append(card); }); // Append the category section to the main container $("#displayLearningCards").append(playlistSection); } } }); function getParameterByName(name) { return new URLSearchParams(window.location.search).get(name); } var pageSectionId = null; pageSectionId = getParameterByName("section-id"); const hamburger = document.getElementById('hamburger'); hamburger.addEventListener('click', () => { hamburger.classList.toggle('open'); }); // Render Products Guides display program data const productGuidesProgramData = [ { "title": "Box guidance services", "url": "https://support.box.com/hc/ja/sections/1500002545282-Box-guidance-services", "links": [ { "text": "導入支援", "url": "https://support.box.com/hc/ja/sections/1500002619301-Implementation" }, { "text": "技術支援", "url": "https://support.box.com/hc/ja/sections/1500002619821-Technology" }, { "text": "利用定着化", "url": "https://support.box.com/hc/ja/sections/1500002586622-Adoption" }, ] }, { "title": "Box Pulse", "url": "", "links": [ { "text": "製品に関するフィードバックの共有", "url": "https://support.box.com/hc/ja/articles/360044196573" } ] } ] ; // Function to render the HTML function renderProgramData(programDataArray) { const container = document.getElementById("displayPrograms"); programDataArray.forEach(data => { if (data) { // Create and append the title const headerElem = document.createElement("h4"); if (data.url) { const headerElemTag = document.createElement("a"); headerElemTag.textContent = data.title; headerElemTag.setAttribute('href', data.url); headerElem.appendChild(headerElemTag); } else { const headerElemTag = document.createElement("span"); headerElemTag.textContent = data.title; headerElem.appendChild(headerElemTag); } container.appendChild(headerElem); // Create and append the list const list = document.createElement("ul"); list.classList.add("program-links"); data.links.forEach(linkData => { const listItem = document.createElement("li"); listItem.classList.add("program-link", "dropdown-item"); // Extract the ID from the URL const urlParts = linkData.url.split('/'); const idWithText = urlParts[urlParts.length - 1]; const idParts = idWithText.split('-'); const id = idParts[0]; // Extracting the ID part const anchor = document.createElement("a"); anchor.href = linkData.url; anchor.textContent = linkData.text; // Generate the class dynamically based on the extracted ID const classId = "icon-svg-" + id; anchor.classList.add(classId); anchor.classList.add("dropdown-icon"); listItem.appendChild(anchor); list.appendChild(listItem); }); container.classList.add("active"); container.appendChild(list); } }); } renderProgramData(productGuidesProgramData); const categoryIds = [21356727474323, 21356672484115, 21356608331155, 21356271827603]; const zendeskAPIUrl = '/api/v2/help_center/ja/categories/'; const cacheTime = 4 * 60 * 60 * 1000; // Set to 4 Hours for now // Function to fetch sections for a given category and page function fetchSections(catID, page = 1) { return new Promise((resolve, reject) => { $.ajax({ url: `${zendeskAPIUrl}${catID}/sections.json?page=${page}&per_page=100&include=categories,translations`, type: 'GET', dataType: 'json', success: resolve, error: reject, }); }); } async function fetchData() { try { var isBtnFound = false; for (const catId of categoryIds) { const sectionsList = $(`#dropdown-${catId}`); let currentPage = 1; let filteredSections; // Declare data outside the loop while (true) { data = await fetchSections(catId, currentPage); if (data.sections && data.sections.length > 0) { filteredSections = data.sections.filter((section) => section.parent_section_id === null); if (filteredSections.length > 0) { appendSectionsToDOM(sectionsList, filteredSections); } } if (data.next_page === null) { // No more pages, break the loop break; } else { currentPage++; } } let sectionListLength = $(`#dropdown-${catId} li`).length; if (sectionListLength > 0) { $(sectionsList).closest(".nav-item").addClass("has-menu"); } if (sectionListLength <= 6) { $(`#dropdown-${catId}`).css("column-count", 1); } } } catch (error) { console.error('Error fetching sections:', error); } } function appendSectionsToDOM(sectionsList, sections) { const customNavPageIds = ["22012531180947", "21356718529939", "21356742765843", "21356707082387", "21356730826259", "21356734487443", "21356758455059", "21356758812563", "21356759103507", "21356759774611", "21356760348691", "21356750924563", "21356609538579", "21356601955859", "21356596816147", "21356627124627", "21356602573331", "21356587547411", "21356595407123", "21356602622483", "21356626314643", "21356608707859", "21356579527315", "26102544955027", "22012531180947", "35107006761235"]; const isCustomPage = (section) => customNavPageIds.some(id => id == section.id); var organizationTags = window.HelpCenter?.user?.organizations[0]?.tags; var enterprisePlusObj = ['premier_services', 'priority_services', 'platinum_services']; var userOrganizationexists = enterprisePlusObj.some(tag => organizationTags?.includes(tag)); sections.forEach((section) => { var sectionName = section.name.replace(/<[^>]+>/g, ''); if ((section.category_id == "21356727474323") || (section.category_id == "21356608331155")) { if (isCustomPage(section)) { sectionsList.append(`