function addChessWebCamClickHandler() {
	// https://stackoverflow.com/questions/34867066/javascript-mouse-click-coordinates-for-image
	document.getElementById('chesswebcam').addEventListener(
			'click',
			function(event) {
				// https://stackoverflow.com/a/288731/1497139
				bounds = this.getBoundingClientRect();
				var left = bounds.left;
				var top = bounds.top;
				var x = event.pageX - left;
				var y = event.pageY - top;
				var cw = this.clientWidth
				var ch = this.clientHeight
				var iw = this.naturalWidth
				var ih = this.naturalHeight
				var px = x / cw * iw
				var py = y / ch * ih
				alert("click on " + this.tagName + " at pixel (" + px + ","
						+ py + ") mouse pos (" + x + "," + y
						+ ") relative to boundingClientRect at (" + left + ","
						+ top + ") client image size: " + cw + " x " + ch
						+ " natural image size: " + iw + " x " + ih);
			});
}
// add a click hander for the webcam
add a click hander for the webcam
add a click hander for the webcam
function addChessWebCamClickHandler() {
	document.getElementById('chesswebcam').addEventListener(
			'click',
			function(event) {
				bounds = this.getBoundingClientRect();
				var left = bounds.left;
				var top = bounds.top;
				var x = event.pageX - left;
				var y = event.pageY - top;
				var cw = this.clientWidth
				var ch = this.clientHeight
				var iw = this.naturalWidth
				var ih = this.naturalHeight
				var px = x / cw * iw
				var py = y / ch * ih
				alert("click on " + this.tagName + " at pixel (" + px + ","
						+ py + ") mouse pos (" + x + "," + y
						+ ") relative to boundingClientRect at (" + left + ","
						+ top + ") client image size: " + cw + " x " + ch
						+ " natural image size: " + iw + " x " + ih);
			});
}
function addChessWebCamClickHandler ( ) { document . getElementById ( 'chesswebcam' ) . addEventListener ( 'click' , function ( event ) { bounds = this . getBoundingClientRect ( ) ; var left = bounds . left ; var top = bounds . top ; var x = event . pageX - left ; var y = event . pageY - top ; var cw = this . clientWidth var ch = this . clientHeight var iw = this . naturalWidth var ih = this . naturalHeight var px = x / cw * iw var py = y / ch * ih alert ( "click on " + this . tagName + " at pixel (" + px + "," + py + ") mouse pos (" + x + "," + y + ") relative to boundingClientRect at (" + left + "," + top + ") client image size: " + cw + " x " + ch + " natural image size: " + iw + " x " + ih ) ; } ) ; }
add a click hander for the webcam
add a click hander for the webcam
// https://stackoverflow.com/questions/34867066/javascript-mouse-click-coordinates-for-image // https://stackoverflow.com/a/288731/1497139