From 41298f1f32e40644b2837c96c45b02e9ad27f95f Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sun, 24 Feb 2008 19:37:21 +0100 Subject: Added functionality to display timer conflicts when polled through the statusbox updates. Created the layout and look of the status message. --- live/js/live/vdr_status.js | 135 +++++++++++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 42 deletions(-) (limited to 'live/js') diff --git a/live/js/live/vdr_status.js b/live/js/live/vdr_status.js index 13e4a0d..84afac2 100644 --- a/live/js/live/vdr_status.js +++ b/live/js/live/vdr_status.js @@ -28,51 +28,13 @@ var LiveVdrInfo = Ajax.extend({ showInfo: function(text, xmldoc) { try { - var infoType = xmldoc.getElementsByTagName('type').item(0); - - var channel = $(this.boxId + '_channel_buttons'); - var playback = $(this.boxId + '_recording_buttons'); - - if (infoType.firstChild.nodeValue != "channel") { - channel.style.display = 'none'; - playback.style.display = 'block'; - this.setTextContent('pause', infoType.firstChild.nodeValue); - this.setTextContent('play', infoType.firstChild.nodeValue); - this.setTextContent('rwd', infoType.firstChild.nodeValue); - this.setTextContent('ffw', infoType.firstChild.nodeValue); - this.setTextContent('stop', infoType.firstChild.nodeValue); - } - else { - playback.style.display = 'none'; - channel.style.display = 'block'; - } - - var epgInfo = xmldoc.getElementsByTagName('epginfo').item(0); + this.selectInfoElems(xmldoc); - 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; - this.setTextContent(node.nodeName, textContent); - } - } + this.setEpgInfo(xmldoc); - /* check if we still need to update the status */ - var upd = xmldoc.getElementsByTagName('update').item(0); - var rel = (upd.firstChild.nodeValue == "1"); + this.setInfoMessage(xmldoc); - if (rel != this.reload) { - this.reload = rel; - var img = $('statusReloadBtn'); - if (img != null) { - // change image according to state. - img.src = this.reload ? 'img/stop_update.png' : 'img/reload.png'; - } - } - if (this.reload) - this.timer = this.request.delay(1000, this, true); + this.setUpdate(xmldoc); } catch (e) { this.reportError(null); @@ -92,6 +54,75 @@ var LiveVdrInfo = Ajax.extend({ this.setTextContent('name', message); }, + // private function to switch visibility of controls. + selectInfoElems: function(xmldoc) + { + var infoType = xmldoc.getElementsByTagName('type').item(0); + + var channel = $(this.boxId + '_channel_buttons'); + var playback = $(this.boxId + '_recording_buttons'); + + if (infoType.firstChild.nodeValue != "channel") { + channel.style.display = 'none'; + playback.style.display = 'block'; + this.setTextContent('pause', infoType.firstChild.nodeValue); + this.setTextContent('play', infoType.firstChild.nodeValue); + this.setTextContent('rwd', infoType.firstChild.nodeValue); + this.setTextContent('ffw', infoType.firstChild.nodeValue); + this.setTextContent('stop', infoType.firstChild.nodeValue); + } + else { + playback.style.display = 'none'; + channel.style.display = 'block'; + } + }, + + // private function to activate the info message display if the + // corresponding element is found in the current page. + setInfoMessage: function(xmldoc) + { + var info = xmldoc.getElementsByTagName('info').item(0); + if (! $defined(info)) + return; + + var messagebar = $('messagebar'); + if (! $defined(messagebar)) + return; + + var message = xmldoc.getElementsByTagName('message').item(0); + var url = xmldoc.getElementsByTagName('url').item(0); + + if (message.firstChild.nodeValue != "") { + $('mbmessage').setText(message.firstChild.nodeValue); + if ($defined(url.firstChild)) { + $('mbdelimiter').removeClass('notpresent'); + $('mbreact').setProperty('href', url.firstChild.nodeValue); + } + else { + $('mbdelimiter').addClass('notpresent'); + $('mbreact').addClass('notpresent'); + } + messagebar.removeClass('notpresent'); + } + }, + + // private function to display information from epg info. + setEpgInfo: function(xmldoc) + { + 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; + this.setTextContent(node.nodeName, textContent); + } + } + }, + + // private function to update text contents. setTextContent: function(nodeName, textContent) { var docNode = $(this.boxId + '_' + nodeName); @@ -148,6 +179,26 @@ var LiveVdrInfo = Ajax.extend({ } }, + // private function to determine update status and to trigger + // the next update. + setUpdate: function(xmldoc) + { + /* check if we still need to update the status */ + var upd = xmldoc.getElementsByTagName('update').item(0); + var rel = (upd.firstChild.nodeValue == "1"); + + if (rel != this.reload) { + this.reload = rel; + var img = $('statusReloadBtn'); + if (img != null) { + // change image according to state. + img.src = this.reload ? 'img/stop_update.png' : 'img/reload.png'; + } + } + if (this.reload) + this.timer = this.request.delay(1000, this, true); + }, + toggleUpdate: function() { if (this.reload) { -- cgit v1.2.3