SitePreview.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. 网站预览 目录展示
  3. */
  4. Namespace.register("U.MD.DK.SP"); //Disk左键事件命名空间
  5. //window.onload = function () {
  6. // U.MD.DK.SP.getDirectioryInfo(directoryid);
  7. //}
  8. /**
  9. *获取用户信息
  10. *
  11. *
  12. */
  13. U.MD.DK.SP.getUser = function (userid) {
  14. var _userid = userid;
  15. U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", _userid], function (r) {//根据用户名获取用户信息
  16. console.log(r.value);
  17. $('.U_MD_DK_SP_Head_Logo_name')[0].innerHTML = r.value[0].UserNickName + '的云盘';
  18. if (r.value[0].UserImageHead) {
  19. $('.U_MD_DK_SP_Head_UImg')[0].src = "http://fs.1473.cn/" + r.value[0].UserImageHead;
  20. }
  21. $('.U_MD_DK_SP_Head_UImg')[0].title = r.value[0].UserNickName;
  22. });
  23. }
  24. /**
  25. * 获取目录信息
  26. * @param {guid} directoryid 目录ID
  27. */
  28. U.MD.DK.SP.getDirectioryInfo = function (directoryid) {
  29. U.UF.CD.loadPageCrossDomain(function () {
  30. U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetDirectroyById", directoryid], U.MD.DK.SP.getDirectioryInfo.asyn);
  31. });
  32. }
  33. /**
  34. * 获取目录信息异步
  35. *
  36. */
  37. U.MD.DK.SP.getDirectioryInfo.asyn = function (r) {
  38. var _directioryinfo = r.value[0];
  39. U.MD.DK.SP.getUser(_directioryinfo.UserID);
  40. U.MD.DK.SP.getAllFileInfo(_directioryinfo.UserDirectoryID, _directioryinfo.UserID, _directioryinfo.GroupID);
  41. }
  42. /**
  43. * 获取目录下的文件
  44. *
  45. */
  46. U.MD.DK.SP.getAllFileInfo = function (directoryid, userid, groupid) {
  47. U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetChildsByDirectoryId", userid, directoryid, groupid], U.MD.DK.SP.getAllFileInfo.asyn);
  48. }
  49. /**
  50. * 获取目录下的文件 异步
  51. *
  52. */
  53. U.MD.DK.SP.getAllFileInfo.asyn = function (r) {
  54. console.log(r.value);
  55. var _contentBox = $('.U_MD_DK_SP_ContentList')[0];
  56. U.MD.DK.SP.getParentFile(r.value[0].UserDirectoryParentID);
  57. for (var i = 0; i < r.value.length; i++) {
  58. var _fileli = $$('div', { 'className': 'U_MD_DK_SP_Li', 'id': 'U_MD_DK_SP_Li' + i }, _contentBox);
  59. $$('div', { 'className': 'U_MD_DK_SP_CTopNum', 'innerHTML': i > 8 ? (i + 1) : '0' + (i + 1) }, $('#U_MD_DK_SP_Li' + i)[0]);
  60. var _icon = U.MD.DK.SP.getIcon(r.value[i].UserDirectoryExtendType); //根据文件扩展名,得到图标的样式
  61. if (!_icon.classname[2]) {
  62. _icon.classname[2] = 'U_MD_DK_SP_unfile';
  63. }
  64. var _filename = $$('div', { 'className': 'U_MD_DK_SP_CTopFileName', 'title': r.value[i].UserallDirectoryName }, $('#U_MD_DK_SP_Li' + i)[0]);
  65. $$('span', { 'className': _icon.classname[2] + ' U_MD_DK_SP_Img U_MD_DK_SP_RZSMI ', 'innerHTML': '&nbsp;&nbsp;&nbsp;&nbsp;' }, _filename);
  66. _filename.innerHTML += r.value[i].UserallDirectoryName;
  67. $$('div', { 'className': 'U_MD_DK_SP_CTopFileType', 'innerHTML': r.value[i].UserDirectoryExtendType }, $('#U_MD_DK_SP_Li' + i)[0]);
  68. $$('div', { 'className': 'U_MD_DK_SP_CTopFileSize', 'innerHTML': U.UF.UP.minUnitToMaxUnit(r.value[i].UserDirectorySize) }, $('#U_MD_DK_SP_Li' + i)[0]);
  69. $$('div', { 'className': 'U_MD_DK_SP_CTopFileAuthor', 'innerHTML': r.value[i].UserNickName }, $('#U_MD_DK_SP_Li' + i)[0]);
  70. var _date = U.UF.D.formatDateToArray(r.value[i].UserDirectoryAddTime);
  71. $$('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]);
  72. _fileli.onclick = U.UF.C.closure(function (fileinfo) {
  73. window.location.href = window.location.origin + window.location.pathname + "/" + fileinfo.UserallDirectoryName + window.location.search;
  74. // window.location.href = window.location.origin + window.location.pathname + window.location.search + fileinfo.UserallDirectoryName ;
  75. }, [r.value[i]]);
  76. }
  77. }
  78. /***
  79. *获取图标
  80. *extendtype {string} 文件种类
  81. */
  82. U.MD.DK.SP.getIcon = function (extendtype) {
  83. var i,
  84. _application = US.disk.applicationTypes //获取所有打开应用的信息
  85. ;
  86. //循环信息中找到指定的应用的信息
  87. for (i in _application) {
  88. //找到后缀名对应的程序信息
  89. if (_application[i].types.indexOf(extendtype.toLowerCase()) > -1) {
  90. return _application[i]; //返回应用的信息
  91. }
  92. }
  93. return _application["unknownfile"]; //如果是本站未知的后缀直接归属于文件
  94. }
  95. /***
  96. *获取上一次文件夹
  97. *extendtype {string} 文件种类
  98. */
  99. U.MD.DK.SP.getParentFile = function (parentid) {
  100. U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetDirectroyById", parentid], function (r) {
  101. $('.U_MD_DK_SP_Head_Logo_name')[0].innerHTML += '-' + r.value[0].UserDirectoryName + '文档详细列表';
  102. }, []);
  103. }