passman/js/app/services/settingsservice.js

35 lines
751 B
JavaScript
Raw Normal View History

2016-10-08 01:56:29 +08:00
(function () {
'use strict';
2016-10-08 01:56:29 +08:00
/**
* @ngdoc service
* @name passmanApp.SettingsService
* @description
* # SettingsService
* Service in the passmanApp.
*/
angular.module('passmanApp')
.service('SettingsService', ['localStorageService', function (localStorageService) {
var settings = {
defaultVault: null,
defaultVaultPass: null
};
2016-10-13 02:12:28 +08:00
2016-10-08 01:56:29 +08:00
var cookie = localStorageService.get('settings');
settings = angular.merge(settings, cookie);
return {
getSettings: function () {
return settings;
},
getSetting: function (name) {
return settings[name];
},
setSetting: function (name, value) {
settings[name] = value;
localStorageService.set('settings', settings);
}
};
}]);
}());