coop.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 = JSON.parse(data);
  32. let html = "<ul id='user_search_list'>";
  33. if (result.length > 0) {
  34. for (x in result) {
  35. html += "<li><a onclick=\"coop_add('" + result[x].id + "')\">" + result[x].username + "[" + result[x].email + "]</a></li>";
  36. }
  37. }
  38. html += "</ul>";
  39. $("#search_result").html(html);
  40. });
  41. }
  42. var coop_show_div_id = "";
  43. var coop_doc_id = "";
  44. function coop_init(doc_id, strDivId) {
  45. coop_show_div_id = strDivId;
  46. coop_doc_id = doc_id
  47. }
  48. function coop_list() {
  49. $.get("../doc/coop.php",
  50. {
  51. do: "list",
  52. doc_id: coop_doc_id
  53. },
  54. function (data, status) {
  55. $("#" + coop_show_div_id).html(data);
  56. });
  57. }
  58. function coop_add(userid) {
  59. $.get("../doc/coop.php",
  60. {
  61. do: "add",
  62. doc_id: coop_doc_id,
  63. user_id: userid
  64. },
  65. function (data, status) {
  66. $("#" + coop_show_div_id).html(data);
  67. });
  68. }
  69. function coop_del(userid) {
  70. $.get("../doc/coop.php",
  71. {
  72. do: "del",
  73. doc_id: coop_doc_id,
  74. user_id: userid
  75. },
  76. function (data, status) {
  77. $("#" + coop_show_div_id).html(data);
  78. });
  79. }
  80. function coop_set(userid, value) {
  81. $.get("../doc/coop.php",
  82. {
  83. do: "set",
  84. doc_id: coop_doc_id,
  85. user_id: userid,
  86. value: value
  87. },
  88. function (data, status) {
  89. $("#" + coop_show_div_id).html(data);
  90. });
  91. }
  92. function coop_power_change(userid, obj) {
  93. coop_set(userid, obj.value)
  94. }