integraded parental conrtol. still stuff to do in webif.py. ugly switching of config....
[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         debug('init TimerList'+xml);
280         try{
281                 this.xmlitems = xml.getElementsByTagName("e2timerlist").item(0).getElementsByTagName("e2timer");
282         } catch (e) {
283                 debug("TimerList parsing Error");
284         }
285         this.getArray = function(){
286                 var listxy = new Array();
287                 for(var i=0;i<this.xmlitems.length;i++){
288                         //debug("parsing timer "+i+" of "+this.xmlitems.length);
289                         var xv = new Timer(this.xmlitems.item(i));
290                         listxy.push(xv);                        
291                 }
292                 return listxy;
293         }
294 }
295 //END class TimerList
296
297 //START class Timer
298 function Timer(xml){    
299         // parsing values from xml-element
300         //debug('init Timer');
301         try{
302                 this.servicereference = xml.getElementsByTagName('e2servicereference').item(0).firstChild.data;
303         } catch (e) {
304                 this.servicereference = "N/A";
305         }
306         try{
307                 this.servicename = xml.getElementsByTagName('e2servicename').item(0).firstChild.data;
308         } catch (e) {
309                 this.servicename = "N/A";
310         }
311         try{
312                 this.eventid = xml.getElementsByTagName('e2eit').item(0).firstChild.data;
313         } catch (e) {
314                 this.eventid = "N/A";
315         }
316         try{
317                 this.name = xml.getElementsByTagName('e2name').item(0).firstChild.data;
318         } catch (e) {
319                 this.name = "N/A";
320         }
321         try{
322                 this.description = xml.getElementsByTagName('e2description').item(0).firstChild.data;
323         } catch (e) {
324                 this.description = "N/A";
325         }
326         try{
327                 this.descriptionextended = xml.getElementsByTagName('e2descriptionextended').item(0).firstChild.data;
328         } catch (e) {
329                 this.descriptionextended = "N/A";
330         }
331         try{
332                 this.disabled = xml.getElementsByTagName('e2disabled').item(0).firstChild.data;
333         } catch (e) {
334                 this.disabled = "0";
335         }
336         try{
337                 this.timebegin = xml.getElementsByTagName('e2timebegin').item(0).firstChild.data;
338         } catch (e) {
339                 this.timebegin = "N/A";
340         }
341         try{
342                 this.timeend = xml.getElementsByTagName('e2timeend').item(0).firstChild.data;
343         } catch (e) {
344                 this.timeend = "N/A";
345         }
346         try{
347                 this.duration = xml.getElementsByTagName('e2duration').item(0).firstChild.data;
348         } catch (e) {           
349                 this.duration = "0";
350         }
351         try{
352                 this.startprepare = xml.getElementsByTagName('e2startprepare').item(0).firstChild.data;
353         } catch (e) {
354                 this.startprepare = "N/A";
355         }
356         try{
357                 this.justplay = xml.getElementsByTagName('e2justplay').item(0).firstChild.data;
358         } catch (e) {
359                 this.justplay = "";
360         }
361         try{
362                 this.afterevent = xml.getElementsByTagName('e2afterevent').item(0).firstChild.data;
363         } catch (e) {
364                 this.afterevent = "0";
365         }
366         try{
367                 this.logentries = xml.getElementsByTagName('e2logentries').item(0).firstChild.data;
368         } catch (e) {
369                 this.logentries = "N/A";
370         }
371         try{
372                 this.tfilename = xml.getElementsByTagName('e2filename').item(0).firstChild.data;
373         } catch (e) {
374                 this.tfilename = "N/A";
375         }
376         try{
377                 this.backoff = xml.getElementsByTagName('e2backoff').item(0).firstChild.data;
378         } catch (e) {
379                 this.backoff = "N/A";
380         }
381         try{
382                 this.nextactivation = xml.getElementsByTagName('e2nextactivation').item(0).firstChild.data;
383         } catch (e) {
384                 this.nextactivation = "N/A";
385         }
386         try{
387                 this.firsttryprepare = xml.getElementsByTagName('e2firsttryprepare').item(0).firstChild.data;
388         } catch (e) {
389                 this.firsttryprepare = "N/A";
390         }
391         try{
392                 this.state = xml.getElementsByTagName('e2state').item(0).firstChild.data;
393         } catch (e) {
394                 this.state = "N/A";
395         }
396         try{
397                 this.repeated = xml.getElementsByTagName('e2repeated').item(0).firstChild.data;
398         } catch (e) {
399                 this.repeated = "0";
400         }
401         try{
402                 this.dontsave = xml.getElementsByTagName('e2dontsave').item(0).firstChild.data;
403         } catch (e) {
404                 this.dontsave = "N/A";
405         }
406         try{
407                 this.cancled = xml.getElementsByTagName('e2cancled').item(0).firstChild.data;
408         } catch (e) {
409                 this.cancled = "N/A";
410         }
411
412         this.getServiceReference = function(){
413                 return encodeURIComponent(this.servicereference);
414         }
415         this.getServiceName = function(){
416                 return this.servicename.replace('&quot;', '"');
417         }       
418         this.getEventID = function(){
419                 return this.eventid;
420         }       
421         this.getName = function(){
422                 return this.name;
423         }       
424         this.getDescription = function(){
425                 return this.description;
426         }       
427         this.getDescriptionExtended = function(){
428                 return this.descriptionextended;
429         }       
430         this.getDisabled = function(){
431                 return this.disabled;
432         }
433         this.getTimeBegin = function(){
434                 return this.timebegin;
435         }       
436         this.getTimeEnd = function(){
437                 return this.timeend;
438         }       
439         this.getDuration = function(){
440                 return parseInt(this.duration);
441         }       
442         this.getStartPrepare = function(){
443                 return this.startprepare;
444         }       
445         this.getJustplay = function(){
446                 return this.justplay;
447         }       
448         this.getAfterevent = function(){
449                 return this.afterevent;
450         }       
451         this.getLogentries = function(){
452                 return this.logentries;
453         }       
454         this.getFilename = function(){
455                 return this.tfilename;
456         }       
457         this.getBackoff = function(){
458                 return this.backoff;
459         }       
460         this.getNextActivation = function(){
461                 return this.nextactivation;
462         }       
463         this.getFirsttryprepare = function(){
464                 return this.firsttryprepare;
465         }       
466         this.getState = function(){
467                 return this.state;
468         }       
469         this.getRepeated = function(){
470                 return this.repeated;
471         }       
472         this.getDontSave = function(){
473                 return this.dontsave;
474         }       
475         this.isCancled = function(){
476                 return this.cancled;
477         }       
478 }
479 // START SimpleXMLResult ehemals TimerAddResult
480 function SimpleXMLResult(xml){
481         // parsing values from xml-element
482         debug('init SimpleXMLResult'+xml);
483         try{
484                 this.xmlitems = xml.getElementsByTagName("e2simplexmlresult").item(0);
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 }