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