Revert "Updated application sources"
[apps/web/sample/CallLog.git] / project / js / app.model.js
index 0273e5c..42c3c64 100644 (file)
-/*
-*      Copyright 2013  Samsung Electronics Co., Ltd
-*
-*      Licensed under the Flora License, Version 1.1 (the "License");
-*      you may not use this file except in compliance with the License.
-*      You may obtain a copy of the License at
-*
-*              http://floralicense.org/license/
-*
-*      Unless required by applicable law or agreed to in writing, software
-*      distributed under the License is distributed on an "AS IS" BASIS,
-*      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*      See the License for the specific language governing permissions and
-*      limitations under the License.
-*/
-
 /*jslint devel: true*/
 /*global tizen, $, app, localStorage */
 
 /**
-* @class Model
-*/
+ * @class Model
+ */
 function Model() {
-    'use strict';
+       'use strict';
 
-    this.init();
+       this.init();
 }
 
 (function () { // strict mode wrapper
-    'use strict';
+       'use strict';
+       Model.prototype = {
+
+               /**
+                * API module initialisation
+                */
+               init: function Model_init() {
+               },
 
-    Model.prototype = {
+               /**
+                * Registers listener for call history change
+                * @param {onSuccessCallback} function
+                */
+               registerChangeListener: function Model_registerChangeListener(onSuccessCallback) {
 
-        /**
-        * API module initialisation
-        */
-        init: function Model_init() {
-        },
+                       var callHistoryListener = {
+                               onadded: onSuccessCallback,
+                               onchanged: onSuccessCallback,
+                               onremoved: onSuccessCallback
+                       };
 
-        /**
-        * Registers listener for call history change
-        * @param {onSuccessCallback} function
-        */
-        registerChangeListener: function Model_registerChangeListener(
-            onSuccessCallback
-        ) {
-            var callHistoryListener = {
-                onadded: onSuccessCallback,
-                onchanged: onSuccessCallback,
-                onremoved: onSuccessCallback
-            };
-            tizen.callhistory.addChangeListener(callHistoryListener);
-        },
+                       tizen.callhistory.addChangeListener(callHistoryListener);
+               },
 
-        /**
-        * @param {function} onSuccess callback
-        * @param {function} onError callback
-        */
-        getCallHistory: function Model_getCallHistory(onSuccess, onError) {
-            if (typeof onError !== 'function') {
-                onError = function (e) {
-                    console.error('Model_getCallHistory error', e);
-                };
-            }
+               /**
+                * @param {function} onSuccess callback
+                * @param {function} onError callback
+                */
+               getCallHistory: function Model_getCallHistory(onSuccess, onError) {
+                       if (typeof onError !== 'function') {
+                               onError = function (e) {
+                                       console.error('Model_getCallHistory error', e);
+                               };
+                       }
 
-            tizen.callhistory.find(
-                onSuccess,
-                onError,
-                null,
-                new tizen.SortMode('startTime', 'DESC')
-            );
-        },
+                       tizen.callhistory.find(onSuccess, onError, null, new tizen.SortMode('startTime', 'DESC'));
+               },
 
-        /**
-        * @param {number} phoneNumber
-        * @param {function} onSuccess Callback
-        */
-        getCallHistoryForCaller: function Model_getCallHistoryForCaller(
-            phoneNumber,
-            onSuccess
-        ) {
-            var filter = null, success;
-            if (phoneNumber) {
-                filter = new tizen.AttributeFilter(
-                    'remoteParties.remoteParty',
-                    'EXACTLY',
-                    phoneNumber
-                );
-                success = onSuccess;
-            } else {
-                success = function (calls) {
-                    onSuccess(calls.filter(function (element) {
-                        if (!element.remoteParties[0].remoteParty) {
-                            return element;
-                        }
-                    }));
-                };
-            }
+               /**
+                * @param {number} phoneNumber
+                * @param {function} onSuccess Callback
+                */
+               getCallHistoryForCaller: function Model_getCallHistoryForCaller(phoneNumber, onSuccess) {
+                       var filter = null, success;
+                       if (phoneNumber) {
+                               filter = new tizen.AttributeFilter('remoteParties.remoteParty', 'EXACTLY', phoneNumber);
+                               success = onSuccess;
+                       } else {
+                               success = function (calls) {
+                                       onSuccess(calls.filter(function (element) {
+                                               if(!element.remoteParties[0].remoteParty) {
+                                                       return element;
+                                               }
+                                       }));
+                               };
+                       }
 
-            tizen.callhistory.find(success,
-                function (e) {
-                    console.error(e);
-                },
-                filter,
-                new tizen.SortMode('startTime', 'DESC')
-                );
-        },
+                       tizen.callhistory.find(success,
+                                       function (e) {
+                                               console.error(e);
+                                       },
+                                       filter,
+                                       new tizen.SortMode('startTime', 'DESC')
+                                       );
+               },
 
-        /**
-        * Deletes specified log entry
-        * @param {CallHistoryEntry} entry
-        */
-        deleteLog: function Model_deleteLog(entry) {
-            try {
-                tizen.callhistory.remove(entry);
-            } catch (e) {
-                console.error('Error on entry delete: ' + e.message);
-            }
-        },
+               /**
+                * Deletes specified log entry
+                * @param {CallHistoryEntry} entry
+                */
+               deleteLog: function Model_deleteLog(entry) {
+                       try {
+                               tizen.callhistory.remove(entry);
+                       } catch (e) {
+                               console.error('Error on entry delete: ' + e.message);
+                       }
+               },
 
-        /**
-        * @param {number} addressBookId
-        * @param {number} contactId
-        * @returns {string} photoURI
-        */
-        getPhotoURIForContact: function Model_getPhotoURIForContact(personId) {
-            try {
-                var addressBook = tizen.contact.getDefaultAddressBook(),
-                    contact;
-                if (addressBook) {
-                    contact = addressBook.get(personId);
-                    return contact.photoURI || false;
-                }
-            } catch (e) {
-                console.error('updatePhotoByContactId error:' + e.message);
-            }
-            return false;
-        }
+               /**
+                * @param {number} addressBookId
+                * @param {number} contactId
+                * @returns {string} photoURI
+                */
+               getPhotoURIForContact: function Model_getPhotoURIForContact(personId) {
+                       try {
+                               var addressBook = tizen.contact.getDefaultAddressBook(),
+                                       contact;
 
-    };
+                               if (addressBook) {
+                                       contact = addressBook.get(personId);
+                                       return contact.photoURI || false;
+                               }
+                       } catch (e) {
+                               console.error('updatePhotoByContactId error:' + e.message);
+                       }
+                       return false;
+               }
 
+       };
 }());