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. --- javascript/Makefile | 2 +- javascript/ajax.js | 15 ------------- javascript/vdr_status.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 javascript/vdr_status.js (limited to 'javascript') 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'; + } +} -- cgit v1.2.3