JavaScript代码
<script>
$(document).ready(function() {
$("#canvas").mousedown(function(event) {
var e = event || window.event;
var canvas = document.getElementById("canvas");
var rect = canvas.getBoundingClientRect();
location_x = e.clientX - rect.left * (canvas.width / rect.width);
location_y = e.clientY - rect.top * (canvas.height / rect.height)
});
$("#canvas").mouseup(function(event) {
var e = event || window.event;
var canvas = document.getElementById("canvas");
var rect = canvas.getBoundingClientRect();
location_width = e.clientX - rect.left * (canvas.width / rect.width);
location_height = e.clientY - rect.top * (canvas.height / rect.height)
location_width = (location_width - location_x) / 2;
location_height = (location_height - location_y) / 2;
location_x = location_x + location_width;
location_y = location_y + location_height;
document.getElementById("addButton").style.display = "";
document.getElementById("updateRemark").style.display = "none";
if(isDraw) {
document.getElementById("detail").value = "";
$("#remarkModal").modal("show");
}
});
});
</script>