Fix changeScale not updating zms url when the page initially loads as not scale to fit

This commit is contained in:
Isaac Connor 2021-01-11 13:38:04 -05:00
parent 0db759ede1
commit 6d9fa27b37
1 changed files with 15 additions and 8 deletions

View File

@ -95,13 +95,17 @@ function changeScale() {
var scale = $j('#scale').val();
var newWidth;
var newHeight;
// Always turn it off, we will re-add it below. I don't know if you can add a callback multiple
// times and what the consequences would be
$j(window).off('resize', endOfResize); //remove resize handler when Scale to Fit is not active
if ( scale == '0' || scale == 'auto' ) {
var newSize = scaleToFit(monitorWidth, monitorHeight, $j('#liveStream'+monitorId), $j('#replayStatus'));
newWidth = newSize.width;
newHeight = newSize.height;
autoScale = newSize.autoScale;
$j(window).on('resize', endOfResize); //remove resize handler when Scale to Fit is not active
} else {
$j(window).off('resize', endOfResize); //remove resize handler when Scale to Fit is not active
newWidth = monitorWidth * scale / SCALE_BASE;
newHeight = monitorHeight * scale / SCALE_BASE;
}
@ -115,11 +119,12 @@ function changeScale() {
streamImg.width(newWidth);
streamImg.height(newHeight);
streamImg.src = ''; // Some browsers need it to be cleared first
streamImg.src = newSrc;
} else {
console.error('No element found for liveStream'+monitorId);
}
}
} // end function changeScale
function setAlarmState( currentAlarmState ) {
alarmState = currentAlarmState;
@ -175,7 +180,8 @@ function setAlarmState( currentAlarmState ) {
function getStreamCmdError(text, error) {
console.log(error);
// Error are normally due to failed auth. reload the page.
window.location.reload();
//window.location.reload();
}
function getStreamCmdResponse(respObj, respText) {
@ -285,7 +291,8 @@ function getStreamCmdResponse(respObj, respText) {
checkStreamForErrors('getStreamCmdResponse', respObj);//log them
// Try to reload the image stream.
// If it's an auth error, we should reload the whole page.
window.location.reload();
console.log("have error");
//window.location.reload();
if ( 0 ) {
var streamImg = $j('#liveStream'+monitorId);
if ( streamImg ) {
@ -854,13 +861,13 @@ function initPage() {
if ( refreshApplet && appletRefreshTime ) {
appletRefresh.delay(appletRefreshTime*1000);
}
if ( scale == '0' || scale == 'auto' ) changeScale();
if ( window.history.length == 1 ) {
$j('#closeControl').html('');
}
document.querySelectorAll('select[name="scale"]').forEach(function(el) {
el.onchange = window['changeScale'];
});
changeScale();
} else if ( monitorRefresh > 0 ) {
setInterval(reloadWebSite, monitorRefresh*1000);
}