From 3ef60cf2f005573ad9c11a7b5765e0bd4d65c5a0 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Thu, 22 Feb 2007 23:51:56 +0000 Subject: - Polling in status box can now be toggled between active and inactive. --- css/styles.css | 4 ++-- images/Makefile | 2 +- images/reload.png | Bin 0 -> 713 bytes images/stop.png | Bin 0 -> 748 bytes javascript/Makefile | 2 +- javascript/ajax.js | 15 ------------ javascript/vdr_status.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++ pages/pageelems.ecpp | 3 ++- 8 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 images/reload.png create mode 100644 images/stop.png create mode 100644 javascript/vdr_status.js diff --git a/css/styles.css b/css/styles.css index cd5b8c7..be76a35 100644 --- a/css/styles.css +++ b/css/styles.css @@ -157,12 +157,12 @@ div#infobox { float: left; border: 1px solid #C0C1DA; margin: 5px; - width: 300px; + width: 320px; } div#infobox div.st_header { overflow: hidden; - padding: 4px; + padding: 1px 4px; background: #E9EFFF; border-bottom: 1px solid #C0C1DA; } diff --git a/images/Makefile b/images/Makefile index 738ecd7..13acb58 100644 --- a/images/Makefile +++ b/images/Makefile @@ -20,7 +20,7 @@ OBJS = logo.o record.o active.o inactive.o button_blue.o \ bg_header_h.o bg_header_l.o bg_header_r.o \ bg_box_h.o bg_box_l.o bg_box_r.o \ movie.o menu_line_bg.o bg_line.o bg_tools.o \ - zap.o favicon.o bg_line_top.o + zap.o favicon.o bg_line_top.o reload.o stop.o ### Default rules: diff --git a/images/reload.png b/images/reload.png new file mode 100644 index 0000000..694efb6 Binary files /dev/null and b/images/reload.png differ diff --git a/images/stop.png b/images/stop.png new file mode 100644 index 0000000..4ffdef7 Binary files /dev/null and b/images/stop.png differ diff --git a/javascript/Makefile b/javascript/Makefile index 5419c64..36582e6 100644 --- a/javascript/Makefile +++ b/javascript/Makefile @@ -16,7 +16,7 @@ VDRDIR ?= ../../../.. ### The object files (add further files here): OBJS = alphaAPI.o domLib.o domTT_drag.o domTT.o fadomatic.o \ - treeview.o ajax.o + treeview.o ajax.o vdr_status.o ### Default rules: diff --git a/javascript/ajax.js b/javascript/ajax.js index 4db64e5..4da2b8d 100644 --- a/javascript/ajax.js +++ b/javascript/ajax.js @@ -66,18 +66,3 @@ function LiveSimpleAjaxRequest(url, param, value) xml.onerror = function(message) { alert(message); } xml.request(param, value); }; - -function LiveStatusAjaxRequest(url, containerid) -{ - var xml = new LiveAjaxCall("text", url); - xml.oncomplete = function() - { - document.getElementById(containerid).innerHTML = this.xml.responseText; - window.setTimeout("LiveStatusAjaxRequest('" + url + "', '" + containerid + "')", 1000); - } - xml.onerror = function(message) - { - document.getElementById(containerid).innerHTML = "
ERROR: " + message + "
"; - } - xml.request("", ""); -} diff --git a/javascript/vdr_status.js b/javascript/vdr_status.js new file mode 100644 index 0000000..2a2a0d1 --- /dev/null +++ b/javascript/vdr_status.js @@ -0,0 +1,58 @@ +/* + * Javascript functions for the status update box. + * This file needs 'ajax.js' to be included on the pages. + */ + +var vst_reload = true; +var vst_timer; +var vst_boxId = null; +var vst_url = null; + +function LiveStatusAjaxRequest(url, containerid) +{ + if (vst_url == null) + vst_url = url; + if (vst_boxId == null) + vst_boxId = containerid; + + var status = new LiveAjaxCall("text", url); + status.oncomplete = function() + { + document.getElementById(containerid).innerHTML = this.xml.responseText; + if (vst_reload) + vst_timer = window.setTimeout("LiveStatusAjaxRequest('" + url + "', '" + containerid + "')", 1000); + } + status.onerror = function(message) + { + vst_reload = false; + document.getElementById(containerid).innerHTML = + '
' + + '
ERROR
' + + '
 toggle reload on and off ERROR
' + + '
' + + '
' + + '
' + message + '
' + + '
' + + ''; + } + status.request("", ""); +} + +function LiveStatusToggleUpdate() +{ + if (vst_reload) { + vst_reload = false; + if (vst_timer != null) + window.clearTimeout(vst_timer); + } + else { + vst_reload = true; + LiveStatusAjaxRequest(vst_url, vst_boxId); + } + var img = document.getElementById('statusReloadBtn'); + if (img != null) { + // change image according to state. + img.src = vst_reload ? 'stop.png' : 'reload.png'; + } +} diff --git a/pages/pageelems.ecpp b/pages/pageelems.ecpp index 92afc5a..851a1c8 100644 --- a/pages/pageelems.ecpp +++ b/pages/pageelems.ecpp @@ -48,6 +48,7 @@ using namespace vdrlive; <%def ajax_js> + <# ---------------------------------------------------------------------- #> @@ -113,7 +114,7 @@ using namespace vdrlive;
<$ caption $>
-
 <$ currentTime $>
+
 toggle reload on and off <$ currentTime $>
<$ title $>
-- cgit v1.2.3