diff options
author | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2007-02-18 22:22:35 +0000 |
---|---|---|
committer | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2007-02-18 22:22:35 +0000 |
commit | 4c0d3398fc6444169ee47935b9ab814eb3929e72 (patch) | |
tree | eed61c51a9c32ee726553d893567419d67b3bfdd /javascript | |
parent | 55076f14be853cb7cb1c801484267214e98c4a5e (diff) | |
download | vdr-plugin-live-4c0d3398fc6444169ee47935b9ab814eb3929e72.tar.gz vdr-plugin-live-4c0d3398fc6444169ee47935b9ab814eb3929e72.tar.bz2 |
- Added status box with current channel, program and elapsed time in the
logo area.
- Added support for progress bars to display elapsed content.
- Extendend ajax.js to be usable for non xml requests.
- adapted styles for the new features.
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/ajax.js | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/javascript/ajax.js b/javascript/ajax.js index 50bec25..4db64e5 100644 --- a/javascript/ajax.js +++ b/javascript/ajax.js @@ -1,9 +1,9 @@ -function LiveAjaxCall(url) +function LiveAjaxCall(mode, url) { var xml = null; if (window.XMLHttpRequest) { xml = new XMLHttpRequest(); - if (xml.overrideMimeType) + if (("xml" == mode) && xml.overrideMimeType) xml.overrideMimeType('text/xml'); } else if (window.ActiveXObject) { try { @@ -14,16 +14,19 @@ function LiveAjaxCall(url) } catch (e) {} } } - + this.url = url; this.xml = xml; this.onerror = function(message) {}; this.oncomplete = function() {}; - this.request = function(param, value) + this.request = function(param, value) { - var url = this.url+'?'+param+"="+value; + var url = this.url; + if (param != "") { + var url = this.url+'?'+param+"="+value; + } var obj = this; this.xml.onreadystatechange = function() { obj.readystatechanged(); } this.xml.open('GET', url, true); @@ -35,27 +38,46 @@ function LiveAjaxCall(url) try { if (this.xml.readyState == 4) { if (this.xml.status == 200) { - var xmldoc = xml.responseXML; - var result = Number(xmldoc.getElementsByTagName('response').item(0).firstChild.data); - if (!result) { - var error = xmldoc.getElementsByTagName('error').item(0).firstChild.data; - this.onerror(error); - } else + if ("xml" == mode) { + var xmldoc = xml.responseXML; + var result = Number(xmldoc.getElementsByTagName('response').item(0).firstChild.data); + if (!result) { + var error = xmldoc.getElementsByTagName('error').item(0).firstChild.data; + this.onerror(error); + } else { + this.oncomplete(); + } + } else { this.oncomplete(); + } } else { this.onerror('Invocation of webservice "'+this.url+'" failed with http status code '+this.xml.status); } } } catch (e) { - this.onerror('Invocation of webservice "'+this.url+'" failed with exception: '+e.description); + this.onerror('Invocation of webservice "'+this.url+'" failed with exception: '+e.message); } }; } - + function LiveSimpleAjaxRequest(url, param, value) { - var xml = new LiveAjaxCall(url); + var xml = new LiveAjaxCall("xml", url); 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 = "<div>ERROR: " + message + "</div>"; + } + xml.request("", ""); +} |