From 0f28a2b6d575c2f2989d100dbadeee708ce562eb Mon Sep 17 00:00:00 2001 From: stan Date: Wed, 25 Jun 2003 14:01:39 +0000 Subject: [PATCH] Added javascript refreshes. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@577 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/zm_config.php.z | 1 + web/zm_html.php | 103 +++++++++++++++++++++++++++++++++++--------- zmconfig.pl.in | 9 +++- 3 files changed, 91 insertions(+), 22 deletions(-) diff --git a/web/zm_config.php.z b/web/zm_config.php.z index 23f670b58..21cda53d2 100644 --- a/web/zm_config.php.z +++ b/web/zm_config.php.z @@ -46,6 +46,7 @@ define( "ZM_OPT_MPEG", "" ); // Is there an (optional) mpeg vi define( "ZM_OPT_FAST_DELETE", ); // Whether we only delete event DB records and leave zmaudit to do the rest define( "ZM_OPT_X10", ); // Whether we want to interface with X10 devices define( "ZM_OPT_FRAME_SERVER", ); // Whether to use the frame server +define( "ZM_WEB_REFRESH_METHOD", ); // What method windows should use to refresh themselves // Bandwidth specific ones from zmconfig.pl, again do not edit these directly as changes may be lost // diff --git a/web/zm_html.php b/web/zm_html.php index 501bb913c..cafc82650 100644 --- a/web/zm_html.php +++ b/web/zm_html.php @@ -57,7 +57,8 @@ switch( $view ) packageControl( 'start' ); } - header("Refresh: ".(($start||$stop)?1:REFRESH_MAIN)."; URL=$PHP_SELF" ); + if ( ZM_WEB_REFRESH_METHOD == "http" ) + header("Refresh: ".(($start||$stop)?1:REFRESH_MAIN)."; URL=$PHP_SELF" ); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 @@ -128,6 +129,14 @@ function confirmDelete() { return( confirm( 'Warning, deleting a monitor also deletes all events and database entries associated with it.\nAre you sure you wish to delete?' ) ); } + +window.setTimeout( 'window.location.reload(true)', ); + @@ -262,7 +271,7 @@ function confirmDelete() ?> - + @@ -310,7 +319,8 @@ function confirmDelete() chdir( ZM_DIR_IMAGES ); $status = exec( escapeshellcmd( ZMU_PATH." -m $monitor[Id] -i" ) ); - header("Refresh: ".REFRESH_CYCLE."; URL=$PHP_SELF?view=cycle&mid=$next_mid&mode=$mode" ); + if ( ZM_WEB_REFRESH_METHOD == "http" ) + header("Refresh: ".REFRESH_CYCLE."; URL=$PHP_SELF?view=cycle&mid=$next_mid&mode=$mode" ); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 @@ -330,6 +340,14 @@ function closeWindow() { top.window.close(); } + +window.setTimeout( "window.location.replace( '', ); + @@ -477,7 +495,8 @@ function closeWindow() chdir( ZM_DIR_IMAGES ); $status = exec( escapeshellcmd( ZMU_PATH." -m $mid -i" ) ); chdir( '..' ); - header("Refresh: ".REFRESH_IMAGE."; URL=$PHP_SELF?view=montagefeed&mid=$mid&mode=still" ); + if ( ZM_WEB_REFRESH_METHOD == "http" ) + header("Refresh: ".REFRESH_IMAGE."; URL=$PHP_SELF?view=montagefeed&mid=$mid&mode=still" ); } header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified @@ -489,6 +508,16 @@ function closeWindow() ZM - <?= $monitor[Name] ?> - MontageFeed + @@ -560,7 +589,8 @@ function closeWindow() $refresh = (isset($force)||$forced||$status)?1:REFRESH_STATUS; $url = "$PHP_SELF?view=montagestatus&mid=$mid&last_status=$status"; - header("Refresh: $refresh; URL=$url" ); + if ( ZM_WEB_REFRESH_METHOD == "http" ) + header("Refresh: $refresh; URL=$url" ); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 @@ -576,6 +606,12 @@ function closeWindow() { ?> top.window.focus(); + +window.setTimeout( "window.location.reload(true)", ); @@ -614,7 +650,7 @@ top.window.focus(); ZM - <?= $monitor[Name] ?> - Watch @@ -647,7 +683,8 @@ window.focus(); chdir( ZM_DIR_IMAGES ); $status = exec( escapeshellcmd( ZMU_PATH." -m $mid -i" ) ); chdir( '..' ); - header("Refresh: ".REFRESH_IMAGE."; URL=$PHP_SELF?view=watchfeed&mid=$mid&mode=still" ); + if ( ZM_WEB_REFRESH_METHOD == "http" ) + header("Refresh: ".REFRESH_IMAGE."; URL=$PHP_SELF?view=watchfeed&mid=$mid&mode=still" ); } header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified @@ -668,6 +705,14 @@ function closeWindow() { top.window.close(); } + +window.setTimeout( "window.location.reload(true)", ); + @@ -738,7 +783,7 @@ function closeWindow() if ( $refresh_parent ) { ?> -opener.location.reload(); +opener.location.reload(true); @@ -812,7 +857,8 @@ function closeWindow() $refresh = (isset($force)||$forced||$status)?1:REFRESH_STATUS; $url = "$PHP_SELF?view=watchstatus&mid=$mid&last_status=$status".(($force||$forced)?"&forced=1":""); - header("Refresh: $refresh; URL=$url" ); + if ( ZM_WEB_REFRESH_METHOD == "http" ) + header("Refresh: $refresh; URL=$url" ); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 @@ -833,7 +879,13 @@ top.window.focus(); if ( $old_alarm ) { ?> -parent.frames[2].location.reload(); +parent.frames[2].location.reload(true); + +window.setTimeout( "window.location.replace( '' )", ); @@ -909,7 +961,8 @@ parent.frames[2].location.reload(); $sort_order = $sort_asc?"asc":"desc"; if ( !$sort_asc ) $sort_asc = 0; - header("Refresh: ".REFRESH_EVENTS."; URL=$PHP_SELF?view=watchevents&mid=$mid&max_events=".MAX_EVENTS ); + if ( ZM_WEB_REFRESH_METHOD == "http" ) + header("Refresh: ".REFRESH_EVENTS."; URL=$PHP_SELF?view=watchevents&mid=$mid&max_events=".MAX_EVENTS ); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 @@ -951,6 +1004,14 @@ function configureButton(form,name) } form.delete_btn.disabled = !checked; } + +window.setTimeout( "window.location.replace( '' )", ); + @@ -1221,7 +1282,7 @@ function configureButton(form,name) } window.focus(); -opener.location.reload(); +opener.location.reload(true); filterWindow( '?view=filter&mid=', 'zmFilter' ); location.href = '?view=events&mid='; @@ -1243,7 +1304,7 @@ location.href = '?view=events&mid= - + @@ -1850,7 +1911,7 @@ function closeWindow() if ( !$event ) { ?> -opener.location.reload(); +opener.location.reload(true); window.close(); -opener.location.reload(); +opener.location.reload(true); function refreshWindow() { - window.location.reload(); + window.location.reload(true); } function closeWindow() { @@ -2182,7 +2243,7 @@ function configureButton(form,name) if ( $refresh_parent ) { ?> -opener.location.reload(); +opener.location.reload(true); @@ -2311,7 +2372,7 @@ $source_types = array( "Local"=>"Local", "Remote"=>"Remote" ); if ( $refresh_parent ) { ?> -opener.location.reload(); +opener.location.reload(true); @@ -2654,14 +2715,14 @@ location.replace(''); if ( $refresh_parent ) { ?> -opener.location.reload(); +opener.location.reload(true); window.focus(); function refreshWindow() { - window.location.reload(); + window.location.reload(true); } function closeWindow() { @@ -2713,7 +2774,7 @@ function closeWindow() { ?> //self.onerror = function() { return( true ); } -opener.location.reload(); +opener.location.reload(true); diff --git a/zmconfig.pl.in b/zmconfig.pl.in index 52f695360..239d23b7c 100755 --- a/zmconfig.pl.in +++ b/zmconfig.pl.in @@ -657,11 +657,18 @@ my @options = help => "This version of ZoneMinder records detailed information about events in the Stats table. This can help in profiling what the optimum settings are for Zones though this is tricky at present. However in future releases this will be done more easily and intuitively, especially with a large sample of events. The default option of 'yes' allows this information to be collected now in readiness for this but if you are concerned about performance you can switch this off in which case no Stats information will be saved.", type => $types{boolean}, }, + { + name => "ZM_WEB_REFRESH_METHOD", + default => "javascript", + description => "What method windows should use to refresh themselves, choose either javascript or http", + help => "Many windows in Javascript need to refresh themselves to keep their information current. This option determines what method they should use to do this. Choosing 'javascript' means that each window will have a short JavaScript statement in with a timer to prompt the refresh. This is the most compatible method. Choosing 'http' means the refresh instruction is put in the HTTP header. This is a cleaner method but refreshes are interrupted or cancelled when a link in the window is clicked meaning that the window will no longer refresh and this would have to be done manually.", + type => { hint => 'javascript|http', parse => sub { return( int($_[0] =~ /^([jh])/i ), $1 =~ /^j/ ? 'javascript' : 'http' ) } }, + }, { name => "ZM_WEB_H_REFRESH_MAIN", default => "300", - description => "How often (in seconds) the main console window should refresh itself", introduction => "There are now a number of options that are grouped into bandwidth categories, this allows you to configure the ZoneMinder client to work optimally over the various access methods you might to access the client.\n\nThe next few options control what happens when the client is running in 'high' bandwidth mode. You should set these options for when accessing the ZoneMinder client over a local network or high speed link. In most cases the default values will be suitable as a starting point.", + description => "How often (in seconds) the main console window should refresh itself", help => "The main console window lists a general status and the event totals for all monitors. This is not a trivial task and should not be repeated too frequently or it may affect the performance of the rest of the system.", type => $types{integer}, },
 
RefreshRefresh Show Filter Window Check All