index_mydoc.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. var my_file_title = "";
  2. var my_file_status = "all";//recycle
  3. var my_file_order = "DESC";//ASC
  4. function file_search_keyup() {
  5. file_list_refresh();
  6. }
  7. function recycleInit() {
  8. ntf_init();
  9. file_list_refresh();
  10. }
  11. function indexInit() {
  12. ntf_init();
  13. file_list_refresh();
  14. }
  15. function time_standardize(date) {
  16. var today_date = new Date();
  17. var Local_time = date.toLocaleTimeString();
  18. //將時間去掉秒的信息
  19. if (Local_time && Local_time.split(":").length == 3) {
  20. var Local_time_string = Local_time.split(":")[0] + ":" + Local_time.split(":")[1];
  21. Local_time_string += Local_time.split(":")[2].slice(2);
  22. }
  23. else {
  24. var Local_time_string = d.toLocaleTimeString()
  25. }
  26. if (date.toLocaleDateString() == today_date.toLocaleDateString()) {//如果是今天的消息,只显示时间
  27. return (Local_time_string);
  28. }
  29. else if (date.toLocaleDateString().slice(0, 5) == today_date.toLocaleDateString().slice(0, 5)) {//如果是今年但非今天的消息,只显示月日
  30. var date_length = date.toLocaleDateString().length;
  31. return (date.toLocaleDateString().slice(5, date_length));
  32. }
  33. else {//如果不是今年的消息,显示年月日
  34. return (date.toLocaleDateString());
  35. }
  36. }
  37. function file_list_refresh() {
  38. var d = new Date();
  39. $.get("getfilelist.php",
  40. {
  41. t: d.getTime(),
  42. keyword: my_file_title,
  43. status: $("#id_index_status").val(),
  44. orderby: "accese_time",
  45. order: "DESC",
  46. currLanguage: $("#id_language").val()
  47. },
  48. function (data, status) {
  49. try {
  50. let file_list = JSON.parse(data);
  51. let html = "";
  52. for (x in file_list) {
  53. html += "<div class=\"file_list_row\">";
  54. html += "<div class=\"file_list_col_1\">";
  55. html += "<input id='file_check_" + x + "' type=\"checkbox\" />";
  56. html += "<input id='file_id_" + x + "' value='" + file_list[x].id + "' type=\"hidden\" />";
  57. html += "</div>";
  58. if (file_list[x].doc_info && file_list[x].doc_info.length > 1) {
  59. $link = "<a href='editor.php?op=opendb&fileid=" + file_list[x].id + "' target='_blank'>[db]";
  60. }
  61. else {
  62. $link = "<a href='editor.php?op=open&fileid=" + file_list[x].id + "' target='_blank'>";
  63. }
  64. html += "<div class=\"file_list_col_2\">";
  65. if ((file_list[x].parent_id == null || file_list[x].parent_id == "") && parseInt(file_list[x].share) == 1) {
  66. //shared
  67. html += "<span onclick=\"file_show_coop_win('" + file_list[x].id + "')\">";
  68. }
  69. else {
  70. html += "<span>";
  71. }
  72. html += "<svg class='icon' style='margin: 0 5px;'>";
  73. if (file_list[x].parent_id == null || file_list[x].parent_id == "") {
  74. if (parseInt(file_list[x].share) == 1) {
  75. //shared
  76. html += "<use xlink:href=\"./svg/icon.svg#share_to_other\"></use>";
  77. }
  78. else {
  79. //my document
  80. html += "<use xlink:href=\"./svg/icon.svg#ic_person\"></use>";
  81. }
  82. }
  83. else {
  84. //fork
  85. html += "<use xlink:href=\"./svg/icon.svg#other_share_to_me\"></use>";
  86. }
  87. html += "</svg>";
  88. html += "</span>";
  89. html += "<div id='coop_show_" + file_list[x].id + "' style='display:inline;'></div>";
  90. html += $link + file_list[x].title;
  91. html += "</a>";
  92. html += "</div>";
  93. html += "<div class=\"file_list_col_3\">";
  94. if ((file_list[x].parent_id && file_list[x].parent_id.length > 10) || parseInt(file_list[x].share) == 1) {
  95. html += "<svg class='icon'>";
  96. html += "<use xlink:href=\"./svg/icon.svg#ic_two_person\"></use>";
  97. html += "</svg>";
  98. }
  99. html += "</div>";
  100. html += "<div class=\"file_list_col_4\">";
  101. let d = new Date();
  102. let today_date = d.toLocaleDateString();
  103. d.setTime(file_list[x].accese_time);
  104. let Local_time = "";
  105. Local_time = time_standardize(d);
  106. /*
  107. if(d.getHours()<=9){
  108. Local_time +=":0"+d.getHours();
  109. }
  110. else{
  111. Local_time += ":"+d.getHours();
  112. }
  113. if(d.getMinutes()<=9){
  114. Local_time +=":0"+d.getMinutes();
  115. }
  116. else{
  117. Local_time += ":"+d.getMinutes();
  118. }
  119. let Local_date = d.toLocaleDateString();
  120. if(today_date==Local_date){
  121. html += gLocal.gui.today+Local_time;
  122. }
  123. else{
  124. html += Local_date;
  125. }
  126. */
  127. html += Local_time
  128. html += "</div>";
  129. html += "<div class=\"file_list_col_5\">";
  130. if (file_list[x].file_size < 102) {
  131. $str_size = file_list[x].file_size + "B";
  132. }
  133. else if (file_list[x].file_size < (1024 * 902)) {
  134. $str_size = (file_list[x].file_size / 1024).toFixed(0) + "KB";
  135. }
  136. else {
  137. $str_size = (file_list[x].file_size / (1024 * 1024)).toFixed(1) + "MB";
  138. }
  139. html += $str_size;
  140. if (!(file_list[x].doc_info && file_list[x].doc_info.length > 1)) {
  141. html += "<a href='../doc/pcs2db.php?doc_id=" + file_list[x].id + "' target='_blank'>转数据库格式</a>";
  142. }
  143. html += "</div>";
  144. html += "</div>";
  145. }
  146. html += "<input id='file_count' type='hidden' value='" + file_list.length + "'/>"
  147. $("#userfilelist").html(html);
  148. }
  149. catch (e) {
  150. console.error(e.message);
  151. }
  152. });
  153. }
  154. function showUserFilaList() {
  155. file_list_refresh();
  156. }
  157. function mydoc_file_select(doSelect) {
  158. if (doSelect) {
  159. $("#file_tools").show();
  160. $("#file_filter").hide();
  161. $(".file_select_checkbox").show();
  162. $(".file_select_checkbox").css("display", "inline-block");
  163. if ($("#id_index_status").val() == "recycle") {
  164. $("#button_group_recycle").show();
  165. $("#button_group_nomal").hide();
  166. }
  167. else {
  168. $("#button_group_recycle").hide();
  169. $("#button_group_nomal").show();
  170. }
  171. }
  172. else {
  173. $("#file_tools").hide();
  174. $("#file_filter").show();
  175. $(".file_select_checkbox").hide();
  176. }
  177. }
  178. function file_del() {
  179. var file_list = new Array();
  180. var file_count = $("#file_count").val();
  181. for (var i = 0; i < file_count; i++) {
  182. if (document.getElementById("file_check_" + i).checked) {
  183. file_list.push($("#file_id_" + i).val());
  184. }
  185. }
  186. if (file_list.length > 0) {
  187. $.post("file_index.php",
  188. {
  189. op: "delete",
  190. file: file_list.join()
  191. },
  192. function (data, status) {
  193. ntf_show(data);
  194. file_list_refresh();
  195. });
  196. }
  197. }
  198. //彻底删除
  199. function file_remove() {
  200. var file_list = new Array();
  201. var file_count = $("#file_count").val();
  202. for (var i = 0; i < file_count; i++) {
  203. if (document.getElementById("file_check_" + i).checked) {
  204. file_list.push($("#file_id_" + i).val());
  205. }
  206. }
  207. if (file_list.length > 0) {
  208. $.post("file_index.php",
  209. {
  210. op: "remove",
  211. file: file_list.join()
  212. },
  213. function (data, status) {
  214. ntf_show(data);
  215. file_list_refresh();
  216. });
  217. }
  218. }
  219. //从回收站中恢复
  220. function file_restore() {
  221. var file_list = new Array();
  222. var file_count = $("#file_count").val();
  223. for (var i = 0; i < file_count; i++) {
  224. if (document.getElementById("file_check_" + i).checked) {
  225. file_list.push($("#file_id_" + i).val());
  226. }
  227. }
  228. if (file_list.length > 0) {
  229. $.post("file_index.php",
  230. {
  231. op: "restore",
  232. file: file_list.join()
  233. },
  234. function (data, status) {
  235. ntf_show(data);
  236. file_list_refresh();
  237. });
  238. }
  239. }
  240. function file_share(isShare) {
  241. var file_list = new Array();
  242. var file_count = $("#file_count").val();
  243. for (var i = 0; i < file_count; i++) {
  244. if (document.getElementById("file_check_" + i).checked) {
  245. file_list.push($("#file_id_" + i).val());
  246. }
  247. }
  248. if (file_list.length > 0) {
  249. if (isShare) {
  250. var share = 1;
  251. }
  252. else {
  253. var share = 0;
  254. }
  255. $.post("file_index.php",
  256. {
  257. op: "share",
  258. share: share,
  259. file: file_list.join()
  260. },
  261. function (data, status) {
  262. alert(data);
  263. //mydoc_file_select(false);
  264. file_list_refresh();
  265. });
  266. }
  267. }
  268. function file_show_coop_win(doc_id) {
  269. let xFileHead = document.getElementById("coop_show_" + doc_id);
  270. let xCoopWin = document.getElementById("rs_doc_coop_win");
  271. xFileHead.appendChild(xCoopWin);
  272. coop_init(doc_id, "rs_doc_coop_win_inner");
  273. coop_list();
  274. }
  275. function file_coop_win_close() {
  276. let xShell = document.getElementById("rs_doc_coop_shell");
  277. let xCoopWin = document.getElementById("rs_doc_coop_win");
  278. xShell.appendChild(xCoopWin);
  279. }