coop.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. function username_search_keyup(e, obj) {
  2. var keynum
  3. var keychar
  4. var numcheck
  5. if ($("#wiki_search_input").val() == "") {
  6. $("#search_result").html("");
  7. return;
  8. }
  9. if (window.event) // IE
  10. {
  11. keynum = e.keyCode
  12. }
  13. else if (e.which) // Netscape/Firefox/Opera
  14. {
  15. keynum = e.which
  16. }
  17. var keychar = String.fromCharCode(keynum)
  18. if (keynum == 13) {
  19. //dict_search(obj.value);
  20. }
  21. else {
  22. username_search(obj.value);
  23. }
  24. }
  25. function username_search(keyword) {
  26. $.get("../ucenter/get.php",
  27. {
  28. username: keyword
  29. },
  30. function (data, status) {
  31. let result;
  32. try {
  33. result = JSON.parse(data);
  34. } catch (error) {
  35. console(error);
  36. }
  37. let html = "<ul id='user_search_list'>";
  38. if (result.length > 0) {
  39. for (x in result) {
  40. html += "<li><a onclick=\"coop_add('" + result[x].id + "')\">" + result[x].username + "[" + result[x].email + "]</a></li>";
  41. }
  42. }
  43. html += "</ul>";
  44. $("#search_result").html(html);
  45. });
  46. }
  47. var coop_show_div_id = "";
  48. var coop_doc_id = "";
  49. function coop_init(doc_id, strDivId) {
  50. coop_show_div_id = strDivId;
  51. coop_doc_id = doc_id
  52. }
  53. function coop_list() {
  54. $.get("../doc/coop.php",
  55. {
  56. do: "list",
  57. doc_id: coop_doc_id
  58. },
  59. function (data, status) {
  60. $("#" + coop_show_div_id).html(data);
  61. });
  62. }
  63. function coop_add(userid) {
  64. $.get("../doc/coop.php",
  65. {
  66. do: "add",
  67. doc_id: coop_doc_id,
  68. user_id: userid
  69. },
  70. function (data, status) {
  71. $("#" + coop_show_div_id).html(data);
  72. });
  73. }
  74. function coop_del(userid) {
  75. $.get("../doc/coop.php",
  76. {
  77. do: "del",
  78. doc_id: coop_doc_id,
  79. user_id: userid
  80. },
  81. function (data, status) {
  82. $("#" + coop_show_div_id).html(data);
  83. });
  84. }
  85. function coop_set(userid, value) {
  86. $.get("../doc/coop.php",
  87. {
  88. do: "set",
  89. doc_id: coop_doc_id,
  90. user_id: userid,
  91. value: value
  92. },
  93. function (data, status) {
  94. $("#" + coop_show_div_id).html(data);
  95. });
  96. }
  97. function coop_power_change(userid, obj) {
  98. coop_set(userid, obj.value)
  99. }