1540 Change innerHTML to value to sync user input

This commit is contained in:
zero41120 2020-02-06 13:50:15 -08:00
parent 2d971af445
commit 94183f7f18

View File

@ -79,7 +79,7 @@
// Load default examples // Load default examples
function loadExample(){ function loadExample(){
polygonList = JSON.parse(JSON.stringify(examples)); polygonList = JSON.parse(JSON.stringify(examples));
previewEl.innerHTML = JSON.stringify(polygonList); previewEl.value = JSON.stringify(polygonList);
} }
loadExample(); loadExample();
@ -91,7 +91,7 @@
p.x = Math.round((p.x + Number.EPSILON) * 100) / 100 p.x = Math.round((p.x + Number.EPSILON) * 100) / 100
p.y = Math.round((p.y + Number.EPSILON) * 100) / 100 p.y = Math.round((p.y + Number.EPSILON) * 100) / 100
polygon.push([p.x, p.y]); polygon.push([p.x, p.y]);
polygonEl.innerHTML += '['+p.x+','+ p.y+']'; polygonEl.value += '['+p.x+','+ p.y+']';
}); });
// Add clicked points to polygon tracker variable // Add clicked points to polygon tracker variable
@ -99,13 +99,13 @@
if (polygon.length == 0) { return; } if (polygon.length == 0) { return; }
polygonList.push(polygon); polygonList.push(polygon);
polygon = []; polygon = [];
polygonEl.innerHTML = ''; polygonEl.value = '';
previewEl.innerHTML = JSON.stringify(polygonList); previewEl.value = JSON.stringify(polygonList);
}; };
document.getElementById('cropBtn').onclick = function(){ document.getElementById('cropBtn').onclick = function(){
polygonList = JSON.parse(previewEl.innerHTML); polygonList = JSON.parse(previewEl.value);
polygonEl.innerHTML = ''; polygonEl.value = '';
var tiledImage = viewer.world.getItemAt(0); var tiledImage = viewer.world.getItemAt(0);
tiledImage.setCroppingPolygons(polygonList); tiledImage.setCroppingPolygons(polygonList);
viewer.forceRedraw(); viewer.forceRedraw();
@ -114,8 +114,8 @@
document.getElementById('resetBtn').onclick = function(){ document.getElementById('resetBtn').onclick = function(){
polygonList = [] polygonList = []
polygon = [] polygon = []
polygonEl.innerHTML = ''; polygonEl.value = '';
previewEl.innerHTML = ''; previewEl.value = '';
var tiledImage = viewer.world.getItemAt(0); var tiledImage = viewer.world.getItemAt(0);
tiledImage.resetCroppingPolygons(); tiledImage.resetCroppingPolygons();
viewer.forceRedraw(); viewer.forceRedraw();