fix streamImg loading when using applet. Also don't alter actParms as it is not a global.

This commit is contained in:
Isaac Connor 2020-03-20 11:06:01 -04:00
parent 5fe1452a1a
commit ecaaae90f3
1 changed files with 23 additions and 16 deletions

View File

@ -54,7 +54,7 @@ function changeScale() {
streamImg.src = streamImg.src.replace(/scale=\d+/i, 'scale='+(scale== 'auto' ? autoScale : scale)); streamImg.src = streamImg.src.replace(/scale=\d+/i, 'scale='+(scale== 'auto' ? autoScale : scale));
} else { } else {
console.error('No element found for liveStream.'); console.error('No element found for liveStream'+monitorId);
} }
} }
@ -239,7 +239,6 @@ function getStreamCmdResponse(respObj, respText) {
streamCmdParms = streamCmdParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth); streamCmdParms = streamCmdParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
statusCmdParms = statusCmdParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth); statusCmdParms = statusCmdParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
eventCmdParms = eventCmdParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth); eventCmdParms = eventCmdParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
actParms = actParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
controlParms = controlParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth); controlParms = controlParms.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
} // end if have a new auth hash } // end if have a new auth hash
} // end if respObj.status } // end if respObj.status
@ -722,10 +721,14 @@ function handleClick( event ) {
function appletRefresh() { function appletRefresh() {
if ( streamStatus && (!streamStatus.paused && !streamStatus.delayed) ) { if ( streamStatus && (!streamStatus.paused && !streamStatus.delayed) ) {
var streamImg = $('liveStream'); var streamImg = $('liveStream'+monitorId);
var parent = streamImg.getParent(); if ( streamImg ) {
streamImg.dispose(); var parent = streamImg.getParent();
streamImg.inject( parent ); streamImg.dispose();
streamImg.inject( parent );
} else {
console.error("Nothing found for liveStream"+monitorId);
}
if ( appletRefreshTime ) { if ( appletRefreshTime ) {
appletRefresh.delay( appletRefreshTime*1000 ); appletRefresh.delay( appletRefreshTime*1000 );
} }
@ -767,7 +770,7 @@ function reloadWebSite() {
function initPage() { function initPage() {
if ( monitorType != 'WebSite' ) { if ( monitorType != 'WebSite' ) {
if ( streamMode == "single" ) { if ( streamMode == 'single' ) {
statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout ); statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );
watchdogCheck.pass('status').periodical(statusRefreshTimeout*2); watchdogCheck.pass('status').periodical(statusRefreshTimeout*2);
} else { } else {
@ -778,20 +781,24 @@ function initPage() {
eventCmdTimer = eventCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout ); eventCmdTimer = eventCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );
watchdogCheck.pass('event').periodical(eventsRefreshTimeout*2); watchdogCheck.pass('event').periodical(eventsRefreshTimeout*2);
if ( canStreamNative || streamMode == "single" ) { if ( canStreamNative || (streamMode == 'single') ) {
var streamImg = $('imageFeed').getElement('img'); var streamImg = $('imageFeed').getElement('img');
if ( !streamImg ) { if ( !streamImg ) {
streamImg = $('imageFeed').getElement('object'); streamImg = $('imageFeed').getElement('object');
} }
if ( streamMode == "single" ) { if ( !streamImg ) {
streamImg.addEvent('click', fetchImage.pass(streamImg)); console.error('No streamImg found for imageFeed');
fetchImage.pass(streamImg).periodical(imageRefreshTimeout);
} else { } else {
streamImg.addEvent('click', function(event) { if ( streamMode == 'single' ) {
handleClick(event); streamImg.addEvent('click', fetchImage.pass(streamImg));
}); fetchImage.pass(streamImg).periodical(imageRefreshTimeout);
} } else {
} streamImg.addEvent('click', function(event) {
handleClick(event);
});
}
} // end if have streamImg
} // streamMode native or single
if ( refreshApplet && appletRefreshTime ) { if ( refreshApplet && appletRefreshTime ) {
appletRefresh.delay(appletRefreshTime*1000); appletRefresh.delay(appletRefreshTime*1000);