/* 网站预览 目录展示 */ Namespace.register("U.MD.DK.SP"); //Disk左键事件命名空间 //window.onload = function () { // U.MD.DK.SP.getDirectioryInfo(directoryid); //} /** *获取用户信息 * * */ U.MD.DK.SP.getUser = function (userid) { var _userid = userid; U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", _userid], function (r) {//根据用户名获取用户信息 console.log(r.value); $('.U_MD_DK_SP_Head_Logo_name')[0].innerHTML = r.value[0].UserNickName + '的云盘'; if (r.value[0].UserImageHead) { $('.U_MD_DK_SP_Head_UImg')[0].src = "http://fs.1473.cn/" + r.value[0].UserImageHead; } $('.U_MD_DK_SP_Head_UImg')[0].title = r.value[0].UserNickName; }); } /** * 获取目录信息 * @param {guid} directoryid 目录ID */ U.MD.DK.SP.getDirectioryInfo = function (directoryid) { U.UF.CD.loadPageCrossDomain(function () { U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetDirectroyById", directoryid], U.MD.DK.SP.getDirectioryInfo.asyn); }); } /** * 获取目录信息异步 * */ U.MD.DK.SP.getDirectioryInfo.asyn = function (r) { var _directioryinfo = r.value[0]; U.MD.DK.SP.getUser(_directioryinfo.UserID); U.MD.DK.SP.getAllFileInfo(_directioryinfo.UserDirectoryID, _directioryinfo.UserID, _directioryinfo.GroupID); } /** * 获取目录下的文件 * */ U.MD.DK.SP.getAllFileInfo = function (directoryid, userid, groupid) { U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetChildsByDirectoryId", userid, directoryid, groupid], U.MD.DK.SP.getAllFileInfo.asyn); } /** * 获取目录下的文件 异步 * */ U.MD.DK.SP.getAllFileInfo.asyn = function (r) { console.log(r.value); var _contentBox = $('.U_MD_DK_SP_ContentList')[0]; U.MD.DK.SP.getParentFile(r.value[0].UserDirectoryParentID); for (var i = 0; i < r.value.length; i++) { var _fileli = $$('div', { 'className': 'U_MD_DK_SP_Li', 'id': 'U_MD_DK_SP_Li' + i }, _contentBox); $$('div', { 'className': 'U_MD_DK_SP_CTopNum', 'innerHTML': i > 8 ? (i + 1) : '0' + (i + 1) }, $('#U_MD_DK_SP_Li' + i)[0]); var _icon = U.MD.DK.SP.getIcon(r.value[i].UserDirectoryExtendType); //根据文件扩展名,得到图标的样式 if (!_icon.classname[2]) { _icon.classname[2] = 'U_MD_DK_SP_unfile'; } var _filename = $$('div', { 'className': 'U_MD_DK_SP_CTopFileName', 'title': r.value[i].UserallDirectoryName }, $('#U_MD_DK_SP_Li' + i)[0]); $$('span', { 'className': _icon.classname[2] + ' U_MD_DK_SP_Img U_MD_DK_SP_RZSMI ', 'innerHTML': '    ' }, _filename); _filename.innerHTML += r.value[i].UserallDirectoryName; $$('div', { 'className': 'U_MD_DK_SP_CTopFileType', 'innerHTML': r.value[i].UserDirectoryExtendType }, $('#U_MD_DK_SP_Li' + i)[0]); $$('div', { 'className': 'U_MD_DK_SP_CTopFileSize', 'innerHTML': U.UF.UP.minUnitToMaxUnit(r.value[i].UserDirectorySize) }, $('#U_MD_DK_SP_Li' + i)[0]); $$('div', { 'className': 'U_MD_DK_SP_CTopFileAuthor', 'innerHTML': r.value[i].UserNickName }, $('#U_MD_DK_SP_Li' + i)[0]); var _date = U.UF.D.formatDateToArray(r.value[i].UserDirectoryAddTime); $$('div', { 'className': 'U_MD_DK_SP_CTopFileUpdateTime', 'innerHTML': _date[0] + "-" + _date[1] + "-" + _date[2] + " " + _date[3] + ":" + _date[4] }, $('#U_MD_DK_SP_Li' + i)[0]); _fileli.onclick = U.UF.C.closure(function (fileinfo) { window.location.href = window.location.origin + window.location.pathname + "/" + fileinfo.UserallDirectoryName + window.location.search; // window.location.href = window.location.origin + window.location.pathname + window.location.search + fileinfo.UserallDirectoryName ; }, [r.value[i]]); } } /*** *获取图标 *extendtype {string} 文件种类 */ U.MD.DK.SP.getIcon = function (extendtype) { var i, _application = US.disk.applicationTypes //获取所有打开应用的信息 ; //循环信息中找到指定的应用的信息 for (i in _application) { //找到后缀名对应的程序信息 if (_application[i].types.indexOf(extendtype.toLowerCase()) > -1) { return _application[i]; //返回应用的信息 } } return _application["unknownfile"]; //如果是本站未知的后缀直接归属于文件 } /*** *获取上一次文件夹 *extendtype {string} 文件种类 */ U.MD.DK.SP.getParentFile = function (parentid) { U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetDirectroyById", parentid], function (r) { $('.U_MD_DK_SP_Head_Logo_name')[0].innerHTML += '-' + r.value[0].UserDirectoryName + '文档详细列表'; }, []); }