2018-07-30 07:18:56 +00:00
|
|
|
|
var locationpath="root";var parentpath="null";var ap;var zipTimer;$(function(){getServerOS();showFolderView(locationpath);$(document).click(function(e){var filetable=$("#filetable")[0];if(e.target!==filetable&&!$.contains(filetable,e.target)){$(".filerow").removeClass("info")}});$('#audioPlayerModal').on('hidden.bs.modal',function(e){if(ap!=null){ap.seek(0);ap.pause()}});$('#downloadAllCheckedModal').on('hidden.bs.modal',function(e){if(zipTimer!=null){window.clearInterval(zipTimer)}})});function getServerOS(){$.ajax({type:"POST",dataType:"text",data:{},url:"homeController/getServerOS.ajax",success:function(result){if(result=="mustLogin"){window.location.href="login.html"}$("#serverOS").text(result)},error:function(){$("#serverOS").html("<a onclick='getServerOS()'>获取失败,点击重试</a>")}})}function showFolderView(fid){startLoading();$.ajax({type:'POST',dataType:'text',data:{fid:fid},url:'homeController/getFolderView.ajax',success:function(result){if(result=="mustLogin"){endLoading();window.location.href="login.html"}else{var folderView=eval("("+result+")");locationpath=folderView.folder.folderId;parentpath=folderView.folder.folderParent;showParentList(folderView);showAccountView(folderView);showPublishTime(folderView);showFolderTable(folderView);endLoading()}},error:function(){$("#tb").html("<span class='graytext'>获取失败,请尝试刷新</span>");$("#publishTime").html("<span class='graytext'>获取失败,请尝试刷新</span>");$("#parentlistbox").html("<span class='graytext'>获取失败,请尝试刷新</span>");endLoading()}})}function startLoading(){$('#loadingModal').modal('show')}function endLoading(){$('#loadingModal').modal('hide')}function dologin(){var accountId=$("#accountid").val();var accountPwd=$("#accountpwd").val();var check="y";if(accountId.length==0){$("#accountidbox").addClass("has-error");check="n"}else{$("#accountidbox").removeClass("has-error")}if(accountPwd.length==0){$("#accountpwdbox").addClass("has-error");check="n"}else{$("#accountpwdbox").removeClass("has-error")}if(check=="y"){$.ajax({url:'homeController/getPublicKey.ajax',type:'POST',data:{},dataType:'text',success:function(result){var publicKeyInfo=eval("("+result+")");var date=new Date();var loginInfo='{accountId:"'+accountId+'",accountPwd:"'+accountPwd+'",time:"'+publicKeyInfo.time+'"}';var encrypt=new JSEncrypt();encrypt.setPublicKey(publicKeyInfo.publicKey);var encrypted=encrypt.encrypt(loginInfo);sendLoginInfo(encrypted)},error:function(){$("#alertbox").addClass("alert");$("#alertbox").addClass("alert-danger");$("#alertbox").text("提示:登录请求失败,请检查网络或服务器运行状态")}})}}function sendLoginInfo(encrypted){$.ajax({type:"POST",dataType:"text",url:"homeController/doLogin.ajax",data:{encrypted:encrypted},success:function(result){$("#alertbox").removeClass("alert");$("#alertbox").removeClass("alert-danger");$("#alertbox").text("");switch(result){case"permitlogin":$("#accountidbox").removeClass("has-error");$("#accountpwdbox").removeClass("has-error");window.location.href="home.html";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("提示:无法登录,未知错误");break}},error:function(){$("#alertbox").addClass("alert");$("#alertbox").addClass("alert-danger");$("#alertbox").text("提示:登录请求<EFBFBD><EFBFBD>
|