file_info.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var fileinfoNewBlockList=new Array();
  2. function fileinfo_add_block(docid,type,blockid){
  3. let newBlock = new Object();
  4. newBlock.type = type;
  5. newBlock.block_id = blockid;
  6. fileinfoNewBlockList.push(newBlock);
  7. return(blockid);
  8. }
  9. function fileinfo_add_block_commit(docid){
  10. fileindex_get(docid,function(data,status){
  11. try{
  12. let result= JSON.parse(data);
  13. if(result.length>0){
  14. let blocklist= JSON.parse(result[0].doc_block);
  15. for(x in fileinfoNewBlockList){
  16. blocklist.push(fileinfoNewBlockList[x]);
  17. }
  18. fileinfo_set(result[0].id,"doc_block",JSON.stringify(blocklist));
  19. console.log("add"+fileinfoNewBlockList.length);
  20. fileinfoNewBlockList=new Array();
  21. }
  22. }
  23. catch(e){
  24. console.error("user_sentence_update:"+e+" data:"+data);
  25. ntf_show("user sentence error");
  26. }
  27. });
  28. }
  29. function fileinfo_remove_block(){
  30. }
  31. function fileindex_get(docid,callback){
  32. $.post("../studio/file_index.php",
  33. {
  34. op:"get",
  35. doc_id:docid
  36. },
  37. callback);
  38. }
  39. function fileinfo_set(docid,key,value){
  40. $.post("../studio/file_index.php",
  41. {
  42. op:"set",
  43. doc_id:docid,
  44. field:key,
  45. value:value
  46. },
  47. function(data,status){
  48. console.log(data);
  49. });
  50. }
  51. function fileinfo_list(filename,del=false,time_desc=false){
  52. }