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