//轮训处理 Namespace.register("U.MD.O.P"); /* * 链接后台,并发送请求 */ U.MD.O.P.connect = function () { if (US.userInfo.userid) { //判断用户是否登录 U.A.Request(US.SCOKET, ["login", JSON.stringify({ //发送登录请求 pageId: US.pageId, userId: US.userInfo.userid, userName: US.userInfo.UserName, type: US.systemId })], U.MD.O.P.pollingAsyn); //回调进 U.MD.O.P.pollingAsyn 函数 } }; /* * 发送请求进入轮训 */ U.MD.O.P.polling = function () { U.A.Request(US.SCOKET, ["polling", US.userInfo.userid, US.pageId, US.systemId], U.MD.O.P.pollingAsyn); //发送轮循 回调进 U.MD.O.P.pollingAsyn函数 } /* * 处理从后台返回的数据 * */ U.MD.O.P.pollingAsyn = function (r) { r = r.value; if (r) { //r是否有值 if (r[0] instanceof Array) { r = r[0]; } // console.log('获取到的数据:', r) var _i, _message, _iframe, _contentWindow; for (_i = 0; _i < r.length; _i++) { _message = r[_i]; switch (_message.type) { case 'us.word': //判断是否是word 的消息 // _iframe = $('#UD_Word' + _message.messageInfo.docId + ' iframe')[0]; _iframe = $('#doc iframe')[0]; if (_iframe) { _contentWindow = _iframe.contentWindow; if (_message.messageInfo.type == "updateName") { $('#UD_Word' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name; } else if (_message.messageInfo.type == "insertModifyRecord") { _contentWindow.U.MD.O.W.Panel.syncHistory(_message.sendId, _message.messageInfo.historyid); } else if (_message.messageInfo.type == "addUser") { _contentWindow.U.MD.O.W.Panel.syncAddUser(_message.messageInfo.userIds, _message.sendId); } else {// if ($('#UD_Word' + _message.messageInfo.docId).css('display') == 'block') switch (_message.messageInfo.type) {// 判断消息种类 case 'update': _contentWindow.U.MD.O.W.E.updateEditorLine(_message.messageInfo); break; case 'add': _contentWindow.U.MD.O.W.E.addEditorLine(_message.messageInfo); break; case 'delete': _contentWindow.U.MD.O.W.E.deleteEditorLine(_message.messageInfo); break; } } } break; case 'us.nav': _iframe = $('#UD_Word' + _message.messageInfo.docId + ' iframe')[0]; if (_message.messageInfo.type == "updateName") { $('#UD_Word' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name; } else if (_message.messageInfo.type == "addUser") { _contentWindow.U.MD.O.W.Panel.syncAddUser(_message.messageInfo.userIds, _message.sendId); } else if ($('#UD_Word' + _message.messageInfo.docId).css('display') == 'block') { _contentWindow = _iframe.contentWindow; switch (_message.messageInfo.type) {// 判断消息种类 case 'update': _contentWindow.U.MD.O.W.T.N.nowNavId == _message.messageInfo.navId && _contentWindow.U.MD.O.W.E.updateEditorLine(_message.messageInfo); break; case 'add': _contentWindow.U.MD.O.W.T.N.nowNavId == _message.messageInfo.navId && _contentWindow.U.MD.O.W.E.addEditorLine(_message.messageInfo); break; case 'delete': _contentWindow.U.MD.O.W.T.N.nowNavId == _message.messageInfo.navId && _contentWindow.U.MD.O.W.E.deleteEditorLine(_message.messageInfo); break; case 'addNav': _contentWindow.U.MD.O.W.T.N.Poll.addNav(_message.messageInfo); break; case 'updateNav': _contentWindow.U.MD.O.W.T.N.Poll.updateNav(_message.messageInfo); break; case 'deleteNav': _contentWindow.U.MD.O.W.T.N.Poll.deleteNav(_message.messageInfo); break; case 'updateLogo': _contentWindow.U.MD.O.W.T.N.Poll.updateLogo(_message.messageInfo); break; } } break; case 'us.excel': //判断是否是word 的消息 _iframe = $('#UD_Excel' + _message.messageInfo.docId + ' iframe')[0]; if (_iframe) { if (_message.messageInfo.type == "updateName") { $('#UD_Excel' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name; } else if (_message.messageInfo.type == "addUser") { } else { _contentWindow = _iframe.contentWindow; switch (_message.messageInfo.type) {// 判断消息种类 case 'blur': _contentWindow.U.MD.O.E.Receiver.Blur(_message.messageInfo); break; case 'setBorder': _contentWindow.U.MD.O.E.Receiver.setBorder(_message.messageInfo); break; case "addLine": _contentWindow.U.MD.O.E.Receiver.addLine(_message.messageInfo); //添加行 break; case "delLine": _contentWindow.U.MD.O.E.Receiver.delLine(_message.messageInfo); //刪除行 break; case "addCol": _contentWindow.U.MD.O.E.Receiver.addCol(_message.messageInfo); //添加列 break; case "delCol": _contentWindow.U.MD.O.E.Receiver.delCol(_message.messageInfo); //刪除列 break; case "merge": _contentWindow.U.MD.O.E.Receiver.merge(_message.messageInfo); //合并单元格 break; case "splitCells": _contentWindow.U.MD.O.E.Receiver.splitCells(_message.messageInfo); //拆分单元格 break; case "rowExpanding": _contentWindow.U.MD.O.E.Receiver.rowExpanding(_message.messageInfo); //行板拉伸 break; case "colExpanding": _contentWindow.U.MD.O.E.Receiver.colExpanding(_message.messageInfo); //列板拉伸 break; case "addTask": _contentWindow.U.MD.O.E.Receiver.addTask(_message.messageInfo); break; case "deleteTask": _contentWindow.U.MD.O.E.Receiver.deleteTask(_message.messageInfo); break; case "reNameTask": _contentWindow.U.MD.O.E.Receiver.reNameTask(_message.messageInfo); break; case "img": _contentWindow.U.MD.O.E.Receiver.img(_message.messageInfo); //插入图片 break; case "imgChange": //图片拉伸及拖拽 _contentWindow.U.MD.O.E.Receiver.imgChange(_message.messageInfo); break; case "excelAddHref": //插入链接 _contentWindow.U.MD.O.E.Receiver.excelAddHref(_message.messageInfo); break; case "clearAContent": //删除链接 _contentWindow.U.MD.O.E.Receiver.clearAContent(_message.messageInfo); break; } } } break; case 'us.mindNetwork': // _iframe = $('#mindNetwork' + _message.messageInfo.docId)[0]; _iframe = $('#mindNetwork iframe')[0]; if (_iframe) { _contentWindow = _iframe.contentWindow; // if (_message.messageInfo.type == "addUser") { // _contentWindow.postMessage({ cid: cid, type: "mindNetwork_addUser" }, "*") // } // else // if ($('#mindNetwork' + _message.messageInfo.docId).css('display') == 'block') { switch (_message.messageInfo.type) {// 判断消息种类 case 'update': _contentWindow.postMessage({ info: _message.messageInfo, type: "mindNetwork_update" }, "*") break; case 'delete': _contentWindow.postMessage({ info: _message.messageInfo, type: "mindNetwork_delete" }, "*") break; case 'move': _contentWindow.postMessage({ info: _message.messageInfo, type: "mindNetwork_move" }, "*") break; } // } } break; case 'us.realTimeClass': _iframe = $('#studentClassRoom iframe')[0]; if (_iframe) { _contentWindow = _iframe.contentWindow; switch (_message.messageInfo.type) {// 判断消息种类 case 'update'://修改页码 _contentWindow.postMessage({ info: _message.messageInfo, type: "realTimeClass_update" }, "*") break; } // } } break; } } } U.MD.O.P.polling(); //进入轮循 }