493 lines
18 KiB
Plaintext
493 lines
18 KiB
Plaintext
<!-- #include virtual = "include/header.asp" -->
|
|
<!-- #include virtual = "include/left.asp" -->
|
|
<!-- Content Wrapper. Contains page content -->
|
|
<div class="content-wrapper">
|
|
<div id="loadingDiv"><div id="loadingMent">Design Library 목록을 최신화하는 중입니다...</div></div>
|
|
<style>
|
|
#container{
|
|
background-color:#eaeaea;
|
|
min-width:1200px;
|
|
}
|
|
#description{
|
|
height: 90px;
|
|
padding: 3px 18px;
|
|
font-size: 15px;
|
|
font-weight: bold;
|
|
letter-spacing: 0px;
|
|
line-height: 27px;
|
|
box-sizing: border-box;
|
|
background-color: #eaeaea;
|
|
border: 15px solid #d8d8d8;
|
|
position:relative;
|
|
}
|
|
.btn{
|
|
display: inline-block;
|
|
padding: 2px 15px;
|
|
border-radius: 5px;
|
|
background-color: #d8d8d8 !important;
|
|
color: #000;
|
|
box-shadow: 1px 1px 1px 1px #6b6b6b;
|
|
cursor: pointer;
|
|
}
|
|
#refreshLib{
|
|
background: url(/images/knowledge/refresh.png) 93px center no-repeat;
|
|
position: absolute;
|
|
right: 10px;
|
|
bottom: 13px;
|
|
width: 134px;
|
|
font-size: 1.25em;
|
|
padding-right: 36px;
|
|
}
|
|
#pathTree{
|
|
width: 346px;
|
|
height: 620px;
|
|
overflow-y: scroll;
|
|
padding: 10px;
|
|
display:inline-block;
|
|
}
|
|
#pathTree *:not(i){
|
|
font-size: 14px;
|
|
letter-spacing: 0px;
|
|
}
|
|
.tj_container ul{
|
|
padding-left: 1em;
|
|
}
|
|
#fileInfo{
|
|
display: inline-block;
|
|
vertical-align: top;
|
|
width: calc(100% - 384px);
|
|
margin: 15px;
|
|
}
|
|
#topInfo{
|
|
width: 100%;
|
|
margin-bottom: 10px;
|
|
}
|
|
#pathInfo{
|
|
width: 69%;
|
|
height: 30px;
|
|
border-radius: 15px;
|
|
display: inline-block;
|
|
padding: 5px 20px;
|
|
background-color: #d8d8d8;
|
|
box-sizing: border-box;
|
|
font-size: 17px;
|
|
}
|
|
#saerchForm{
|
|
display: inline-block;
|
|
width: 30%;
|
|
height: 30px;
|
|
vertical-align: top;
|
|
text-align: right;
|
|
}
|
|
#searchKeyword{
|
|
height: 30px;
|
|
width: 240px;
|
|
border: none;
|
|
background: url(/images/knowledge/search_icon.png) 210px center no-repeat;
|
|
background-color: #d8d8d8;
|
|
border-radius: 15px;
|
|
padding: 3px 35px 3px 15px;
|
|
font-size: 15px;
|
|
}
|
|
#fileContents{
|
|
display: inline-block;
|
|
background-color: #fff;
|
|
width: 100%;
|
|
padding-top: 10px;
|
|
height: 555px;
|
|
overflow-y: scroll;
|
|
}
|
|
#baseMessage{
|
|
text-align: center;
|
|
font-size: 23px;
|
|
font-weight: bold;
|
|
top: 50%;
|
|
position: relative;
|
|
}
|
|
#progress{
|
|
position: absolute;
|
|
left: 10px;
|
|
width: calc(100% - 20px);
|
|
top: 90px;
|
|
height: calc(100% - 52px - 38px);
|
|
background-color: rgba(255,255,255,0.4);
|
|
display:none;
|
|
}
|
|
#progressDiv{
|
|
position: absolute;
|
|
width: 500px;
|
|
height: 28px;
|
|
top: calc(50% - 80px);
|
|
left: calc(50% - 250px);
|
|
background-color: #eaeaea;
|
|
border-radius: 5px;
|
|
border: 3px solid #172f59;
|
|
}
|
|
#progressBar{
|
|
background-color: #ffd700;
|
|
width: 0%;
|
|
height: 100%;
|
|
}
|
|
#progressCnt{
|
|
position: absolute;
|
|
top: -1px;
|
|
width: 300px;
|
|
height: 16px;
|
|
font-size: 16px;
|
|
text-align: center;
|
|
font-weight: bold;
|
|
left: calc(50% - 150px);
|
|
}
|
|
#loadingDiv{
|
|
background: url(/images/loadingBar.gif) no-repeat center;
|
|
background-size: 240px;
|
|
width: 100%;
|
|
height: 100%;
|
|
left:0;
|
|
top:0;
|
|
background-color: rgba(255,255,255,0.4);
|
|
text-align:center;
|
|
position: absolute;
|
|
z-index: 5001;
|
|
display:none;
|
|
}
|
|
#loadingMent{
|
|
font-size: 20px;
|
|
font-weight:bold;
|
|
position: relative;
|
|
top: calc(50% + 134px);
|
|
}
|
|
.filePreview{
|
|
display: inline-block;
|
|
width: 220px;
|
|
height: 170px;
|
|
margin: 5px;
|
|
vertical-align: top;
|
|
}
|
|
.filePreview a{
|
|
text-decoration: none;
|
|
}
|
|
.filePreview div{
|
|
text-align: center;
|
|
height: 80%;
|
|
display: flex;
|
|
align-items: center;
|
|
/* justify-content: center; */
|
|
}
|
|
.filePreview div img{
|
|
display: block;
|
|
max-width: 95%;
|
|
max-height: 90%;
|
|
padding: 5px;
|
|
margin: 2px auto;
|
|
}
|
|
.filePreview img.transBack{
|
|
background: url(/images/knowledge/trans_back.png);
|
|
}
|
|
.filePreview span{
|
|
display: block;
|
|
width: 100%;
|
|
height: 22px;
|
|
font-size: 14px;
|
|
color: #000;
|
|
text-align: center;
|
|
white-space: nowrap;
|
|
overflow-x: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
</style>
|
|
<!-- Content Header (Page header) -->
|
|
<div class="content-header">
|
|
<h1>Design Library</h1>
|
|
</div>
|
|
<!-- /.content-header -->
|
|
<!-- Main content -->
|
|
<div class="content-body">
|
|
<div class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div id="container">
|
|
<div id="description">
|
|
Design Library는 제안서, 보고서, 기타 자료에 필요한 소스를 다운받아 활용하실 수 있는 게시판입니다.<br>
|
|
모든 임직원이 저작권 문제 없이 자유롭게 이용 가능합니다.
|
|
<% If Session("Depart_Code") = "18" Then %>
|
|
<span class='btn' id="refreshLib">Update</span>
|
|
<% End If %>
|
|
</div>
|
|
<div id="pathTree"></div>
|
|
<div id="fileInfo">
|
|
<div id="topInfo">
|
|
<div id="pathInfo"></div>
|
|
<div id="saerchForm">
|
|
<input type="text" id="searchKeyword" value="" maxlength="50" />
|
|
</div>
|
|
</div>
|
|
<div id="fileContents">
|
|
<div id="baseMessage">좌측 목록에서 폴더를 선택해주세요.</div>
|
|
</div>
|
|
</div>
|
|
<div id="progress"><div id="progressDiv"><div id="progressBar"></div><div id="progressCnt"></div></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- /.content -->
|
|
<%
|
|
Dim pathTreeSQL, fileListSQL
|
|
pathTreeSQL = ""
|
|
pathTreeSQL = pathTreeSQL & " SELECT tpath, tidx "
|
|
pathTreeSQL = pathTreeSQL & " FROM T_DESIGN_TREE "
|
|
|
|
fileListSQL = ""
|
|
fileListSQL = fileListSQL & " SELECT REPLACE('[' + STUFF(( "
|
|
fileListSQL = fileListSQL & " SELECT "
|
|
fileListSQL = fileListSQL & " ',{""fpath"":""' + fpath + '""' "
|
|
fileListSQL = fileListSQL & " + ',""fname"":""' + fname + '""' "
|
|
fileListSQL = fileListSQL & " + ',""fext"":""' + fext + '""' "
|
|
fileListSQL = fileListSQL & " +'}' "
|
|
fileListSQL = fileListSQL & " FROM T_DESIGN_FILE "
|
|
fileListSQL = fileListSQL & " FOR XML PATH('')), 1, 1, '') + ']', '&', '&') AS jsonStr "
|
|
%>
|
|
<!-- REQUIRED SCRIPTS -->
|
|
<script>
|
|
var pathTree = <%= queryToJson(pathTreeSQL) %>;
|
|
<%
|
|
Rs.open fileListSQL, adoConn, 1
|
|
%>
|
|
var fileList = <%= Rs("jsonStr") %>;
|
|
<%
|
|
Rs.Close
|
|
%>
|
|
var sid = "";
|
|
var rootName = "design library";
|
|
var setTimeoutObj = undefined;
|
|
var treeDiv = undefined;
|
|
|
|
var totalCnt = 0;
|
|
var nowCnt = 0;
|
|
$(function(){
|
|
var knasID = "admin";
|
|
var knasPW = "krco#51304";
|
|
var loginSrc = "auth.cgi?api=SYNO.API.Auth&version=3&method=login&account="+knasID+"&passwd="+encodeURIComponent(knasPW)+"&session=FileStation&format=sid";
|
|
$.ajax({
|
|
url : "/knas_api.asp?call=" + encodeURIComponent(loginSrc),
|
|
dataType : 'json',
|
|
success:function(response) {
|
|
sid = response[1].data.sid;
|
|
}
|
|
});
|
|
|
|
createTree();
|
|
$("#refreshLib").on("click", function(){
|
|
if(confirm("Degisn Library를 최신화하시겠습니까?\n(소요시간 1~10분 소요)")){
|
|
refreshLib();
|
|
}
|
|
});
|
|
$("#searchKeyword").on("keyup", function(e){
|
|
var keycode = e.which ? e.which : e.keyCode;
|
|
if(keycode == 13){
|
|
if($.trim($("#searchKeyword").val()).length >= 2){
|
|
var searchFiles = $.grep(fileList, function(obj, idx){ return obj.fname.indexOf($("#searchKeyword").val()) > -1; });
|
|
fileListView(searchFiles, "Search Keyword: <i>" + $("#searchKeyword").val() + "</i>", true, "search");
|
|
}else{
|
|
alert("두글자 이상 입력해주세요.");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
function createTree(){
|
|
var cPathTree = $.map(pathTree, function(obj){
|
|
return {
|
|
"parentNode":obj.tpath.substr(0, obj.tpath.lastIndexOf("/")),
|
|
"nodeName":obj.tpath.split("/")[obj.tidx],
|
|
"nodeObj": new TreeNode(obj.tpath.split("/")[obj.tidx], {
|
|
expanded : false
|
|
})
|
|
};
|
|
});
|
|
cPathTree.push({
|
|
"parentNode":"",
|
|
"nodeName":rootName,
|
|
"nodeObj": new TreeNode(rootName)
|
|
});
|
|
var cPathTreeClone = cPathTree;
|
|
$.each(cPathTreeClone, function(idx, obj){
|
|
if(obj.parentNode != ""){
|
|
var tmpNode = $.grep(cPathTree, function(o, i){ return (o.parentNode + "/" + o.nodeName) == obj.parentNode; })[0];
|
|
obj.nodeObj.on("click", selectNode);
|
|
tmpNode.nodeObj.addChild(obj.nodeObj);
|
|
}
|
|
});
|
|
|
|
var root = $.grep(cPathTree, function(o, i){ return o.parentNode == ""; })[0].nodeObj;
|
|
|
|
treeDiv = new TreeView(root, "#pathTree", {
|
|
leaf_icon: '<i class="fas fa-folder-open"></i>',
|
|
parent_icon: '<i class="fas fa-folder"></i>',
|
|
open_icon: '<i class="fas fa-angle-down"></i>',
|
|
close_icon: '<i class="fas fa-angle-right"></i>'
|
|
});
|
|
|
|
browserChk();
|
|
}
|
|
|
|
function selectNode(e, node){
|
|
var treePath = new TreePath(treeDiv.getRoot(), node);
|
|
var fullpath = $.map(treePath.getPath(), function(obj){ return obj.getUserObject(); }).join("/");
|
|
var selFolderFiles = $.grep(fileList, function(obj, idx){ return obj.fpath.substr(1, obj.fpath.lastIndexOf("/")-1) == fullpath; });
|
|
fileListView(selFolderFiles, fullpath + "/", node.isLeaf(), "select");
|
|
}
|
|
|
|
function fileListView(files, path, isLeaf, stype){
|
|
if(files.length > 0){
|
|
var htmlContents = "";
|
|
setProg(files.length);
|
|
$.each(files, function(idx, obj){
|
|
var tmpHtml = "";
|
|
var thumbnailURL = "";
|
|
var transBack = false;
|
|
if("jpg,jpeg,jpe,bmp,png,tif,tiff,gif".indexOf(obj.fext.toLowerCase()) > -1){
|
|
thumbnailURL = "/knas_api.asp?type=thumb&call=" + encodeURIComponent("entry.cgi?api=SYNO.Finder.File.Thumbnail&version=1&method=get&_sid="+sid+"&full_path=" + encodeURIComponent(obj.fpath));
|
|
if("png,tif,tiff,gif".indexOf(obj.fext.toLowerCase()) > -1){
|
|
transBack = true;
|
|
}
|
|
}else if("ppt,pptx".indexOf(obj.fext.toLowerCase()) > -1){
|
|
thumbnailURL = "/images/knowledge/ppt_icon.png";
|
|
}else if("xls,xlsx".indexOf(obj.fext.toLowerCase()) > -1){
|
|
thumbnailURL = "/images/knowledge/xls_icon.png";
|
|
}else if("zip".indexOf(obj.fext.toLowerCase()) > -1){
|
|
thumbnailURL = "/images/knowledge/zip_icon.png";
|
|
}else{
|
|
thumbnailURL = "/images/knowledge/etc_icon.png";
|
|
}
|
|
|
|
tmpHtml += "<div class='filePreview'>";
|
|
tmpHtml += "<a href='/knas_api.asp?type=down&call=" + encodeURIComponent("entry.cgi?api=SYNO.FileStation.Download&version=1&method=download&_sid="+sid+"&mode=download&path=" + encodeURIComponent(obj.fpath)) + "'>";
|
|
tmpHtml += "<div><img src='" + thumbnailURL + "' alt='" + obj.fname + "' onload='progPlus();' class='" + (transBack ? "transBack" : "") + "'/></div>";
|
|
tmpHtml += "<span>" + obj.fname + "</span>";
|
|
tmpHtml += "</a>";
|
|
tmpHtml += "</div>";
|
|
if(thumbnailURL.indexOf("amp") > -1){
|
|
console.log(obj.fpath);
|
|
console.log(thumbnailURL);
|
|
}
|
|
htmlContents += tmpHtml;
|
|
});
|
|
$("#pathInfo").html(path);
|
|
$("#fileContents").html(htmlContents);
|
|
}else{
|
|
if(isLeaf){
|
|
$("#pathInfo").html(path);
|
|
var tmpMent = stype == 'search' ? '검색결과 -' : '선택한 폴더에';
|
|
$("#fileContents").html('<div id="baseMessage">' + tmpMent + ' 파일이 없습니다.</div>');
|
|
}
|
|
}
|
|
}
|
|
|
|
function refreshLib(){
|
|
$("#loadingDiv").show();
|
|
pathTree = [];
|
|
fileList = [];
|
|
var rootFolder = "/" + rootName;
|
|
callPathList(rootFolder, 1);
|
|
}
|
|
|
|
function findLastFiles(pathList, tidx){
|
|
$.each(pathList, function(idx, obj){
|
|
if(obj.isdir == true){
|
|
pathTree.push({"tidx":tidx+1, "path":obj.path});
|
|
callPathList(obj.path, tidx+1);
|
|
}else{
|
|
obj.ext = obj.additional.type.toLowerCase();
|
|
delete obj.additional;
|
|
delete obj.isdir;
|
|
fileList.push(obj);
|
|
}
|
|
});
|
|
}
|
|
|
|
function callPathList(folderPath, tidx){
|
|
var folderTreeSrc = "entry.cgi?api=SYNO.FileStation.List&version=1&method=list&additional=type&_sid="+sid+"&folder_path="+encodeURIComponent(folderPath);
|
|
$.ajax({
|
|
url : "/knas_api.asp?call=" + encodeURIComponent(folderTreeSrc),
|
|
dataType : 'json',
|
|
success:function(response) {
|
|
findLastFiles(response[1].data.files, tidx);
|
|
if(setTimeoutObj != undefined){
|
|
clearTimeout(setTimeoutObj);
|
|
}
|
|
setTimeoutObj = setTimeout(function(){
|
|
updateDB();
|
|
}, 1000);
|
|
}
|
|
});
|
|
}
|
|
|
|
function updateDB(){
|
|
var param = {
|
|
"tarr" : JSON.stringify(pathTree),
|
|
"farr" : JSON.stringify(fileList)
|
|
};
|
|
$.ajax({
|
|
url : "./design_library_update.asp",
|
|
type : "POST",
|
|
data : param,
|
|
dataType : 'json',
|
|
success : function(response){
|
|
if(response.status == "1"){
|
|
alert("Update Complete!!");
|
|
}else{
|
|
alert("Web Service Error!");
|
|
}
|
|
},
|
|
error : function(){
|
|
alert("web Service Error!");
|
|
},
|
|
complete : function(){
|
|
$("#loadingDiv").hide();
|
|
$(location).attr("href", $(location).attr("href"));
|
|
}
|
|
})
|
|
}
|
|
|
|
function setProg(cnt){
|
|
totalCnt = cnt;
|
|
nowCnt = 0;
|
|
$("#progress").show();
|
|
}
|
|
|
|
function progPlus(){
|
|
nowCnt++;
|
|
$("#progressCnt").text("Loading... (" + nowCnt + "/" + totalCnt + ")");
|
|
$("#progressBar").css("width", (nowCnt / totalCnt * 100) + "%");
|
|
if(nowCnt == totalCnt){
|
|
$("#progressCnt").text("Complete!!!");
|
|
setTimeout(function(){
|
|
endProg();
|
|
}, 500);
|
|
}
|
|
}
|
|
|
|
function endProg(){
|
|
totalCnt = 0;
|
|
nowCnt = 0;
|
|
$("#progressCnt").text("");
|
|
$("#progress").hide();
|
|
}
|
|
|
|
function browserChk(){
|
|
var agent = navigator.userAgent.toLowerCase();
|
|
if ( (navigator.appName == 'Netscape' && navigator.userAgent.search('Trident') != -1) || (agent.indexOf("msie") != -1) ) {
|
|
alert("Internet Explorer에서는 \n기능이 작동하지 않을 수 있습니다.\n\nChrome을 이용해주세요.");
|
|
} else {
|
|
//alert("인터넷 익스플로러 브라우저가 아닙니다.");
|
|
}
|
|
}
|
|
</script>
|
|
</div>
|
|
<!-- /.content-wrapper -->
|
|
<!-- #include virtual = "include/footer.asp" --> |