1function Title(content) { 2 const languageMatch = 3 content.template_languages.find( 4 ({ language }) => language === pageLang 5 ) || 6 content.template_languages.find(({ language }) => language === "TH"); 7 8 return languageMatch?.title || ""; 9} 10 11function contentTemp5(data) { 12 return data.map((content) => { 13 const title = Title(content); 14 return ` 15 <h4 class="mt-5 text-blue">${title}</h4> 16 ${topic(content.children).join("")} 17 `; 18 }); 19} 20 21function topic(data) { 22 return data.map((content) => { 23 const title = Title(content); 24 const collapseId = `collapseExample${content.id}`; 25 26 return ` 27 <div class="card card-list-dowload border-0 mt-4 mb-4"> 28 <div class="card-body p-0 d-flex position-relative"> 29 <p class="pt-3 ps-3 font-16 text-blue text-wrap-1">${title}</p> 30 <a class="d-flex align-items-center font-18 text-blue me-4 ms-auto" 31 data-bs-toggle="collapse" 32 href="#${collapseId}" 33 role="button" 34 aria-expanded="true" 35 aria-controls="${collapseId}"> 36 <i class="fas fa-angle-down"></i> 37 </a> 38 </div> 39 </div> 40 <div class="collapse show w-collapse mt-1" id="${collapseId}"> 41 ${contentComponent(content.components).join("")} 42 </div> 43 `; 44 }); 45} 46 47function getTitleFromComponent(content) { 48 const languageMatch = 49 content.component_languages.find( 50 ({ language }) => language === pageLang 51 ) || 52 content.component_languages.find(({ language }) => language === "TH"); 53 54 return languageMatch?.title || ""; 55} 56 57function contentComponent(data) { 58 return data.map((content) => { 59 const title = getTitleFromComponent(content); 60 61 return ` 62 <div class="d-flex ms-3 mb-3"> 63 <h5 class="text-blue text-wrap-1 ms-3">${title}</h5> 64 </div> 65 <div class="row mt-2 mb-2 ms-3"> 66 ${contentComponentFilelist( 67 content.component_files, 68 content.id 69 ).join("")} 70 </div> 71 `; 72 }); 73} 74 75function getFileType(path) { 76 if (!path) return ""; 77 const pathSegments = path.split("/"); 78 return pathSegments[pathSegments.length - 1].split(".").pop(); 79} 80 81function contentComponentFilelist(data, dataID) { 82 return data.map((content, index) => { 83 const typeFile = getFileType(content.path); 84 85 const isLink = content.link != null; 86 const linkAttributes = { 87 href: isLink 88 ? `href="${content.link}"` 89 : `href="/api/component-file/image/${content.id}/o"`, 90 download: isLink 91 ? "" 92 : `download="${content.name_display}.${typeFile}"`, 93 target: isLink ? 'target="_blank"' : "", 94 text: isLink ? "รายละà¹à¸à¸µà¸¢à¸à¹à¸à¸´à¹à¸¡à¹à¸à¸´à¸¡" : "à¸à¸²à¸§à¸à¹à¹à¸«à¸¥à¸", 95 icon: isLink ? "" : "fas fa-download me-2", 96 }; 97 98 let master_status = [ 99 "à¹à¸«à¸¡à¹", 100 "à¹à¸à¹à¹à¸", 101 "à¹à¸à¸°à¸à¸³", 102 "à¹à¸à¸´à¸à¸£à¸±à¸à¸ªà¸¡à¸±à¸à¸£", 103 "à¸à¸´à¸à¸£à¸±à¸à¸ªà¸¡à¸±à¸à¸£", 104 ]; 105 let master_status_bg = [ 106 "bg-success-custom", 107 "bg-edit-custom", 108 "bg-success-custom", 109 "bg-success-custom", 110 "bg-close-custom", 111 ]; 112 113 let ribbon = ""; 114 if (content.component_file_status != null) { 115 let status_ribbon = content.component_file_status.master_status_id; 116 ribbon = `<span class="rounded ${ 117 master_status_bg[status_ribbon - 1] 118 } pt-1 ps-3 pe-3 pb-1">${master_status[status_ribbon - 1]}</span>`; 119 } 120 121 const visibilityClass = 122 index <= 2 ? "" : `d-none componentfilelist-${dataID}`; 123 124 return ` 125 <div class="card card-dowload-item card-dowload-item-2 ms-4 me-5"> 126 <div class="card-body p-0 d-flex position-relative"> 127 <a class="mt-3 font-18 text-blue me-2 ms-3"><i class="fas fa-file"></i></a> 128 <p class="mt-3 font-14 text-blue text-dowload-item text-wrap-1">${content.name_display} ${ribbon}</p> 129 <a class="mt-3 font-14 text-blue me-4 ms-auto" ${linkAttributes.href} ${linkAttributes.download} ${linkAttributes.target}> 130 <i class="${linkAttributes.icon}"></i> ${linkAttributes.text} 131 </a> 132 </div> 133 </div> 134 `; 135 });
136} 137 138function contentfile(data) { 139 return data.map((content) => { 140 let typeFile = ""; 141 if (content.path != null) { 142 typeFile = content.path.split("/").last().split(".").last(); 143 } 144 145 const link = 146 content.link != null 147 ? `href="${content.link}"` 148 : `href="/api/component-file/image/${content.id}/o"`; 149 const linkDownload = 150 content.link != null 151 ? "" 152 : `download="${content.name_display}.${typeFile}"`; 153 const linkText = 154 content.link != null ? "รายละà¹à¸à¸µà¸¢à¸à¹à¸à¸´à¹à¸¡à¹à¸à¸´à¸¡" : "à¸à¸²à¸§à¸à¹à¹à¸«à¸¥à¸"; 155 const linkIcon = content.link != null ? "" : "fas fa-download me-2"; 156 const linkClass = "font-14 text-blue p-3 btn-download"; 157 const linkTarget = content.link != null ? 'target="_blank"' : ""; 158 159 return ` 160 <div class="col-4"> 161 <div class="card border-0 card-download"> 162 <p class="font-14 text-blue p-3">${content.name_display}</p> 163 <a ${link} ${linkDownload} class="${linkClass}" ${linkTarget}><i class=" ${linkIcon}"></i> ${linkText} </a> 164 </div> 165 </div> 166 `; 167 }); 168} 169 170function ShowAll(id) { 171 $(`.componentfilelist-${id}`).toggleClass("d-none"); 172 $(`.text-componentfilelist2-${id}`).toggleClass("d-none"); 173 $(`.text-componentfilelist3-${id}`).toggleClass("d-none"); 174}
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.