@@ -2,8 +2,8 @@ var _ = require('underscore');
2
2
3
3
var h = require ( './helper' ) ;
4
4
5
- var DEFAULT_CONFIG = {
6
- // usually you don't wanna change those
5
+ // usually you don't wanna change those
6
+ var DEFAULT_SYS_CONFIG = {
7
7
URL_BASE : 'https://leetcode.com' ,
8
8
URL_LOGIN : 'https://leetcode.com/accounts/login/' ,
9
9
URL_PROBLEMS : 'https://leetcode.com/api/problems/$category/' ,
@@ -16,23 +16,53 @@ var DEFAULT_CONFIG = {
16
16
URL_FAVORITES : 'https://leetcode.com/list/api/questions' ,
17
17
URL_FAVORITE_DELETE : 'https://leetcode.com/list/api/questions/$hash/$id' ,
18
18
19
- // but you will want change these
20
- LANG : 'cpp' , // avail: [c,cpp,csharp,golang,java,javascript,python,ruby,swift]
19
+ LANGS : [
20
+ 'bash' ,
21
+ 'c' ,
22
+ 'cpp' ,
23
+ 'csharp' ,
24
+ 'golang' ,
25
+ 'java' ,
26
+ 'javascript' ,
27
+ 'mysql' ,
28
+ 'python' ,
29
+ 'python3' ,
30
+ 'ruby' ,
31
+ 'scala' ,
32
+ 'swift'
33
+ ]
34
+ } ;
35
+
36
+ // but you will want change these
37
+ var DEFAULT_USER_CONFIG = {
21
38
AUTO_LOGIN : false ,
22
- USE_COLOR : true ,
23
39
COLOR_THEME : 'default' ,
24
40
ICON_THEME : '' ,
25
- MAX_WORKERS : 10
41
+ LANG : 'cpp' ,
42
+ MAX_WORKERS : 10 ,
43
+ USE_COLOR : true
26
44
} ;
27
45
28
46
function Config ( ) { }
29
47
30
48
Config . prototype . init = function ( ) {
31
- _ . extendOwn ( this , DEFAULT_CONFIG ) ;
32
-
33
49
// check local config: ~/.lcconfig
34
50
var localConfig = JSON . parse ( h . getFileData ( h . getConfigFile ( ) ) ) || { } ;
51
+ _ . extendOwn ( this , this . getDefaultConfig ( ) ) ;
35
52
_ . extendOwn ( this , localConfig ) ;
36
53
} ;
37
54
55
+ Config . prototype . getDefaultConfig = function ( ) {
56
+ var cfg = { } ;
57
+ _ . extendOwn ( cfg , DEFAULT_SYS_CONFIG ) ;
58
+ _ . extendOwn ( cfg , DEFAULT_USER_CONFIG ) ;
59
+ return cfg ;
60
+ } ;
61
+
62
+ Config . prototype . getUserConfig = function ( ) {
63
+ return _ . pick ( this , function ( v , k ) {
64
+ return k in DEFAULT_USER_CONFIG ;
65
+ } ) ;
66
+ } ;
67
+
38
68
module . exports = new Config ( ) ;
0 commit comments