<commit_before>angular.module('starter.controllers', [])

    .controller('SecureStorageCtrl', function ($scope) {
        var self = this;

        self.loading = true;

        self.storeFile = function () {
            self.imgSrc = null;
            self.loading = true;
            appworks.storage.storeFile('file.jpg', 'http://thecatapi.com/api/images/get', function () {
                self.loading = false;
                $scope.$apply();
            });
        };

        self.getFile = function () {
            appworks.storage.getFile('file.jpg', function (dataUrl) {
                self.imgSrc = dataUrl;
                $scope.$apply();
            });
        }
    })

    .controller('CacheCtrl', function () {

        var self = this;

        self.key = 'myKey';
        self.data = 1234;

        self.setItem = function (key, data) {
            self.data = null;
            self.cacheData = null;
            appworks.cache.setItem(key, data);
        };

        self.getItem = function (key) {
            appworks.cache.getItem(key, function (data) {
                if (!data) {
                    alert('This key does not exist in the cache');
                }
                self.cacheData = data;
            });
        };

        self.clear = function () {
            self.cacheData = null;
            self.key = null;
            self.data = null;
            appworks.cache.clear();
            self.$applyAsync();
        };
    })

    .controller('OfflineCtrl', function ($scope, $timeout) {
        var self = this,
            url = 'https://randomuser.me/api/',
            options1 = {eventListener: 'myEvent1', method: 'GET'},
            options2 = {eventListener: 'myEvent2', method: 'GET'},
            options3 = {eventListener: 'myEvent3', method: 'GET'};

        self.users = [];

        self.queue = function (options) {
            self.err = null;
            if (options) {
                appworks.offline.queue(options.url, options.options).then(options.success, options.error);
            } else {
                appworks.offline.queue(url, options1).then(successFn, errorFn);
            }
        };

        self.queueMultiple = function () {
            self.users = [];
            $timeout(function () {
                self.queue({url: url, options: options1, success: successFn, error: errorFn});
            }, 1000);
            $timeout(function () {
                self.queue({url: url, options: options2, success: successFn2, error: errorFn});
            }, 1000);
            $timeout(function () {
                self.queue({url: url, options: options3, success: successFn3, error: errorFn});
            }, 1000);
        };

        function addUser(user) {
            $scope.$apply(self.users.push(user));
        }

        function successFn(res) {
            res = JSON.parse(res.data);
            addUser(res.results[0]);
            appworks.offline.removeEventHandler('myEvent1', successFn);
        }

        function successFn2(res) {
            res = JSON.parse(res.data);
            addUser(res.results[0]);
            appworks.offline.removeEventHandler('myEvent2', successFn2);
        }

        function successFn3(res) {
            res = JSON.parse(res.data);
            addUser(res.results[0]);
            appworks.offline.removeEventHandler('myEvent3', successFn3);
        }

        function errorFn(err) {
            $scope.$apply(self.err = err);
        }
    })

    .controller('DeviceCtrl', function ($scope) {
        var self = this;

        self.notifications = [];
        self.notificationsEnabled = true;

        $scope.$watch('device.notificationsEnabled', function (on) {
            if (on) {
                self.enableNotifications();
            } else {
                self.stopNotifications();
            }
        });

        self.openCamera = function () {
            self.err = null;
            self.imgSrc = null;
            appworks.camera.takePicture(function (dataUrl) {
                self.imgSrc = dataUrl;
                $scope.$apply();
            }, function (err) {
                self.err = err;
                $scope.$apply();
            });
        };

        self.openGallery = function () {
            self.err = null;
            self.imgSrc = null;
            appworks.camera.chooseFromLibrary(function (dataUrl) {
                self.imgSrc = dataUrl;
                $scope.$apply();
            }, function (err) {
                self.err = err;
                $scope.$apply();
            });
        };

        self.getLocation = function () {
            appworks.geolocation.getCurrentPosition(onSuccess, onError);

            function onSuccess(position) {
                console.log(position);
                alert('Latitude: '          + position.coords.latitude          + '\n' +
                    'Longitude: '         + position.coords.longitude         + '\n' +
                    'Altitude: '          + position.coords.altitude          + '\n' +
                    'Accuracy: '          + position.coords.accuracy          + '\n' +
                    'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
                    'Heading: '           + position.coords.heading           + '\n' +
                    'Speed: '             + position.coords.speed             + '\n' +
                    'Timestamp: '         + position.timestamp                + '\n');
            }

            function onError(err) {
                console.log(err);
                alert('Unable to get current location. Please make sure location services are enabled for this app');
            }
        };

        appworks.notifications.handler(function (notification) {
            $scope.$apply(self.notifications.push(notification));
        });

        self.clearNotifications = function () {
            self.notifications = [];
        };

        self.stopNotifications = function () {
            appworks.notifications.off();
        };

        self.enableNotifications = function () {
            appworks.notifications.on();
        };

        self.getNotifications = function () {
            self.syncNotifications();
        };

        self.syncNotifications = function () {
            $scope.$applyAsync(self.notifications = appworks.notifications.get());
        };<commit_msg>added options for retrieving location<commit_after>angular.module('starter.controllers', [])

    .controller('SecureStorageCtrl', function ($scope) {
        var self = this;

        self.loading = true;

        self.storeFile = function () {
            self.imgSrc = null;
            self.loading = true;
            appworks.storage.storeFile('file.jpg', 'http://thecatapi.com/api/images/get', function () {
                self.loading = false;
                $scope.$apply();
            });
        };

        self.getFile = function () {
            appworks.storage.getFile('file.jpg', function (dataUrl) {
                self.imgSrc = dataUrl;
                $scope.$apply();
            });
        }
    })

    .controller('CacheCtrl', function () {

        var self = this;

        self.key = 'myKey';
        self.data = 1234;

        self.setItem = function (key, data) {
            self.data = null;
            self.cacheData = null;
            appworks.cache.setItem(key, data);
        };

        self.getItem = function (key) {
            appworks.cache.getItem(key, function (data) {
                if (!data) {
                    alert('This key does not exist in the cache');
                }
                self.cacheData = data;
            });
        };

        self.clear = function () {
            self.cacheData = null;
            self.key = null;
            self.data = null;
            appworks.cache.clear();
            self.$applyAsync();
        };
    })

    .controller('OfflineCtrl', function ($scope, $timeout) {
        var self = this,
            url = 'https://randomuser.me/api/',
            options1 = {eventListener: 'myEvent1', method: 'GET'},
            options2 = {eventListener: 'myEvent2', method: 'GET'},
            options3 = {eventListener: 'myEvent3', method: 'GET'};

        self.users = [];

        self.queue = function (options) {
            self.err = null;
            if (options) {
                appworks.offline.queue(options.url, options.options).then(options.success, options.error);
            } else {
                appworks.offline.queue(url, options1).then(successFn, errorFn);
            }
        };

        self.queueMultiple = function () {
            self.users = [];
            $timeout(function () {
                self.queue({url: url, options: options1, success: successFn, error: errorFn});
            }, 1000);
            $timeout(function () {
                self.queue({url: url, options: options2, success: successFn2, error: errorFn});
            }, 1000);
            $timeout(function () {
                self.queue({url: url, options: options3, success: successFn3, error: errorFn});
            }, 1000);
        };

        function addUser(user) {
            $scope.$apply(self.users.push(user));
        }

        function successFn(res) {
            res = JSON.parse(res.data);
            addUser(res.results[0]);
            appworks.offline.removeEventHandler('myEvent1', successFn);
        }

        function successFn2(res) {
            res = JSON.parse(res.data);
            addUser(res.results[0]);
            appworks.offline.removeEventHandler('myEvent2', successFn2);
        }

        function successFn3(res) {
            res = JSON.parse(res.data);
            addUser(res.results[0]);
            appworks.offline.removeEventHandler('myEvent3', successFn3);
        }

        function errorFn(err) {
            $scope.$apply(self.err = err);
        }
    })

    .controller('DeviceCtrl', function ($scope) {
        var self = this;

        self.notifications = [];
        self.notificationsEnabled = true;

        $scope.$watch('device.notificationsEnabled', function (on) {
            if (on) {
                self.enableNotifications();
            } else {
                self.stopNotifications();
            }
        });

        self.openCamera = function () {
            self.err = null;
            self.imgSrc = null;
            appworks.camera.takePicture(function (dataUrl) {
                self.imgSrc = dataUrl;
                $scope.$apply();
            }, function (err) {
                self.err = err;
                $scope.$apply();
            });
        };

        self.openGallery = function () {
            self.err = null;
            self.imgSrc = null;
            appworks.camera.chooseFromLibrary(function (dataUrl) {
                self.imgSrc = dataUrl;
                $scope.$apply();
            }, function (err) {
                self.err = err;
                $scope.$apply();
            });
        };

        self.getLocation = function () {
            appworks.geolocation.getCurrentPosition(onSuccess, onError, {enableHighAccuracy: true, timeout: 2000});

            function onSuccess(position) {
                console.log(position);
                alert('Latitude: '          + position.coords.latitude          + '\n' +
                    'Longitude: '         + position.coords.longitude         + '\n' +
                    'Altitude: '          + position.coords.altitude          + '\n' +
                    'Accuracy: '          + position.coords.accuracy          + '\n' +
                    'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
                    'Heading: '           + position.coords.heading           + '\n' +
                    'Speed: '             + position.coords.speed             + '\n' +
                    'Timestamp: '         + position.timestamp                + '\n');
            }

            function onError(err) {
                console.log(err);
                alert('Unable to get current location. In general this means the device has no network connectivity and/or cannot get a satellite fix');
            }
        };

        appworks.notifications.handler(function (notification) {
            $scope.$apply(self.notifications.push(notification));
        });

        self.clearNotifications = function () {
            self.notifications = [];
        };

        self.stopNotifications = function () {
            appworks.notifications.off();
        };

        self.enableNotifications = function () {
            appworks.notifications.on();
        };

        self.getNotifications = function () {
            self.syncNotifications();
        };

        self.syncNotifications = function () {
            $scope.$applyAsync(self.notifications = appworks.notifications.get());
        };
{'fraction_non_alphanumeric': 0.12780616194457348, 'fraction_numerical': 0.006192909119058678, 'mean_word_length': 1.4338733986435568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7519605', 'n_tokens_mistral': 3472, 'n_tokens_neox': 3298, 'n_words': 603}