add Movielist
[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 function ServiceList(xml){
119         // parsing values from xml-element
120         //debug('init ServiceList'+xml);
121         try{
122                 this.xmlitems = xml.getElementsByTagName("e2servicelist").item(0).getElementsByTagName("e2service");
123         } catch (e) {
124                 //debug("Service parsing Error");
125         }
126         this.getArray = function(){
127                 var listxy = new Array();
128                 for (var i=0;i<this.xmlitems.length;i++){
129                         var xv = new ServiceReference(this.xmlitems.item(i));
130                         listxy.push(xv);                        
131                 }
132                 return listxy;
133         }
134 }
135 //END class ServiceList
136
137
138 //START class MovieList
139 function MovieList(xml){
140         // parsing values from xml-element
141         debug('init MovieList'+xml);
142         try{
143                 this.xmlitems = xml.getElementsByTagName("e2movielist").item(0).getElementsByTagName("e2movie");
144         } catch (e) {
145                 debug("MovieList parsing Error");
146         }
147         this.getArray = function(){
148                 var listxy = new Array();
149                 for(var i=0;i<this.xmlitems.length;i++){
150                         //debug("parsing movie "+i+" of "+this.xmlitems.length);
151                         var xv = new Movie(this.xmlitems.item(i));
152                         listxy.push(xv);                        
153                 }
154                 return listxy;
155         }
156 }
157 //END class MovieList
158
159 //START class Movie
160 function Movie(xml){    
161         // parsing values from xml-element
162         //debug('init Movie');
163         try{
164                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
165         } catch (e) {
166                 this.servicereference = "N/A";
167         }
168         try{
169                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
170         } catch (e) {
171                 this.servicename = "N/A";
172         }
173         try{
174                 this.title = xml.getElementsByTagName('e2title').item(0).firstChild.data;
175         } catch (e) {
176                 this.title = "N/A";
177         }
178         try{
179                 this.description = xml.getElementsByTagName('e2description').item(0).firstChild.data;
180         } catch (e) {
181                 this.description = "N/A";
182         }
183         try{
184                 this.tags = xml.getElementsByTagName('e2tags').item(0).firstChild.data;
185         } catch (e) {
186                 this.tags = "no&nbsp;tags"; // no whitespaces... tags will be splittet later
187         }
188         this.getServiceReference = function(){
189                 return encodeURIComponent(this.servicereference);
190         }
191         this.getServiceName = function(){
192                 return this.servicename.replace('&quot;', '"');
193         }       
194         this.getTitle = function(){
195                 return this.title;
196         }       
197         this.getDescription = function(){
198                 return this.description;
199         }       
200         this.getTags = function(){              
201                 return this.tags.split(" ");
202         }       
203 }       
204 //END class Movie