2021-01-05 00:28:16 +08:00
|
|
|
var pauseBtn = $j('#pauseBtn');
|
|
|
|
var playBtn = $j('#playBtn');
|
|
|
|
var saveBtn = $j('#saveBtn');
|
|
|
|
var cancelBtn = $j('#cancelBtn');
|
|
|
|
var backBtn = $j('#backBtn');
|
|
|
|
var refreshBtn = $j('#refreshBtn');
|
2022-01-08 05:06:38 +08:00
|
|
|
var analyseBtn = $j('#analyseBtn');
|
2021-01-05 00:28:16 +08:00
|
|
|
var monitors = [];
|
2022-01-08 05:06:38 +08:00
|
|
|
var analyse_frames = true;
|
2021-01-05 00:28:16 +08:00
|
|
|
|
2017-04-06 04:09:40 +08:00
|
|
|
function validateForm( form ) {
|
2021-01-05 00:28:16 +08:00
|
|
|
var errors = [];
|
2017-05-19 02:06:13 +08:00
|
|
|
if ( selfIntersecting ) {
|
|
|
|
errors[errors.length] = selfIntersectingString;
|
|
|
|
}
|
|
|
|
if ( form.elements['newZone[Type]'].value != 'Inactive' && form.elements['newZone[Type]'].value != 'Privacy' ) {
|
|
|
|
if ( !form.newAlarmRgbR.value || !form.newAlarmRgbG.value || !form.newAlarmRgbB.value ) {
|
|
|
|
errors[errors.length] = alarmRGBUnsetString;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 02:06:13 +08:00
|
|
|
form.elements['newZone[AlarmRGB]'].value = (form.newAlarmRgbR.value<<16)|(form.newAlarmRgbG.value<<8)|form.newAlarmRgbB.value;
|
|
|
|
if ( !form.elements['newZone[MinPixelThreshold]'].value || (parseInt(form.elements['newZone[MinPixelThreshold]'].value) <= 0 ) ) {
|
|
|
|
errors[errors.length] = minPixelThresUnsetString;
|
|
|
|
} else if ( (parseInt(form.elements['newZone[MinPixelThreshold]'].value) >= parseInt(form.elements['newZone[MaxPixelThreshold]'].value)) && (parseInt(form.elements['newZone[MaxPixelThreshold]'].value) > 0) ) {
|
|
|
|
errors[errors.length] = minPixelThresLtMaxString;
|
|
|
|
}
|
|
|
|
if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' || form.elements['newZone[CheckMethod]'].value == 'Blobs' ) {
|
|
|
|
if ( !form.elements['newZone[FilterX]'].value || !form.elements['newZone[FilterY]'].value ) {
|
|
|
|
errors[errors.length] = filterUnsetString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !form.elements['newZone[MinAlarmPixels]'].value || (parseFloat(form.elements['newZone[MinAlarmPixels]'].value) <= 0 ) ) {
|
|
|
|
errors[errors.length] = minAlarmAreaUnsetString;
|
|
|
|
} else if ( (parseFloat(form.elements['newZone[MinAlarmPixels]'].value) >= parseFloat(form.elements['newZone[MaxAlarmPixels]'].value)) && (parseFloat(form.elements['newZone[MaxAlarmPixels]'].value) > 0) ) {
|
|
|
|
errors[errors.length] = minAlarmAreaLtMaxString;
|
|
|
|
}
|
|
|
|
if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' || form.elements['newZone[CheckMethod]'].value == 'Blobs' ) {
|
|
|
|
if ( !form.elements['newZone[MinFilterPixels]'].value || (parseFloat(form.elements['newZone[MinFilterPixels]'].value) <= 0 ) ) {
|
|
|
|
errors[errors.length] = minFilterAreaUnsetString;
|
|
|
|
} else if ( (parseFloat(form.elements['newZone[MinFilterPixels]'].value) >= parseFloat(form.elements['newZone[MaxFilterPixels]'].value)) && (parseFloat(form.elements['newZone[MaxFilterPixels]'].value) > 0) ) {
|
|
|
|
errors[errors.length] = minFilterAreaLtMaxString;
|
|
|
|
} else if ( parseFloat(form.elements['newZone[MinAlarmPixels]'].value) < parseFloat(form.elements['newZone[MinFilterPixels]'].value) ) {
|
|
|
|
errors[errors.length] = minFilterLtMinAlarmString;
|
|
|
|
}
|
|
|
|
if ( form.elements['newZone[CheckMethod]'].value == 'Blobs' ) {
|
|
|
|
if ( !form.elements['newZone[MinBlobPixels]'].value || (parseFloat(form.elements['newZone[MinBlobPixels]'].value) <= 0 ) ) {
|
|
|
|
errors[errors.length] = minBlobAreaUnsetString;
|
|
|
|
} else if ( (parseFloat(form.elements['newZone[MinBlobPixels]'].value) >= parseFloat(form.elements['newZone[MaxBlobPixels]'].value)) && (parseFloat(form.elements['newZone[MaxBlobPixels]'].value) > 0) ) {
|
|
|
|
errors[errors.length] = minBlobAreaLtMaxString;
|
|
|
|
} else if ( parseFloat(form.elements['newZone[MinFilterPixels]'].value) < parseFloat(form.elements['newZone[MinBlobPixels]'].value) ) {
|
|
|
|
errors[errors.length] = minBlobLtMinFilterString;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 02:06:13 +08:00
|
|
|
if ( !form.elements['newZone[MinBlobs]'].value || (parseInt(form.elements['newZone[MinBlobs]'].value) <= 0 ) ) {
|
|
|
|
errors[errors.length] = minBlobsUnsetString;
|
|
|
|
} else if ( (parseInt(form.elements['newZone[MinBlobs]'].value) >= parseInt(form.elements['newZone[MaxBlobs]'].value)) && (parseInt(form.elements['newZone[MaxBlobs]'].value) > 0) ) {
|
|
|
|
errors[errors.length] = minBlobsLtMaxString;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
|
|
|
if ( errors.length ) {
|
2019-10-30 06:06:32 +08:00
|
|
|
alert(errors.join("\n"));
|
2018-10-25 00:43:43 +08:00
|
|
|
return false;
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
2018-10-25 00:43:43 +08:00
|
|
|
return true;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function submitForm(form) {
|
2017-05-19 02:06:13 +08:00
|
|
|
form.elements['newZone[AlarmRGB]'].value = (form.newAlarmRgbR.value<<16)|(form.newAlarmRgbG.value<<8)|form.newAlarmRgbB.value;
|
|
|
|
form.elements['newZone[NumCoords]'].value = zone['Points'].length;
|
|
|
|
form.elements['newZone[Coords]'].value = getCoordString();
|
|
|
|
form.elements['newZone[Area]'].value = zone.Area;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-05-19 02:06:13 +08:00
|
|
|
form.submit();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-04-06 04:09:40 +08:00
|
|
|
function applyZoneType() {
|
2017-05-19 02:06:13 +08:00
|
|
|
var form = document.zoneForm;
|
|
|
|
if ( form.elements['newZone[Type]'].value == 'Inactive' || form.elements['newZone[Type]'].value == 'Privacy' ) {
|
|
|
|
form.presetSelector.disabled = true;
|
|
|
|
form.newAlarmRgbR.disabled = true;
|
|
|
|
form.newAlarmRgbG.disabled = true;
|
|
|
|
form.newAlarmRgbB.disabled = true;
|
|
|
|
form.elements['newZone[CheckMethod]'].disabled = true;
|
|
|
|
form.elements['newZone[MinPixelThreshold]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxPixelThreshold]'].disabled = true;
|
|
|
|
form.elements['newZone[MinAlarmPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxAlarmPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[FilterX]'].disabled = true;
|
|
|
|
form.elements['newZone[FilterY]'].disabled = true;
|
|
|
|
form.elements['newZone[MinFilterPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxFilterPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MinBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MinBlobs]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobs]'].disabled = true;
|
|
|
|
form.elements['newZone[OverloadFrames]'].disabled = true;
|
|
|
|
form.elements['newZone[ExtendAlarmFrames]'].disabled = true;
|
|
|
|
} else if ( form.elements['newZone[Type]'].value == 'Preclusive' ) {
|
|
|
|
form.presetSelector.disabled = false;
|
|
|
|
form.newAlarmRgbR.disabled = true;
|
|
|
|
form.newAlarmRgbG.disabled = true;
|
|
|
|
form.newAlarmRgbB.disabled = true;
|
|
|
|
form.elements['newZone[CheckMethod]'].disabled = false;
|
|
|
|
form.elements['newZone[MinPixelThreshold]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxPixelThreshold]'].disabled = false;
|
|
|
|
form.elements['newZone[MinAlarmPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxAlarmPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[OverloadFrames]'].disabled = false;
|
|
|
|
form.elements['newZone[ExtendAlarmFrames]'].disabled = false;
|
|
|
|
applyCheckMethod();
|
|
|
|
} else {
|
|
|
|
form.presetSelector.disabled = false;
|
|
|
|
form.newAlarmRgbR.disabled = false;
|
|
|
|
form.newAlarmRgbG.disabled = false;
|
|
|
|
form.newAlarmRgbB.disabled = false;
|
|
|
|
form.elements['newZone[CheckMethod]'].disabled = false;
|
|
|
|
form.elements['newZone[MinPixelThreshold]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxPixelThreshold]'].disabled = false;
|
|
|
|
form.elements['newZone[MinAlarmPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxAlarmPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[OverloadFrames]'].disabled = false;
|
|
|
|
form.elements['newZone[ExtendAlarmFrames]'].disabled = true;
|
|
|
|
applyCheckMethod();
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-04-06 04:09:40 +08:00
|
|
|
function applyCheckMethod() {
|
2017-05-19 02:06:13 +08:00
|
|
|
var form = document.zoneForm;
|
|
|
|
if ( form.elements['newZone[CheckMethod]'].value == 'AlarmedPixels' ) {
|
|
|
|
form.elements['newZone[FilterX]'].disabled = true;
|
|
|
|
form.elements['newZone[FilterY]'].disabled = true;
|
|
|
|
form.elements['newZone[MinFilterPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxFilterPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MinBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MinBlobs]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobs]'].disabled = true;
|
|
|
|
} else if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' ) {
|
|
|
|
form.elements['newZone[FilterX]'].disabled = false;
|
|
|
|
form.elements['newZone[FilterY]'].disabled = false;
|
|
|
|
form.elements['newZone[MinFilterPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxFilterPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MinBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MinBlobs]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobs]'].disabled = true;
|
|
|
|
} else {
|
|
|
|
form.elements['newZone[FilterX]'].disabled = false;
|
|
|
|
form.elements['newZone[FilterY]'].disabled = false;
|
|
|
|
form.elements['newZone[MinFilterPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxFilterPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MinBlobPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxBlobPixels]'].disabled = false;
|
|
|
|
form.elements['newZone[MinBlobs]'].disabled = false;
|
|
|
|
form.elements['newZone[MaxBlobs]'].disabled = false;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-04-06 04:09:40 +08:00
|
|
|
function applyPreset() {
|
2017-05-19 02:06:13 +08:00
|
|
|
var form = document.zoneForm;
|
2021-01-03 01:33:21 +08:00
|
|
|
var presetId = $j('#presetSelector').val();
|
2017-05-19 02:06:13 +08:00
|
|
|
|
|
|
|
if ( presets[presetId] ) {
|
|
|
|
var preset = presets[presetId];
|
|
|
|
|
|
|
|
form.elements['newZone[Units]'].selectedIndex = preset['UnitsIndex'];
|
|
|
|
form.elements['newZone[CheckMethod]'].selectedIndex = preset['CheckMethodIndex'];
|
|
|
|
form.elements['newZone[MinPixelThreshold]'].value = preset['MinPixelThreshold'];
|
|
|
|
form.elements['newZone[MaxPixelThreshold]'].value = preset['MaxPixelThreshold'];
|
|
|
|
form.elements['newZone[FilterX]'].value = preset['FilterX'];
|
|
|
|
form.elements['newZone[FilterY]'].value = preset['FilterY'];
|
|
|
|
form.elements['newZone[MinAlarmPixels]'].value = preset['MinAlarmPixels'];
|
|
|
|
form.elements['newZone[MaxAlarmPixels]'].value = preset['MaxAlarmPixels'];
|
|
|
|
form.elements['newZone[MinFilterPixels]'].value = preset['MinFilterPixels'];
|
|
|
|
form.elements['newZone[MaxFilterPixels]'].value = preset['MaxFilterPixels'];
|
|
|
|
form.elements['newZone[MinBlobPixels]'].value = preset['MinBlobPixels'];
|
|
|
|
form.elements['newZone[MaxBlobPixels]'].value = preset['MaxBlobPixels'];
|
|
|
|
form.elements['newZone[MinBlobs]'].value = preset['MinBlobs'];
|
|
|
|
form.elements['newZone[MaxBlobs]'].value = preset['MaxBlobs'];
|
|
|
|
form.elements['newZone[OverloadFrames]'].value = preset['OverloadFrames'];
|
|
|
|
form.elements['newZone[ExtendAlarmFrames]'].value = preset['ExtendAlarmFrames'];
|
|
|
|
|
|
|
|
applyCheckMethod();
|
|
|
|
form.elements['newZone[TempArea]'].value = 100;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function toPixels(field, maxValue) {
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( field.value != '' ) {
|
2017-05-19 02:06:13 +08:00
|
|
|
field.value = Math.round((field.value*maxValue)/100);
|
2020-10-18 04:17:30 +08:00
|
|
|
if ( field.value > maxValue ) {
|
2020-08-10 10:19:43 +08:00
|
|
|
field.value = maxValue;
|
2020-10-18 04:17:30 +08:00
|
|
|
}
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-06-16 04:06:51 +08:00
|
|
|
field.setAttribute('step', 1);
|
2020-08-10 10:19:43 +08:00
|
|
|
field.setAttribute('max', maxValue);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-08-10 10:19:43 +08:00
|
|
|
// maxValue is the max Pixels value which is normally the max area
|
2019-10-30 06:06:32 +08:00
|
|
|
function toPercent(field, maxValue) {
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( field.value != '' ) {
|
2017-05-19 02:06:13 +08:00
|
|
|
field.value = Math.round((100*100*field.value)/maxValue)/100;
|
2020-08-10 10:19:43 +08:00
|
|
|
if ( field.value > 100 ) {
|
|
|
|
field.value = 100;
|
|
|
|
}
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-03-22 00:30:56 +08:00
|
|
|
field.setAttribute('step', 'any');
|
2020-06-16 04:06:51 +08:00
|
|
|
field.setAttribute('max', 100);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-04-06 04:09:40 +08:00
|
|
|
function applyZoneUnits() {
|
2017-05-19 02:06:13 +08:00
|
|
|
var area = zone.Area;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-05-19 02:06:13 +08:00
|
|
|
var form = document.zoneForm;
|
|
|
|
if ( form.elements['newZone[Units]'].value == 'Pixels' ) {
|
|
|
|
form.elements['newZone[TempArea]'].value = area;
|
2019-10-30 06:06:32 +08:00
|
|
|
toPixels(form.elements['newZone[MinAlarmPixels]'], area);
|
|
|
|
toPixels(form.elements['newZone[MaxAlarmPixels]'], area);
|
|
|
|
toPixels(form.elements['newZone[MinFilterPixels]'], area);
|
|
|
|
toPixels(form.elements['newZone[MaxFilterPixels]'], area);
|
|
|
|
toPixels(form.elements['newZone[MinBlobPixels]'], area);
|
|
|
|
toPixels(form.elements['newZone[MaxBlobPixels]'], area);
|
2017-05-19 02:06:13 +08:00
|
|
|
} else {
|
2019-10-30 06:06:32 +08:00
|
|
|
form.elements['newZone[TempArea]'].value = Math.round(area/monitorArea * 100);
|
|
|
|
toPercent(form.elements['newZone[MinAlarmPixels]'], area);
|
|
|
|
toPercent(form.elements['newZone[MaxAlarmPixels]'], area);
|
|
|
|
toPercent(form.elements['newZone[MinFilterPixels]'], area);
|
|
|
|
toPercent(form.elements['newZone[MaxFilterPixels]'], area);
|
|
|
|
toPercent(form.elements['newZone[MinBlobPixels]'], area);
|
|
|
|
toPercent(form.elements['newZone[MaxBlobPixels]'], area);
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function limitRange(field, minValue, maxValue) {
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( field.value != '' ) {
|
2019-10-30 06:06:32 +08:00
|
|
|
field.value = constrainValue(
|
2019-11-20 00:37:45 +08:00
|
|
|
parseInt(field.value),
|
|
|
|
parseInt(minValue),
|
|
|
|
parseInt(maxValue)
|
|
|
|
);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function limitRangeToUnsignedByte(field) {
|
|
|
|
if ( field.value != '' ) {
|
|
|
|
field.value = constrainValue(parseInt(field.value), 0, 255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function limitFilter(field) {
|
2017-05-19 02:06:13 +08:00
|
|
|
field.value = (Math.floor((field.value-1)/2)*2) + 1;
|
|
|
|
field.value = constrainValue(parseInt(field.value), 3, 15);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function limitArea(field) {
|
2017-05-19 02:06:13 +08:00
|
|
|
var minValue = 0;
|
|
|
|
var maxValue = zone.Area;
|
2019-10-30 06:06:32 +08:00
|
|
|
if ( document.zoneForm.elements['newZone[Units]'].value == 'Percent' ) {
|
2017-05-19 02:06:13 +08:00
|
|
|
maxValue = 100;
|
|
|
|
}
|
2019-10-30 06:06:32 +08:00
|
|
|
limitRange(field, minValue, maxValue);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-08-20 02:39:15 +08:00
|
|
|
function highlightOn(index) {
|
2021-01-03 01:33:21 +08:00
|
|
|
$j('#row'+index).addClass('highlight');
|
|
|
|
$j('#point'+index).addClass('highlight');
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-08-20 02:39:15 +08:00
|
|
|
function highlightOff(index) {
|
2021-01-03 01:33:21 +08:00
|
|
|
row = $j('#row'+index);
|
2020-09-03 02:44:11 +08:00
|
|
|
if ( row ) {
|
|
|
|
row.removeClass('highlight');
|
|
|
|
} else {
|
|
|
|
console.log("No row for index " + index);
|
|
|
|
}
|
2021-01-03 01:33:21 +08:00
|
|
|
$j('#point'+index).removeClass('highlight');
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function setActivePoint(index) {
|
|
|
|
highlightOff(index);
|
2021-01-03 01:33:21 +08:00
|
|
|
$j('#row'+index).addClass('active');
|
|
|
|
$j('#point'+index).addClass('active');
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function unsetActivePoint(index) {
|
2021-01-03 01:33:21 +08:00
|
|
|
$j('#row'+index).removeClass('active');
|
|
|
|
$j('#point'+index).removeClass('active');
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-04-06 04:09:40 +08:00
|
|
|
function getCoordString() {
|
2021-01-05 00:28:16 +08:00
|
|
|
var coords = [];
|
2019-01-19 23:32:40 +08:00
|
|
|
for ( var i = 0; i < zone['Points'].length; i++ ) {
|
2017-05-19 02:06:13 +08:00
|
|
|
coords[coords.length] = zone['Points'][i].x+','+zone['Points'][i].y;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2019-10-30 06:06:32 +08:00
|
|
|
return coords.join(' ');
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-04-06 04:09:40 +08:00
|
|
|
function updateZoneImage() {
|
2021-01-03 01:33:21 +08:00
|
|
|
var SVG = document.getElementById('zoneSVG');
|
|
|
|
var Poly = document.getElementById('zonePoly');
|
2017-05-19 02:06:13 +08:00
|
|
|
Poly.points.clear();
|
|
|
|
for ( var i = 0; i < zone['Points'].length; i++ ) {
|
|
|
|
var Point = SVG.createSVGPoint();
|
|
|
|
Point.x = zone['Points'][i].x;
|
2021-01-03 02:24:12 +08:00
|
|
|
Point.y = zone['Points'][i].y;
|
2019-10-30 06:06:32 +08:00
|
|
|
Poly.points.appendItem(Point);
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function fixActivePoint(index) {
|
|
|
|
updateActivePoint(index);
|
|
|
|
unsetActivePoint(index);
|
2017-05-19 02:06:13 +08:00
|
|
|
updateZoneImage();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function constrainValue(value, loVal, hiVal) {
|
2017-05-19 02:06:13 +08:00
|
|
|
if ( value < loVal ) {
|
|
|
|
return loVal;
|
|
|
|
}
|
|
|
|
if ( value > hiVal ) {
|
|
|
|
return hiVal;
|
|
|
|
}
|
|
|
|
return value;
|
2013-11-03 06:56:42 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function updateActivePoint(index) {
|
2021-01-03 01:58:03 +08:00
|
|
|
var point = $j('#point'+index);
|
2021-01-03 01:33:21 +08:00
|
|
|
var imageFrame = document.getElementById('imageFrame');
|
2020-09-03 02:44:11 +08:00
|
|
|
var style = imageFrame.currentStyle || window.getComputedStyle(imageFrame);
|
2021-01-03 01:58:03 +08:00
|
|
|
var padding_left = parseInt(style.paddingLeft);
|
|
|
|
var padding_top = parseInt(style.paddingTop);
|
|
|
|
var padding_right = parseInt(style.paddingRight);
|
|
|
|
var scale = (imageFrame.clientWidth - ( padding_top + padding_right )) / maxX;
|
|
|
|
var left = parseInt(point.css('left'), 10);
|
2020-09-03 02:44:11 +08:00
|
|
|
|
|
|
|
if ( left < padding_left ) {
|
2021-01-03 01:58:03 +08:00
|
|
|
point.css('left', style.paddingLeft);
|
|
|
|
left = parseInt(padding_left);
|
2020-09-03 02:44:11 +08:00
|
|
|
}
|
2021-01-03 01:58:03 +08:00
|
|
|
var top = parseInt(point.css('top'));
|
2020-09-03 02:44:11 +08:00
|
|
|
if ( top < padding_top ) {
|
2021-01-03 01:58:03 +08:00
|
|
|
point.css('top', style.paddingTop);
|
|
|
|
top = parseInt(padding_top);
|
2020-09-03 02:44:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var x = constrainValue(Math.ceil(left / scale)-Math.ceil(padding_left/scale), 0, maxX);
|
|
|
|
var y = constrainValue(Math.ceil(top / scale)-Math.ceil(padding_top/scale), 0, maxY);
|
|
|
|
|
2021-01-05 00:28:16 +08:00
|
|
|
zone['Points'][index].x = document.getElementById('newZone[Points]['+index+'][x]').value = x;
|
|
|
|
zone['Points'][index].y = document.getElementById('newZone[Points]['+index+'][y]').value = y;
|
|
|
|
var Point = document.getElementById('zonePoly').points.getItem(index);
|
2020-07-08 06:57:11 +08:00
|
|
|
Point.x = x;
|
|
|
|
Point.y = y;
|
2017-05-19 02:06:13 +08:00
|
|
|
updateArea();
|
2020-09-03 02:44:11 +08:00
|
|
|
} // end function updateActivePoint(index)
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function addPoint(index) {
|
2017-05-19 02:06:13 +08:00
|
|
|
var nextIndex = index+1;
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( index >= (zone['Points'].length-1) ) {
|
2017-05-19 02:06:13 +08:00
|
|
|
nextIndex = 0;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-08-20 02:39:15 +08:00
|
|
|
|
2017-05-19 02:06:13 +08:00
|
|
|
var newX = parseInt(Math.round((zone['Points'][index]['x']+zone['Points'][nextIndex]['x'])/2));
|
|
|
|
var newY = parseInt(Math.round((zone['Points'][index]['y']+zone['Points'][nextIndex]['y'])/2));
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( nextIndex == 0 ) {
|
|
|
|
zone['Points'][zone['Points'].length] = {'x': newX, 'y': newY};
|
|
|
|
} else {
|
2020-08-20 02:39:15 +08:00
|
|
|
zone['Points'].splice(nextIndex, 0, {'x': newX, 'y': newY});
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2017-05-19 02:06:13 +08:00
|
|
|
drawZonePoints();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function delPoint(index) {
|
|
|
|
zone['Points'].splice(index, 1);
|
2017-05-19 02:06:13 +08:00
|
|
|
drawZonePoints();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function limitPointValue(point, loVal, hiVal) {
|
2017-05-19 02:09:46 +08:00
|
|
|
point.value = constrainValue(point.value, loVal, hiVal);
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
function updateArea( ) {
|
2018-10-25 00:43:43 +08:00
|
|
|
area = Polygon_calcArea(zone['Points']);
|
2017-05-19 02:09:46 +08:00
|
|
|
zone.Area = area;
|
2021-01-05 00:28:16 +08:00
|
|
|
var form = document.getElementById('zoneForm');
|
2017-05-19 02:09:46 +08:00
|
|
|
form.elements['newZone[Area]'].value = area;
|
|
|
|
if ( form.elements['newZone[Units]'].value == 'Percent' ) {
|
|
|
|
form.elements['newZone[TempArea]'].value = Math.round( area/monitorArea*100 );
|
|
|
|
} else if ( form.elements['newZone[Units]'].value == 'Pixels' ) {
|
|
|
|
form.elements['newZone[TempArea]'].value = area;
|
|
|
|
} else {
|
2020-07-08 06:57:11 +08:00
|
|
|
alert('Unknown units: ' + form.elements['newZone[Units]'].value);
|
2016-06-07 23:40:53 +08:00
|
|
|
}
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2016-06-07 23:40:53 +08:00
|
|
|
|
2020-07-08 06:57:11 +08:00
|
|
|
function updateX(input) {
|
|
|
|
index = input.getAttribute('data-point-index');
|
|
|
|
|
|
|
|
limitPointValue(input, 0, maxX);
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-01-03 01:58:03 +08:00
|
|
|
var point = $j('#point'+index);
|
2020-07-08 06:57:11 +08:00
|
|
|
var x = input.value;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-01-03 01:58:03 +08:00
|
|
|
point.css('left', x+'px');
|
2017-05-19 02:09:46 +08:00
|
|
|
zone['Points'][index].x = x;
|
2021-01-05 00:28:16 +08:00
|
|
|
var Point = document.getElementById('zonePoly').points.getItem(index);
|
2017-05-19 02:09:46 +08:00
|
|
|
Point.x = x;
|
2018-12-28 03:28:14 +08:00
|
|
|
updateArea();
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2020-07-08 06:57:11 +08:00
|
|
|
function updateY(input) {
|
|
|
|
index = input.getAttribute('data-point-index');
|
|
|
|
limitPointValue(input, 0, maxY);
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-01-03 01:58:03 +08:00
|
|
|
var point = $j('#point'+index);
|
2020-07-08 06:57:11 +08:00
|
|
|
var y = input.value;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-01-03 01:58:03 +08:00
|
|
|
point.css('top', y+'px');
|
2017-05-19 02:09:46 +08:00
|
|
|
zone['Points'][index].y = y;
|
2021-01-05 00:28:16 +08:00
|
|
|
var Point = document.getElementById('zonePoly').points.getItem(index);
|
2017-05-19 02:09:46 +08:00
|
|
|
Point.y = y;
|
2018-12-28 03:28:14 +08:00
|
|
|
updateArea();
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function saveChanges(element) {
|
2017-05-19 02:09:46 +08:00
|
|
|
var form = element.form;
|
2019-08-02 20:04:38 +08:00
|
|
|
if ( validateForm(form) ) {
|
|
|
|
submitForm(form);
|
2017-05-19 02:09:46 +08:00
|
|
|
if ( form.elements['newZone[Type]'].value == 'Privacy' ) {
|
2020-06-16 04:06:51 +08:00
|
|
|
alert('Capture process for this monitor will be restarted for the Privacy zone changes to take effect.');
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2018-10-25 00:43:43 +08:00
|
|
|
return true;
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
2018-10-25 00:43:43 +08:00
|
|
|
return false;
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
function drawZonePoints() {
|
2021-01-03 00:52:17 +08:00
|
|
|
var imageFrame = document.getElementById('imageFrame');
|
|
|
|
$j('.zonePoint').remove();
|
2021-01-03 01:58:03 +08:00
|
|
|
var style = imageFrame.currentStyle || window.getComputedStyle(imageFrame);
|
|
|
|
var padding_left = parseInt(style.paddingLeft);
|
|
|
|
var padding_right = parseInt(style.paddingRight);
|
|
|
|
var padding_top = parseInt(style.paddingTop);
|
|
|
|
var scale = (imageFrame.clientWidth - ( padding_left + padding_right )) / maxX;
|
2020-09-03 02:44:11 +08:00
|
|
|
|
2021-01-03 00:52:17 +08:00
|
|
|
$j.each( zone['Points'], function(i, coord) {
|
|
|
|
var div = $j('<div>');
|
|
|
|
div.attr({
|
2018-10-25 00:43:43 +08:00
|
|
|
'id': 'point'+i,
|
2020-07-14 02:51:07 +08:00
|
|
|
'data-point-index': i,
|
2018-10-25 00:43:43 +08:00
|
|
|
'class': 'zonePoint',
|
2021-01-03 00:52:17 +08:00
|
|
|
'title': 'Point '+(i+1)
|
2019-10-30 06:06:32 +08:00
|
|
|
});
|
2021-01-03 00:52:17 +08:00
|
|
|
div.css({
|
2021-01-03 01:58:03 +08:00
|
|
|
left: (Math.round(coord.x * scale) + padding_left)+"px",
|
2021-01-03 02:06:02 +08:00
|
|
|
top: ((parseInt(coord.y * scale)) + padding_top) +"px"
|
2021-01-03 00:52:17 +08:00
|
|
|
});
|
|
|
|
|
2021-01-03 02:06:02 +08:00
|
|
|
div.mouseover(highlightOn.bind(i, i));
|
|
|
|
div.mouseout(highlightOff.bind(i, i));
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-01-03 00:52:17 +08:00
|
|
|
$j('#imageFrame').append(div);
|
2021-01-03 02:06:02 +08:00
|
|
|
|
2021-01-03 00:52:17 +08:00
|
|
|
div.draggable({
|
|
|
|
'containment': imageFrame,
|
2021-01-03 02:06:02 +08:00
|
|
|
'start': setActivePoint.bind(i, i),
|
|
|
|
'stop': fixActivePoint.bind(i, i),
|
|
|
|
'drag': updateActivePoint.bind(i, i)
|
2021-01-03 00:52:17 +08:00
|
|
|
});
|
|
|
|
}); // end $j.each point
|
|
|
|
|
2021-01-11 23:06:21 +08:00
|
|
|
var tables = $j('#zonePoints table table');
|
|
|
|
tables.find('tbody').empty();
|
2019-10-30 06:06:32 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
for ( var i = 0; i < zone['Points'].length; i++ ) {
|
2021-01-03 00:52:17 +08:00
|
|
|
var row = document.createElement('tr');
|
|
|
|
row.id = 'row'+i;
|
2021-01-11 23:06:21 +08:00
|
|
|
$j(row).mouseover(highlightOn.bind(i, i));
|
|
|
|
$j(row).mouseout(highlightOn.bind(i, i));
|
2021-01-03 00:52:17 +08:00
|
|
|
|
|
|
|
var cell = document.createElement('td');
|
|
|
|
$j(cell).text(i+1).appendTo(row);
|
|
|
|
|
|
|
|
cell = document.createElement('td');
|
|
|
|
var input = document.createElement('input');
|
|
|
|
$j(input).attr({
|
2019-11-20 00:37:45 +08:00
|
|
|
'id': 'newZone[Points]['+i+'][x]',
|
|
|
|
'name': 'newZone[Points]['+i+'][x]',
|
|
|
|
'value': zone['Points'][i].x,
|
2020-07-08 06:57:11 +08:00
|
|
|
'type': 'number',
|
2020-08-07 00:24:51 +08:00
|
|
|
'class': 'ZonePoint',
|
2020-07-31 00:15:05 +08:00
|
|
|
'min': '0',
|
|
|
|
'max': maxX,
|
|
|
|
'data-point-index': i
|
2019-11-20 00:37:45 +08:00
|
|
|
});
|
2020-07-08 06:57:11 +08:00
|
|
|
input.oninput = window['updateX'].bind(input, input);
|
2021-01-03 00:52:17 +08:00
|
|
|
$j(input).appendTo(cell);
|
|
|
|
$j(cell).appendTo(row);
|
2019-10-30 06:06:32 +08:00
|
|
|
|
2021-01-03 00:52:17 +08:00
|
|
|
cell = document.createElement('td');
|
|
|
|
input = document.createElement('input');
|
|
|
|
$j(input).attr({
|
2019-11-20 00:37:45 +08:00
|
|
|
'id': 'newZone[Points]['+i+'][y]',
|
|
|
|
'name': 'newZone[Points]['+i+'][y]',
|
|
|
|
'value': zone['Points'][i].y,
|
2020-07-08 06:57:11 +08:00
|
|
|
'type': 'number',
|
2020-08-07 00:24:51 +08:00
|
|
|
'class': 'ZonePoint',
|
2020-07-31 00:15:05 +08:00
|
|
|
'min': '0',
|
|
|
|
'max': maxY,
|
|
|
|
'data-point-index': i
|
2021-01-03 00:52:17 +08:00
|
|
|
});
|
2020-07-08 06:57:11 +08:00
|
|
|
input.oninput = window['updateY'].bind(input, input);
|
2021-01-03 00:52:17 +08:00
|
|
|
$j(input).appendTo(cell);
|
|
|
|
$j(cell).appendTo(row);
|
|
|
|
|
|
|
|
cell = document.createElement('td');
|
|
|
|
var pbtn = document.createElement('button');
|
|
|
|
$j(pbtn)
|
2021-01-03 02:06:02 +08:00
|
|
|
.attr('type', 'button')
|
|
|
|
.text('+')
|
|
|
|
.click(addPoint.bind(i, i))
|
|
|
|
.appendTo(cell);
|
2021-01-03 00:52:17 +08:00
|
|
|
|
2018-10-25 00:43:43 +08:00
|
|
|
if ( zone['Points'].length > 3 ) {
|
2021-01-03 00:52:17 +08:00
|
|
|
var mbtn = document.createElement('button');
|
|
|
|
$j(mbtn)
|
2021-01-03 02:06:02 +08:00
|
|
|
.attr('id', 'delete'+i)
|
|
|
|
.attr('type', 'button')
|
|
|
|
.addClass('ml-1')
|
|
|
|
.text('-')
|
|
|
|
.click(delPoint.bind(i, i))
|
|
|
|
.appendTo(cell);
|
2018-10-25 00:43:43 +08:00
|
|
|
}
|
2021-01-03 00:52:17 +08:00
|
|
|
$j(cell).appendTo(row);
|
2017-05-19 02:09:46 +08:00
|
|
|
|
2021-01-11 23:06:21 +08:00
|
|
|
$j(row).appendTo(tables.eq((i%tables.length)).find('tbody'));
|
2020-08-20 02:39:15 +08:00
|
|
|
} // end foreach point
|
2017-05-19 02:09:46 +08:00
|
|
|
// Sets up the SVG polygon
|
|
|
|
updateZoneImage();
|
|
|
|
}
|
2016-04-10 10:34:30 +08:00
|
|
|
|
2020-09-03 02:44:11 +08:00
|
|
|
function streamCmdPause() {
|
|
|
|
for ( var i = 0, length = monitors.length; i < length; i++ ) {
|
|
|
|
monitors[i].pause();
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
2021-01-05 00:28:16 +08:00
|
|
|
pauseBtn.hide();
|
|
|
|
playBtn.show();
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2016-04-10 10:34:30 +08:00
|
|
|
|
2020-09-03 02:44:11 +08:00
|
|
|
function streamCmdPlay() {
|
|
|
|
for ( var i = 0, length = monitors.length; i < length; i++ ) {
|
|
|
|
monitors[i].play();
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-01-05 00:28:16 +08:00
|
|
|
pauseBtn.show();
|
|
|
|
playBtn.hide();
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2016-04-10 10:34:30 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
//Make sure the various refreshes are still taking effect
|
2019-10-30 06:06:32 +08:00
|
|
|
function watchdogCheck(type) {
|
2017-05-19 02:09:46 +08:00
|
|
|
if ( watchdogInactive[type] ) {
|
|
|
|
watchdogFunctions[type]();
|
2016-04-10 10:34:30 +08:00
|
|
|
watchdogInactive[type] = false;
|
2017-05-19 02:09:46 +08:00
|
|
|
} else {
|
|
|
|
watchdogInactive[type] = true;
|
2017-05-19 02:06:13 +08:00
|
|
|
}
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2016-04-10 10:34:30 +08:00
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function watchdogOk(type) {
|
2017-05-19 02:09:46 +08:00
|
|
|
watchdogInactive[type] = false;
|
|
|
|
}
|
2020-09-10 03:06:49 +08:00
|
|
|
|
2020-09-18 08:58:18 +08:00
|
|
|
function presetSelectorBlur() {
|
|
|
|
this.selectedIndex = 0;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
function initPage() {
|
|
|
|
var form = document.zoneForm;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
//form.elements['newZone[Name]'].disabled = true;
|
|
|
|
//form.elements['newZone[Type]'].disabled = true;
|
|
|
|
form.presetSelector.disabled = true;
|
2020-09-18 08:58:18 +08:00
|
|
|
form.presetSelector.onblur = window['presetSelectorBlur'].bind(form.presetSelector, form.presetSelector);
|
2017-05-19 02:09:46 +08:00
|
|
|
//form.elements['newZone[Units]'].disabled = true;
|
2019-11-20 00:37:45 +08:00
|
|
|
if ( CheckMethod = form.elements['newZone[CheckMethod]'] ) {
|
|
|
|
CheckMethod.disabled = true;
|
|
|
|
CheckMethod.onchange = window['applyCheckMethod'].bind(CheckMethod, CheckMethod);
|
|
|
|
}
|
|
|
|
|
|
|
|
[
|
|
|
|
'newZone[MinPixelThreshold]',
|
|
|
|
'newZone[MaxPixelThreshold]',
|
|
|
|
'newAlarmRgbR',
|
|
|
|
'newAlarmRgbG',
|
|
|
|
'newAlarmRgbB',
|
|
|
|
].forEach(
|
|
|
|
function(element_name, index) {
|
|
|
|
var el = form.elements[element_name];
|
|
|
|
if ( el ) {
|
|
|
|
el.oninput = window['limitRangeToUnsignedByte'].bind(el, el);
|
|
|
|
el.disabled = true;
|
|
|
|
} else {
|
|
|
|
console.error("Element " + element_name + " not found in zone edit form");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
[
|
|
|
|
'newZone[FilterX]',
|
|
|
|
'newZone[FilterY]'
|
|
|
|
].forEach(
|
|
|
|
function(element_name, index) {
|
|
|
|
var el = form.elements[element_name];
|
|
|
|
if ( el ) {
|
|
|
|
el.oninput = window['limitFilter'].bind(el, el);
|
|
|
|
el.disabled = true;
|
|
|
|
} else {
|
|
|
|
console.error("Element " + element_name + " not found in zone edit form");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
[
|
|
|
|
'newZone[MinAlarmPixels]',
|
|
|
|
'newZone[MaxAlarmPixels]',
|
|
|
|
'newZone[MinFilterPixels]',
|
|
|
|
'newZone[MaxFilterPixels]'
|
|
|
|
].forEach(function(element_name, index) {
|
|
|
|
var el = form.elements[element_name];
|
|
|
|
if ( el ) {
|
|
|
|
el.oninput = window['limitArea'].bind(el, el);
|
|
|
|
el.disabled = true;
|
|
|
|
} else {
|
|
|
|
console.error("Element " + element_name + " not found in zone edit form");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2019-10-30 06:06:32 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
form.elements['newZone[MinBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
|
|
|
form.elements['newZone[MinBlobs]'].disabled = true;
|
|
|
|
form.elements['newZone[MaxBlobs]'].disabled = true;
|
|
|
|
form.elements['newZone[OverloadFrames]'].disabled = true;
|
|
|
|
|
|
|
|
applyZoneType();
|
|
|
|
|
|
|
|
if ( form.elements['newZone[Units]'].value == 'Percent' ) {
|
|
|
|
applyZoneUnits();
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-05-19 02:09:46 +08:00
|
|
|
applyCheckMethod();
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-01-05 00:28:16 +08:00
|
|
|
pauseBtn.click(streamCmdPause);
|
|
|
|
playBtn.click(streamCmdPlay);
|
|
|
|
playBtn.hide(); // hide pause initially
|
2020-09-03 02:44:11 +08:00
|
|
|
|
2021-01-05 00:28:16 +08:00
|
|
|
if ( el = saveBtn[0] ) {
|
2019-11-20 00:37:45 +08:00
|
|
|
el.onclick = window['saveChanges'].bind(el, el);
|
|
|
|
}
|
2021-01-05 00:28:16 +08:00
|
|
|
if ( el = cancelBtn[0] ) {
|
2019-11-20 00:37:45 +08:00
|
|
|
el.onclick = function() {
|
2021-01-05 00:28:16 +08:00
|
|
|
window.location.reload(true);
|
2019-10-30 06:06:32 +08:00
|
|
|
};
|
2019-11-20 00:37:45 +08:00
|
|
|
}
|
2019-10-30 06:06:32 +08:00
|
|
|
|
2022-01-08 05:06:38 +08:00
|
|
|
if ( el = analyseBtn[0] ) {
|
|
|
|
el.onclick = function() {
|
|
|
|
console.log(analyse_frames);
|
|
|
|
analyse_frames = !analyse_frames;
|
|
|
|
if (analyse_frames) {
|
2022-01-08 05:30:14 +08:00
|
|
|
analyseBtn.addClass('btn-primary');
|
|
|
|
analyseBtn.removeClass('btn-secondary');
|
|
|
|
analyseBtn.attr('title', translate['Showing Analysis']);
|
2020-09-10 03:06:49 +08:00
|
|
|
} else {
|
2022-01-08 05:30:14 +08:00
|
|
|
analyseBtn.removeClass('btn-primaryary');
|
|
|
|
analyseBtn.addClass('btn-secondary');
|
|
|
|
analyseBtn.attr('title', translate['Not Showing Analysis']);
|
2020-09-10 03:06:49 +08:00
|
|
|
}
|
|
|
|
for ( var i = 0, length = monitors.length; i < length; i++ ) {
|
2022-01-08 05:06:38 +08:00
|
|
|
monitors[i].show_analyse_frames(analyse_frames);
|
2020-09-10 03:06:49 +08:00
|
|
|
}
|
2022-01-08 05:06:38 +08:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
console.log('Analyse button not found');
|
2020-09-10 03:06:49 +08:00
|
|
|
}
|
|
|
|
|
2020-09-03 02:44:11 +08:00
|
|
|
for ( var i = 0, length = monitorData.length; i < length; i++ ) {
|
|
|
|
monitors[i] = new MonitorStream(monitorData[i]);
|
2016-04-10 10:34:30 +08:00
|
|
|
|
2020-09-03 02:44:11 +08:00
|
|
|
// Start the fps and status updates. give a random delay so that we don't assault the server
|
|
|
|
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
|
2021-11-11 03:25:29 +08:00
|
|
|
monitors[i].setScale('auto');
|
2022-01-08 05:06:38 +08:00
|
|
|
monitors[i].show_analyse_frames(analyse_frames);
|
2020-09-03 02:44:11 +08:00
|
|
|
monitors[i].start(delay);
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2016-04-10 10:34:30 +08:00
|
|
|
|
2020-09-03 02:44:11 +08:00
|
|
|
document.querySelectorAll('#imageFrame img').forEach(function(el) {
|
2020-09-04 22:02:43 +08:00
|
|
|
el.addEventListener("load", imageLoadEvent, {passive: true});
|
2020-09-03 02:44:11 +08:00
|
|
|
});
|
2020-09-04 22:02:43 +08:00
|
|
|
window.addEventListener("resize", drawZonePoints, {passive: true});
|
2020-10-17 00:21:12 +08:00
|
|
|
// if the image link is broken for some reason we won't draw the points, so do it manually
|
|
|
|
drawZonePoints();
|
2020-09-26 02:37:06 +08:00
|
|
|
|
|
|
|
// Manage the BACK button
|
|
|
|
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.history.back();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Disable the back button if there is nothing to go back to
|
2021-01-05 00:28:16 +08:00
|
|
|
backBtn.prop('disabled', !document.referrer.length);
|
2020-09-26 02:37:06 +08:00
|
|
|
|
|
|
|
// Manage the REFRESH Button
|
|
|
|
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.location.reload(true);
|
|
|
|
});
|
2020-09-03 02:44:11 +08:00
|
|
|
} // initPage
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2020-09-03 02:44:11 +08:00
|
|
|
function imageLoadEvent() {
|
|
|
|
// We only need this event on the first image load to set dimensions.
|
|
|
|
// Turn it off after it has been called.
|
|
|
|
document.querySelectorAll('#imageFrame img').forEach(function(el) {
|
2020-09-04 22:02:43 +08:00
|
|
|
el.removeEventListener("load", imageLoadEvent, {passive: true});
|
2020-09-03 02:44:11 +08:00
|
|
|
});
|
|
|
|
drawZonePoints();
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2016-06-07 23:40:53 +08:00
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
function Polygon_calcArea(coords) {
|
2017-05-19 02:09:46 +08:00
|
|
|
var n_coords = coords.length;
|
|
|
|
var float_area = 0.0;
|
|
|
|
|
2019-01-23 23:35:18 +08:00
|
|
|
for ( i = 0; i < n_coords-1; i++ ) {
|
|
|
|
var trap_area = (coords[i].x*coords[i+1].y - coords[i+1].x*coords[i].y) / 2;
|
2017-05-19 02:09:46 +08:00
|
|
|
float_area += trap_area;
|
|
|
|
//printf( "%.2f (%.2f)\n", float_area, trap_area );
|
2016-06-07 23:40:53 +08:00
|
|
|
}
|
2019-01-23 23:35:18 +08:00
|
|
|
float_area += (coords[n_coords-1].x*coords[0].y - coords[0].x*coords[n_coords-1].y) / 2;
|
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
return Math.round(Math.abs(float_area));
|
2017-05-19 02:09:46 +08:00
|
|
|
}
|
2016-06-07 23:40:53 +08:00
|
|
|
|
2019-10-30 06:06:32 +08:00
|
|
|
window.addEventListener('DOMContentLoaded', initPage);
|