Poll.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //轮训处理
  2. Namespace.register("U.MD.O.P");
  3. /*
  4. * 链接后台,并发送请求
  5. */
  6. U.MD.O.P.connect = function () {
  7. if (US.userInfo.UserId) { //判断用户是否登录
  8. U.A.Request(US.SCOKET, ["login", JSON.stringify({ //发送登录请求
  9. pageId: US.pageId,
  10. userId: US.userInfo.UserId,
  11. userName: US.userInfo.UserName,
  12. type: US.systemId
  13. })], U.MD.O.P.pollingAsyn); //回调进 U.MD.O.P.pollingAsyn 函数
  14. }
  15. };
  16. /*
  17. * 发送请求进入轮训
  18. */
  19. U.MD.O.P.polling = function () {
  20. U.A.Request(US.SCOKET, ["polling", US.userInfo.UserId, US.pageId, US.systemId], U.MD.O.P.pollingAsyn);
  21. //发送轮循 回调进 U.MD.O.P.pollingAsyn函数
  22. }
  23. /*
  24. * 处理从后台返回的数据
  25. *
  26. */
  27. U.MD.O.P.pollingAsyn = function (r) {
  28. r = r.value;
  29. if (r) { //r是否有值
  30. if (r[0] instanceof Array) {
  31. r = r[0];
  32. }
  33. // console.log('获取到的数据:', r)
  34. var _i, _message, _iframe, _contentWindow;
  35. for (_i = 0; _i < r.length; _i++) {
  36. _message = r[_i];
  37. switch (_message.type) {
  38. case 'us.word': //判断是否是word 的消息
  39. _iframe = $('#UD_Word' + _message.messageInfo.docId + ' iframe')[0];
  40. if (_iframe) {
  41. _contentWindow = _iframe.contentWindow;
  42. if (_message.messageInfo.type == "updateName") {
  43. $('#UD_Word' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name;
  44. }
  45. else if (_message.messageInfo.type == "insertModifyRecord") {
  46. _contentWindow.U.MD.O.W.Panel.syncHistory(_message.sendId, _message.messageInfo.historyid);
  47. }
  48. else if (_message.messageInfo.type == "addUser") {
  49. _contentWindow.U.MD.O.W.Panel.syncAddUser(_message.messageInfo.userIds, _message.sendId);
  50. }
  51. else if ($('#UD_Word' + _message.messageInfo.docId).css('display') == 'block') {
  52. switch (_message.messageInfo.type) {// 判断消息种类
  53. case 'update':
  54. _contentWindow.U.MD.O.W.E.updateEditorLine(_message.messageInfo);
  55. break;
  56. case 'add':
  57. _contentWindow.U.MD.O.W.E.addEditorLine(_message.messageInfo);
  58. break;
  59. case 'delete':
  60. _contentWindow.U.MD.O.W.E.deleteEditorLine(_message.messageInfo);
  61. break;
  62. }
  63. }
  64. }
  65. break;
  66. case 'us.nav':
  67. _iframe = $('#UD_Word' + _message.messageInfo.docId + ' iframe')[0];
  68. if (_message.messageInfo.type == "updateName") {
  69. $('#UD_Word' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name;
  70. } else if (_message.messageInfo.type == "addUser") {
  71. _contentWindow.U.MD.O.W.Panel.syncAddUser(_message.messageInfo.userIds, _message.sendId);
  72. }
  73. else if ($('#UD_Word' + _message.messageInfo.docId).css('display') == 'block') {
  74. _contentWindow = _iframe.contentWindow;
  75. switch (_message.messageInfo.type) {// 判断消息种类
  76. case 'update':
  77. _contentWindow.U.MD.O.W.T.N.nowNavId == _message.messageInfo.navId && _contentWindow.U.MD.O.W.E.updateEditorLine(_message.messageInfo);
  78. break;
  79. case 'add':
  80. _contentWindow.U.MD.O.W.T.N.nowNavId == _message.messageInfo.navId && _contentWindow.U.MD.O.W.E.addEditorLine(_message.messageInfo);
  81. break;
  82. case 'delete':
  83. _contentWindow.U.MD.O.W.T.N.nowNavId == _message.messageInfo.navId && _contentWindow.U.MD.O.W.E.deleteEditorLine(_message.messageInfo);
  84. break;
  85. case 'addNav':
  86. _contentWindow.U.MD.O.W.T.N.Poll.addNav(_message.messageInfo);
  87. break;
  88. case 'updateNav':
  89. _contentWindow.U.MD.O.W.T.N.Poll.updateNav(_message.messageInfo);
  90. break;
  91. case 'deleteNav':
  92. _contentWindow.U.MD.O.W.T.N.Poll.deleteNav(_message.messageInfo);
  93. break;
  94. case 'updateLogo':
  95. _contentWindow.U.MD.O.W.T.N.Poll.updateLogo(_message.messageInfo);
  96. break;
  97. }
  98. }
  99. break;
  100. case 'us.excel': //判断是否是word 的消息
  101. _iframe = $('#UD_Excel' + _message.messageInfo.docId + ' iframe')[0];
  102. if (_iframe) {
  103. if (_message.messageInfo.type == "updateName") {
  104. $('#UD_Excel' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name;
  105. }
  106. else if (_message.messageInfo.type == "addUser") {
  107. }
  108. else {
  109. _contentWindow = _iframe.contentWindow;
  110. switch (_message.messageInfo.type) {// 判断消息种类
  111. case 'blur':
  112. _contentWindow.U.MD.O.E.Receiver.Blur(_message.messageInfo);
  113. break;
  114. case 'setBorder':
  115. _contentWindow.U.MD.O.E.Receiver.setBorder(_message.messageInfo);
  116. break;
  117. case "addLine":
  118. _contentWindow.U.MD.O.E.Receiver.addLine(_message.messageInfo);
  119. //添加行
  120. break;
  121. case "delLine":
  122. _contentWindow.U.MD.O.E.Receiver.delLine(_message.messageInfo);
  123. //刪除行
  124. break;
  125. case "addCol":
  126. _contentWindow.U.MD.O.E.Receiver.addCol(_message.messageInfo);
  127. //添加列
  128. break;
  129. case "delCol":
  130. _contentWindow.U.MD.O.E.Receiver.delCol(_message.messageInfo);
  131. //刪除列
  132. break;
  133. case "merge":
  134. _contentWindow.U.MD.O.E.Receiver.merge(_message.messageInfo);
  135. //合并单元格
  136. break;
  137. case "splitCells":
  138. _contentWindow.U.MD.O.E.Receiver.splitCells(_message.messageInfo);
  139. //拆分单元格
  140. break;
  141. case "rowExpanding":
  142. _contentWindow.U.MD.O.E.Receiver.rowExpanding(_message.messageInfo);
  143. //行板拉伸
  144. break;
  145. case "colExpanding":
  146. _contentWindow.U.MD.O.E.Receiver.colExpanding(_message.messageInfo);
  147. //列板拉伸
  148. break;
  149. case "addTask":
  150. _contentWindow.U.MD.O.E.Receiver.addTask(_message.messageInfo);
  151. break;
  152. case "deleteTask":
  153. _contentWindow.U.MD.O.E.Receiver.deleteTask(_message.messageInfo);
  154. break;
  155. case "reNameTask":
  156. _contentWindow.U.MD.O.E.Receiver.reNameTask(_message.messageInfo);
  157. break;
  158. case "img":
  159. _contentWindow.U.MD.O.E.Receiver.img(_message.messageInfo);
  160. //插入图片
  161. break;
  162. case "imgChange": //图片拉伸及拖拽
  163. _contentWindow.U.MD.O.E.Receiver.imgChange(_message.messageInfo);
  164. break;
  165. case "excelAddHref": //插入链接
  166. _contentWindow.U.MD.O.E.Receiver.excelAddHref(_message.messageInfo);
  167. break;
  168. case "clearAContent": //删除链接
  169. _contentWindow.U.MD.O.E.Receiver.clearAContent(_message.messageInfo);
  170. break;
  171. }
  172. }
  173. }
  174. break;
  175. }
  176. }
  177. }
  178. U.MD.O.P.polling(); //进入轮循
  179. }