1 /*
  2  * This is time cordova_plugin (TV specific API).
  3  * Apache License (2004). See http://www.apache.org/licenses/LICENSE-2.0
  4  *
  5  * Copyright (c) 2014, LG Electronics, Inc.
  6  */
  7 
  8 /**
  9  * This represents the time API itself, and provides a global namespace for operating time service.
 10  * @class
 11  */
 12 cordova.define('cordova/plugin/time', function (require, exports, module) { // jshint ignore:line
 13     
 14     function log(msg) {
 15     //    //console.log//will be removed // jshint ignore:line
 16     }
 17     
 18     var service;
 19     if (window.PalmSystem) { // jshint ignore:line
 20         log("Window.PalmSystem Available");
 21         service = require('cordova/plugin/webos/service');
 22     } else {
 23         service = {
 24             Request : function(uri, params) {
 25                 log(uri + " invoked. But I am a dummy because PalmSystem is not available");
 26                         
 27                 if (typeof params.onFailure === 'function') {
 28                     params.onFailure({
 29                         returnValue:false,
 30                         errorText:"PalmSystem Not Available. Cordova is not installed?"
 31                     });
 32                }
 33         }};
 34     }
 35 
 36     /**
 37      * time interface
 38      */
 39     var Time = function () {
 40     };
 41     
 42     function checkErrorCodeNText(result, errorCode, errorText) {
 43         
 44         if (result.errorCode === undefined || result.errorCode === null ) {
 45             result.errorCode = errorCode;
 46         }
 47         if (result.errorText ===undefined || result.errorText === null) {
 48             result.errorText = errorText;
 49         }
 50     }
 51 
 52     var version = null;
 53     var platformInfoObj = {}; 
 54     function checkPlatformVersion(cb) {
 55 
 56         if (version === null) {
 57 
 58             service.Request('luna://com.webos.service.tv.systemproperty', {
 59                 method: 'getSystemInfo',
 60                 parameters: {
 61                     keys: ["sdkVersion", "boardType"]
 62                 },
 63                 onSuccess: function(result) {
 64                     log("getPlatformInfo: onSuccess");
 65                     log("version : " + result.sdkVersion);
 66 
 67                     var temp = result.sdkVersion.split('.');
 68                     if (temp.length >= 1 && temp[0] === '1') {
 69                         platformInfoObj = {
 70                             webOSVer: 1,
 71                             chipset: result.boardType.split("_")[0]
 72                         };
 73                     } else if (temp.length >= 1 && temp[0] === '2') {
 74                         platformInfoObj = {
 75                             webOSVer: 2,
 76                             chipset: result.boardType.split("_")[0]
 77                         };
 78                     } else if (temp.length >= 1 && temp[0] === '3') {
 79                         platformInfoObj = {
 80                             webOSVer: 3,
 81                             chipset: result.boardType.split("_")[0]
 82                         };
 83                     } else {
 84                         platformInfoObj = {
 85                             webOSVer: 0,
 86                             chipset: ""
 87                         };
 88                     }
 89                     version = platformInfoObj.webOSVer;
 90                     cb(platformInfoObj);
 91                 },
 92                 onFailure: function(error) {
 93                     log("getPlatformInfo: onFailure");
 94                     platformInfoObj = {
 95                         webOSVer: 0,
 96                         chipset: ""
 97                     }
 98                     cb(platformInfoObj);
 99                 }
100             });
101 
102         } else {
103             cb(platformInfoObj);
104         }
105     }
106 
107 		/**
108      * set HolidayScheduleMode enabled/disabled
109      * @class Time
110      * @param {Function} successCallback success callback function.
111      * @param {Function} errorCallback failure callback function.     
112      * @param {Object} options
113      * <div align=left>
114      * <table class="hcap_spec" width=400>
115      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
116      *   <tbody>
117      *       <tr><th>enabled</th><th>Boolean</th><th>Intelligent auto is enabled. true: enabled, false: disabled</th><th>required</th></tr>
118      *   </tbody>
119      * </table>
120      * </div>
121      * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br>
122      * If an error occurs, failure callback function is called with failure callback object as a parameter.</p>
123      * @example
124      * // Javascript code
125      * 
126      * function setHolidayScheduleMode () {
127      *   var options = {
128      *      enabled : true
129      *   };   
130      *     
131      *   function successCb() {
132      *      // Do something
133      *   }
134      *
135      *   function failureCb(cbObject) {
136      *      var errorCode = cbObject.errorCode;
137      *      var errorText = cbObject.errorText;
138      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
139      *   }
140      *
141      *   var time = new Time();
142      *   time.setHolidayScheduleMode(successCb, failureCb, options);
143      * }
144      * @since 1.4
145      * @see
146      * <a href="Time%23getHolidayScheduleMode.html">Time.getHolidayScheduleMode()</a><br>
147      */
148     Time.prototype.setHolidayScheduleMode = function (successCallback, errorCallback, options) {        
149         log("setHolidayScheduleMode: " + options.enabled);
150         
151         if (options.enabled === null && typeof errorCallback === 'function') {
152             var result = {};
153             checkErrorCodeNText(result, "TSHM", "Time.setHolidayScheduleMode returns failure. command was not defined.");
154             errorCallback(result);
155             log("Time.setHolidayScheduleMode invalid ");
156             return;
157         }      
158         
159         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
160             method : "set",
161             parameters : {
162                 category : "commercial",        
163                 settings : {
164                     "holidayScheduleMode" : (options.enabled === true ) ? "on" : "off" 
165                 }
166             },
167             onSuccess : function(result) {
168                 log("setHolidayScheduleMode: On Success");
169 
170                 if (result.returnValue === true) {
171                     if(typeof successCallback === 'function') {
172                         successCallback();
173                     }
174                 }
175             },
176             onFailure : function(result) {
177                 log("setHolidayScheduleMode: On Failure");
178                 delete result.returnValue;
179                 if (typeof errorCallback === 'function') {
180                     checkErrorCodeNText(result, "TSHM", "Time.setHolidayScheduleMode returns failure.");
181                     errorCallback(result);
182                 }
183             }
184         });
185         
186         log("Time.setHolidayScheduleMode Done");
187     };
188 
189 		/**
190      * Gets HolidayScheduleMode enabled
191      * @class Time
192      * @param {Function} successCallback success callback function.
193      * @param {Function} errorCallback failure callback function.
194      * @return {Object} 
195      * <div align=left>
196      * <table class="hcap_spec" width=400>
197      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
198      *   <tbody>
199      *       <tr><th>enabled</th><th>Boolean</th><th>Intelligent auto is enabled. true: enabled, false: disabled</th></tr>
200      *   </tbody>
201      * </table>
202      * </div>
203      *
204      * @example
205      * // Javascript code
206      * function getHolidayScheduleMode () {
207      *   function successCb(cbObject) {
208      *      console.log("cbObject : " + JSON.stringify(cbObject));
209      *
210      *      console.log("enabled : " + cbObject.enabled);     
211      *
212      *      // Do something
213      *         ...
214      *   }
215      *
216      *   function failureCb(cbObject) {
217      *      var errorCode = cbObject.errorCode;
218      *      var errorText = cbObject.errorText;
219      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
220      *   }
221      *
222      *   var time = new Time();
223      *   time.getHolidayScheduleMode(successCb, failureCb);
224      * }
225      * @since 1.4
226      * @see
227      * <a href="Time%23setHolidayScheduleMode.html">Time.setHolidayScheduleMode()</a><br>  
228      */
229     Time.prototype.getHolidayScheduleMode = function (successCallback, errorCallback) {
230         
231         log("getHolidayScheduleMode: ");
232 
233         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
234             method: "get",
235             parameters: {
236                 category: "commercial",
237                 keys: ["holidayScheduleMode"]
238             },
239             onSuccess: function(result) {
240                 log("getHolidayScheduleMode: On Success");
241 
242                 if (result.returnValue === true) {
243                     var cbObj = {};
244                     cbObj.enabled = (result.settings.holidayScheduleMode === "on") ? true : false;
245 
246                     if (typeof successCallback === 'function') {
247                         successCallback(cbObj);
248                     }
249                 }
250             },
251             onFailure: function(result) {
252                 log("getHolidayScheduleMode: On Failure");
253                 delete result.returnValue;
254                 if (typeof errorCallback === 'function') {
255                     checkErrorCodeNText(result, "TGHM", "Time.getHolidayScheduleMode returns failure.");
256                     errorCallback(result);
257                 }
258             }
259         });
260 
261         log("Time.getHolidayScheduleMode Done");
262     };
263 
264 	/**
265      * add HolidaySchedule
266      * @class Time
267      * @param {Function} successCallback success callback function.
268      * @param {Function} errorCallback failure callback function.     
269      * @param {Object} options
270      * <div align=left>
271      * <table class="hcap_spec" width=400>
272      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
273      *   <tbody>
274      *       <tr><th>startMonth</th><th>Number</th><th>start month</th><th>required</th></tr>
275      *       <tr class="odd"><th>startDay</th><th>Number</th><th>start day</th><th>required</th></tr>
276      * 		 <tr><th>endMonth</th><th>Number</th><th>end month</th><th>required</th></tr>
277      *       <tr class="odd"><th>endDay</th><th>Number</th><th>end day</th><th>required</th></tr>
278      *   </tbody>
279      * </table>
280      * </div>
281      * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br>
282      * If an error occurs, failure callback function is called with failure callback object as a parameter.</p>
283      * @example
284      * // Javascript code
285      * 
286      * function addHolidaySchedule () {
287      *   var options = {
288  	 *		startMonth : 3,
289 	 *		startDay : 7,
290 	 *		endMonth : 3,
291  	 *		endDay : 9 //ex. 3/7~3/9
292 	 *	 };  
293      *     
294      *   function successCb() {
295      *      // Do something
296      *   }
297      *
298      *   function failureCb(cbObject) {
299      *      var errorCode = cbObject.errorCode;
300      *      var errorText = cbObject.errorText;
301      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
302      *   }
303      *
304      *   var time = new Time();
305      *   time.addHolidaySchedule(successCb, failureCb, options);
306      * }
307      * @since 1.4
308      * @see
309      * <a href="Time%23getHolidayScheduleMode.html">Time.getHolidayScheduleMode()</a><br>
310      */
311     Time.prototype.addHolidaySchedule = function (successCallback, errorCallback, options) {        
312         log("addHolidaySchedule: " + "startMonth : " + options.startMonth + ", startDay : " + options.startDay + ", endMonth : " + options.endMonth + ", endDay : " + options.endDay);
313      
314         var startSch = new Date((new Date()).getFullYear(), options.startMonth-1, options.startDay, 0, 0);
315         var endSch = new Date((new Date()).getFullYear(), options.endMonth-1, options.endDay, 0, 0);         
316 
317         //validation check
318         if (typeof errorCallback === 'function') {
319             if (typeof options.startMonth !== 'number' || typeof options.startDay !== 'number' || isNaN(options.startMonth) || isNaN(options.startDay) ||
320                     typeof options.endMonth !== 'number' || typeof options.endDay !== 'number' || isNaN(options.endMonth) || isNaN(options.endDay)) {
321                 var result = {};
322                 checkErrorCodeNText(result, "TAHS", "Time.addHolidaySchedule returns failure. parmas are not valid.");
323                 errorCallback(result);                
324                 return;
325             }
326 
327             if (startSch.getMonth() !== options.startMonth - 1 || startSch.getDate() !== options.startDay ||
328                 endSch.getMonth() !== options.endMonth - 1 || endSch.getDate() !== options.endDay) {
329                 var result = {};
330                 checkErrorCodeNText(result, "TAHS", "Time.addHolidaySchedule returns failure for out of range.");
331                 errorCallback(result);                
332                 return;
333             }
334 
335             if (startSch.getTime() > endSch.getTime())
336             {
337                 var result = {};
338                 checkErrorCodeNText(result, "TAHS", "Time.addHolidaySchedule returns failure. schedule is not valid.");
339                 errorCallback(result);                
340                 return;
341             }           
342         }
343 
344         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
345             method : "get",
346             parameters : {
347                 category : "commercial",
348                 keys : ["holidaySchedule"]
349             },
350             onSuccess : function(result) {
351                 log("getHolidaySchedule: On Success");
352 
353                 if (result.returnValue === true) {
354                     if (typeof successCallback === 'function') {
355                         var schedule      = {};
356                         var savedStartSch = null
357                         var savedEndSch   = null
358                         var scheduleList  = result.settings.holidaySchedule;
359 
360                         if(scheduleList.length >= 7)
361                         {
362                             var result = {};
363                             checkErrorCodeNText(result, "TAHS", "Time.addHolidaySchedule returns failure. schedule list is full");
364                             errorCallback(result);                            
365                             return;
366                         }     
367 
368                         //check same schedule
369                         for(var i=0; i<scheduleList.length; i++) {
370 
371                             savedStartSch = new Date((new Date()).getFullYear(), scheduleList[i].startMonth - 1, scheduleList[i].startDay, 0, 0);
372                             savedEndSch   = new Date((new Date()).getFullYear(), scheduleList[i].endMonth - 1, scheduleList[i].endDay, 0, 0);
373 
374                             if ( ((savedStartSch.getTime() <= startSch.getTime()) && (savedEndSch.getTime() > startSch.getTime())) ||
375                                  ((savedStartSch.getTime() < endSch.getTime()) && (savedEndSch.getTime() >= endSch.getTime())) ||
376                                  ((savedStartSch.getTime() === startSch.getTime()) && (savedEndSch.getTime() === endSch.getTime())) ||
377                                  ((startSch.getTime() === endSch.getTime()) && (savedEndSch.getTime() === startSch.getTime())) ) {
378                                 var result = {};
379                                 checkErrorCodeNText(result, "TAHS", "Time.addHolidaySchedule returns failure. schedule is not valid");
380                                 errorCallback(result);                                
381                                 return;
382                             }                     
383                         }
384 
385                         schedule.startMonth = options.startMonth;
386                         schedule.startDay   = options.startDay;
387                         schedule.endMonth   = options.endMonth;
388                         schedule.endDay     = options.endDay;
389                         scheduleList.push(schedule);
390 
391                         log("scheduleList : " + JSON.stringify(scheduleList));
392 
393                         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
394                             method: "set",
395                             parameters: {
396                                 category: "commercial",
397                                 settings: {
398                                     "holidaySchedule": scheduleList
399                                 }
400                             },
401                             onSuccess: function(result) {
402                                 log("addHolidaySchedule: On Success");
403 
404                                 if (result.returnValue === true) {
405                                     if (typeof successCallback === 'function') {
406                                         successCallback();
407                                     }
408                                 }
409                             },
410                             onFailure: function(result) {
411                                 log("addHolidaySchedule: On Failure");
412                                 delete result.returnValue;
413                                 if (typeof errorCallback === 'function') {
414                                     checkErrorCodeNText(result, "TAHS", "Time.addHolidaySchedule returns failure.");
415                                     errorCallback(result);
416                                 }
417                             }
418                         });
419                     }
420                 }
421             },
422             onFailure : function(result) {
423                 log("addHolidaySchedule: On Failure");
424                 delete result.returnValue;
425                 if (typeof errorCallback === 'function') {
426                     checkErrorCodeNText(result, "TAHS", "Time.addHolidaySchedule returns failure.");
427                     errorCallback(result);
428                 }
429             }
430         });
431 
432         log("Time.addHolidaySchedule Done");
433     };
434 
435 	/**
436      * del HolidaySchedule
437      * @class Time
438      * @param {Function} successCallback success callback function.
439      * @param {Function} errorCallback failure callback function.     
440      * @param {Object} options
441      * <div align=left>
442      * <table class="hcap_spec" width=400>
443      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
444      *   <tbody>
445      *       <tr><th>schduleId</th><th>String</th><th>schedule id (getAllHolidaySchedules() ���� ���� schedule id)</th><th>required</th></tr>
446      *   </tbody>
447      * </table>
448      * </div>
449      * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br>
450      * If an error occurs, failure callback function is called with failure callback object as a parameter.</p>
451      * @example
452      * // Javascript code
453      * 
454      * function delHolidaySchedule () {
455      *   var options = {
456  	 *		scheduleId : "d704"
457 	 *	 };  
458      *     
459      *   function successCb() {
460      *      // Do something
461      *   }
462      *
463      *   function failureCb(cbObject) {
464      *      var errorCode = cbObject.errorCode;
465      *      var errorText = cbObject.errorText;
466      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
467      *   }
468      *
469      *   var time = new Time();
470      *   time.delHolidaySchedule(successCb, failureCb, options);
471      * }
472      * @since 1.4
473      * @see
474      * <a href="Time%23getHolidayScheduleMode.html">Time.getHolidayScheduleMode()</a><br>
475      */
476     Time.prototype.delHolidaySchedule = function (successCallback, errorCallback, options) {        
477         log("delHolidaySchedule: " + "id : " + options.scheduleId);
478         
479         if ((typeof options.scheduleId !== 'string' || options.scheduleId === undefined || options.scheduleId === null) && typeof errorCallback === 'function') 
480         {
481             var result = {};
482             checkErrorCodeNText(result, "TDHS", "Time.delHolidaySchedule returns failure. scheduleId is not valid.");
483             errorCallback(result);
484             log("Time.delHolidaySchedule invalid ");
485             return;
486         }    
487 
488         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
489             method : "get",
490             parameters : {
491                 category : "commercial",
492                 keys : ["holidaySchedule"]
493             },
494             onSuccess : function(result) {
495                 log("getHolidaySchedule: On Success");
496 
497                 if (result.returnValue === true) {                
498                     if (typeof successCallback === 'function') {
499                         var scheduleList = null;
500                         var tempList     = [];
501                         var flag         = false;
502                         
503                         scheduleList     = result.settings.holidaySchedule;
504 
505                         log("before scheduleList : " + JSON.stringify(scheduleList));
506 
507                         for(var i=0; i<scheduleList.length; i++) {
508                             if(scheduleList[i]._id === options.scheduleId) {                                
509                                 flag = true;                      
510                             } else {
511                                 tempList.push(scheduleList[i]); //copy schedulelist except for schedule to remove
512                             }
513                         }                     
514                         
515                         if(flag === false && typeof errorCallback === 'function') {
516                             var result = {};
517                             checkErrorCodeNText(result, "TDHS", "Time.delHolidaySchedule returns failure. can not find schedule id.");
518                             errorCallback(result);
519                             log("Time.delHolidaySchedule invalid ");
520                             return;
521                         }
522 
523                         log("after scheduleList : " + JSON.stringify(tempList));
524 
525                         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
526                             method: "set",
527                             parameters: {
528                                 category: "commercial",
529                                 settings: {
530                                     "holidaySchedule": tempList
531                                 }
532                             },
533                             onSuccess: function(result) {
534                                 log("delHolidaySchedule: On Success");
535 
536                                 if (result.returnValue === true) {
537                                     if (typeof successCallback === 'function') {
538                                         successCallback();
539                                     }
540                                 }
541                             },
542                             onFailure: function(result) {
543                                 log("delHolidaySchedule: On Failure");
544                                 delete result.returnValue;
545                                 if (typeof errorCallback === 'function') {
546                                     checkErrorCodeNText(result, "TDHS", "Time.delHolidaySchedule returns failure.");
547                                     errorCallback(result);
548                                 }
549                             }
550                         });
551                     }                    
552                 }
553             },
554             onFailure : function(result) {
555                 log("delHolidaySchedule: On Failure");
556                 delete result.returnValue;
557                 if (typeof errorCallback === 'function') {
558                     checkErrorCodeNText(result, "TDHS", "Time.delHolidaySchedule returns failure.");
559                     errorCallback(result);
560                 }
561             }
562         });
563 
564         log("Time.delHolidaySchedule Done");
565     };
566 
567 	/**
568      * delAll HolidaySchedule
569      * @class Time
570      * @param {Function} successCallback success callback function.
571      * @param {Function} errorCallback failure callback function.     
572      * @param {Object} None
573      * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br>
574      * If an error occurs, failure callback function is called with failure callback object as a parameter.</p>
575      * @example
576      * // Javascript code
577      * 
578      * function delAllHolidaySchedule () {
579      *   function successCb() {
580      *      // Do something
581      *   }
582      *
583      *   function failureCb(cbObject) {
584      *      var errorCode = cbObject.errorCode;
585      *      var errorText = cbObject.errorText;
586      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
587      *   }
588      *
589      *   var time = new Time();
590      *   time.delAllHolidaySchedule(successCb, failureCb);
591      * }
592      * @since 1.4
593      * @see
594      * <a href="Time%23getHolidayScheduleMode.html">Time.getHolidayScheduleMode()</a><br>
595      */
596     Time.prototype.delAllHolidaySchedules = function (successCallback, errorCallback) {        
597         log("delAllHolidaySchedules: ");
598         
599         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
600             method: "set",
601             parameters: {
602                 category: "commercial",
603                 settings: {
604                     "holidaySchedule": []
605                 }
606             },
607             onSuccess: function(result) {
608                 log("delAllHolidaySchedules: On Success");
609 
610                 if (result.returnValue === true) {
611                     if (typeof successCallback === 'function') {
612                         successCallback();
613                     }
614                 }
615             },
616             onFailure: function(result) {
617                 log("delAllHolidaySchedules: On Failure");
618                 delete result.returnValue;
619                 if (typeof errorCallback === 'function') {
620                     checkErrorCodeNText(result, "TDAS", "Time.delAllHolidaySchedules returns failure.");
621                     errorCallback(result);
622                 }
623             }
624         });
625 
626         log("Time.delAllHolidaySchedules Done");
627     };
628     
629 	/**
630      * Gets all HolidaySchedule List
631      * @class Time
632      * @param {Function} successCallback success callback function.
633      * @param {Function} errorCallback failure callback function.
634      * @return {Object} 
635      * <div align=left>
636      * <table class="hcap_spec" width=400>
637      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
638      *   <tbody>
639      *       <tr><th>holidayScheduleList[]</th><th>Array</th><th>holiday schedule list</th></tr>
640      *       <tr class="odd"><tr><th>holidayScheduleList[]._id</th><th>String</th><th>schedule id</th></tr>
641      *       <tr><th>holidayScheduleList[].startMonth</th><th>Number</th><th>start month</th></tr>
642      *       <tr class="odd"><tr><th>holidayScheduleList[].startDay</th><th>Number</th><th>	start day</th></tr>
643      *       <tr><th>holidayScheduleList[].endMonth</th><th>Number</th><th>end month</th></tr>
644      *       <tr class="odd"><tr><th>holidayScheduleList[].endDay</th><th>Number</th><th>end day</th></tr>
645      *   </tbody>
646      * </table>
647      *
648      * @example
649      * // Javascript code
650 	 *	function getAllHolidaySchedules () {
651 	 *		function successCb(cbObject) {
652 	 *			console.log("cbObject : " + JSON.stringify(cbObject));
653 	 *			for (var i = cbObject.holidayScheduleList.length-1; i>=0; i--) {
654 	 *				console.log("holidayScheduleList[" + i + "].startMonth : " + cbObject.holidayScheduleList[i].startMonth);
655 	 *				console.log("holidayScheduleList[" + i + "].startDay : " + cbObject.holidayScheduleList[i].startDay);
656 	 *				console.log("holidayScheduleList[" + i + "].endMonth : " + cbObject.holidayScheduleList[i].endMonth);
657 	 *				console.log("holidayScheduleList[" + i + "].endDay : " + cbObject.holidayScheduleList[i].endDay);
658 	 *			}
659 	 *		}
660 	 *		function failureCb(cbObject) {
661 	 *			var errorCode = cbObject.errorCode;
662 	 *			var errorText = cbObject.errorText;
663 	 *			console.log ("Error Code [" + errorCode + "]: " + errorText);
664 	 *		}
665 	 *		var time = new Time();
666 	 *		time.getAllHolidaySchedules(successCb, failureCb);
667 	 *	}
668      * @since 1.4
669      * @see
670      * <a href="Time%23getHolidayScheduleMode.html">Time.getHolidayScheduleMode()</a><br>
671      */
672     Time.prototype.getAllHolidaySchedules = function (successCallback, errorCallback) {           
673         log("getAllHolidaySchedules: ");
674         
675         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
676             method : "get",
677             parameters : {
678                 category : "commercial",
679                 keys : ["holidaySchedule"]
680             },
681             onSuccess : function(result) {
682                 log("getHolidaySchedule: On Success");
683 
684                 if (result.returnValue === true) {
685                     if (typeof successCallback === 'function') {
686                         var cbObj = {};
687                         cbObj.holidayScheduleList = result.settings.holidaySchedule;
688 
689                         if (typeof successCallback === 'function') {
690                             successCallback(cbObj);
691                         }
692                     }
693                 }
694             },
695             onFailure : function(result) {
696                 log("getAllHolidaySchedules: On Failure");
697                 delete result.returnValue;
698                 if (typeof errorCallback === 'function') {
699                     checkErrorCodeNText(result, "TGAS", "Time.getAllHolidaySchedules returns failure.");
700                     errorCallback(result);
701                 }
702             }
703         });
704 
705         log("Time.getAllHolidaySchedules Done");
706     };
707 
708     module.exports = Time;
709 });
710 
711 Time = cordova.require('cordova/plugin/time'); // jshint ignore:line
712 
713