function doAlert(){alert("错误:无法连接到kiftd服务器,请检查您的网络连接或查看服务器运行状态。")}function getServerOS(){$.ajax({type:"POST",dataType:"text",data:{},url:"homeController/getServerOS.ajax",success:function(a){"mustLogin"==a&&(window.location.href="login.html"),$("#serverOS").text(a)},error:function(){$("#serverOS").html("获取失败,点击重试")}})}function showFolderView(fid){startLoading(),$.ajax({type:"POST",dataType:"text",data:{fid:fid},url:"homeController/getFolderView.ajax",success:function(result){endLoading(),"mustLogin"==result?window.location.href="login.html":(folderView=eval("("+result+")"),locationpath=folderView.folder.folderId,parentpath=folderView.folder.folderParent,showParentList(folderView),showAccountView(folderView),showPublishTime(folderView),originFolderView=$.extend(!0,{},folderView),$("#sortByFN").removeClass(),$("#sortByCD").removeClass(),$("#sortByFS").removeClass(),$("#sortByCN").removeClass(),showFolderTable(folderView))},error:function(){endLoading(),doAlert(),$("#tb").html("获取失败,请尝试刷新"),$("#publishTime").html("获取失败,请尝试刷新"),$("#parentlistbox").html("获取失败,请尝试刷新")}})}function startLoading(){$("#loadingModal").modal({backdrop:"static",keyboard:!1}),$("#loadingModal").modal("show")}function endLoading(){$("#loadingModal").modal("hide")}function startLogin(){$("#accountid").attr("disabled","disabled"),$("#accountpwd").attr("disabled","disabled"),$("#dologinButton").attr("disabled","disabled")}function finishLogin(){$("#accountid").removeAttr("disabled","disabled"),$("#accountpwd").removeAttr("disabled","disabled"),$("#dologinButton").removeAttr("disabled","disabled")}function dologin(){var accountId=$("#accountid").val(),accountPwd=$("#accountpwd").val(),check="y";0==accountId.length?($("#accountidbox").addClass("has-error"),check="n"):$("#accountidbox").removeClass("has-error"),0==accountPwd.length?($("#accountpwdbox").addClass("has-error"),check="n"):$("#accountpwdbox").removeClass("has-error"),"y"==check&&(startLogin(),$.ajax({url:"homeController/getPublicKey.ajax",type:"POST",data:{},dataType:"text",success:function(result){var encrypted,publicKeyInfo=eval("("+result+")"),date=new Date,loginInfo='{accountId:"'+accountId+'",accountPwd:"'+accountPwd+'",time:"'+publicKeyInfo.time+'"}',encrypt=new JSEncrypt;encrypt.setPublicKey(publicKeyInfo.publicKey),encrypted=encrypt.encrypt(loginInfo),sendLoginInfo(encrypted)},error:function(){finishLogin(),$("#alertbox").addClass("alert"),$("#alertbox").addClass("alert-danger"),$("#alertbox").text("提示:登录请求失败,请检查网络或服务器运行状态")}}))}function sendLoginInfo(a){$.ajax({type:"POST",dataType:"text",url:"homeController/doLogin.ajax",data:{encrypted:a},success:function(a){switch(finishLogin(),$("#alertbox").removeClass("alert"),$("#alertbox").removeClass("alert-danger"),$("#alertbox").text(""),a){case"permitlogin":$("#accountidbox").removeClass("has-error"),$("#accountpwdbox").removeClass("has-error"),$("#loginModal").modal("hide"),showFolderView(locationpath);break;case"accountnotfound":$("#accountidbox").addClass("has-error"),$("#accountpwdbox").removeClass("has-error"),$("#alertbox").addClass("alert"),$("#alertbox").addClass("alert-danger"),$("#alertbox").text("提示:登录失败,账户不存在或未设置");break;case"accountpwderror":$("#accountpwdbox").addClass("has-error"),$("#accountidbox").removeClass("has-error"),$("#alertbox").addClass("alert"),$("#alertbox").addClass("alert-danger"),$("#alertbox").text("提示:登录失败,密码错误或未设置");break;case"error":$("#alertbox").addClass("alert"),$("#alertbox").addClass("alert-danger"),$("#alertbox").text("提示:登录失败,登录请求无法通过效验(可能是请求耗时过长导致的)");break;default:$("#alertbox").addClass("alert"),$("#alertbox").addClass("alert-danger"),$("#alertbox").text("提示:无法登录,未知错误")}},error:function(){finishLogin(),$("#alertbox").addClass("alert"),$("#alertbox").addClass("alert-danger"),$("#alertbox").text("提示:登录请求失败,请检查网络或服务器运行状态")}})}function dologout(){$("#logoutModal").modal("hide"),$.ajax({url:"homeController/doLogout.ajax",type:"POST",data:{},dataType:"text",success:function(a){"SUCCESS"==a&&showFolderView(locationpath)},error:function(){doAlert()}})}function showParentList(a){var b,c;$("#parentlistbox").html(""),b=a.folder,c=0,$.each(a.parentList,function(a,b){3>=c&&($("#parentlistbox").append(" / "),c++)}),c>3&&$("#parentlistbox").append("... / "),$("#parentlistbox").append(b.folderName)}function showAccountView(a){$("#tb").html(""),null!=a.account?$("#tb").append(""):$("#tb").append("");var b=a.authList;null!=b&&(checkAuth(b,"C")&&$("#parentlistbox").append(""),checkAuth(b,"U")&&$("#parentlistbox").append(""),checkAuth(b,"L")&&$("#parentlistbox").append(""),checkAuth(b,"D")&&$("#parentlistbox").append(""),checkAuth(b,"M")&&($("#parentlistbox").append(""),void 0!==checkedMovefiles&&checkedMovefiles.length>0&&($("#cutSignTx").text("粘贴("+checkedMovefiles.length+")"),$("#cutSignSp").removeClass(),$("#cutSignSp").addClass("glyphicon glyphicon-import"))))}function checkAuth(a,b){var c=!1;return $.each(a,function(a,d){d==b&&(c=!0)}),c}function showPublishTime(a){$("#publishTime").html("");var b="";b=null!=a.publishTime?a.publishTime:"--",$("#publishTime").text(b)}function refreshFolderView(){null!=locationpath&&locationpath.length>0?showFolderView(locationpath):showFolderView("root")}function returnPF(){null!=parentpath&&"null"!=parentpath?showFolderView(parentpath):showFolderView("root")}function showFolderTable(a){var b,c,d,e;$("#foldertable").html(""),null!=parentpath&&"null"!=parentpath&&$("#foldertable").append("
"+d+"[正在上传...]
"),xhr=new XMLHttpRequest,e=new FormData,e.append("file",c),e.append("folderId",locationpath),xhr.open("POST","homeController/douploadFile.ajax",!0),xhr.upload.addEventListener("progress",uploadProgress,!1),xhr.send(e),xhr.onloadend=function(){if(200===xhr.status){var c=xhr.responseText;"uploadsuccess"==c?($("#uls_"+a).text("[已完成]"),b>a?doupload(a+1):($("#uploadfile").val(""),$("#filepath").val(""),$("#pros").width("0%"),$("#uploadFileModal").modal("hide"),$("#umbutton").attr("disabled",!1),showFolderView(locationpath),$("#filecount").text(""),$("#uploadstatus").text(""),$("#selectcount").text(""))):"uploaderror"==c?(showUploadFileAlert("提示:出现意外错误,文件:["+d+"]上传失败,上传被中断。"),$("#uls_"+a).text("[失败]")):($("#uploadFileModal").modal("hide"),$("#uls_"+a).text("[失败]"))}else showUploadFileAlert("提示:出现意外错误,文件:["+d+"]上传失败,上传被中断。"),$("#uls_"+a).text("[失败]")}):(showUploadFileAlert("提示:要上传的文件不存在。"),$("#uploadstatus").prepend("未找到要上传的文件[失败]
"))}function uploadProgress(a){if(a.lengthComputable){var b=Math.round(100*a.loaded/a.total);$("#pros").width(b+"%")}}function showUploadFileAlert(a){$("#uploadFileAlert").addClass("alert"),$("#uploadFileAlert").addClass("alert-danger"),$("#uploadFileAlert").text(a),$("#umbutton").attr("disabled",!1)}function showDownloadModel(a,b){$("#downloadModal").modal("toggle"),$("#downloadFileName").text("提示:您确认要下载文件:["+b+"]么?"),$("#downloadFileBox").html(""),$("#dlmbutton").attr("disabled",!1)}function dodownload(a){$("#dlmbutton").attr("disabled",!0),$("#downloadFileName").text("提示:准备开始下载,请稍候..."),setTimeout("$('#downloadModal').modal('hide');",800),window.location.href="homeController/downloadFile.do?fileId="+a}function showDeleteFileModel(a,b){$("#deleteFileBox").html(""),$("#dfmbutton").attr("disabled",!1),$("#deleteFileMessage").text("提示:确定要彻底删除文件:["+b+"]么?该操作不可恢复"),$("#deleteFileModal").modal("toggle")}function deleteFile(a){$("#dfmbutton").attr("disabled",!0),$("#deleteFileMessage").text("提示:正在删除,请稍候..."),$.ajax({type:"POST",dataType:"text",data:{fileId:a},url:"homeController/deleteFile.ajax",success:function(a){"mustLogin"==a?window.location.href="login.html":"noAuthorized"==a?($("#deleteFileMessage").text("提示:您的操作未被授权,删除失败"),$("#dfmbutton").attr("disabled",!1)):"errorParameter"==a?($("#deleteFileMessage").text("提示:参数不正确,删除失败"),$("#dfmbutton").attr("disabled",!1)):"cannotDeleteFile"==a?($("#deleteFileMessage").text("提示:出现意外错误,可能未能删除文件"),$("#dfmbutton").attr("disabled",!1)):"deleteFileSuccess"==a?($("#deleteFileModal").modal("hide"),showFolderView(locationpath)):($("#deleteFileMessage").text("提示:出现意外错误,可能未能删除文件"),$("#dfmbutton").attr("disabled",!1))},error:function(){$("#deleteFileMessage").text("提示:出现意外错误,可能未能删除文件"),$("#dfmbutton").attr("disabled",!1)}})}function showRenameFileModel(a,b){$("#newFileNamealert").removeClass("alert"),$("#newFileNamealert").removeClass("alert-danger"),$("#filerenamebox").removeClass("has-error"),$("#newFileNamealert").text(""),$("#renameFileBox").html(""),$("#newfilename").val(b),$("#renameFileModal").modal("toggle")}function renameFile(a){var b=new RegExp('[/|\\s\\\\*\\<\\>"]+',"g"),c=$("#newfilename").val();c.length>0?c.length<128?b.test(c)?showRenameFolderAlert("提示:文件名中不应含有:空格 引号 / * | < > "):$.ajax({type:"POST",dataType:"text",data:{fileId:a,newFileName:c},url:"homeController/renameFile.ajax",success:function(a){"mustLogin"==a?window.location.href="login.html":"cannotRenameFile"==a?showRenameFolderAlert("提示:出现意外错误,可能未能重命名文件"):"renameFileSuccess"==a?($("#renameFileModal").modal("hide"),showFolderView(locationpath)):"errorParameter"==a?showRenameFolderAlert("提示:参数错误,重命名失败"):"noAuthorized"==a?showRenameFolderAlert("提示:您的操作未被授权,重命名失败"):showRenameFolderAlert("提示:出现意外错误,可能未能重命名文件")},error:function(){showRenameFolderAlert("提示:出现意外错误,可能未能重命名文件")}}):showRenameFolderAlert("提示:文件名称太长"):showRenameFolderAlert("提示:文件名不能为空")}function showRenameFolderAlert(a){$("#newFileNamealert").addClass("alert"),$("#newFileNamealert").addClass("alert-danger"),$("#filerenamebox").addClass("has-error"),$("#newFileNamealert").text(a)}function abortUpload(){null!=xhr&&(xhr.abort(),$("#umbutton").attr("disabled",!1),$("#pros").width("0%"),$("#filecount").text("")),$("#uploadfile").val(""),$("#filepath").val(""),$("#uploadstatus").html(""),$("#selectcount").text(""),$("#uploadFileModal").modal("hide"),showFolderView(locationpath)}function getSuffix(a){var b=a.lastIndexOf("."),c=a.length,d=a.substring(b+1,c);return d.toLowerCase()}function playVideo(a){window.open("quickview/video.html?fileId="+a)}function pdfView(a){window.open("homeController/pdfView.do?fileId="+a)}function showPicture(fileId){$.ajax({url:"homeController/getPrePicture.ajax",data:{fileId:fileId},type:"POST",dataType:"text",success:function(result){var pvl,imageslist;"ERROR"!=result?(pvl=eval("("+result+")"),imageslist=document.createElement("ul"),$.each(pvl.pictureViewList,function(a,b){var d,c=new Image;c.src="fileblocks/"+b.filePath,c.alt=b.fileName,d=document.createElement("li"),d.appendChild(c),imageslist.appendChild(d)}),viewer=new Viewer(imageslist,{hidden:function(){viewer.destroy()}}),viewer.view(pvl.index),viewer.show()):alert("错误:无法定位要预览的文件或该操作未被授权。")},error:function(){alert("错误:请求失败,请刷新重试。")}})}function checkfile(a){window.event.shiftKey?$("#"+a).hasClass("info")?$("#"+a).removeClass("info"):$("#"+a).addClass("info"):($(".filerow").removeClass("info"),$("#"+a).addClass("info"))}function checkallfile(){checkAll?($(".filerow").addClass("info"),checkAll=!1):($(".filerow").removeClass("info"),checkAll=!0)}function showDownloadAllCheckedModel(){$("#downloadAllCheckedBox").html(""),$("#downloadAllCheckedLoad").text("");var a=$(".info").get();0==a.length?$("#downloadAllCheckedName").text("提示:您还未选择任何文件,请先选中一些文件后再执行本操作(点击某一文件行来选中单一文件;按住Shift并点击文件行选中多个文件;使用Shitf+A选中/取消选中所有文件)。"):($("#downloadAllCheckedName").text("提示:您确认要打包并下载这"+a.length+"项么?"),$("#downloadAllCheckedBox").html(""),$("#dclmbutton").attr("disabled",!1)),$("#downloadAllCheckedModal").modal("toggle")}function downloadAllChecked(){var a,b,c,d;for($("#dclmbutton").attr("disabled",!0),a=$(".info").get(),b=new Array,c=0;c