Commit d31268e7 by Valera Rozuvan

Minor changes by Valera.

parent 79519b7a
///////////////////////////////////////////////////////////////////////////// /**
// * 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) { window.image_input_click = function (id, event) {
var iidiv = document.getElementById("imageinput_" + id), 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, 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 // To reduce differences between values returned by different kinds of
// browsers, we round `pos_x` and `pos_y`. // browsers, we round `posX` and `posY`.
// IE10: `pos_x` and `pos_y` - float. //
// Chrome, FF: `pos_x` and `pos_y` - integers. // IE10: `posX` and `posY` - float.
result = "[" + Math.round(pos_x) + "," + Math.round(pos_y) + "]", // Chrome, FF: `posX` and `posY` - integers.
cx = (pos_x - 15) + "px", result = '[' + Math.round(posX) + ',' + Math.round(posY) + ']';
cy = (pos_y - 15) + "px",
cross = document.getElementById("cross_" + id); cross.style.left = (posX - 15) + 'px';
cross.style.top = (posY - 15) + 'px';
cross.style.visibility = 'visible';
cross.style.left = cx; document.getElementById('input_' + id).value = result;
cross.style.top = cy;
cross.style.visibility = "visible" ;
document.getElementById("input_" + id).value = result;
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment