2016-12-31 02:55:59 +01:00
|
|
|
|
angular
|
|
|
|
|
.module('bit.settings')
|
|
|
|
|
|
2017-02-25 05:49:36 +01:00
|
|
|
|
.controller('settingsFeaturesController', function ($scope, i18nService, $analytics, constantsService, utilsService) {
|
2016-12-31 02:55:59 +01:00
|
|
|
|
$scope.i18n = i18nService;
|
|
|
|
|
$scope.disableGa = false;
|
2017-01-04 00:40:07 +01:00
|
|
|
|
$scope.disableAddLoginNotification = false;
|
2016-12-31 02:55:59 +01:00
|
|
|
|
|
|
|
|
|
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
2017-02-25 05:49:36 +01:00
|
|
|
|
// Default for Firefox is disabled.
|
|
|
|
|
if ((utilsService.isFirefox() && obj[constantsService.disableGaKey] === undefined) ||
|
|
|
|
|
obj[constantsService.disableGaKey]) {
|
2016-12-31 02:55:59 +01:00
|
|
|
|
$scope.disableGa = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$scope.disableGa = false;
|
|
|
|
|
}
|
2017-02-25 05:49:36 +01:00
|
|
|
|
|
|
|
|
|
$scope.$apply();
|
2016-12-31 02:55:59 +01:00
|
|
|
|
});
|
|
|
|
|
|
2017-01-04 00:40:07 +01:00
|
|
|
|
chrome.storage.local.get(constantsService.disableAddLoginNotificationKey, function (obj) {
|
|
|
|
|
if (obj && obj[constantsService.disableAddLoginNotificationKey]) {
|
|
|
|
|
$scope.disableAddLoginNotification = true;
|
2016-12-31 02:55:59 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
2017-01-04 00:40:07 +01:00
|
|
|
|
$scope.disableAddLoginNotification = false;
|
2016-12-31 02:55:59 +01:00
|
|
|
|
}
|
2017-02-25 05:49:36 +01:00
|
|
|
|
|
|
|
|
|
$scope.$apply();
|
2016-12-31 02:55:59 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$scope.updateGa = function () {
|
|
|
|
|
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
2017-02-25 05:49:36 +01:00
|
|
|
|
// Default for Firefox is disabled.
|
|
|
|
|
if ((utilsService.isFirefox() && obj[constantsService.disableGaKey] === undefined) ||
|
|
|
|
|
obj[constantsService.disableGaKey]) {
|
2016-12-31 02:55:59 +01:00
|
|
|
|
// enable
|
|
|
|
|
obj[constantsService.disableGaKey] = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// disable
|
|
|
|
|
$analytics.eventTrack('Disabled Google Analytics');
|
|
|
|
|
obj[constantsService.disableGaKey] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chrome.storage.local.set(obj, function () {
|
|
|
|
|
$scope.disableGa = obj[constantsService.disableGaKey];
|
2017-02-25 05:49:36 +01:00
|
|
|
|
$scope.$apply();
|
2016-12-31 02:55:59 +01:00
|
|
|
|
if (!obj[constantsService.disableGaKey]) {
|
|
|
|
|
$analytics.eventTrack('Enabled Google Analytics');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-04 00:40:07 +01:00
|
|
|
|
$scope.updateAddLoginNotification = function () {
|
|
|
|
|
chrome.storage.local.get(constantsService.disableAddLoginNotificationKey, function (obj) {
|
|
|
|
|
if (obj[constantsService.disableAddLoginNotificationKey]) {
|
2016-12-31 02:55:59 +01:00
|
|
|
|
// enable
|
2017-01-04 00:40:07 +01:00
|
|
|
|
obj[constantsService.disableAddLoginNotificationKey] = false;
|
2016-12-31 02:55:59 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// disable
|
2017-01-04 00:40:07 +01:00
|
|
|
|
$analytics.eventTrack('Disabled Add Login Notification');
|
|
|
|
|
obj[constantsService.disableAddLoginNotificationKey] = true;
|
2016-12-31 02:55:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chrome.storage.local.set(obj, function () {
|
2017-01-04 00:40:07 +01:00
|
|
|
|
$scope.disableAddLoginNotification = obj[constantsService.disableAddLoginNotificationKey];
|
2017-02-25 05:49:36 +01:00
|
|
|
|
$scope.$apply();
|
2017-01-04 00:40:07 +01:00
|
|
|
|
if (!obj[constantsService.disableAddLoginNotificationKey]) {
|
|
|
|
|
$analytics.eventTrack('Enabled Add Login Notification');
|
2016-12-31 02:55:59 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|