-
Notifications
You must be signed in to change notification settings - Fork 2
/
preferences.js
54 lines (46 loc) · 1.62 KB
/
preferences.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*global brackets, define */
define(function (require, exports, module) {
"use strict";
var PREFERENCES_KEY = "brackets-snippets",
_ = brackets.getModule("thirdparty/lodash"),
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
prefs = PreferencesManager.getExtensionPrefs(PREFERENCES_KEY);
var defaultPreferences = {
"autoBackupTime": {
"type": "integer", "value": 10
},
};
_.each(defaultPreferences, function (definition, key) {
if (definition.os && definition.os[brackets.platform]) {
prefs.definePreference(key, definition.type, definition.os[brackets.platform].value);
} else {
prefs.definePreference(key, definition.type, definition.value);
}
});
prefs.save();
prefs.getAll = function () {
var obj = {};
_.each(defaultPreferences, function (definition, key) {
obj[key] = this.get(key);
}, this);
return obj;
};
prefs.getDefaults = function () {
var obj = {};
_.each(defaultPreferences, function (definition, key) {
var defaultValue;
if (definition.os && definition.os[brackets.platform]) {
defaultValue = definition.os[brackets.platform].value;
} else {
defaultValue = definition.value;
}
obj[key] = defaultValue;
}, this);
return obj;
};
prefs.persist = function (key, value) {
this.set(key, value);
this.save();
};
module.exports = prefs;
});