fix indention
[enigma2-plugins.git] / webinterface / src / web-data / tools.js
1 var url_getvolume = '/web/vol?set=state'; 
2 var url_setvolume = '/web/vol?set=set'; // plus new value eq. set=set15
3 var url_volumeup = '/web/vol?set=up';
4 var url_volumedown = '/web/vol?set=down';
5 var url_volumemute = '/web/vol?set=mute';
6
7 var url_epgservice = "/web/epgservice?ref="; // plus serviceRev
8 var url_epgsearch = "/web/epgsearch?search="; // plus serviceRev
9 var url_epgnownext = "/web/epgnownext?ref="; // plus serviceRev
10
11 var url_fetchchannels = "/web/fetchchannels?ServiceListBrowse="; // plus encoded serviceref
12
13 var url_updates= "/web/updates";
14
15 var DBG = true;
16
17 /**
18 *
19 *  UTF-8 data encode / decode
20 *  http://www.webtoolkit.info/
21 *
22 **/
23
24 var Utf8 = {
25
26     // public method for url encoding
27     encode : function (string) {
28         string = string.replace(/\r\n/g,"\n");
29         var utftext = "";
30
31         for (var n = 0; n < string.length; n++) {
32
33             var c = string.charCodeAt(n);
34
35             if (c < 128) {
36                 utftext += String.fromCharCode(c);
37             }
38             else if((c > 127) && (c < 2048)) {
39                 utftext += String.fromCharCode((c >> 6) | 192);
40                 utftext += String.fromCharCode((c & 63) | 128);
41             }
42             else {
43                 utftext += String.fromCharCode((c >> 12) | 224);
44                 utftext += String.fromCharCode(((c >> 6) & 63) | 128);
45                 utftext += String.fromCharCode((c & 63) | 128);
46             }
47
48         }
49
50         return utftext;
51     },
52
53     // public method for url decoding
54     decode : function (utftext) {
55         var string = "";
56         var i = 0;
57         var c = c1 = c2 = 0;
58
59         while ( i < utftext.length ) {
60
61             c = utftext.charCodeAt(i);
62
63             if (c < 128) {
64                 string += String.fromCharCode(c);
65                 i++;
66             }
67             else if((c > 191) && (c < 224)) {
68                 c2 = utftext.charCodeAt(i+1);
69                 string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
70                 i += 2;
71             }
72             else {
73                 c2 = utftext.charCodeAt(i+1);
74                 c3 = utftext.charCodeAt(i+2);
75                 string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
76                 i += 3;
77             }
78
79         }
80
81         return string;
82     }
83
84 }
85
86 // UpdateStreamReader
87 var UpdateStreamReaderNextReadPos = 0;
88 var UpdateStreamReaderPollTimer;
89 UpdateStreamReaderRequest = null;
90 function UpdateStreamReaderStart(){
91         var ua = navigator.userAgent;
92         if(navigator.userAgent.indexOf("MSIE") >=0) {
93                 debug("UpdateStreamReader IE Fix *IE sucks*");
94                 $('UpdateStreamReaderIEFixPanel').innerHTML = '<iframe id="UpdateStreamReaderIEFixIFrame" src="'+url_updates+'" height="0" width="0" scrolling="none" frameborder="0">no iframe support!</iframe>';
95         }else {
96                 debug("UpdateStreamReader Start");
97                 UpdateStreamReaderNextReadPos = 0;
98                 allMessages = "";
99                 UpdateStreamReaderRequest =new XMLHttpRequest();
100                 UpdateStreamReaderRequest.onload = UpdateStreamReaderOnLoad;
101                 UpdateStreamReaderRequest.onerror = UpdateStreamReaderOnError;
102                 UpdateStreamReaderRequest.open("GET", url_updates, true);
103                 UpdateStreamReaderRequest.send(null);
104                 UpdateStreamReaderPollTimer = setInterval(UpdateStreamReaderLatestResponse, 500);
105         }
106 }
107   
108 function UpdateStreamReaderLatestResponse() {
109         var allMessages = UpdateStreamReaderRequest.responseText;
110         do {
111                 var unprocessed = allMessages.substring(UpdateStreamReaderNextReadPos);
112                 var messageXMLEndIndex = unprocessed.indexOf("\n");
113                 if (messageXMLEndIndex!=-1) {
114                         var endOfFirstMessageIndex = messageXMLEndIndex + "\n".length;
115                         var anUpdate = unprocessed.substring(0, endOfFirstMessageIndex);
116                         anUpdate = anUpdate.replace(/<div id="scriptzone"\/>/,'');
117                         anUpdate = anUpdate.replace(/<script>parent./, '');
118                         anUpdate = anUpdate.replace(/<\/script>\n/, '');
119                         anUpdate = Utf8.decode(anUpdate);
120
121                         //debug(Utf8.decode(anUpdate))
122                         eval(anUpdate);
123                         UpdateStreamReaderNextReadPos += endOfFirstMessageIndex;
124                 }
125         } while (messageXMLEndIndex != -1);
126 }
127
128 function UpdateStreamReaderOnLoad(){
129         window.clearInterval(UpdateStreamReaderPollTimer);
130         debug("UpdateStreamReaderOnLoad");
131         Dialog.confirm(
132                 "Live Update Stream ends!<br><br>You will not receive any Update from Enigma2.<br>Should I reconnect?",
133                  {windowParameters: {width:300, className: "alphacube"},
134                         okLabel: "reconnect",
135                         buttonClass: "myButtonClass",
136                         cancel: function(win) {debug("cancel confirm panel")},
137                         ok: function(win) {UpdateStreamReaderStart(); return true;}
138                         }
139                 );
140 }
141 function UpdateStreamReaderOnError(){
142         // TODO: change this, because it will be called on 'PageUnload' while the request is still running
143         debug("UpdateStreamReaderOnError");
144         window.clearInterval(UpdateStreamReaderPollTimer);
145         Dialog.confirm(
146                 "Live Update Stream has an Error!<br><br>You will not receive any Update from Enigma2.<br>Should I try to reconnect?",
147                  {windowParameters: {width:300, className: "alphacube"},
148                          okLabel: "reconnect",
149                          buttonClass: "myButtonClass",
150                          cancel: function(win) {debug("cancel confirm panel")},
151                          ok: function(win) {UpdateStreamReaderStart(); return true;}
152                         }
153                 );
154 }
155
156 //end UpdateStreamReader
157
158
159 function openWindow(title, inner, width, height, id){
160                         if(id == null) id = new Date().toUTCString();
161                         
162                         //debug(id);
163                         var win = new Window(id, {className: "alphacube", title: title, width: width, height: height});
164                         win.getContent().innerHTML = inner;
165                         win.setDestroyOnClose();
166                         win.showCenter();
167                         debug("opening Window: "+title);
168                         return win;
169 }
170
171 function messageBox(t, m){
172         Dialog.alert(m, {windowParameters: {title: t, className: "alphacube", width:200}, okLabel: "Close"});
173 }
174
175 function getHTTPObject( ){
176     var xmlHttp = false;
177             
178     // try to create a new instance of the xmlhttprequest object        
179     try{
180         // Internet Explorer
181         if( window.ActiveXObject ){
182             for( var i = 5; i; i-- ){
183                 try{
184                     // loading of a newer version of msxml dll (msxml3 - msxml5) failed
185                     // use fallback solution
186                     // old style msxml version independent, deprecated
187                     if( i == 2 ){
188                         xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );    
189                     }
190                     // try to use the latest msxml dll
191                     else{
192                         
193                         xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
194                     }
195                     break;
196                 }
197                 catch( excNotLoadable ){                        
198                     xmlHttp = false;
199                 }
200             }
201         }
202         // Mozilla, Opera und Safari
203         else if( window.XMLHttpRequest ){
204             xmlHttp = new XMLHttpRequest();
205         }
206     }
207     // loading of xmlhttp object failed
208     catch( excNotLoadable ){
209         xmlHttp = false;
210     }
211     return xmlHttp ;
212 }
213
214 //RND Template Function
215 function RND(tmpl, ns) {
216         var fn = function(w, g) {
217           g = g.split("|");
218           var cnt = ns[g[0]];
219
220           //Support for filter functions
221           for(var i=1; i < g.length; i++) {
222                 cnt = eval(g[i])(cnt);
223           }
224           return cnt || w;
225         };
226         return tmpl.replace(/%\(([A-Za-z0-9_|.]*)\)/g, fn);
227 }
228
229 function debug(text){
230         if(DBG){
231                 try{
232                         debugWin.getContent().innerHTML += "DEBUG: "+text+"<br>";
233                 } catch (windowNotPresent) {}
234         }
235 }
236
237 function showhide(id){
238         o = document.getElementById(id).style;
239         o.display = (o.display!="none")? "none":"";
240 }
241
242 function set(what, value){
243         //debug(what+"-"+value);
244         element = parent.document.getElementById(what);
245         if (element){
246                 element.innerHTML = value;
247         }
248         if(navigator.userAgent.indexOf("MSIE") >=0) {
249                 elementscript= $('UpdateStreamReaderIEFixIFrame').document.getElementById('scriptzone');
250                 if(elementscript){
251                         elementscript.innerHTML = ""; // deleting set() from page, to keep the page short and to save memory                    
252                 }
253         }
254 }
255 // requestindikator
256 var requestcounter = 0;
257
258 function requestIndicatorUpdate(){
259         //debug(requestcounter+" open requests");
260         if(requestcounter>=1){
261                 $('RequestIndicator').style.display = "inline";
262         }else{
263                 $('RequestIndicator').style.display = "none";
264         }
265 }
266 function requestStarted(){
267         requestcounter +=1;
268         requestIndicatorUpdate();
269 }
270 function requestFinished(){
271         requestcounter -=1;
272         requestIndicatorUpdate();
273 }
274 // end requestindikator
275
276 function doRequest(url, readyFunction){
277         //debug("requesting "+url);
278         requestStarted();
279         new Ajax.Request(url,
280                 {
281                         method: 'get',
282                         requestHeaders: ['Pragma', 'no-cache', 'Cache-Control', 'must-revalidate', 'If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT'],
283                         onSuccess: readyFunction,
284                         onComplete: requestFinished 
285                 });
286 }
287
288 function getXML(request){
289         if (document.implementation && document.implementation.createDocument){
290                 debug("using responseXML");
291                 var xmlDoc = request.responseXML
292         }
293         else if (window.ActiveXObject){
294                 debug("Creating XML for IE");
295                 var xmlInsert = document.createElement('xml');
296
297                 xmlInsert.setAttribute('innerHTML',request.responseText);
298                 xmlInsert.setAttribute('id','_MakeAUniqueID');
299                 document.body.appendChild(xmlInsert);
300                 xmlDoc = document.getElementById('_MakeAUniqueID');
301                 document.body.removeChild(document.getElementById('_MakeAUniqueID'));
302         } else {
303                 debug("Your Browser Sucks!");
304         }
305         return xmlDoc;
306 }
307
308 function zap(li){
309         var url = "/web/zap?ZapTo=" + escape(li.id);
310         //debug("requesting "+url);
311         new Ajax.Request( url,
312                 {
313                         method: 'get'                           
314                 });
315 }
316 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
317 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
318 //++++       SignalPanel                           ++++
319 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
320 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
321
322 function initSignalPanel(){
323         $('SignalPanel').innerHTML = tplSignalPanelButton;
324 }
325 function openSignalDialog(){
326         openWindow("Signal Info",tplSignalPanel, 215, 75);
327 }
328
329 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
330 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
331 //++++ EPG functions                               ++++
332 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
333 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
334 var EPGList = Class.create();
335 EPGList.prototype = {
336         //contructor
337         initialize: function(){
338                 debug("init class EPGList");
339         },
340         getBySearchString: function(string){
341                 debug("requesting "+ url_epgsearch+string);
342                 doRequest(url_epgsearch+string,this.incomingEPGrequest);
343                 
344         },
345         getByServiceReference: function(serviceRef){
346                 doRequest(url_epgservice+serviceRef,this.incomingEPGrequest);
347         },
348         
349         
350         renderTable: function(epglist){
351                 debug("rendering Table with "+epglist.length+" events");
352                 var html = tplEPGListHeader;
353                 for (var i=0; i < epglist.length; i++){
354                         try{
355                                 var item = epglist[i];
356                                 
357                                 //Create JSON Object for Template
358                                 var namespace = {       'date': item.getTimeDay(), 
359                                                                         'servicename': item.getServiceName(), 
360                                                                         'title': item.getTitle(),
361                                                                         'titleESC': escape(item.getTitle()),
362                                                                         'starttime': item.getTimeStartString(), 
363                                                                         'duration': (item.getDuration()/60000), 
364                                                                         'description': item.getDescription(), 
365                                                                         'endtime': item.getTimeEndString(), 
366                                                                         'extdescription': item.getDescriptionExtended()
367                                                                 };
368                                 //Fill template with data and add id to our result
369                                 html += RND(tplEPGListItem, namespace);
370                         } catch (blubb) {
371                                 //debug("Error rendering: "+blubb);
372                         }
373                 }
374                 
375                 html += tplEPGListFooter;
376                 //element.innerHTML = html;
377                 openWindow("Electronic Program Guide", html, 900, 500);
378                 
379         },
380         incomingEPGrequest: function(request){
381                 debug("incoming request" +request.readyState);          
382                 if (request.readyState == 4)
383                 {
384                         var EPGItems = getXML(request).getElementsByTagName("e2eventlist").item(0).getElementsByTagName("e2event");
385                         
386                         debug("have "+EPGItems.length+" e2events");
387                         if(EPGItems.length > 0){
388                         
389                                 epglist = new Array();
390                                 for(var i=0; i < EPGItems.length; i++){         
391                                         epglist.push(new EPGEvent(EPGItems.item(i)));
392                                 }
393                                 debug("Calling prototype.renderTable(epglist)");
394                                 EPGList.prototype.renderTable(epglist);
395                                 
396                         } else {
397                                 messageBox('No Items found!', 'Sorry but i could not find any EPG Content containing your search value');
398                         }
399                         
400                 }
401         }
402         
403 }
404
405 function EPGEvent(element){     
406         // parsing values from xml-element
407         try{
408                 this.eventID = element.getElementsByTagName('e2eventid').item(0).firstChild.data;
409                 this.startTime = element.getElementsByTagName('e2eventstart').item(0).firstChild.data;
410                 this.duration = element.getElementsByTagName('e2eventduration').item(0).firstChild.data;
411                 this.title = element.getElementsByTagName('e2eventtitle').item(0).firstChild.data;
412                 this.serviceRef = element.getElementsByTagName('e2eventservicereference').item(0).firstChild.data;
413                 this.serviceName = element.getElementsByTagName('e2eventservicename').item(0).firstChild.data;
414         } catch (e) {
415                 debug("EPGEvent parsing Error");
416         }       
417         try{
418                 this.description = element.getElementsByTagName('e2eventdescription').item(0).firstChild.data;
419         } catch (e) {   this.description= 'N/A';        }
420         
421         try{
422                 this.descriptionE = element.getElementsByTagName('e2eventdescriptionextended').item(0).firstChild.data;
423         } catch (e) {   this.descriptionE = 'N/A';      }
424
425         
426         this.getEventId = function ()
427         {
428                 return this.eventID;
429         }
430         this.getTimeStart = function ()
431         {
432                 var date = new Date(parseInt(this.startTime)*1000);
433                 return date;
434         }
435         this.getTimeStartString = function ()
436         {
437                 var h = this.getTimeStart().getHours();
438                 var m = this.getTimeStart().getMinutes();
439                 if (m < 10){
440                         m="0"+m;
441                 }
442                 return h+":"+m;
443         }
444         this.getTimeDay = function ()
445         {
446                 var Wochentag = new Array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
447                 var wday = Wochentag[this.getTimeStart().getDay()];
448                 var day = this.getTimeStart().getDate();
449                 var month = this.getTimeStart().getMonth()+1;
450                 var year = this.getTimeStart().getFullYear();
451                 
452                 return wday+".&nbsp;"+day+"."+month+"."+year;
453         }
454         this.getTimeEnd = function ()
455         {
456                 var date = new Date((parseInt(this.startTime)+parseInt(this.duration))*1000);
457                 return date;
458         }
459         this.getTimeEndString = function ()
460         {
461                 var h = this.getTimeEnd().getHours();
462                 var m = this.getTimeEnd().getMinutes();
463                 if (m < 10){
464                         m="0"+m;
465                 }
466                 return h+":"+m;
467         }
468         this.getDuration = function ()
469         {
470                 return  new Date(parseInt(this.duration)*1000);
471         }
472         this.getTitle = function ()
473         {
474                 return this.title;
475         }
476         this.getDescription = function ()
477         {
478                 return this.description;
479         }
480         this.getDescriptionExtended = function ()
481         {
482                 return this.descriptionE;
483         }
484         this.getServiceReference = function ()
485         {
486                 return this.serviceRef;
487         }
488         this.getServiceName = function ()
489         {
490                 return this.serviceName.replace(" ","&nbsp;");
491         }
492 }//END class EPGEvent
493
494 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
495 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
496 //++++ GUI functions                               ++++
497 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
498 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
499 var currentBodyMainElement = null
500
501 function setBodyMainContent(newelementname){
502         newelement =document.getElementById(newelementname);
503         if(currentBodyMainElement != null){
504                 currentBodyMainElement.style.display = "none";
505                 
506         }
507         newelement.style.display = "";
508         currentBodyMainElement = newelement;
509 }
510
511 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
512 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
513 //++++ volume functions                            ++++
514 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
515 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
516
517 function initVolumePanel(){
518         document.getElementById('VolumePanel').innerHTML = tplVolumePanel;
519         getVolume(); 
520 }
521 function getVolume()
522 {
523         doRequest(url_getvolume,handleVolumeRequest);
524 }
525 function volumeSet(newvalue)
526 {
527         doRequest(url_setvolume+newvalue,handleVolumeRequest);
528 }
529 function volumeUp()
530 {
531         doRequest(url_volumeup,handleVolumeRequest);
532 }
533 function volumeDown()
534 {
535         doRequest(url_volumedown,handleVolumeRequest);  
536 }
537 function volumeMute()
538 {
539         doRequest(url_volumemute,handleVolumeRequest);
540 }
541 function handleVolumeRequest(request){
542         if (request.readyState == 4) {
543                 var b = getXML(request).getElementsByTagName("e2volume");
544                 var newvalue = b.item(0).getElementsByTagName('e2current').item(0).firstChild.data;
545                 var mute = b.item(0).getElementsByTagName('e2ismuted').item(0).firstChild.data;
546                 debug("volume"+newvalue+";"+mute);
547                 
548                 for (var i = 1; i <= 10; i++)
549                 {
550                         if ( (newvalue/10)>=i){
551                                 $("volume"+i).src = "/webdata/gfx/led_on.png";
552                         }else{
553                                 $("volume"+i).src = "/webdata/gfx/led_off.png";
554                         }
555                 }
556                 if (mute == "False"){
557                         $("speaker").src = "/webdata/gfx/speak_on.png";
558                 }else{
559                         $("speaker").src = "/webdata/gfx/speak_off.png";
560                 }
561         }       
562 }
563 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
564 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
565 //++++ bouquet managing functions                  ++++
566 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
567 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
568 function initChannelList(){
569         debug("init ChannelList");      
570
571         //refreshChannellist('Favourites (TV)', '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet');
572         var url = url_fetchchannels+encodeURIComponent('1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25)FROM BOUQUET "bouquets.tv" ORDER BY bouquet');
573         doRequest(url, incomingTVBouquetList);
574
575         var url = url_fetchchannels+encodeURIComponent('1:7:2:0:0:0:0:0:0:0:(type == 2)FROM BOUQUET "bouquets.radio" ORDER BY bouquet');
576         doRequest(url, incomingRadioBouquetList);
577
578         var url = url_fetchchannels+encodeURIComponent('1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM PROVIDERS ORDER BY name');
579         doRequest(url, incomingProviderTVBouquetList);
580
581         var url = url_fetchchannels+encodeURIComponent('1:7:2:0:0:0:0:0:0:0:(type == 2) FROM PROVIDERS ORDER BY name');
582         doRequest(url, incomingProviderRadioBouquetList);
583 }
584
585 function loadBouquet(servicereference){ 
586         debug("loading bouquet with "+servicereference);        
587         doRequest(url_fetchchannels+servicereference, incomingChannellist);
588 }
589
590 function incomingTVBouquetList(request){
591         if (request.readyState == 4) {
592                 var list0 = e2servicelistToArray(getXML(request));
593                 debug("have "+list0.length+" TV Bouquet ");     
594                 $('accordionMenueBouquetContentTV').innerHTML = renderBouquetTable(list0,tplBouquetListItem);
595                 
596                 //loading first entry of TV Favorites as default for ServiceList
597                 loadBouquet(list0[0][1]);
598         }
599 }
600 function incomingRadioBouquetList(request){
601         if (request.readyState == 4) {
602                 var list1 = e2servicelistToArray(getXML(request));
603                 debug("have "+list1.length+" Radio Bouquet ");  
604                 $('accordionMenueBouquetContentRadio').innerHTML = renderBouquetTable(list1,tplBouquetListItem);
605         }       
606 }
607 function incomingProviderTVBouquetList(request){
608         if (request.readyState == 4) {
609                 var list2 = e2servicelistToArray(getXML(request));
610                 debug("have "+list2.length+" TV Provider Bouquet ");    
611                 $('accordionMenueBouquetContentProviderTV').innerHTML = renderBouquetTable(list2,tplBouquetListItem);
612         }       
613 }
614 function incomingProviderRadioBouquetList(request){
615         if (request.readyState == 4) {
616                 var list2 = e2servicelistToArray(getXML(request));
617                 debug("have "+list2.length+" Radio Provider Bouquet "); 
618                 $('accordionMenueBouquetContentProviderRadio').innerHTML = renderBouquetTable(list2,tplBouquetListItem);
619         }       
620 }
621
622 function e2servicelistToArray(xml){
623         var b = xml.getElementsByTagName("e2servicelist").item(0).getElementsByTagName("e2service");
624         var list = new Array();
625         for ( var i=0; i < b.length; i++){
626                 var bRef = escape(b.item(i).getElementsByTagName('e2servicereference').item(0).firstChild.data.replace('&quot;', '"'));
627                 var bName = b.item(i).getElementsByTagName('e2servicename').item(0).firstChild.data;
628                 var listitem = new Array(bName,bRef);
629                 list.push(listitem)
630         }
631         return list
632 }
633
634 function renderBouquetTable(bouquet,template){
635         var html = tplBouquetListHeader;
636         for (var i=0; i < bouquet.length; i++){
637                 try{
638                         var item = bouquet[i];
639                         
640                         //Create JSON Object for Template
641                         var namespace = {
642                                 'bouquetname': item[0], 
643                                 'servicereference': item[1] 
644                                 };
645                         
646                         html += RND(template, namespace);
647                 } catch (blubb) {}
648         }
649         html += tplBouquetListFooter;
650         return html;
651 }       
652
653 function incomingChannellist(request){
654         if(request.readyState == 4){
655
656                 services = getXML(request).getElementsByTagName("e2servicelist").item(0).getElementsByTagName("e2service");
657                 
658                 listerHtml      = tplServiceListHeader;
659                 
660                 debug("got "+services.length+" Services");
661                 
662                 for ( var i = 0; i < (services.length ); i++){
663                         sRef = services.item(i).getElementsByTagName('e2servicereference').item(0).firstChild.data;
664                         sName = services.item(i).getElementsByTagName('e2servicename').item(0).firstChild.data;
665                                 
666                         var namespace = {       'serviceref': sRef,
667                                                                 'servicerefESC': escape(sRef), 
668                                                                 'servicename': sName 
669                                                         };
670                                                         
671                         listerHtml += RND(tplServiceListItem, namespace);
672                         
673                 }
674                 
675                 listerHtml += tplServiceListFooter;
676                 document.getElementById('BodyContentChannellist').innerHTML = listerHtml;
677                 setBodyMainContent('BodyContentChannellist');
678         }
679 }
680
681
682
683