add Timerlist to Menu
[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
205
206 //START class TimerList
207 function TimerList(xml){
208         // parsing values from xml-element
209         debug('init TimerList'+xml);
210         try{
211                 this.xmlitems = xml.getElementsByTagName("e2timerlist").item(0).getElementsByTagName("e2timer");
212         } catch (e) {
213                 debug("TimerList parsing Error");
214         }
215         this.getArray = function(){
216                 var listxy = new Array();
217                 for(var i=0;i<this.xmlitems.length;i++){
218                         //debug("parsing timer "+i+" of "+this.xmlitems.length);
219                         var xv = new Timer(this.xmlitems.item(i));
220                         listxy.push(xv);                        
221                 }
222                 return listxy;
223         }
224 }
225 //END class TimerList
226
227 //START class Timer
228 function Timer(xml){    
229         // parsing values from xml-element
230         //debug('init Timer');
231         try{
232                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
233         } catch (e) {
234                 this.servicereference = "N/A";
235         }
236         try{
237                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
238         } catch (e) {
239                 this.servicename = "N/A";
240         }
241         try{
242                 this.eventid = xml.getElementsByTagName('e2eit').item(0).firstChild.data;
243         } catch (e) {
244                 this.eventid = "N/A";
245         }
246         try{
247                 this.name = xml.getElementsByTagName('e2name').item(0).firstChild.data;
248         } catch (e) {
249                 this.name = "N/A";
250         }
251         try{
252                 this.description = xml.getElementsByTagName('e2description').item(0).firstChild.data;
253         } catch (e) {
254                 this.description = "N/A";
255         }
256         try{
257                 this.disabled = xml.getElementsByTagName('e2disabled').item(0).firstChild.data;
258         } catch (e) {
259                 this.disabled = "N/A";
260         }
261         try{
262                 this.timeend = xml.getElementsByTagName('e2timeend').item(0).firstChild.data;
263         } catch (e) {
264                 this.timeend = "N/A";
265         }
266         try{
267                 this.duration = xml.getElementsByTagName('e2duration').item(0).firstChild.data;
268         } catch (e) {           
269                 this.duration = "0";
270         }
271         try{
272                 this.startprepare = xml.getElementsByTagName('e2startprepare').item(0).firstChild.data;
273         } catch (e) {
274                 this.startprepare = "N/A";
275         }
276         try{
277                 this.justplay = xml.getElementsByTagName('e2justplay').item(0).firstChild.data;
278         } catch (e) {
279                 this.justplay = "N/A";
280         }
281         try{
282                 this.afterevent = xml.getElementsByTagName('e2afterevent').item(0).firstChild.data;
283         } catch (e) {
284                 this.afterevent = "N/A";
285         }
286         try{
287                 this.logentries = xml.getElementsByTagName('e2logentries').item(0).firstChild.data;
288         } catch (e) {
289                 this.logentries = "N/A";
290         }
291         try{
292                 this.tfilename = xml.getElementsByTagName('e2filename').item(0).firstChild.data;
293         } catch (e) {
294                 this.tfilename = "N/A";
295         }
296         try{
297                 this.backoff = xml.getElementsByTagName('e2backoff').item(0).firstChild.data;
298         } catch (e) {
299                 this.backoff = "N/A";
300         }
301         try{
302                 this.nextactivation = xml.getElementsByTagName('e2nextactivation').item(0).firstChild.data;
303         } catch (e) {
304                 this.nextactivation = "N/A";
305         }
306         try{
307                 this.firsttryprepare = xml.getElementsByTagName('e2firsttryprepare').item(0).firstChild.data;
308         } catch (e) {
309                 this.firsttryprepare = "N/A";
310         }
311         try{
312                 this.state = xml.getElementsByTagName('e2state').item(0).firstChild.data;
313         } catch (e) {
314                 this.state = "N/A";
315         }
316         try{
317                 this.repeated = xml.getElementsByTagName('e2repeated').item(0).firstChild.data;
318         } catch (e) {
319                 this.repeated = "N/A";
320         }
321         try{
322                 this.dontsave = xml.getElementsByTagName('e2dontsave').item(0).firstChild.data;
323         } catch (e) {
324                 this.dontsave = "N/A";
325         }
326         try{
327                 this.cancled = xml.getElementsByTagName('e2cancled').item(0).firstChild.data;
328         } catch (e) {
329                 this.cancled = "N/A";
330         }
331
332         this.getServiceReference = function(){
333                 return encodeURIComponent(this.servicereference);
334         }
335         this.getServiceName = function(){
336                 return this.servicename.replace('&quot;', '"');
337         }       
338         this.getEventID = function(){
339                 return this.eventid;
340         }       
341         this.getName = function(){
342                 return this.name;
343         }       
344         this.getDescription = function(){
345                 return this.description;
346         }       
347         this.getDisabled = function(){
348                 return this.tdisabled;
349         }       
350         this.getTimeEnd = function(){
351                 return this.timeend;
352         }       
353         this.getDuration = function(){
354                 return parseInt(this.duration);
355         }       
356         this.getStartPrepare = function(){
357                 return this.startprepare;
358         }       
359         this.getJustplay = function(){
360                 return this.justplay;
361         }       
362         this.getAfterevent = function(){
363                 return this.afterevent;
364         }       
365         this.getAfterevent = function(){
366                 return this.logentries;
367         }       
368         this.getFilename = function(){
369                 return this.tfilename;
370         }       
371         this.getBackoff = function(){
372                 return this.backoff;
373         }       
374         this.getNextActivation = function(){
375                 return this.nextactivation;
376         }       
377         this.getFirsttryprepare = function(){
378                 return this.firsttryprepare;
379         }       
380         this.getState = function(){
381                 return this.state;
382         }       
383         this.getRepeated = function(){
384                 return this.repeated;
385         }       
386         this.getDontSave = function(){
387                 return this.dontsave;
388         }       
389         this.isCancled = function(){
390                 return this.cancled;
391         }       
392 }
393 // START TimerAddResult
394 function TimerAddResult(xml){
395         // parsing values from xml-element
396         debug('init TimerAddResult'+xml);
397         try{
398                 this.xmlitems = xml.getElementsByTagName("e2timeraddresult").item(0);
399         } catch (e) {
400                 debug("TimerAddResult parsing e2timeraddresult"+e);
401         }
402         try{
403                 this.state = this.xmlitems.getElementsByTagName("e2state").item(0).firstChild.data;
404         } catch (e) {
405                 debug("TimerAddResult parsing e2state"+e);
406         }
407         try{
408                 this.statetext = this.xmlitems.getElementsByTagName("e2statetext").item(0).firstChild.data;
409         } catch (e) {
410                 debug("TimerAddResult parsing e2statetext"+e);
411         }
412         
413         this.getState = function(){
414                 if(this.state == 'True'){
415                         return true;
416                 }else{
417                         return false;
418                 }
419         }
420         this.getStateText = function(){
421                         return this.statetext;
422         }
423 }
424 // END TimerAddResult