edit timer is now functional
[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                 
142         } catch (e) {
143                 //debug("Service parsing Error "+e);
144         }
145         
146         this.getServiceReference = function(){
147                 return encodeURIComponent(this.servicereference);
148         }
149                 
150         this.getServiceName = function(){
151                 return this.servicename.replace('&quot;', '"');
152         }       
153 }       
154 //END class Service
155
156
157 //START class ServiceList
158 function ServiceList(xml){
159         // parsing values from xml-element
160         //debug('init ServiceList'+xml);
161         try{
162                 this.xmlitems = xml.getElementsByTagName("e2servicelist").item(0).getElementsByTagName("e2service");
163         } catch (e) {
164                 //debug("Service parsing Error");
165         }
166         this.getArray = function(){
167                 var listxy = new Array();
168                 for (var i=0;i<this.xmlitems.length;i++){
169                         var xv = new ServiceReference(this.xmlitems.item(i));
170                         listxy.push(xv);                        
171                 }
172                 return listxy;
173         }
174 }
175 //END class ServiceList
176
177
178 //START class MovieList
179 function MovieList(xml){
180         // parsing values from xml-element
181         debug('init MovieList'+xml);
182         try{
183                 this.xmlitems = xml.getElementsByTagName("e2movielist").item(0).getElementsByTagName("e2movie");
184         } catch (e) {
185                 debug("MovieList parsing Error");
186         }
187         this.getArray = function(){
188                 var listxy = new Array();
189                 for(var i=0;i<this.xmlitems.length;i++){
190                         //debug("parsing movie "+i+" of "+this.xmlitems.length);
191                         var xv = new Movie(this.xmlitems.item(i));
192                         listxy.push(xv);                        
193                 }
194                 return listxy;
195         }
196 }
197 //END class MovieList
198
199 //START class Movie
200 function Movie(xml){    
201         // parsing values from xml-element
202         //debug('init Movie');
203         try{
204                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
205         } catch (e) {
206                 this.servicereference = "N/A";
207         }
208         try{
209                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
210         } catch (e) {
211                 this.servicename = "N/A";
212         }
213         try{
214                 this.title = xml.getElementsByTagName('e2title').item(0).firstChild.data;
215         } catch (e) {
216                 this.title = "N/A";
217         }
218         try{
219                 this.descriptionextended = xml.getElementsByTagName('e2descriptionextended').item(0).firstChild.data;
220         } catch (e) {
221                 this.descriptionextended = "N/A";
222         }
223         try{
224                 this.description = xml.getElementsByTagName('e2description').item(0).firstChild.data;
225         } catch (e) {
226                 this.description = "N/A";
227         }
228         try{
229                 this.tags = xml.getElementsByTagName('e2tags').item(0).firstChild.data;
230         } catch (e) {
231                 this.tags = "no&nbsp;tags"; // no whitespaces... tags will be splittet later
232         }
233         try{
234                 this.filename = xml.getElementsByTagName('e2filename').item(0).firstChild.data;
235         } catch (e) {
236                 this.filename = "n/a";
237         }
238         this.getServiceReference = function(){
239                 return encodeURIComponent(this.servicereference);
240         }
241         this.getServiceName = function(){
242                 return this.servicename.replace('&quot;', '"');
243         }       
244         this.getTitle = function(){
245                 return this.title;
246         }       
247         this.getDescription = function(){
248                 return this.description;
249         }       
250         this.getDescriptionExtended = function(){
251                 return this.descriptionextended;
252         }       
253         this.getTags = function(){              
254                 return this.tags.split(" ");
255         }       
256         this.getFilename = function(){          
257                 return encodeURIComponent(this.filename);
258                 
259         }       
260 }       
261 //END class Movie
262
263 //START class TimerList
264 function TimerList(xml){
265         // parsing values from xml-element
266         debug('init TimerList'+xml);
267         try{
268                 this.xmlitems = xml.getElementsByTagName("e2timerlist").item(0).getElementsByTagName("e2timer");
269         } catch (e) {
270                 debug("TimerList parsing Error");
271         }
272         this.getArray = function(){
273                 var listxy = new Array();
274                 for(var i=0;i<this.xmlitems.length;i++){
275                         //debug("parsing timer "+i+" of "+this.xmlitems.length);
276                         var xv = new Timer(this.xmlitems.item(i));
277                         listxy.push(xv);                        
278                 }
279                 return listxy;
280         }
281 }
282 //END class TimerList
283
284 //START class Timer
285 function Timer(xml){    
286         // parsing values from xml-element
287         //debug('init Timer');
288         try{
289                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
290         } catch (e) {
291                 this.servicereference = "N/A";
292         }
293         try{
294                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
295         } catch (e) {
296                 this.servicename = "N/A";
297         }
298         try{
299                 this.eventid = xml.getElementsByTagName('e2eit').item(0).firstChild.data;
300         } catch (e) {
301                 this.eventid = "N/A";
302         }
303         try{
304                 this.name = xml.getElementsByTagName('e2name').item(0).firstChild.data;
305         } catch (e) {
306                 this.name = "N/A";
307         }
308         try{
309                 this.description = xml.getElementsByTagName('e2description').item(0).firstChild.data;
310         } catch (e) {
311                 this.description = "N/A";
312         }
313         try{
314                 this.descriptionextended = xml.getElementsByTagName('e2descriptionextended').item(0).firstChild.data;
315         } catch (e) {
316                 this.descriptionextended = "N/A";
317         }
318         try{
319                 this.disabled = xml.getElementsByTagName('e2disabled').item(0).firstChild.data;
320         } catch (e) {
321                 this.disabled = "N/A";
322         }
323         try{
324                 this.timebegin = xml.getElementsByTagName('e2timebegin').item(0).firstChild.data;
325         } catch (e) {
326                 this.timebegin = "N/A";
327         }
328         try{
329                 this.timeend = xml.getElementsByTagName('e2timeend').item(0).firstChild.data;
330         } catch (e) {
331                 this.timeend = "N/A";
332         }
333         try{
334                 this.duration = xml.getElementsByTagName('e2duration').item(0).firstChild.data;
335         } catch (e) {           
336                 this.duration = "0";
337         }
338         try{
339                 this.startprepare = xml.getElementsByTagName('e2startprepare').item(0).firstChild.data;
340         } catch (e) {
341                 this.startprepare = "N/A";
342         }
343         try{
344                 this.justplay = xml.getElementsByTagName('e2justplay').item(0).firstChild.data;
345         } catch (e) {
346                 this.justplay = "";
347         }
348         try{
349                 this.afterevent = xml.getElementsByTagName('e2afterevent').item(0).firstChild.data;
350         } catch (e) {
351                 this.afterevent = "0";
352         }
353         try{
354                 this.logentries = xml.getElementsByTagName('e2logentries').item(0).firstChild.data;
355         } catch (e) {
356                 this.logentries = "N/A";
357         }
358         try{
359                 this.tfilename = xml.getElementsByTagName('e2filename').item(0).firstChild.data;
360         } catch (e) {
361                 this.tfilename = "N/A";
362         }
363         try{
364                 this.backoff = xml.getElementsByTagName('e2backoff').item(0).firstChild.data;
365         } catch (e) {
366                 this.backoff = "N/A";
367         }
368         try{
369                 this.nextactivation = xml.getElementsByTagName('e2nextactivation').item(0).firstChild.data;
370         } catch (e) {
371                 this.nextactivation = "N/A";
372         }
373         try{
374                 this.firsttryprepare = xml.getElementsByTagName('e2firsttryprepare').item(0).firstChild.data;
375         } catch (e) {
376                 this.firsttryprepare = "N/A";
377         }
378         try{
379                 this.state = xml.getElementsByTagName('e2state').item(0).firstChild.data;
380         } catch (e) {
381                 this.state = "N/A";
382         }
383         try{
384                 this.repeated = xml.getElementsByTagName('e2repeated').item(0).firstChild.data;
385         } catch (e) {
386                 this.repeated = "0";
387         }
388         try{
389                 this.dontsave = xml.getElementsByTagName('e2dontsave').item(0).firstChild.data;
390         } catch (e) {
391                 this.dontsave = "N/A";
392         }
393         try{
394                 this.cancled = xml.getElementsByTagName('e2cancled').item(0).firstChild.data;
395         } catch (e) {
396                 this.cancled = "N/A";
397         }
398
399         this.getServiceReference = function(){
400                 return encodeURIComponent(this.servicereference);
401         }
402         this.getServiceName = function(){
403                 return this.servicename.replace('&quot;', '"');
404         }       
405         this.getEventID = function(){
406                 return this.eventid;
407         }       
408         this.getName = function(){
409                 return this.name;
410         }       
411         this.getDescription = function(){
412                 return this.description;
413         }       
414         this.getDescriptionExtended = function(){
415                 return this.descriptionextended;
416         }       
417         this.getDisabled = function(){
418                 return this.tdisabled;
419         }
420         this.getTimeBegin = function(){
421                 return this.timebegin;
422         }       
423         this.getTimeEnd = function(){
424                 return this.timeend;
425         }       
426         this.getDuration = function(){
427                 return parseInt(this.duration);
428         }       
429         this.getStartPrepare = function(){
430                 return this.startprepare;
431         }       
432         this.getJustplay = function(){
433                 return this.justplay;
434         }       
435         this.getAfterevent = function(){
436                 return this.afterevent;
437         }       
438         this.getAfterevent = function(){
439                 return this.logentries;
440         }       
441         this.getFilename = function(){
442                 return this.tfilename;
443         }       
444         this.getBackoff = function(){
445                 return this.backoff;
446         }       
447         this.getNextActivation = function(){
448                 return this.nextactivation;
449         }       
450         this.getFirsttryprepare = function(){
451                 return this.firsttryprepare;
452         }       
453         this.getState = function(){
454                 return this.state;
455         }       
456         this.getRepeated = function(){
457                 return this.repeated;
458         }       
459         this.getDontSave = function(){
460                 return this.dontsave;
461         }       
462         this.isCancled = function(){
463                 return this.cancled;
464         }       
465 }
466 // START TimerAddResult
467 function TimerAddResult(xml){
468         // parsing values from xml-element
469         debug('init TimerAddResult'+xml);
470         try{
471                 this.xmlitems = xml.getElementsByTagName("e2timeraddresult").item(0);
472         } catch (e) {
473                 debug("TimerAddResult parsing e2timeraddresult"+e);
474         }
475         try{
476                 this.state = this.xmlitems.getElementsByTagName("e2state").item(0).firstChild.data;
477         } catch (e) {
478                 debug("TimerAddResult parsing e2state"+e);
479         }
480         try{
481                 this.statetext = this.xmlitems.getElementsByTagName("e2statetext").item(0).firstChild.data;
482         } catch (e) {
483                 debug("TimerAddResult parsing e2statetext"+e);
484         }
485         
486         this.getState = function(){
487                 if(this.state == 'True'){
488                         return true;
489                 }else{
490                         return false;
491                 }
492         }
493         this.getStateText = function(){
494                         return this.statetext;
495         }
496 }
497 // END TimerAddResult