Index: lams_tool_mindmap/web/common/mapjs.jsp =================================================================== diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6 --- lams_tool_mindmap/web/common/mapjs.jsp (.../mapjs.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7) +++ lams_tool_mindmap/web/common/mapjs.jsp (.../mapjs.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6) @@ -63,69 +63,65 @@ <%-- Websockets used to get the node updates from the server --%> <%-- init the connection with server using server URL but with different protocol --%> - let websocket = initWebsocket('mindmapNodes${sessionId}', + initWebsocket('mindmapNodes${sessionId}', ''.replace('http', 'ws') - + 'learningWebsocket?toolSessionID=${sessionId}&lastActionId=' + initialActionId); + + 'learningWebsocket?toolSessionID=${sessionId}&lastActionId=' + initialActionId, + function (e) { + // create JSON object + var response = JSON.parse(e.data); - if (websocket) { - // when the server pushes new inputs - websocket.onmessage = function (e) { - // create JSON object - var response = JSON.parse(e.data); - - if ( ! response.actions ) { - return; - } - - var valuesChanged = false; - for ( i=0; i'); + if ( ! response.actions ) { return; } - // only process requests we have not done already otherwise we would redo any we trigger - if ( requestId > initialActionId && requestsProcessed.indexOf(requestId) == -1 ) { - if ( action.type == 0 ) { - customRemoveSubIdea(action.nodeId); - } else if ( action.type == 1 ) { - updateUnsavedNodeIds(action.childNodeId); - // add node response.nodeId, response.title, response.color - contentAggregate.addSubIdea(action.nodeId, action.title, action.childNodeId); - var newChildNode = contentAggregate.findSubIdeaById(action.childNodeId); - newChildNode.attr = {}; - newChildNode.attr.contentLocked = true; - newChildNode.creator = action.creator; - if ( action.color ) { - newChildNode.attr.style = {}; - newChildNode.attr.style.background = action.color; - } - } else if ( action.type == 2 ) { - // update colour - this call updates the node on screen but also triggers the change - // action which will call onIdeaChangedLAMS() - so the change to the other user's node - // will need to be ignored. - contentAggregate.mergeAttrProperty(action.nodeId, 'style', 'background', action.color); - } else if ( action.type == 3 ) { - // update title - var ideaToUpdate = contentAggregate.findSubIdeaById(action.nodeId); - ideaToUpdate.title = action.title; - } else { + + var valuesChanged = false; + for ( i=0; i'); + return; } - requestsProcessed.push( requestId ); - updateLastActionId( requestId ); - valuesChanged = true; + // only process requests we have not done already otherwise we would redo any we trigger + if ( requestId > initialActionId && requestsProcessed.indexOf(requestId) == -1 ) { + if ( action.type == 0 ) { + customRemoveSubIdea(action.nodeId); + } else if ( action.type == 1 ) { + updateUnsavedNodeIds(action.childNodeId); + // add node response.nodeId, response.title, response.color + contentAggregate.addSubIdea(action.nodeId, action.title, action.childNodeId); + var newChildNode = contentAggregate.findSubIdeaById(action.childNodeId); + newChildNode.attr = {}; + newChildNode.attr.contentLocked = true; + newChildNode.creator = action.creator; + if ( action.color ) { + newChildNode.attr.style = {}; + newChildNode.attr.style.background = action.color; + } + } else if ( action.type == 2 ) { + // update colour - this call updates the node on screen but also triggers the change + // action which will call onIdeaChangedLAMS() - so the change to the other user's node + // will need to be ignored. + contentAggregate.mergeAttrProperty(action.nodeId, 'style', 'background', action.color); + } else if ( action.type == 3 ) { + // update title + var ideaToUpdate = contentAggregate.findSubIdeaById(action.nodeId); + ideaToUpdate.title = action.title; + } else { + abortLoad(''); + } + requestsProcessed.push( requestId ); + updateLastActionId( requestId ); + valuesChanged = true; + } } - } - if ( valuesChanged ) { - window.mapModel.rebuildRequired(); - } - + if ( valuesChanged ) { + window.mapModel.rebuildRequired(); + } // reset ping timer websocketPing('mindmapNodes${sessionId}', true); - }; - } + }); + }, error: function (response) {