|
| 1 | +var selectedMonitorIndex = 0; |
| 2 | +var monitorCount = 0; |
| 3 | + |
| 4 | +$(document).ready(function () { |
| 5 | + |
| 6 | + function InitializeHub() { |
| 7 | + $.connection.hub.url = "/signalr"; |
| 8 | + var hubMessenger = $.connection.pointerHub; |
| 9 | + |
| 10 | + |
| 11 | + $.connection.hub.start().done(function () { |
| 12 | + |
| 13 | + var lookHereImage = document.querySelector("#lookHereImage"); |
| 14 | + var canvasContainer = document.querySelector("#canvasContainer"); |
| 15 | + |
| 16 | + function movePointerPositionToNewLocation(xPosition, yPosition) { |
| 17 | + lookHereImage.style.left = xPosition + "px"; |
| 18 | + lookHereImage.style.top = yPosition + "px"; |
| 19 | + } |
| 20 | + |
| 21 | + |
| 22 | + function sendPointerServerNewLocation(selectedScreen, xPosition, yPosition) { |
| 23 | + |
| 24 | + var positions = selectedScreen + "," + xPosition + "," + yPosition; |
| 25 | + hubMessenger.server.send("position", positions); |
| 26 | + } |
| 27 | + |
| 28 | + function getTouchMovePosition(e) { |
| 29 | + e.preventDefault(); |
| 30 | + var pointer = e.changedTouches[0]; |
| 31 | + var xFinalPosition = pointer.pageX; |
| 32 | + var yFinalPosition = pointer.pageY; |
| 33 | + |
| 34 | + movePointerPositionToNewLocation(xFinalPosition, yFinalPosition); |
| 35 | + |
| 36 | + sendPointerServerNewLocation(selectedMonitorIndex, xFinalPosition, yFinalPosition); |
| 37 | + } |
| 38 | + |
| 39 | + canvasContainer.addEventListener("touchmove", getTouchMovePosition, false); |
| 40 | + canvasContainer.addEventListener("touchstart", getTouchMovePosition, false); |
| 41 | + |
| 42 | + }); |
| 43 | + |
| 44 | + } |
| 45 | + |
| 46 | + InitializeHub(); |
| 47 | + |
| 48 | +}); |
| 49 | + |
0 commit comments