index_mydoc.js 6.5 KB

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