From ecaaae90f3e266518498344630f20ec201107c84 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 20 Mar 2020 11:06:01 -0400 Subject: [PATCH] fix streamImg loading when using applet. Also don't alter actParms as it is not a global. --- web/skins/classic/views/js/watch.js | 39 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 242ec80f0..83eae3475 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -54,7 +54,7 @@ function changeScale() { streamImg.src = streamImg.src.replace(/scale=\d+/i, 'scale='+(scale== 'auto' ? autoScale : scale)); } 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); statusCmdParms = statusCmdParms.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); } // end if have a new auth hash } // end if respObj.status @@ -722,10 +721,14 @@ function handleClick( event ) { function appletRefresh() { if ( streamStatus && (!streamStatus.paused && !streamStatus.delayed) ) { - var streamImg = $('liveStream'); - var parent = streamImg.getParent(); - streamImg.dispose(); - streamImg.inject( parent ); + var streamImg = $('liveStream'+monitorId); + if ( streamImg ) { + var parent = streamImg.getParent(); + streamImg.dispose(); + streamImg.inject( parent ); + } else { + console.error("Nothing found for liveStream"+monitorId); + } if ( appletRefreshTime ) { appletRefresh.delay( appletRefreshTime*1000 ); } @@ -767,7 +770,7 @@ function reloadWebSite() { function initPage() { if ( monitorType != 'WebSite' ) { - if ( streamMode == "single" ) { + if ( streamMode == 'single' ) { statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout ); watchdogCheck.pass('status').periodical(statusRefreshTimeout*2); } else { @@ -778,20 +781,24 @@ function initPage() { eventCmdTimer = eventCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout ); watchdogCheck.pass('event').periodical(eventsRefreshTimeout*2); - if ( canStreamNative || streamMode == "single" ) { + if ( canStreamNative || (streamMode == 'single') ) { var streamImg = $('imageFeed').getElement('img'); if ( !streamImg ) { streamImg = $('imageFeed').getElement('object'); } - if ( streamMode == "single" ) { - streamImg.addEvent('click', fetchImage.pass(streamImg)); - fetchImage.pass(streamImg).periodical(imageRefreshTimeout); + if ( !streamImg ) { + console.error('No streamImg found for imageFeed'); } else { - streamImg.addEvent('click', function(event) { - handleClick(event); - }); - } - } + if ( streamMode == 'single' ) { + 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 ) { appletRefresh.delay(appletRefreshTime*1000);