Minor changes by Valera.
This commit is contained in:
@@ -1,27 +1,36 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Simple image input
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Simple image input
|
||||
*
|
||||
*
|
||||
* Click on image. Update the coordinates of a dot on the image.
|
||||
* The new coordinates are the location of the click.
|
||||
*/
|
||||
|
||||
// click on image, update coordinates
|
||||
// put a dot at location of click, on image
|
||||
/**
|
||||
* 'The wise adapt themselves to circumstances, as water molds itself to the
|
||||
* pitcher.'
|
||||
*
|
||||
* ~ Chinese Proverb
|
||||
*/
|
||||
|
||||
window.image_input_click = function (id, event) {
|
||||
var iidiv = document.getElementById("imageinput_" + id),
|
||||
pos_x = event.offsetX ? (event.offsetX) : event.pageX - iidiv.offsetLeft,
|
||||
pos_y = event.offsetY ? (event.offsetY) : event.pageY - iidiv.offsetTop,
|
||||
// To reduce differences between values returned by different kinds of
|
||||
// browsers, we round `pos_x` and `pos_y`.
|
||||
// IE10: `pos_x` and `pos_y` - float.
|
||||
// Chrome, FF: `pos_x` and `pos_y` - integers.
|
||||
result = "[" + Math.round(pos_x) + "," + Math.round(pos_y) + "]",
|
||||
cx = (pos_x - 15) + "px",
|
||||
cy = (pos_y - 15) + "px",
|
||||
cross = document.getElementById("cross_" + id);
|
||||
var iiDiv = document.getElementById('imageinput_' + id),
|
||||
|
||||
cross.style.left = cx;
|
||||
cross.style.top = cy;
|
||||
cross.style.visibility = "visible" ;
|
||||
document.getElementById("input_" + id).value = result;
|
||||
posX = event.offsetX ? event.offsetX : event.pageX - iiDiv.offsetLeft,
|
||||
posY = event.offsetY ? event.offsetY : event.pageY - iiDiv.offsetTop,
|
||||
|
||||
cross = document.getElementById('cross_' + id),
|
||||
|
||||
// To reduce differences between values returned by different kinds of
|
||||
// browsers, we round `posX` and `posY`.
|
||||
//
|
||||
// IE10: `posX` and `posY` - float.
|
||||
// Chrome, FF: `posX` and `posY` - integers.
|
||||
result = '[' + Math.round(posX) + ',' + Math.round(posY) + ']';
|
||||
|
||||
cross.style.left = (posX - 15) + 'px';
|
||||
cross.style.top = (posY - 15) + 'px';
|
||||
cross.style.visibility = 'visible';
|
||||
|
||||
document.getElementById('input_' + id).value = result;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user