From 162677a55f93defc8fc124b89b137a444ab78edb Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sun, 29 Apr 2007 18:02:47 +0000 Subject: - xml version of infobox, updates only pagelements inside the box not whole box. This circumvents the tooltip stacking problem. - updated styles for this change. - updated i18n.cpp for this change. - Changed javascript implementation for infobox. - Box doesn't change size after first update. - added some <%cpp> { tags to prevent newlines inserted by tntnet. See tntnet documentation about this. - Added infobox to all pages that didn't had one. --- javascript/vdr_status.js | 89 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 16 deletions(-) (limited to 'javascript') diff --git a/javascript/vdr_status.js b/javascript/vdr_status.js index 2a2a0d1..829b19c 100644 --- a/javascript/vdr_status.js +++ b/javascript/vdr_status.js @@ -8,35 +8,92 @@ var vst_timer; var vst_boxId = null; var vst_url = null; -function LiveStatusAjaxRequest(url, containerid) +function LiveStatusRequest(url, containerid) { if (vst_url == null) + { vst_url = url; + } if (vst_boxId == null) vst_boxId = containerid; - var status = new LiveAjaxCall("text", url); + var status = new LiveAjaxCall("xml", url); status.oncomplete = function() { - document.getElementById(containerid).innerHTML = this.xml.responseText; + try { + LiveStatusShowInfo(this.xml.responseXML, containerid); + } + catch (e) { + LiveStatusReportError(e.message, containerid); + } if (vst_reload) - vst_timer = window.setTimeout("LiveStatusAjaxRequest('" + url + "', '" + containerid + "')", 1000); + vst_timer = window.setTimeout("LiveStatusRequest('" + url + "', '" + containerid + "')", 1000); } status.onerror = function(message) { vst_reload = false; - document.getElementById(containerid).innerHTML = - '
' + - '
ERROR
' + - '
 toggle reload on and off ERROR
' + - '
' + - '
' + - '
' + message + '
' + - '
' + - ''; + LiveStatusReportError(message, containerid); + } + status.request("update", vst_reload ? "1" : "0"); +} + +function LiveStatusShowInfo(xmldoc, containerId) +{ + var epgInfo = xmldoc.getElementsByTagName('epginfo').item(0); + + for (var i = 0; i < epgInfo.childNodes.length; i++) { + var node = epgInfo.childNodes.item(i); + if (node.nodeType == 1) { + var textContent = ""; + if (node.firstChild != null) + textContent = node.firstChild.nodeValue; + LiveStatusSetTextContent(containerId, node.nodeName, textContent); } - status.request("", ""); + } +} + +function LiveStatusReportError(message, containerId) +{ + LiveStatusSetTextContent(containerId, 'caption', 'ERROR'); + LiveStatusSetTextContent(containerId, 'name', message); +} + +function LiveStatusSetTextContent(containerId, nodeName, textContent) +{ + var docNode = document.getElementById(containerId + '_' + nodeName); + if (docNode != null) { + switch (nodeName) { + case "caption": + case "timenow": + case "name": + case "duration": + { + if (docNode.innerHTML != textContent) + docNode.innerHTML = textContent; + break; + } + case "elapsed": + { + var width = textContent + "px"; + if (docNode.style.width != width) + docNode.style.width = width; + break; + } + case "nextchan": + case "prevchan": + { + if (textContent != "") { + docNode.href = "javascript:LiveSimpleAjaxRequest('switch_channel.xml', 'param', '" + textContent + "');"; + docNode.style.visibility = "visible"; + } + else { + docNode.style.visibility = "hidden"; + } + } + default: + break; + } + } } function LiveStatusToggleUpdate() @@ -48,7 +105,7 @@ function LiveStatusToggleUpdate() } else { vst_reload = true; - LiveStatusAjaxRequest(vst_url, vst_boxId); + LiveStatusRequest(vst_url, vst_boxId); } var img = document.getElementById('statusReloadBtn'); if (img != null) { -- cgit v1.2.3