fix some csp violations

y
This commit is contained in:
Isaac Connor 2020-07-07 18:57:11 -04:00
parent 9b447bde8e
commit 6469300af5
2 changed files with 34 additions and 18 deletions

View File

@ -244,12 +244,14 @@ function limitArea(field) {
limitRange(field, minValue, maxValue); limitRange(field, minValue, maxValue);
} }
function highlightOn(index) { function highlightOn(point) {
var index = point.getAttribute('data-index');
$('row'+index).addClass('highlight'); $('row'+index).addClass('highlight');
$('point'+index).addClass('highlight'); $('point'+index).addClass('highlight');
} }
function highlightOff(index) { function highlightOff(point) {
var index = point.getAttribute('data-index');
$('row'+index).removeClass('highlight'); $('row'+index).removeClass('highlight');
$('point'+index).removeClass('highlight'); $('point'+index).removeClass('highlight');
} }
@ -310,9 +312,11 @@ function updateActivePoint(index) {
$('newZone[Points]['+index+'][y]').value = y; $('newZone[Points]['+index+'][y]').value = y;
zone['Points'][index].x = x; zone['Points'][index].x = x;
zone['Points'][index].y = y; zone['Points'][index].y = y;
console.log('hello');
var Point = $('zonePoly').points.getItem(index); var Point = $('zonePoly').points.getItem(index);
Point.x =x; console.log('hello');
Point.y =y; Point.x = x;
Point.y = y;
updateArea(); updateArea();
} }
@ -353,15 +357,17 @@ function updateArea( ) {
} else if ( form.elements['newZone[Units]'].value == 'Pixels' ) { } else if ( form.elements['newZone[Units]'].value == 'Pixels' ) {
form.elements['newZone[TempArea]'].value = area; form.elements['newZone[TempArea]'].value = area;
} else { } else {
alert("Unknown units: " + form.elements['newZone[Units]'].value); alert('Unknown units: ' + form.elements['newZone[Units]'].value);
} }
} }
function updateX(index) { function updateX(input) {
limitPointValue($('newZone[Points]['+index+'][x]'), 0, maxX); index = input.getAttribute('data-point-index');
limitPointValue(input, 0, maxX);
var point = $('point'+index); var point = $('point'+index);
var x = $('newZone[Points]['+index+'][x]').get('value'); var x = input.value;
point.setStyle('left', x+'px'); point.setStyle('left', x+'px');
zone['Points'][index].x = x; zone['Points'][index].x = x;
@ -370,11 +376,12 @@ function updateX(index) {
updateArea(); updateArea();
} }
function updateY(index) { function updateY(input) {
limitPointValue($('newZone[Points]['+index+'][y]'), 0, maxY); index = input.getAttribute('data-point-index');
limitPointValue(input, 0, maxY);
var point = $('point'+index); var point = $('point'+index);
var y = $('newZone[Points]['+index+'][y]').get('value'); var y = input.value;
point.setStyle('top', y+'px'); point.setStyle('top', y+'px');
zone['Points'][index].y = y; zone['Points'][index].y = y;
@ -403,6 +410,7 @@ function drawZonePoints() {
for ( var i = 0; i < zone['Points'].length; i++ ) { for ( var i = 0; i < zone['Points'].length; i++ ) {
var div = new Element('div', { var div = new Element('div', {
'id': 'point'+i, 'id': 'point'+i,
'data-index': i,
'class': 'zonePoint', 'class': 'zonePoint',
'title': 'Point '+(i+1), 'title': 'Point '+(i+1),
'styles': { 'styles': {
@ -410,7 +418,9 @@ function drawZonePoints() {
'top': zone['Points'][i].y 'top': zone['Points'][i].y
} }
}); });
div.addEvent('mouseover', highlightOn.pass(i)); //div.addEvent('mouseover', highlightOn.pass(i));
div.onmouseover = window['highlightOn'].bind(div, div);
div.onmouseout = window['highlightOff'].bind(div, div);
div.addEvent('mouseout', highlightOff.pass(i)); div.addEvent('mouseout', highlightOff.pass(i));
div.inject($('imageFrame')); div.inject($('imageFrame'));
div.makeDraggable( { div.makeDraggable( {
@ -439,9 +449,12 @@ function drawZonePoints() {
'id': 'newZone[Points]['+i+'][x]', 'id': 'newZone[Points]['+i+'][x]',
'name': 'newZone[Points]['+i+'][x]', 'name': 'newZone[Points]['+i+'][x]',
'value': zone['Points'][i].x, 'value': zone['Points'][i].x,
'size': 5 'type': 'number',
'min' : '0',
'max' : maxX,
'data-point-index' : i
}); });
input.addEvent('input', updateX.pass(i)); input.oninput = window['updateX'].bind(input, input);
input.inject(cell); input.inject(cell);
cell.inject(row); cell.inject(row);
@ -450,9 +463,12 @@ function drawZonePoints() {
'id': 'newZone[Points]['+i+'][y]', 'id': 'newZone[Points]['+i+'][y]',
'name': 'newZone[Points]['+i+'][y]', 'name': 'newZone[Points]['+i+'][y]',
'value': zone['Points'][i].y, 'value': zone['Points'][i].y,
'size': 5 'type': 'number',
'min' : '0',
'max' : maxY,
'data-point-index' : i
} ); } );
input.addEvent('input', updateY.pass(i)); input.oninput = window['updateY'].bind(input, input);
input.inject(cell); input.inject(cell);
cell.inject(row); cell.inject(row);

View File

@ -212,8 +212,8 @@ xhtmlHeaders(__FILE__, translate('Zone'));
</tr> </tr>
<tr> <tr>
<th scope="row"><?php echo translate('ZoneMinMaxPixelThres') ?></th> <th scope="row"><?php echo translate('ZoneMinMaxPixelThres') ?></th>
<td><input type="number" name="newZone[MinPixelThreshold]" value="<?php echo $newZone['MinPixelThreshold'] ?>"/></td> <td><input type="number" name="newZone[MinPixelThreshold]" value="<?php echo $newZone['MinPixelThreshold'] ?>" min="0" max="255"/></td>
<td><input type="number" name="newZone[MaxPixelThreshold]" value="<?php echo $newZone['MaxPixelThreshold'] ?>"/></td> <td><input type="number" name="newZone[MaxPixelThreshold]" value="<?php echo $newZone['MaxPixelThreshold'] ?>" min="0" max="255"/></td>
</tr> </tr>
<tr> <tr>
<th scope="row"><?php echo translate('ZoneFilterSize') ?></th> <th scope="row"><?php echo translate('ZoneFilterSize') ?></th>