| 1 | // $Header$
|
|---|
| 2 | // store all objects here
|
|---|
| 3 |
|
|---|
| 4 | //START class EPGList
|
|---|
| 5 |
|
|---|
| 6 | function getNodeContent(xml, nodename, defaultString){
|
|---|
| 7 | try{
|
|---|
| 8 | var node = xml.getElementsByTagName(nodename);
|
|---|
| 9 | var retVal = node.item(0).firstChild.data;
|
|---|
| 10 |
|
|---|
| 11 | if(retVal === "" || retVal === null){
|
|---|
| 12 | return 'N/A';
|
|---|
| 13 | } else if (retVal === "None"){
|
|---|
| 14 | return "";
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | return retVal;
|
|---|
| 18 | } catch(e){
|
|---|
| 19 | if(typeof(defaultString) !== 'undefined') {
|
|---|
| 20 | return defaultString;
|
|---|
| 21 | }
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | return 'N/A';
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | function getNamedChildren(xml, parentname, childname){
|
|---|
| 28 | try {
|
|---|
| 29 | var ret = xml.getElementsByTagName(parentname).item(0).getElementsByTagName(childname);
|
|---|
| 30 | return ret;
|
|---|
| 31 | } catch (e) {
|
|---|
| 32 | return {};
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | //START class EPGEvent
|
|---|
| 37 | function EPGEvent(xml, number){
|
|---|
| 38 | this.eventID = getNodeContent(xml, 'e2eventid', '');
|
|---|
| 39 | this.startTime = parseNr(getNodeContent(xml, 'e2eventstart', ''));
|
|---|
| 40 | this.duration = parseNr(getNodeContent(xml, 'e2eventduration', ''));
|
|---|
| 41 | this.currentTime = parseNr(getNodeContent(xml, 'e2eventcurrenttime')),
|
|---|
| 42 | this.title = getNodeContent(xml, 'e2eventtitle', '');
|
|---|
| 43 | this.serviceRef = getNodeContent(xml, 'e2eventservicereference', '');
|
|---|
| 44 | this.serviceName = getNodeContent(xml, 'e2eventservicename', '');
|
|---|
| 45 | this.fileName = getNodeContent(xml, 'e2filename', '');
|
|---|
| 46 | this.description = getNodeContent(xml, 'e2eventdescription');
|
|---|
| 47 | this.descriptionE = getNodeContent(xml, 'e2eventdescriptionextended');
|
|---|
| 48 |
|
|---|
| 49 | if(typeof(number) != "undefined"){
|
|---|
| 50 | this.number = number;
|
|---|
| 51 | } else {
|
|---|
| 52 | this.number = 0;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | this.getFilename = function() {
|
|---|
| 56 | return this.fileName;
|
|---|
| 57 | };
|
|---|
| 58 | this.getEventId = function() {
|
|---|
| 59 | return this.eventID;
|
|---|
| 60 | };
|
|---|
| 61 | this.getTimeStart = function() {
|
|---|
| 62 | var date = new Date(this.startTime *1000);
|
|---|
| 63 | return date;
|
|---|
| 64 | };
|
|---|
| 65 | this.getTimeStartString = function() {
|
|---|
| 66 | var h = this.getTimeStart().getHours();
|
|---|
| 67 | var m = this.getTimeStart().getMinutes();
|
|---|
| 68 | if (m < 10){
|
|---|
| 69 | m="0"+m;
|
|---|
| 70 | }
|
|---|
| 71 | return h+":"+m;
|
|---|
| 72 | };
|
|---|
| 73 | this.getTimeDay = function() {
|
|---|
| 74 | var weekday = ["So", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|---|
| 75 | var wday = weekday[this.getTimeStart().getDay()];
|
|---|
| 76 | var day = this.getTimeStart().getDate();
|
|---|
| 77 | var month = this.getTimeStart().getMonth()+1;
|
|---|
| 78 | var year = this.getTimeStart().getFullYear();
|
|---|
| 79 |
|
|---|
| 80 | return wday+". "+day+"."+month+"."+year;
|
|---|
| 81 | };
|
|---|
| 82 | this.getTimeBegin = function(){
|
|---|
| 83 | return this.getTimeStart().getTime()/1000;
|
|---|
| 84 | };
|
|---|
| 85 | this.getTimeEnd = function() {
|
|---|
| 86 | var date = new Date(( this.startTime + this.duration ) * 1000);
|
|---|
| 87 | return parseInt( date.getTime()/1000 );
|
|---|
| 88 | };
|
|---|
| 89 | this.getTimeEndString = function() {
|
|---|
| 90 | var date = new Date(( this.startTime + this.duration ) * 1000);
|
|---|
| 91 | var h = date.getHours();
|
|---|
| 92 | var m = date.getMinutes();
|
|---|
| 93 | if (m < 10){
|
|---|
| 94 | m="0"+m;
|
|---|
| 95 | }
|
|---|
| 96 | return h+":"+m;
|
|---|
| 97 | };
|
|---|
| 98 | this.getDuration = function() {
|
|---|
| 99 | var date = new Date( this.duration * 1000);
|
|---|
| 100 | return date;
|
|---|
| 101 | };
|
|---|
| 102 | this.getTimeRemainingString = function() {
|
|---|
| 103 |
|
|---|
| 104 | if( this.currentTime <= this.startTime ){
|
|---|
| 105 | return Math.ceil(this.getDuration() / 60000);
|
|---|
| 106 | } else {
|
|---|
| 107 | if( this.getTimeEnd() > 0){
|
|---|
| 108 | var remaining = Math.ceil( ( this.getTimeEnd() - this.currentTime ) / 60);
|
|---|
| 109 | return remaining;
|
|---|
| 110 | } else {
|
|---|
| 111 | return this.getTimeEnd();
|
|---|
| 112 | }
|
|---|
| 113 | }
|
|---|
| 114 | };
|
|---|
| 115 |
|
|---|
| 116 | this.getTitle = function() {
|
|---|
| 117 | return this.title;
|
|---|
| 118 | };
|
|---|
| 119 | this.getDescription = function() {
|
|---|
| 120 | return this.description;
|
|---|
| 121 | };
|
|---|
| 122 | this.getDescriptionExtended = function() {
|
|---|
| 123 | return this.descriptionE;
|
|---|
| 124 | };
|
|---|
| 125 | this.getServiceReference = function() {
|
|---|
| 126 | return encodeURIComponent(this.serviceRef);
|
|---|
| 127 | };
|
|---|
| 128 | this.getServiceName = function() {
|
|---|
| 129 | return this.serviceName;
|
|---|
| 130 | };
|
|---|
| 131 |
|
|---|
| 132 | this.json = {
|
|---|
| 133 | 'date': this.getTimeDay(),
|
|---|
| 134 | 'eventid': this.getEventId(),
|
|---|
| 135 | 'servicereference': this.getServiceReference(),
|
|---|
| 136 | 'servicename': quotes2html(this.getServiceName()),
|
|---|
| 137 | 'title': quotes2html(this.getTitle()),
|
|---|
| 138 | 'shorttitle': quotes2html(this.getTitle().substring(0, 40) ) + '...',
|
|---|
| 139 | 'titleESC': escape(this.getTitle()),
|
|---|
| 140 | 'starttime': this.getTimeStartString(),
|
|---|
| 141 | 'duration': Math.ceil(this.getDuration()/60000),
|
|---|
| 142 | 'description': quotes2html(this.getDescription()),
|
|---|
| 143 | 'endtime': this.getTimeEndString(),
|
|---|
| 144 | 'remaining': this.getTimeRemainingString(),
|
|---|
| 145 | 'extdescription': quotes2html(this.getDescriptionExtended()),
|
|---|
| 146 | 'number': String(this.number),
|
|---|
| 147 | 'start': this.getTimeBegin(),
|
|---|
| 148 | 'end': this.getTimeEnd()
|
|---|
| 149 | };
|
|---|
| 150 |
|
|---|
| 151 | this.toJSON = function() {
|
|---|
| 152 | return this.json;
|
|---|
| 153 | };
|
|---|
| 154 |
|
|---|
| 155 | }
|
|---|
| 156 | //END class EPGEvent
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 | function EPGList(xml){
|
|---|
| 160 | // parsing values from xml-element
|
|---|
| 161 | try{
|
|---|
| 162 | this.xmlitems = xml.getElementsByTagName("e2eventlist").item(0).getElementsByTagName("e2event");
|
|---|
| 163 | } catch (e) {
|
|---|
| 164 | notify("Error Parsing EPG: " + e, false);
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | this.getArray = function(sortbytime){
|
|---|
| 168 | debug("[EPGList] Sort by time "+sortbytime);
|
|---|
| 169 | var list = [];
|
|---|
| 170 |
|
|---|
| 171 | if (sortbytime === true){
|
|---|
| 172 | var sortList = [];
|
|---|
| 173 | for(var i=0;i<this.xmlitems.length;i++){
|
|---|
| 174 | var event = new EPGEvent(this.xmlitems.item(i), i).toJSON();
|
|---|
| 175 | sortList.push( [event.starttime, event] );
|
|---|
| 176 | }
|
|---|
| 177 | sortList.sort(this.sortFunction);
|
|---|
| 178 |
|
|---|
| 179 | list = [];
|
|---|
| 180 | for(i=0;i<sortList.length;i++){
|
|---|
| 181 | list.push(sortList[i][1]);
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | return list;
|
|---|
| 185 |
|
|---|
| 186 | }else{
|
|---|
| 187 | list = [];
|
|---|
| 188 | for (i=0;i<this.xmlitems.length;i++){
|
|---|
| 189 | xv = new EPGEvent(this.xmlitems.item(i)).toJSON();
|
|---|
| 190 | list.push(xv);
|
|---|
| 191 | }
|
|---|
| 192 | return list;
|
|---|
| 193 | }
|
|---|
| 194 | };
|
|---|
| 195 |
|
|---|
| 196 | this.sortFunction = function(a, b){
|
|---|
| 197 | return a[0] - b[0];
|
|---|
| 198 | };
|
|---|
| 199 | }
|
|---|
| 200 | //END class EPGList
|
|---|
| 201 |
|
|---|
| 202 | // START class Service
|
|---|
| 203 | function Service(xml, cssclass){
|
|---|
| 204 | this.servicereference = getNodeContent(xml, 'e2servicereference', '');
|
|---|
| 205 | this.servicename = getNodeContent(xml, 'e2servicename');
|
|---|
| 206 | this.videowidth = getNodeContent(xml, 'e2videowidth');
|
|---|
| 207 | this.videoheight = getNodeContent(xml, 'e2videoheight');
|
|---|
| 208 | this.videosize = getNodeContent(xml, 'e2servicevideosize');
|
|---|
| 209 | this.widescreen = getNodeContent(xml, 'e2iswidescreen');
|
|---|
| 210 | this.apid = dec2hex( getNodeContent(xml, 'e2apid'),4 );
|
|---|
| 211 | this.vpid = dec2hex( getNodeContent(xml, 'e2vpid'),4 );
|
|---|
| 212 | this.pcrpid = dec2hex( getNodeContent(xml, 'e2pcrpid'),4 );
|
|---|
| 213 | this.pmtpid = dec2hex( getNodeContent(xml, 'e2pmtpid'),4 );
|
|---|
| 214 | this.txtpid = dec2hex( getNodeContent(xml, 'e2txtpid'),4 );
|
|---|
| 215 | this.tsid = dec2hex( getNodeContent(xml, 'e2tsid'),4 );
|
|---|
| 216 | this.onid = dec2hex( getNodeContent(xml, 'e2onid'),4 );
|
|---|
| 217 | this.sid = dec2hex( getNodeContent(xml, 'e2sid'),4 );
|
|---|
| 218 |
|
|---|
| 219 | this.getServiceReference = function(){
|
|---|
| 220 | return encodeURIComponent(this.servicereference);
|
|---|
| 221 | };
|
|---|
| 222 |
|
|---|
| 223 | this.getClearServiceReference = function(){
|
|---|
| 224 | return this.servicereference;
|
|---|
| 225 | };
|
|---|
| 226 |
|
|---|
| 227 | this.getServiceName = function(){
|
|---|
| 228 | return this.servicename.replace('"', '"');
|
|---|
| 229 | };
|
|---|
| 230 |
|
|---|
| 231 | this.setServiceReference = function(sref){
|
|---|
| 232 | this.servicereference = sref;
|
|---|
| 233 | };
|
|---|
| 234 |
|
|---|
| 235 | this.setServiceName = function(sname){
|
|---|
| 236 | this.servicename = sname.replace('"', '"');
|
|---|
| 237 | };
|
|---|
| 238 |
|
|---|
| 239 | if( typeof( cssclass ) == undefined ){
|
|---|
| 240 | cssclass = 'odd';
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | this.json = {
|
|---|
| 244 | 'servicereference' : this.getServiceReference(),
|
|---|
| 245 | 'servicename' : this.getServiceName(),
|
|---|
| 246 | 'videowidth' : this.videowidth,
|
|---|
| 247 | 'videoheight' : this.videoheight,
|
|---|
| 248 | 'videosize' : this.videosize,
|
|---|
| 249 | 'widescreen' : this.widescreen,
|
|---|
| 250 | 'apid' : this.apid,
|
|---|
| 251 | 'vpid' : this.vpid,
|
|---|
| 252 | 'pcrpid' : this.pcrpid,
|
|---|
| 253 | 'pmtpid' : this.pmtpid,
|
|---|
| 254 | 'txtpid' : this.txtpid,
|
|---|
| 255 | 'tsid' : this.tsid,
|
|---|
| 256 | 'onid' : this.onid,
|
|---|
| 257 | 'sid' : this.sid,
|
|---|
| 258 | 'cssclass' : cssclass
|
|---|
| 259 | };
|
|---|
| 260 |
|
|---|
| 261 | this.toJSON = function(){
|
|---|
| 262 | return this.json;
|
|---|
| 263 | };
|
|---|
| 264 | }
|
|---|
| 265 | //END class Service
|
|---|
| 266 |
|
|---|
| 267 | // START class ServiceList
|
|---|
| 268 | function ServiceList(xml){
|
|---|
| 269 | this.xmlitems = getNamedChildren(xml, "e2servicelist", "e2service");
|
|---|
| 270 | this.servicelist = [];
|
|---|
| 271 | this.getArray = function(){
|
|---|
| 272 | if(this.servicelist.length === 0){
|
|---|
| 273 | var cssclass = 'even';
|
|---|
| 274 |
|
|---|
| 275 | for (var i=0;i<this.xmlitems.length;i++){
|
|---|
| 276 | cssclass = cssclass == 'even' ? 'odd' : 'even';
|
|---|
| 277 | var service = new Service(this.xmlitems.item(i), cssclass).toJSON();
|
|---|
| 278 | this.servicelist.push(service);
|
|---|
| 279 | }
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | return this.servicelist;
|
|---|
| 283 | };
|
|---|
| 284 | }
|
|---|
| 285 | //END class ServiceList
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 | // START class Movie
|
|---|
| 289 | function Movie(xml, cssclass){
|
|---|
| 290 | this.servicereference = getNodeContent(xml, 'e2servicereference');
|
|---|
| 291 | this.servicename = getNodeContent(xml, 'e2servicename');
|
|---|
| 292 | this.title = getNodeContent(xml, 'e2title');
|
|---|
| 293 | this.descriptionextended = getNodeContent(xml, 'e2descriptionextended');
|
|---|
| 294 | this.description = getNodeContent(xml, 'e2description');
|
|---|
| 295 | this.tags = getNodeContent(xml, 'e2tags', ' ');
|
|---|
| 296 | this.filename = getNodeContent(xml, 'e2filename');
|
|---|
| 297 | this.filesize = getNodeContent(xml, 'e2filesize', 0);
|
|---|
| 298 | this.startTime = getNodeContent(xml, 'e2time', 0);
|
|---|
| 299 | this.length = getNodeContent(xml, 'e2length', 0);
|
|---|
| 300 |
|
|---|
| 301 | this.getLength = function() {
|
|---|
| 302 | return this.length;
|
|---|
| 303 | };
|
|---|
| 304 |
|
|---|
| 305 | this.getTimeStart = function() {
|
|---|
| 306 | var date = new Date(parseInt(this.startTime, 10)*1000);
|
|---|
| 307 | return date;
|
|---|
| 308 | };
|
|---|
| 309 |
|
|---|
| 310 | this.getTimeStartString = function() {
|
|---|
| 311 | var h = this.getTimeStart().getHours();
|
|---|
| 312 | var m = this.getTimeStart().getMinutes();
|
|---|
| 313 | if (m < 10){
|
|---|
| 314 | m="0"+m;
|
|---|
| 315 | }
|
|---|
| 316 | return h+":"+m;
|
|---|
| 317 | };
|
|---|
| 318 |
|
|---|
| 319 | this.getTimeDay = function() {
|
|---|
| 320 | var Wochentag = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
|
|---|
| 321 | var wday = Wochentag[this.getTimeStart().getDay()];
|
|---|
| 322 | var day = this.getTimeStart().getDate();
|
|---|
| 323 | var month = this.getTimeStart().getMonth()+1;
|
|---|
| 324 | var year = this.getTimeStart().getFullYear();
|
|---|
| 325 |
|
|---|
| 326 | return wday+". "+day+"."+month+"."+year;
|
|---|
| 327 | };
|
|---|
| 328 |
|
|---|
| 329 | this.getServiceReference = function(){
|
|---|
| 330 | return encodeURIComponent(this.servicereference);
|
|---|
| 331 | };
|
|---|
| 332 | this.getServiceName = function(){
|
|---|
| 333 | return this.servicename.replace('"', '"');
|
|---|
| 334 | };
|
|---|
| 335 |
|
|---|
| 336 | this.getTitle = function(){
|
|---|
| 337 | return this.title;
|
|---|
| 338 | };
|
|---|
| 339 |
|
|---|
| 340 | this.getDescription = function(){
|
|---|
| 341 | return this.description;
|
|---|
| 342 | };
|
|---|
| 343 |
|
|---|
| 344 | this.getDescriptionExtended = function(){
|
|---|
| 345 | return this.descriptionextended;
|
|---|
| 346 | };
|
|---|
| 347 |
|
|---|
| 348 | this.getTags = function(){
|
|---|
| 349 | return this.tags.split(" ");
|
|---|
| 350 | };
|
|---|
| 351 |
|
|---|
| 352 | this.getFilename = function(){
|
|---|
| 353 | return encodeURIComponent(this.filename);
|
|---|
| 354 | };
|
|---|
| 355 |
|
|---|
| 356 | this.getFilesizeMB = function(){
|
|---|
| 357 | return Math.round((parseInt(this.filesize, 10)/1024)/1024)+"MB";
|
|---|
| 358 | };
|
|---|
| 359 |
|
|---|
| 360 | if( typeof( cssclass) == 'undefined'){
|
|---|
| 361 | cssclass = 'odd';
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | this.json = {
|
|---|
| 365 | 'servicereference': escape(this.getServiceReference()),
|
|---|
| 366 | 'servicename': this.getServiceName(),
|
|---|
| 367 | 'title': this.getTitle(),
|
|---|
| 368 | 'escapedTitle': escape(this.getTitle()),
|
|---|
| 369 | 'description': this.getDescription(),
|
|---|
| 370 | 'descriptionextended': this.getDescriptionExtended(),
|
|---|
| 371 | 'filename': String(this.getFilename()),
|
|---|
| 372 | 'filesize': this.getFilesizeMB(),
|
|---|
| 373 | 'tags': this.getTags().join(', ') ,
|
|---|
| 374 | 'length': this.getLength() ,
|
|---|
| 375 | 'time': this.getTimeDay()+" "+ this.getTimeStartString(),
|
|---|
| 376 | 'cssclass' : cssclass
|
|---|
| 377 | };
|
|---|
| 378 |
|
|---|
| 379 | this.toJSON = function(){
|
|---|
| 380 | return this.json;
|
|---|
| 381 | };
|
|---|
| 382 | }
|
|---|
| 383 | //END class Movie
|
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 | // START class MovieList
|
|---|
| 387 | function MovieList(xml){
|
|---|
| 388 | this.xmlitems = getNamedChildren(xml, "e2movielist", "e2movie");
|
|---|
| 389 | this.movielist = [];
|
|---|
| 390 |
|
|---|
| 391 | this.getArray = function(){
|
|---|
| 392 | if(this.movielist.length === 0){
|
|---|
| 393 | var cssclass = "even";
|
|---|
| 394 |
|
|---|
| 395 | for(var i=0;i<this.xmlitems.length;i++){
|
|---|
| 396 | cssclass = cssclass == 'even' ? 'odd' : 'even';
|
|---|
| 397 |
|
|---|
| 398 | var movie = new Movie(this.xmlitems.item(i), cssclass).toJSON();
|
|---|
| 399 | this.movielist.push(movie);
|
|---|
| 400 | }
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | return this.movielist;
|
|---|
| 404 | };
|
|---|
| 405 | }
|
|---|
| 406 | //END class MovieList
|
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 | // START class Timer
|
|---|
| 411 | function Timer(xml, cssclass){
|
|---|
| 412 | this.servicereference = getNodeContent(xml, 'e2servicereference');
|
|---|
| 413 | this.servicename = getNodeContent(xml, 'e2servicename');
|
|---|
| 414 | this.eventid = getNodeContent(xml, 'e2eit');
|
|---|
| 415 | this.name = getNodeContent(xml, 'e2name');
|
|---|
| 416 | this.description = getNodeContent(xml, 'e2description', '');
|
|---|
| 417 | this.descriptionextended = getNodeContent(xml, 'e2descriptionextended', '');
|
|---|
| 418 | this.disabled = getNodeContent(xml, 'e2disabled', '0');
|
|---|
| 419 | this.timebegin = getNodeContent(xml, 'e2timebegin');
|
|---|
| 420 | this.timeend = getNodeContent(xml, 'e2timeend');
|
|---|
| 421 | this.duration = getNodeContent(xml, 'e2duration', '0');
|
|---|
| 422 | this.startprepare = getNodeContent(xml, 'e2startprepare');
|
|---|
| 423 | this.justplay = getNodeContent(xml, 'e2justplay', '');
|
|---|
| 424 | this.afterevent = getNodeContent(xml, 'e2afterevent', '0');
|
|---|
| 425 | this.dirname = getNodeContent(xml, 'e2dirname', '/hdd/movie/');
|
|---|
| 426 | this.tags = getNodeContent(xml, 'e2tags', '');
|
|---|
| 427 | this.logentries = getNodeContent(xml, 'e2logentries');
|
|---|
| 428 | this.tfilename = getNodeContent(xml, 'e2filename');
|
|---|
| 429 | this.backoff = getNodeContent(xml, 'e2backoff');
|
|---|
| 430 | this.nextactivation = getNodeContent(xml, 'e2nextactivation');
|
|---|
| 431 | this.firsttryprepare = getNodeContent(xml, 'e2firsttryprepare');
|
|---|
| 432 | this.state = getNodeContent(xml, 'e2state');
|
|---|
| 433 | this.repeated = getNodeContent(xml, 'e2repeated', '0');
|
|---|
| 434 | this.dontsave = getNodeContent(xml, 'e2dontsave');
|
|---|
| 435 | this.cancled = getNodeContent(xml, 'e2cancled');
|
|---|
| 436 | this.color = getNodeContent(xml, 'e2color');
|
|---|
| 437 | this.toggledisabled = getNodeContent(xml, 'e2toggledisabled');
|
|---|
| 438 | this.toggledisabledimg = getNodeContent(xml, 'e2toggledisabledimg');
|
|---|
| 439 |
|
|---|
| 440 | this.getColor = function(){
|
|---|
| 441 | return this.color;
|
|---|
| 442 | };
|
|---|
| 443 |
|
|---|
| 444 | this.getToggleDisabled = function(){
|
|---|
| 445 | return this.toggledisabled;
|
|---|
| 446 | };
|
|---|
| 447 |
|
|---|
| 448 | this.getToggleDisabledIMG = function(){
|
|---|
| 449 | return this.toggledisabledimg;
|
|---|
| 450 | };
|
|---|
| 451 |
|
|---|
| 452 | this.getToggleDisabledText = function(){
|
|---|
| 453 | var retVal = this.toggledisabled == "0" ? "Enable timer" : "Disable timer";
|
|---|
| 454 | return retVal;
|
|---|
| 455 | };
|
|---|
| 456 |
|
|---|
| 457 | this.getServiceReference = function(){
|
|---|
| 458 | return encodeURIComponent(this.servicereference);
|
|---|
| 459 | };
|
|---|
| 460 |
|
|---|
| 461 | this.getServiceName = function(){
|
|---|
| 462 | return this.servicename.replace('"', '"');
|
|---|
| 463 | };
|
|---|
| 464 |
|
|---|
| 465 | this.getEventID = function(){
|
|---|
| 466 | return this.eventid;
|
|---|
| 467 | };
|
|---|
| 468 |
|
|---|
| 469 | this.getName = function(){
|
|---|
| 470 | return this.name;
|
|---|
| 471 | };
|
|---|
| 472 |
|
|---|
| 473 | this.getDescription = function(){
|
|---|
| 474 | return this.description;
|
|---|
| 475 | };
|
|---|
| 476 |
|
|---|
| 477 | this.getDescriptionExtended = function(){
|
|---|
| 478 | return this.descriptionextended;
|
|---|
| 479 | };
|
|---|
| 480 |
|
|---|
| 481 | this.getDisabled = function(){
|
|---|
| 482 | return this.disabled;
|
|---|
| 483 | };
|
|---|
| 484 |
|
|---|
| 485 | this.getTimeBegin = function(){
|
|---|
| 486 | return this.timebegin;
|
|---|
| 487 | };
|
|---|
| 488 |
|
|---|
| 489 | this.getTimeEnd = function(){
|
|---|
| 490 | return this.timeend;
|
|---|
| 491 | };
|
|---|
| 492 |
|
|---|
| 493 | this.getDuration = function(){
|
|---|
| 494 | return parseInt(this.duration, 10);
|
|---|
| 495 | };
|
|---|
| 496 |
|
|---|
| 497 | this.getStartPrepare = function(){
|
|---|
| 498 | return this.startprepare;
|
|---|
| 499 | };
|
|---|
| 500 |
|
|---|
| 501 | this.getJustplay = function(){
|
|---|
| 502 | return this.justplay;
|
|---|
| 503 | };
|
|---|
| 504 |
|
|---|
| 505 | this.getAfterevent = function(){
|
|---|
| 506 | return this.afterevent;
|
|---|
| 507 | };
|
|---|
| 508 |
|
|---|
| 509 | this.getDirname = function(){
|
|---|
| 510 | return this.dirname;
|
|---|
| 511 | };
|
|---|
| 512 |
|
|---|
| 513 | this.getTags = function(){
|
|---|
| 514 | return this.tags;
|
|---|
| 515 | };
|
|---|
| 516 |
|
|---|
| 517 | this.getLogentries = function(){
|
|---|
| 518 | return this.logentries;
|
|---|
| 519 | };
|
|---|
| 520 |
|
|---|
| 521 | this.getFilename = function(){
|
|---|
| 522 | return this.tfilename;
|
|---|
| 523 | };
|
|---|
| 524 |
|
|---|
| 525 | this.getBackoff = function(){
|
|---|
| 526 | return this.backoff;
|
|---|
| 527 | };
|
|---|
| 528 |
|
|---|
| 529 | this.getNextActivation = function(){
|
|---|
| 530 | return this.nextactivation;
|
|---|
| 531 | };
|
|---|
| 532 |
|
|---|
| 533 | this.getFirsttryprepare = function(){
|
|---|
| 534 | return this.firsttryprepare;
|
|---|
| 535 | };
|
|---|
| 536 |
|
|---|
| 537 | this.getState = function(){
|
|---|
| 538 | return this.state;
|
|---|
| 539 | };
|
|---|
| 540 |
|
|---|
| 541 | this.getRepeated = function(){
|
|---|
| 542 | return this.repeated;
|
|---|
| 543 | };
|
|---|
| 544 |
|
|---|
| 545 | this.getDontSave = function(){
|
|---|
| 546 | return this.dontsave;
|
|---|
| 547 | };
|
|---|
| 548 |
|
|---|
| 549 | this.isCancled = function(){
|
|---|
| 550 | return this.cancled;
|
|---|
| 551 | };
|
|---|
| 552 |
|
|---|
| 553 | if( typeof( cssclass ) == undefined ){
|
|---|
| 554 | cssclass = 'odd';
|
|---|
| 555 | }
|
|---|
| 556 |
|
|---|
| 557 | this.beginDate = new Date(Number(this.getTimeBegin()) * 1000);
|
|---|
| 558 | this.endDate = new Date(Number(this.getTimeEnd()) * 1000);
|
|---|
| 559 |
|
|---|
| 560 | this.aftereventReadable = [ 'Nothing', 'Standby',
|
|---|
| 561 | 'Deepstandby/Shutdown', 'Auto' ];
|
|---|
| 562 |
|
|---|
| 563 | this.justplayReadable = [ 'record', 'zap' ];
|
|---|
| 564 |
|
|---|
| 565 | this.json = {
|
|---|
| 566 | 'servicereference' : this.getServiceReference(),
|
|---|
| 567 | 'servicename' : quotes2html(this.getServiceName()),
|
|---|
| 568 | 'title' : quotes2html(this.getName()),
|
|---|
| 569 | 'description' : quotes2html(this.getDescription()),
|
|---|
| 570 | 'descriptionextended' : quotes2html(this
|
|---|
| 571 | .getDescriptionExtended()),
|
|---|
| 572 | 'begin' : this.getTimeBegin(),
|
|---|
| 573 | 'beginDate' : dateToString(this.beginDate),
|
|---|
| 574 | 'end' : this.getTimeEnd(),
|
|---|
| 575 | 'endDate' : dateToString(this.endDate),
|
|---|
| 576 | 'state' : this.getState(),
|
|---|
| 577 | 'duration' : Math.ceil((this.getDuration() / 60)),
|
|---|
| 578 | 'repeated' : this.getRepeated(),
|
|---|
| 579 | 'repeatedReadable' : repeatedReadable(this.getRepeated()),
|
|---|
| 580 | 'justplay' : this.getJustplay(),
|
|---|
| 581 | 'justplayReadable' : this.justplayReadable[Number(this
|
|---|
| 582 | .getJustplay())],
|
|---|
| 583 | 'afterevent' : this.getAfterevent(),
|
|---|
| 584 | 'aftereventReadable' : this.aftereventReadable[Number(this
|
|---|
| 585 | .getAfterevent())],
|
|---|
| 586 | 'dirname' : this.getDirname(),
|
|---|
| 587 | 'tags' : this.getTags(),
|
|---|
| 588 | 'disabled' : this.getDisabled(),
|
|---|
| 589 | 'onOff' : this.getToggleDisabledIMG(),
|
|---|
| 590 | 'enDis' : this.getToggleDisabledText(),
|
|---|
| 591 | 'cssclass' : cssclass
|
|---|
| 592 | };
|
|---|
| 593 |
|
|---|
| 594 | this.toJSON = function(){
|
|---|
| 595 | return this.json;
|
|---|
| 596 | };
|
|---|
| 597 | }
|
|---|
| 598 |
|
|---|
| 599 |
|
|---|
| 600 | // START class TimerList
|
|---|
| 601 | function TimerList(xml){
|
|---|
| 602 | this.xmlitems = getNamedChildren(xml, "e2timerlist", "e2timer");
|
|---|
| 603 | this.timerlist = [];
|
|---|
| 604 |
|
|---|
| 605 | this.getArray = function(){
|
|---|
| 606 | if(this.timerlist.length === 0){
|
|---|
| 607 | var cssclass = 'even';
|
|---|
| 608 |
|
|---|
| 609 | for(var i=0;i<this.xmlitems.length;i++){
|
|---|
| 610 | cssclass = cssclass == 'even' ? 'odd' : 'even';
|
|---|
| 611 | var timer = new Timer(this.xmlitems.item(i), cssclass).toJSON();
|
|---|
| 612 | this.timerlist.push(timer);
|
|---|
| 613 | }
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | return this.timerlist;
|
|---|
| 617 | };
|
|---|
| 618 | }
|
|---|
| 619 | //END class TimerList
|
|---|
| 620 | function DeviceInfo(xml){
|
|---|
| 621 | xml = xml.getElementsByTagName("e2deviceinfo").item(0);
|
|---|
| 622 |
|
|---|
| 623 | this.info = {};
|
|---|
| 624 |
|
|---|
| 625 | this.nims = [];
|
|---|
| 626 | this.hdds = [];
|
|---|
| 627 | this.nics = [];
|
|---|
| 628 |
|
|---|
| 629 | this.fpversion = "V"+xml.getElementsByTagName('e2fpversion').item(0).firstChild.data;
|
|---|
| 630 |
|
|---|
| 631 | var nimnodes = xml.getElementsByTagName('e2frontends').item(0).getElementsByTagName('e2frontend');
|
|---|
| 632 | for(var i = 0; i < nimnodes.length; i++){
|
|---|
| 633 | try {
|
|---|
| 634 | var name = nimnodes.item(i).getElementsByTagName('e2name').item(0).firstChild.data;
|
|---|
| 635 | var model = nimnodes.item(i).getElementsByTagName('e2model').item(0).firstChild.data;
|
|---|
| 636 | this.nims[i] = {
|
|---|
| 637 | 'name' : name,
|
|---|
| 638 | 'model' : model
|
|---|
| 639 | };
|
|---|
| 640 | } catch (e) {
|
|---|
| 641 | notify("Error parsing frontend data: " + e);
|
|---|
| 642 | }
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|
| 645 |
|
|---|
| 646 | var hddnodes = xml.getElementsByTagName('e2hdd');
|
|---|
| 647 | for( var i = 0; i < hddnodes.length; i++){
|
|---|
| 648 | try{
|
|---|
| 649 | var hdd = hddnodes.item(i);
|
|---|
| 650 |
|
|---|
| 651 | var model = hdd.getElementsByTagName('e2model').item(0).firstChild.data;
|
|---|
| 652 | var capacity = hdd.getElementsByTagName('e2capacity').item(0).firstChild.data;
|
|---|
| 653 | var free = hdd.getElementsByTagName('e2free').item(0).firstChild.data;
|
|---|
| 654 |
|
|---|
| 655 | this.hdds[i] = {
|
|---|
| 656 | 'model' : model,
|
|---|
| 657 | 'capacity' : capacity,
|
|---|
| 658 | 'free' : free
|
|---|
| 659 | };
|
|---|
| 660 | } catch(e){
|
|---|
| 661 | notify("Error parsing HDD data: " + e, false);
|
|---|
| 662 | }
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 |
|
|---|
| 666 | var nicnodes = xml.getElementsByTagName('e2interface');
|
|---|
| 667 | for( var i = 0; i < nicnodes.length; i++){
|
|---|
| 668 | try {
|
|---|
| 669 | var nic = nicnodes.item(i);
|
|---|
| 670 | var name = nic.getElementsByTagName('e2name').item(0).firstChild.data;
|
|---|
| 671 | var mac = nic.getElementsByTagName('e2mac').item(0).firstChild.data;
|
|---|
| 672 | var dhcp = nic.getElementsByTagName('e2dhcp').item(0).firstChild.data;
|
|---|
| 673 | var ip = nic.getElementsByTagName('e2ip').item(0).firstChild.data;
|
|---|
| 674 | var gateway = nic.getElementsByTagName('e2gateway').item(0).firstChild.data;
|
|---|
| 675 | var netmask = nic.getElementsByTagName('e2netmask').item(0).firstChild.data;
|
|---|
| 676 |
|
|---|
| 677 | this.nics[i] = {
|
|---|
| 678 | 'name' : name,
|
|---|
| 679 | 'mac' : mac,
|
|---|
| 680 | 'dhcp' : dhcp,
|
|---|
| 681 | 'ip' : ip,
|
|---|
| 682 | 'gateway' : gateway,
|
|---|
| 683 | 'netmask' : netmask
|
|---|
| 684 | };
|
|---|
| 685 | } catch (e) {
|
|---|
| 686 | notify("Error parsing NIC data: " + e, false);
|
|---|
| 687 | }
|
|---|
| 688 | }
|
|---|
| 689 |
|
|---|
| 690 | try{
|
|---|
| 691 | this.info = {
|
|---|
| 692 | 'devicename' : xml.getElementsByTagName('e2devicename').item(0).firstChild.data,
|
|---|
| 693 | 'enigmaVersion': xml.getElementsByTagName('e2enigmaversion').item(0).firstChild.data,
|
|---|
| 694 | 'imageVersion': xml.getElementsByTagName('e2imageversion').item(0).firstChild.data,
|
|---|
| 695 | 'fpVersion': this.fpversion,
|
|---|
| 696 | 'webifversion': xml.getElementsByTagName('e2webifversion').item(0).firstChild.data,
|
|---|
| 697 | 'recPath': xml.getElementsByTagName('e2recPath').item(0).firstChild.data,
|
|---|
| 698 | 'recCapacity': xml.getElementsByTagName('e2recCapacity').item(0).firstChild.data,
|
|---|
| 699 | 'recFree': xml.getElementsByTagName('e2recFree').item(0).firstChild.data
|
|---|
| 700 | };
|
|---|
| 701 | } catch (e) {
|
|---|
| 702 | notify("Error parsing deviceinfo data: " + e, false);
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 | this.json = {
|
|---|
| 706 | info : this.info,
|
|---|
| 707 | hdds : this.hdds,
|
|---|
| 708 | nics : this.nics,
|
|---|
| 709 | nims : this.nims
|
|---|
| 710 | };
|
|---|
| 711 |
|
|---|
| 712 | this.toJSON = function(){
|
|---|
| 713 | return this.json;
|
|---|
| 714 | };
|
|---|
| 715 |
|
|---|
| 716 | }
|
|---|
| 717 |
|
|---|
| 718 | function SimpleXMLResult(xml){
|
|---|
| 719 | try{
|
|---|
| 720 | this.xmlitems = xml.getElementsByTagName("e2simplexmlresult").item(0);
|
|---|
| 721 | } catch (e) {
|
|---|
| 722 | notify("Error parsing e2simplexmlresult: " + e, false);
|
|---|
| 723 | }
|
|---|
| 724 |
|
|---|
| 725 | this.state = getNodeContent(this.xmlitems, 'e2state', 'False');
|
|---|
| 726 | this.statetext = getNodeContent(this.xmlitems, 'e2statetext', 'Error Parsing XML');
|
|---|
| 727 |
|
|---|
| 728 | this.getState = function(){
|
|---|
| 729 | if(this.state == 'True'){
|
|---|
| 730 | return true;
|
|---|
| 731 | }else{
|
|---|
| 732 | return false;
|
|---|
| 733 | }
|
|---|
| 734 | };
|
|---|
| 735 |
|
|---|
| 736 | this.getStateText = function(){
|
|---|
| 737 | return this.statetext;
|
|---|
| 738 | };
|
|---|
| 739 | }
|
|---|
| 740 | // END SimpleXMLResult
|
|---|
| 741 |
|
|---|
| 742 | // START SimpleXMLList
|
|---|
| 743 | function SimpleXMLList(xml, tagname){
|
|---|
| 744 | // parsing values from xml-element
|
|---|
| 745 | try{
|
|---|
| 746 | this.xmlitems = xml.getElementsByTagName(tagname);
|
|---|
| 747 | } catch (e) {
|
|---|
| 748 | notify("Error parsing SimpleXMLList: " + e, false);
|
|---|
| 749 | }
|
|---|
| 750 |
|
|---|
| 751 | this.xmllist = [];
|
|---|
| 752 |
|
|---|
| 753 | this.getList = function(){
|
|---|
| 754 | if(this.xmllist.length === 0){
|
|---|
| 755 | for(var i=0;i<this.xmlitems.length;i++){
|
|---|
| 756 | this.xmllist.push(this.xmlitems.item(i).firstChild.data);
|
|---|
| 757 | }
|
|---|
| 758 | }
|
|---|
| 759 |
|
|---|
| 760 | return this.xmllist;
|
|---|
| 761 | };
|
|---|
| 762 | }
|
|---|
| 763 | // END SimpleXMLList
|
|---|
| 764 |
|
|---|
| 765 |
|
|---|
| 766 | // START class Setting
|
|---|
| 767 | function Setting(xml){
|
|---|
| 768 | this.settingvalue = getNodeContent(xml, 'e2settingvalue');
|
|---|
| 769 | this.settingname = getNodeContent(xml, 'e2settingname');
|
|---|
| 770 |
|
|---|
| 771 | this.getSettingValue = function(){
|
|---|
| 772 | return this.settingvalue;
|
|---|
| 773 | };
|
|---|
| 774 |
|
|---|
| 775 | this.getSettingName = function(){
|
|---|
| 776 | return this.settingname;
|
|---|
| 777 | };
|
|---|
| 778 |
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 |
|
|---|
| 782 | // START class Settings
|
|---|
| 783 | function Settings(xml){
|
|---|
| 784 | // parsing values from xml-element
|
|---|
| 785 | try{
|
|---|
| 786 | this.xmlitems = xml.getElementsByTagName("e2settings").item(0).getElementsByTagName("e2setting");
|
|---|
| 787 | debug("[Settings] Number of items: " + this.xmlitems);
|
|---|
| 788 | } catch (e) {
|
|---|
| 789 | notify("Error parsing Settings: " + e, false);
|
|---|
| 790 | }
|
|---|
| 791 |
|
|---|
| 792 | this.settings = [];
|
|---|
| 793 |
|
|---|
| 794 | this.getArray = function(){
|
|---|
| 795 | if(this.settings.length === 0){
|
|---|
| 796 | for (var i=0;i<this.xmlitems.length;i++){
|
|---|
| 797 | var setting = new Setting(this.xmlitems.item(i));
|
|---|
| 798 | this.settings.push(setting);
|
|---|
| 799 | }
|
|---|
| 800 | }
|
|---|
| 801 |
|
|---|
| 802 | return this.settings;
|
|---|
| 803 | };
|
|---|
| 804 | }
|
|---|
| 805 | //END class Settings
|
|---|
| 806 |
|
|---|
| 807 | //START class FileList
|
|---|
| 808 | function FileList(xml){
|
|---|
| 809 | // parsing values from xml-element
|
|---|
| 810 | try{
|
|---|
| 811 | this.xmlitems = xml.getElementsByTagName("e2filelist").item(0).getElementsByTagName("e2file");
|
|---|
| 812 | } catch (e) {
|
|---|
| 813 | notify("Error parsing FileList: " + e, false);
|
|---|
| 814 | }
|
|---|
| 815 | this.filelist = [];
|
|---|
| 816 |
|
|---|
| 817 | this.getArray = function(){
|
|---|
| 818 | if(this.filelist.length === 0){
|
|---|
| 819 | for(var i=0;i<this.xmlitems.length;i++){
|
|---|
| 820 | var file = new File(this.xmlitems.item(i));
|
|---|
| 821 | this.filelist.push(file);
|
|---|
| 822 | }
|
|---|
| 823 | }
|
|---|
| 824 |
|
|---|
| 825 | return this.filelist;
|
|---|
| 826 | };
|
|---|
| 827 | }
|
|---|
| 828 | //END class FileList
|
|---|
| 829 |
|
|---|
| 830 | //START class File
|
|---|
| 831 | function File(xml){
|
|---|
| 832 | // parsing values from xml-element
|
|---|
| 833 | this.servicereference = getNodeContent(xml, 'e2servicereference', 'Filesystems');
|
|---|
| 834 | this.isdirectory = getNodeContent(xml, 'e2isdirectory');
|
|---|
| 835 | this.root = getNodeContent(xml, 'e2root', 'Filesystems');
|
|---|
| 836 |
|
|---|
| 837 | this.getServiceReference = function(){
|
|---|
| 838 | return this.servicereference;
|
|---|
| 839 | };
|
|---|
| 840 |
|
|---|
| 841 | this.getNameOnly = function(){
|
|---|
| 842 | if(this.root == '/') {
|
|---|
| 843 | return this.servicereference;
|
|---|
| 844 | } else {
|
|---|
| 845 | return this.servicereference.replace(new RegExp('.*'+this.root, "i"), '');
|
|---|
| 846 | }
|
|---|
| 847 | };
|
|---|
| 848 |
|
|---|
| 849 | this.getIsDirectory = function(){
|
|---|
| 850 | return this.isdirectory;
|
|---|
| 851 | };
|
|---|
| 852 |
|
|---|
| 853 | this.getRoot = function(){
|
|---|
| 854 | return this.root;
|
|---|
| 855 | };
|
|---|
| 856 | }
|
|---|
| 857 | //END class File
|
|---|