From 6c3a3d3d50ddc4d9a93d1317b32c4e8727bebf49 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 27 Sep 2016 09:46:04 -0400 Subject: [PATCH] store the scale value for watch and event views in a cookie, differentiated by monitorId. --- web/skins/classic/views/event.php | 12 ++++++++---- web/skins/classic/views/js/event.js | 1 + web/skins/classic/views/js/event.js.php | 1 + web/skins/classic/views/js/watch.js | 3 +-- web/skins/classic/views/watch.php | 11 +++++++---- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/web/skins/classic/views/event.php b/web/skins/classic/views/event.php index d3a185f33..11c57a28e 100644 --- a/web/skins/classic/views/event.php +++ b/web/skins/classic/views/event.php @@ -41,10 +41,14 @@ if ( isset( $_REQUEST['rate'] ) ) $rate = validInt($_REQUEST['rate']); else $rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE ); -if ( isset( $_REQUEST['scale'] ) ) - $scale = validInt($_REQUEST['scale']); -else - $scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); + +if ( isset( $_REQUEST['scale'] ) ) { + $scale = validInt($_REQUEST['scale']); +} else if ( isset( $_COOKIE['zmWatchScale'.$event['MonitorId'] ) ) { + $scale = $_COOKIE['zmEventScale'.$event['MonitorId']; +} else { + $scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); +} $replayModes = array( 'single' => translate('ReplaySingle'), diff --git a/web/skins/classic/views/js/event.js b/web/skins/classic/views/js/event.js index a1b2a2e55..6c63e6e4a 100644 --- a/web/skins/classic/views/js/event.js +++ b/web/skins/classic/views/js/event.js @@ -13,6 +13,7 @@ function changeScale() var newHeight = ( baseHeight * scale ) / SCALE_BASE; streamScale( scale ); + Cookie.write( 'zmEventScale'+eventData.monitorId, scale, { duration: 10*365 } ); /*Stream could be an applet so can't use moo tools*/ var streamImg = document.getElementById('evtStream'); diff --git a/web/skins/classic/views/js/event.js.php b/web/skins/classic/views/js/event.js.php index 7415e2c72..c8fa60056 100644 --- a/web/skins/classic/views/js/event.js.php +++ b/web/skins/classic/views/js/event.js.php @@ -27,6 +27,7 @@ var connKey = ''; var eventData = { Id: , + MonitorId: , Width: , Height: , Length: diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 264a4b65f..b38749c9c 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -32,8 +32,7 @@ function changeScale() var newWidth = ( monitorWidth * scale ) / SCALE_BASE; var newHeight = ( monitorHeight * scale ) / SCALE_BASE; - // This causes FF3 to kill the stream now, ok with FF2 - //streamCmdScale( scale ); + Cookie.write( 'zmWatchScale'+monitorId, scale, { duration: 10*365 } ); /*Stream could be an applet so can't use moo tools*/ var streamImg = document.getElementById('liveStream'); diff --git a/web/skins/classic/views/watch.php b/web/skins/classic/views/watch.php index 102ae41ac..492ed5b29 100644 --- a/web/skins/classic/views/watch.php +++ b/web/skins/classic/views/watch.php @@ -44,10 +44,13 @@ else $showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable() && canView( 'Control' ) ); -if ( isset( $_REQUEST['scale'] ) ) - $scale = validInt($_REQUEST['scale']); -else - $scale = reScale( SCALE_BASE, $monitor->DefaultScale, ZM_WEB_DEFAULT_SCALE ); +if ( isset( $_REQUEST['scale'] ) ) { + $scale = validInt($_REQUEST['scale']); +} else if ( isset( $_COOKIE['zmWatchScale'.$mid] ) ) { + $scale = $_COOKIE['zmWatchScale'.$mid]; +} else { + $scale = reScale( SCALE_BASE, $monitor->DefaultScale, ZM_WEB_DEFAULT_SCALE ); +} $connkey = generateConnKey();