Index: lams_tool_whiteboard/web/pages/learning/learning.jsp =================================================================== diff -u -r9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7 -r876e644c066e81c2721ffa085fd12f386e2f3bb6 --- lams_tool_whiteboard/web/pages/learning/learning.jsp (.../learning.jsp) (revision 9496ff3ffe5e98272f7939a2cf4e8c6dbb2901f7) +++ lams_tool_whiteboard/web/pages/learning/learning.jsp (.../learning.jsp) (revision 876e644c066e81c2721ffa085fd12f386e2f3bb6) @@ -84,44 +84,40 @@ document.addEventListener("msfullscreenchange", whiteboardFullScreenChanged); - let websocket = initWebsocket('whiteboardTimeLimit${sessionMap.toolContentID}', + let timeLimitExceeded = ${timeLimitExceeded}; + initWebsocket('whiteboardTimeLimit${sessionMap.toolContentID}', ''.replace('http', 'ws') - + 'learningWebsocket?toolContentID=${sessionMap.toolContentID}'), - timeLimitExceeded = ${timeLimitExceeded}; + + 'learningWebsocket?toolContentID=${sessionMap.toolContentID}', + function (e) { + // create JSON object + var input = JSON.parse(e.data); - if (websocket) { - // when the server pushes new inputs - websocket.onmessage = function (e) { - // create JSON object - var input = JSON.parse(e.data); + if (input.clearTimer == true) { + // teacher stopped the timer, destroy it + $('#countdown').countdown('destroy').remove(); + } else if (typeof input.secondsLeft != 'undefined'){ + // teacher updated the timer + var secondsLeft = +input.secondsLeft, + counterInitialised = $('#countdown').length > 0; - if (input.clearTimer == true) { - // teacher stopped the timer, destroy it - $('#countdown').countdown('destroy').remove(); - } else if (typeof input.secondsLeft != 'undefined'){ - // teacher updated the timer - var secondsLeft = +input.secondsLeft, - counterInitialised = $('#countdown').length > 0; - - if (counterInitialised) { - // just set the new time - $('#countdown').countdown('option', 'until', secondsLeft + 'S'); - } else if (timeLimitExceeded){ - if (secondsLeft > 0) { - // teacher gave extra time, reload to writable Whiteboard - location.reload(); - return; + if (counterInitialised) { + // just set the new time + $('#countdown').countdown('option', 'until', secondsLeft + 'S'); + } else if (timeLimitExceeded){ + if (secondsLeft > 0) { + // teacher gave extra time, reload to writable Whiteboard + location.reload(); + return; + } + } else { + // initialise the timer + displayCountdown(secondsLeft); } - } else { - // initialise the timer - displayCountdown(secondsLeft); } - } - // reset ping timer - websocketPing('whiteboardTimeLimit${sessionMap.toolContentID}', true); - }; - } + // reset ping timer + websocketPing('whiteboardTimeLimit${sessionMap.toolContentID}', true); + }); }); if (${!hasEditRight && mode != "teacher" && !finishedLock}) {