add a call to drawZonePoints to handle case where image doesn't load. Remove debug and dead code

This commit is contained in:
Isaac Connor 2020-10-16 12:21:12 -04:00
parent b9b45d8b9e
commit 8c7c4c4b1b
1 changed files with 3 additions and 6 deletions

View File

@ -439,10 +439,8 @@ function drawZonePoints() {
}); });
var style = imageFrame.currentStyle || window.getComputedStyle(imageFrame); var style = imageFrame.currentStyle || window.getComputedStyle(imageFrame);
scale = (imageFrame.clientWidth - ( style.paddingLeft.toInt() + style.paddingRight.toInt() )) / maxX; scale = (imageFrame.clientWidth - ( style.paddingLeft.toInt() + style.paddingRight.toInt() )) / maxX;
console.log("Scale = width: " + imageFrame.clientWidth);
for ( var i = 0; i < zone['Points'].length; i++ ) { for ( var i = 0; i < zone['Points'].length; i++ ) {
console.log("scale: " + scale + " x " + zone['Points'][i].x + " = " + Math.round(zone['Points'][i].x * scale));
var div = new Element('div', { var div = new Element('div', {
'id': 'point'+i, 'id': 'point'+i,
'data-point-index': i, 'data-point-index': i,
@ -470,12 +468,9 @@ function drawZonePoints() {
} ); } );
for ( var i = 0; i < zone['Points'].length; i++ ) { for ( var i = 0; i < zone['Points'].length; i++ ) {
var row; var row = new Element('tr', {'id': 'row'+i});
row = new Element('tr', {'id': 'row'+i});
row.addEvent('mouseover', highlightOn.pass(i)); row.addEvent('mouseover', highlightOn.pass(i));
row.addEvent('mouseout', highlightOff.pass(i)); row.addEvent('mouseout', highlightOff.pass(i));
//row.onmouseover = highlightOn.pass(i)
//row.onmouseout = window['highlightOff'].bind(div, div);
var cell = new Element('td'); var cell = new Element('td');
cell.set('text', i+1); cell.set('text', i+1);
cell.inject(row); cell.inject(row);
@ -669,6 +664,8 @@ function initPage() {
el.addEventListener("load", imageLoadEvent, {passive: true}); el.addEventListener("load", imageLoadEvent, {passive: true});
}); });
window.addEventListener("resize", drawZonePoints, {passive: true}); window.addEventListener("resize", drawZonePoints, {passive: true});
// if the image link is broken for some reason we won't draw the points, so do it manually
drawZonePoints();
// Manage the BACK button // Manage the BACK button
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) { document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {