Index: arms/detail.html =================================================================== diff -u -rbeefe05179de36f0b4a3e8b5d3da6198efdb124d -r5ec1de6097ec8967e6df493b2a89d48f0826778a --- arms/detail.html (.../detail.html) (revision beefe05179de36f0b4a3e8b5d3da6198efdb124d) +++ arms/detail.html (.../detail.html) (revision 5ec1de6097ec8967e6df493b2a89d48f0826778a) @@ -657,9 +657,9 @@
Index: arms/js/detail.js =================================================================== diff -u -reae3582f0fa4c0587b47a9db409bff1aac439fb3 -r5ec1de6097ec8967e6df493b2a89d48f0826778a --- arms/js/detail.js (.../detail.js) (revision eae3582f0fa4c0587b47a9db409bff1aac439fb3) +++ arms/js/detail.js (.../detail.js) (revision 5ec1de6097ec8967e6df493b2a89d48f0826778a) @@ -11,6 +11,44 @@ '#question': false }; +var iconsMap = { + 'application/vnd.ms-htmlhelp': 'CHM.png', + 'application/vnd.ms-excel': 'XLS.png', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'XLSX.png', + 'application/vnd.ms-powerpoint': 'PPT.png', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'PPTX.png', + 'application/msword': 'DOC.png', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'DOCX.png', + 'application/pdf': 'PDF.png', + 'application/x-rar-compressed': 'RAR.png', + 'application/zip': 'ZIP.png', + // 'application/x-gzip': 'ZIP.png', + 'application/x-msdownload': 'DLL.png', + 'application/javascript': 'JS.png', + 'application/x-shockwave-flash': 'SWF.png', + 'application/xml': 'XML.png', + 'application/x-yaml': 'YAML.svg', + 'image/bmp': 'BMP.png', + 'image/gif': 'GIF.png', + 'image/jpeg': 'JPEG.png', + 'image/png': 'PNG.png', + 'image/tiff': 'TIFF.png', + 'image/vnd.dwg': 'DWG.png', + 'text/css': 'CSS.png', + 'text/html': 'HTML.png', + 'text/plain': 'TXT.png', + 'text/richtext': 'RTF.png', + 'text/xml': 'XML.png', + 'text/yaml': 'YAML.svg', + 'text/x-yaml': 'YAML.svg', + 'video/mp4': 'MP4.png', + 'video/mpeg': 'MPEG.png', + 'audio/mpeg': 'MP3.png', + 'audio/x-wav': 'WAV.png', + // 추가 타입 여기에 추가 + // 'application/java-archive': 'JAR.png', +}; + function execDocReady() { var pluginGroups = [ [ @@ -593,7 +631,6 @@ // 각 파일 정보(fileSet)을 처리 fileSet.forEach(function (file) { console.log(file.fileName); - var $target = $('#filter-files'); var filterClass; if (file.contentType.includes("image")) { filterClass = 'filter-image'; @@ -603,18 +640,24 @@ filterClass = 'filter-etc'; } - var imgSrc = "../arms/html/armsDetailExceptTemplate/assets/img/portfolio/portfolio-3.jpg"; // 이미지 경로 + var iconFileName = iconsMap[file.contentType] || 'Default.png'; + var imgSrc = "./img/fileIconPack/" + iconFileName; // 이미지 경로 var title = file.fileName; - var fileSize = file.size; + var downloadUrl = file.url; + var thumbnailUrl = file.thumbnailUrl; + var fileSize = formatBytes(file.size, 3); + // var fileSize = file.size; + var imageLinkHtml = file.contentType.includes("image") ? `` : ''; + var $newHtml = $(`
-
- +
+

${title}

${fileSize}

@@ -653,6 +696,18 @@ }); } +function formatBytes(bytes, decimals = 2) { + if (bytes === 0) return '0 Bytes'; + + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + + const i = Math.floor(Math.log(bytes) / Math.log(k)); + + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; +} + // ------------------ QnA 게시판보기 ------------------ // function reqCommentListViewTabClick() { $("#get_req_comment_list").click(function () {