if you now zap on a channel, the scripts are checking for subchannels to insert.
[enigma2-plugins.git] / webinterface / src / web-data / objects.js
1 // store all objects here
2
3 //START class EPGList
4 function EPGList(xml){
5         // parsing values from xml-element
6         //debug('init EPGList'+xml);
7         try{
8                 this.xmlitems = xml.getElementsByTagName("e2eventlist").item(0).getElementsByTagName("e2event");
9         } catch (e) { debug("EPGList parsing Error");}
10         
11         this.getArray = function(sortbytime){
12                 debug("sort EPGList by time "+sortbytime);
13                 if (sortbytime = true){
14                         var sort1 = new Array();
15                         for(var i=0;i<this.xmlitems.length;i++){
16                                 var xv = new EPGEvent(this.xmlitems.item(i));
17                                 sort1.push(new Array(xv.startTime,xv));
18                         }
19                         sort1.sort(this.sortFunction);
20                         var sort2 = new Array();
21                         for(var i=0;i<sort1.length;i++){
22                                 sort2.push(sort1[i][1]);
23                         }
24                         return sort2;
25                 }else{
26                         var listxy = new Array();
27                         for (var i=0;i<this.xmlitems.length;i++){
28                                 var xv = new EPGEvent(this.xmlitems.item(i));
29                                 listxy.push(xv);                        
30                         }
31                         return listxy;
32                 }
33         }
34         this.sortFunction = function(a,b){
35           return a[0] - b[0];
36         }
37 }
38 //END class EPGList
39
40 //START class EPGEvent
41 function EPGEvent(xml){ 
42         // parsing values from xml-element
43         try{
44                 this.eventID = xml.getElementsByTagName('e2eventid').item(0).firstChild.data;
45                 this.startTime = xml.getElementsByTagName('e2eventstart').item(0).firstChild.data;
46                 this.duration = xml.getElementsByTagName('e2eventduration').item(0).firstChild.data;
47                 this.title = xml.getElementsByTagName('e2eventtitle').item(0).firstChild.data;
48                 this.serviceRef = xml.getElementsByTagName('e2eventservicereference').item(0).firstChild.data;
49                 this.serviceName = xml.getElementsByTagName('e2eventservicename').item(0).firstChild.data;
50         } catch (e) {
51                 //debug("EPGEvent parsing Error");
52         }       
53         try{
54                 this.description = xml.getElementsByTagName('e2eventdescription').item(0).firstChild.data;
55         } catch (e) {   this.description= 'N/A';        }
56         
57         try{
58                 this.descriptionE = xml.getElementsByTagName('e2eventdescriptionextended').item(0).firstChild.data;
59         } catch (e) {   this.descriptionE = 'N/A';      }
60
61         
62         this.getEventId = function ()
63         {
64                 return this.eventID;
65         }
66         this.getTimeStart = function ()
67         {
68                 var date = new Date(parseInt(this.startTime)*1000);
69                 return date;
70         }
71         this.getTimeStartString = function ()
72         {
73                 var h = this.getTimeStart().getHours();
74                 var m = this.getTimeStart().getMinutes();
75                 if (m < 10){
76                         m="0"+m;
77                 }
78                 return h+":"+m;
79         }
80         this.getTimeDay = function ()
81         {
82                 var Wochentag = new Array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
83                 var wday = Wochentag[this.getTimeStart().getDay()];
84                 var day = this.getTimeStart().getDate();
85                 var month = this.getTimeStart().getMonth()+1;
86                 var year = this.getTimeStart().getFullYear();
87                 
88                 return wday+".&nbsp;"+day+"."+month+"."+year;
89         }
90         this.getTimeBegin = function(){
91                 return this.timebegin;
92         }
93         this.getTimeEnd = function ()
94         {
95                 var date = new Date((parseInt(this.startTime)+parseInt(this.duration))*1000);
96                 return date;
97         }
98         this.getTimeEndString = function ()
99         {
100                 var h = this.getTimeEnd().getHours();
101                 var m = this.getTimeEnd().getMinutes();
102                 if (m < 10){
103                         m="0"+m;
104                 }
105                 return h+":"+m;
106         }
107         this.getDuration = function ()
108         {
109                 return  new Date(parseInt(this.duration)*1000);
110         }
111         this.getTitle = function ()
112         {
113                 return this.title;
114         }
115         this.getDescription = function ()
116         {
117                 return this.description;
118         }
119         this.getDescriptionExtended = function ()
120         {
121                 return this.descriptionE;
122         }
123         this.getServiceReference = function ()
124         {
125                 return encodeURIComponent(this.serviceRef);
126         }
127         this.getServiceName = function ()
128         {
129                 return this.serviceName.replace(" ","&nbsp;");
130         }
131 }
132 //END class EPGEvent
133
134 //START class Service
135 function ServiceReference(xml){ 
136         // parsing values from xml-element
137         //debug('init ServiceReference'+xml);
138         try{
139                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
140                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
141         } catch (e) {
142                 //debug("Service parsing Error "+e);
143         }
144         
145         this.getServiceReference = function(){
146                 return encodeURIComponent(this.servicereference);
147         }
148                 
149         this.getServiceName = function(){
150                 return this.servicename.replace('&quot;', '"');
151         }       
152 }       
153 //END class Service
154
155 //START class ServiceList
156 function ServiceList(xml){
157         // parsing values from xml-element
158         //debug('init ServiceList'+xml);
159         try{
160                 this.xmlitems = xml.getElementsByTagName("e2servicelist").item(0).getElementsByTagName("e2service");
161         } catch (e) {
162                 //debug("Service parsing Error");
163         }
164         this.getArray = function(){
165                 var listxy = new Array();
166                 for (var i=0;i<this.xmlitems.length;i++){
167                         var xv = new ServiceReference(this.xmlitems.item(i));
168                         listxy.push(xv);                        
169                 }
170                 return listxy;
171         }
172 }
173 //END class ServiceList
174
175 //START class MovieList
176 function MovieList(xml){
177         // parsing values from xml-element
178         debug('init MovieList'+xml);
179         try{
180                 this.xmlitems = xml.getElementsByTagName("e2movielist").item(0).getElementsByTagName("e2movie");
181         } catch (e) {
182                 debug("MovieList parsing Error");
183         }
184         this.getArray = function(){
185                 var listxy = new Array();
186                 for(var i=0;i<this.xmlitems.length;i++){
187                         //debug("parsing movie "+i+" of "+this.xmlitems.length);
188                         var xv = new Movie(this.xmlitems.item(i));
189                         listxy.push(xv);                        
190                 }
191                 return listxy;
192         }
193 }
194 //END class MovieList
195
196 //START class Movie
197 function Movie(xml){    
198         // parsing values from xml-element
199         //debug('init Movie');
200         try{
201                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
202         } catch (e) {
203                 this.servicereference = "N/A";
204         }
205         try{
206                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
207         } catch (e) {
208                 this.servicename = "N/A";
209         }
210         try{
211                 this.title = xml.getElementsByTagName('e2title').item(0).firstChild.data;
212         } catch (e) {
213                 this.title = "N/A";
214         }
215         try{
216                 this.descriptionextended = xml.getElementsByTagName('e2descriptionextended').item(0).firstChild.data;
217         } catch (e) {
218                 this.descriptionextended = "N/A";
219         }
220         try{
221                 this.description = xml.getElementsByTagName('e2description').item(0).firstChild.data;
222         } catch (e) {
223                 this.description = "N/A";
224         }
225         try{
226                 this.tags = xml.getElementsByTagName('e2tags').item(0).firstChild.data;
227         } catch (e) {
228                 this.tags = "no&nbsp;tags"; // no whitespaces... tags will be splittet later
229         }
230         try{
231                 this.filename = xml.getElementsByTagName('e2filename').item(0).firstChild.data;
232         } catch (e) {
233                 this.filename = "n/a";
234         }
235         this.getServiceReference = function(){
236                 return encodeURIComponent(this.servicereference);
237         }
238         this.getServiceName = function(){
239                 return this.servicename.replace('&quot;', '"');
240         }       
241         this.getTitle = function(){
242                 return this.title;
243         }       
244         this.getDescription = function(){
245                 return this.description;
246         }       
247         this.getDescriptionExtended = function(){
248                 return this.descriptionextended;
249         }       
250         this.getTags = function(){              
251                 return this.tags.split(" ");
252         }       
253         this.getFilename = function(){          
254                 return encodeURIComponent(this.filename);
255                 
256         }       
257 }       
258 //END class Movie
259
260 //START class TimerList
261 function TimerList(xml){
262         // parsing values from xml-element
263         debug('init TimerList'+xml);
264         try{
265                 this.xmlitems = xml.getElementsByTagName("e2timerlist").item(0).getElementsByTagName("e2timer");
266         } catch (e) {
267                 debug("TimerList parsing Error");
268         }
269         this.getArray = function(){
270                 var listxy = new Array();
271                 for(var i=0;i<this.xmlitems.length;i++){
272                         //debug("parsing timer "+i+" of "+this.xmlitems.length);
273                         var xv = new Timer(this.xmlitems.item(i));
274                         listxy.push(xv);                        
275                 }
276                 return listxy;
277         }
278 }
279 //END class TimerList
280
281 //START class Timer
282 function Timer(xml){    
283         // parsing values from xml-element
284         //debug('init Timer');
285         try{
286                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
287         } catch (e) {
288                 this.servicereference = "N/A";
289         }
290         try{
291                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
292         } catch (e) {
293                 this.servicename = "N/A";
294         }
295         try{
296                 this.eventid = xml.getElementsByTagName('e2eit').item(0).firstChild.data;
297         } catch (e) {
298                 this.eventid = "N/A";
299         }
300         try{
301                 this.name = xml.getElementsByTagName('e2name').item(0).firstChild.data;
302         } catch (e) {
303                 this.name = "N/A";
304         }
305         try{
306                 this.description = xml.getElementsByTagName('e2description').item(0).firstChild.data;
307         } catch (e) {
308                 this.description = "N/A";
309         }
310         try{
311                 this.descriptionextended = xml.getElementsByTagName('e2descriptionextended').item(0).firstChild.data;
312         } catch (e) {
313                 this.descriptionextended = "N/A";
314         }
315         try{
316                 this.disabled = xml.getElementsByTagName('e2disabled').item(0).firstChild.data;
317         } catch (e) {
318                 this.disabled = "0";
319         }
320         try{
321                 this.timebegin = xml.getElementsByTagName('e2timebegin').item(0).firstChild.data;
322         } catch (e) {
323                 this.timebegin = "N/A";
324         }
325         try{
326                 this.timeend = xml.getElementsByTagName('e2timeend').item(0).firstChild.data;
327         } catch (e) {
328                 this.timeend = "N/A";
329         }
330         try{
331                 this.duration = xml.getElementsByTagName('e2duration').item(0).firstChild.data;
332         } catch (e) {           
333                 this.duration = "0";
334         }
335         try{
336                 this.startprepare = xml.getElementsByTagName('e2startprepare').item(0).firstChild.data;
337         } catch (e) {
338                 this.startprepare = "N/A";
339         }
340         try{
341                 this.justplay = xml.getElementsByTagName('e2justplay').item(0).firstChild.data;
342         } catch (e) {
343                 this.justplay = "";
344         }
345         try{
346                 this.afterevent = xml.getElementsByTagName('e2afterevent').item(0).firstChild.data;
347         } catch (e) {
348                 this.afterevent = "0";
349         }
350         try{
351                 this.logentries = xml.getElementsByTagName('e2logentries').item(0).firstChild.data;
352         } catch (e) {
353                 this.logentries = "N/A";
354         }
355         try{
356                 this.tfilename = xml.getElementsByTagName('e2filename').item(0).firstChild.data;
357         } catch (e) {
358                 this.tfilename = "N/A";
359         }
360         try{
361                 this.backoff = xml.getElementsByTagName('e2backoff').item(0).firstChild.data;
362         } catch (e) {
363                 this.backoff = "N/A";
364         }
365         try{
366                 this.nextactivation = xml.getElementsByTagName('e2nextactivation').item(0).firstChild.data;
367         } catch (e) {
368                 this.nextactivation = "N/A";
369         }
370         try{
371                 this.firsttryprepare = xml.getElementsByTagName('e2firsttryprepare').item(0).firstChild.data;
372         } catch (e) {
373                 this.firsttryprepare = "N/A";
374         }
375         try{
376                 this.state = xml.getElementsByTagName('e2state').item(0).firstChild.data;
377         } catch (e) {
378                 this.state = "N/A";
379         }
380         try{
381                 this.repeated = xml.getElementsByTagName('e2repeated').item(0).firstChild.data;
382         } catch (e) {
383                 this.repeated = "0";
384         }
385         try{
386                 this.dontsave = xml.getElementsByTagName('e2dontsave').item(0).firstChild.data;
387         } catch (e) {
388                 this.dontsave = "N/A";
389         }
390         try{
391                 this.cancled = xml.getElementsByTagName('e2cancled').item(0).firstChild.data;
392         } catch (e) {
393                 this.cancled = "N/A";
394         }
395
396         this.getServiceReference = function(){
397                 return encodeURIComponent(this.servicereference);
398         }
399         this.getServiceName = function(){
400                 return this.servicename.replace('&quot;', '"');
401         }       
402         this.getEventID = function(){
403                 return this.eventid;
404         }       
405         this.getName = function(){
406                 return this.name;
407         }       
408         this.getDescription = function(){
409                 return this.description;
410         }       
411         this.getDescriptionExtended = function(){
412                 return this.descriptionextended;
413         }       
414         this.getDisabled = function(){
415                 return this.disabled;
416         }
417         this.getTimeBegin = function(){
418                 return this.timebegin;
419         }       
420         this.getTimeEnd = function(){
421                 return this.timeend;
422         }       
423         this.getDuration = function(){
424                 return parseInt(this.duration);
425         }       
426         this.getStartPrepare = function(){
427                 return this.startprepare;
428         }       
429         this.getJustplay = function(){
430                 return this.justplay;
431         }       
432         this.getAfterevent = function(){
433                 return this.afterevent;
434         }       
435         this.getLogentries = function(){
436                 return this.logentries;
437         }       
438         this.getFilename = function(){
439                 return this.tfilename;
440         }       
441         this.getBackoff = function(){
442                 return this.backoff;
443         }       
444         this.getNextActivation = function(){
445                 return this.nextactivation;
446         }       
447         this.getFirsttryprepare = function(){
448                 return this.firsttryprepare;
449         }       
450         this.getState = function(){
451                 return this.state;
452         }       
453         this.getRepeated = function(){
454                 return this.repeated;
455         }       
456         this.getDontSave = function(){
457                 return this.dontsave;
458         }       
459         this.isCancled = function(){
460                 return this.cancled;
461         }       
462 }
463 // START TimerAddResult
464 function TimerAddResult(xml){
465         // parsing values from xml-element
466         debug('init TimerAddResult'+xml);
467         try{
468                 this.xmlitems = xml.getElementsByTagName("e2timeraddresult").item(0);
469         } catch (e) {
470                 debug("TimerAddResult parsing e2timeraddresult"+e);
471         }
472         try{
473                 this.state = this.xmlitems.getElementsByTagName("e2state").item(0).firstChild.data;
474         } catch (e) {
475                 debug("TimerAddResult parsing e2state"+e);
476         }
477         try{
478                 this.statetext = this.xmlitems.getElementsByTagName("e2statetext").item(0).firstChild.data;
479         } catch (e) {
480                 debug("TimerAddResult parsing e2statetext"+e);
481         }
482         
483         this.getState = function(){
484                 if(this.state == 'True'){
485                         return true;
486                 }else{
487                         return false;
488                 }
489         }
490         this.getStateText = function(){
491                         return this.statetext;
492         }
493 }
494 // END TimerAddResult
495
496 //START class Settings
497 function Settings(xml){
498         // parsing values from xml-element
499         //debug('init ServiceList'+xml);
500         try{
501                 this.xmlitems = xml.getElementsByTagName("e2settings").item(0).getElementsByTagName("e2setting");
502                 debug(this.xmlitems);
503         } catch (e) {
504                 //debug("Service parsing Error");
505         }
506         this.getArray = function(){
507                 var listxy = new Array();
508                 for (var i=0;i<this.xmlitems.length;i++){
509                         var xv = new Setting(this.xmlitems.item(i));
510                         listxy.push(xv);                        
511                 }
512                 return listxy;
513         }
514 }
515 //END class Settings
516
517 //START class Setting
518 function Setting(xml){  
519         // parsing values from xml-element
520         //debug('init ServiceReference'+xml);
521         try{
522                 this.settingvalue = xml.getElementsByTagName('e2settingvalue').item(0).firstChild.data;
523                 this.settingname = xml.getElementsByTagName('e2settingname').item(0).firstChild.data;
524                 
525         } catch (e) {
526                 //debug("Service parsing Error "+e);
527         }
528         
529         this.getSettingValue = function(){
530                 return this.settingvalue;
531         }
532                 
533         this.getSettingName = function(){
534                 return this.settingname;
535         }       
536 }       
537 //END class Setting