moved objects from tools.js
[enigma2-plugins.git] / webinterface / src / web-data / objects.js
1 // store all objects here
2
3 //START class EPGEvent
4 function EPGEvent(xml){ 
5         // parsing values from xml-element
6         try{
7                 this.eventID = xml.getElementsByTagName('e2eventid').item(0).firstChild.data;
8                 this.startTime = xml.getElementsByTagName('e2eventstart').item(0).firstChild.data;
9                 this.duration = xml.getElementsByTagName('e2eventduration').item(0).firstChild.data;
10                 this.title = xml.getElementsByTagName('e2eventtitle').item(0).firstChild.data;
11                 this.serviceRef = xml.getElementsByTagName('e2eventservicereference').item(0).firstChild.data;
12                 this.serviceName = xml.getElementsByTagName('e2eventservicename').item(0).firstChild.data;
13         } catch (e) {
14                 debug("EPGEvent parsing Error");
15         }       
16         try{
17                 this.description = xml.getElementsByTagName('e2eventdescription').item(0).firstChild.data;
18         } catch (e) {   this.description= 'N/A';        }
19         
20         try{
21                 this.descriptionE = xml.getElementsByTagName('e2eventdescriptionextended').item(0).firstChild.data;
22         } catch (e) {   this.descriptionE = 'N/A';      }
23
24         
25         this.getEventId = function ()
26         {
27                 return this.eventID;
28         }
29         this.getTimeStart = function ()
30         {
31                 var date = new Date(parseInt(this.startTime)*1000);
32                 return date;
33         }
34         this.getTimeStartString = function ()
35         {
36                 var h = this.getTimeStart().getHours();
37                 var m = this.getTimeStart().getMinutes();
38                 if (m < 10){
39                         m="0"+m;
40                 }
41                 return h+":"+m;
42         }
43         this.getTimeDay = function ()
44         {
45                 var Wochentag = new Array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
46                 var wday = Wochentag[this.getTimeStart().getDay()];
47                 var day = this.getTimeStart().getDate();
48                 var month = this.getTimeStart().getMonth()+1;
49                 var year = this.getTimeStart().getFullYear();
50                 
51                 return wday+".&nbsp;"+day+"."+month+"."+year;
52         }
53         this.getTimeEnd = function ()
54         {
55                 var date = new Date((parseInt(this.startTime)+parseInt(this.duration))*1000);
56                 return date;
57         }
58         this.getTimeEndString = function ()
59         {
60                 var h = this.getTimeEnd().getHours();
61                 var m = this.getTimeEnd().getMinutes();
62                 if (m < 10){
63                         m="0"+m;
64                 }
65                 return h+":"+m;
66         }
67         this.getDuration = function ()
68         {
69                 return  new Date(parseInt(this.duration)*1000);
70         }
71         this.getTitle = function ()
72         {
73                 return this.title;
74         }
75         this.getDescription = function ()
76         {
77                 return this.description;
78         }
79         this.getDescriptionExtended = function ()
80         {
81                 return this.descriptionE;
82         }
83         this.getServiceReference = function ()
84         {
85                 return encodeURIComponent(this.serviceRef);
86         }
87         this.getServiceName = function ()
88         {
89                 return this.serviceName.replace(" ","&nbsp;");
90         }
91 }
92 //END class EPGEvent
93
94 //START class Service
95 function ServiceReference(xml){ 
96         // parsing values from xml-element
97         //debug('init ServiceReference'+xml);
98         try{
99                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
100                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
101                 
102         } catch (e) {
103                 debug("Service parsing Error "+e);
104         }
105         
106         this.getServiceReference = function(){
107                 return encodeURIComponent(this.servicereference);
108         }
109                 
110         this.getServiceName = function(){
111                 return this.servicename.replace('&quot;', '"');
112         }       
113 }       
114 //END class Service
115
116
117 //START class ServiceList
118
119 function ServiceList(xml){
120         // parsing values from xml-element
121         debug('init ServiceList'+xml)
122         try{
123                 this.xmlitems = xml.getElementsByTagName("e2servicelist").item(0).getElementsByTagName("e2service");
124         } catch (e) {
125                 debug("Service parsing Error");
126         }
127         this.getArray = function(){
128                 var listxy = new Array();
129                 for (var i=0;i<this.xmlitems.length;i++){
130                         var xv = new ServiceReference(this.xmlitems.item(i));
131                         listxy.push(xv);                        
132                 }
133                 return listxy;
134         }
135 }
136 //END class ServiceList