forked from harytfw/GlitterDrag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault_config.js
123 lines (117 loc) · 3.57 KB
/
default_config.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//TODO:减少全局变量,修改变量名
const ACTION_CONSTRUCTOR = (
act = "",
active = "",
pos = "", en = "",
open_type = "",
search_type = "",
copy_type = "",
download_type = "",
download_directory = "",
download_saveas = "",
search_onsite = "",
) => {
return {
act_name: act,
tab_active: active,
tab_pos: pos,
engine_name: en,
open_type,
search_type,
download_type,
download_directory,
download_saveas,
copy_type,
search_onsite,
}
}
const GENERATE_DEFAULT_CONFIG = () => {
const clone = (obj = {}) => {
return JSON.parse(JSON.stringify(obj));
}
let tempAction = {
DIR_U: null,
DIR_D: null,
DIR_L: null,
DIR_R: null,
DIR_UP_L: null,
DIR_UP_R: null,
DIR_LOW_L: null,
DIR_LOW_R: null,
DIR_OUTER: null
};
for (let k of Object.keys(tempAction)) {
tempAction[k] = ACTION_CONSTRUCTOR();
}
return {
enableSync: false,
enableIndicator: false,
enablePrompt: false,
enableStyle: false,
enableTimeoutCancel: false,
enableAutoSelectPreviousTab: true,
enableCtrlKey: false,
enableShiftKey: false,
timeoutCancel: 2000, // ms
triggeredDistance: 20, // px
disableAdjustTabSequence: false,
switchToParentTab: false,
Actions: {
textAction: clone(tempAction),
linkAction: clone(tempAction),
imageAction: clone(tempAction)
},
Actions_ShiftKey: {
textAction: clone(tempAction),
linkAction: clone(tempAction),
imageAction: clone(tempAction)
},
Actions_CtrlKey: {
textAction: clone(tempAction),
linkAction: clone(tempAction),
imageAction: clone(tempAction)
},
Engines: [],
directionControl: {
textAction: commons.ALLOW_NORMAL,
linkAction: commons.ALLOW_NORMAL,
imageAction: commons.ALLOW_NORMAL
},
directionControl_CtrlKey: {
textAction: commons.ALLOW_NORMAL,
linkAction: commons.ALLOW_NORMAL,
imageAction: commons.ALLOW_NORMAL
},
directionControl_ShiftKey: {
textAction: commons.ALLOW_NORMAL,
linkAction: commons.ALLOW_NORMAL,
imageAction: commons.ALLOW_NORMAL
},
downloadDirectories: ["", "", "", "", "", "", "", ""],
style: "",
};
}
const DEFAULT_CONFIG = GENERATE_DEFAULT_CONFIG();
const DEFAULT_CONFIG_A = () => {
let a = DEFAULT_CONFIG;
Object.assign(a.Actions.textAction, {
DIR_U: ACTION_CONSTRUCTOR(commons.ACT_OPEN, commons.FORGE_GROUND, commons.TAB_CLEFT),
DIR_D: ACTION_CONSTRUCTOR(commons.ACT_OPEN, commons.BACK_GROUND, commons.TAB_CLEFT),
});
Object.assign(a.Actions.linkAction, {
DIR_U: ACTION_CONSTRUCTOR(commons.ACT_OPEN, commons.FORGE_GROUND, commons.TAB_CLEFT),
DIR_D: ACTION_CONSTRUCTOR(commons.ACT_OPEN, commons.BACK_GROUND, commons.TAB_CLEFT),
});
Object.assign(a.Actions.imageAction, {
DIR_U: ACTION_CONSTRUCTOR(commons.ACT_OPEN, commons.FORGE_GROUND, commons.TAB_CLEFT),
DIR_D: ACTION_CONSTRUCTOR(commons.ACT_OPEN, commons.BACK_GROUND, commons.TAB_CLEFT),
});
return a;
}
const DEFAULT_CONFIG_B = () => {
return DEFAULT_CONFIG_A;
}
Object.freeze(DEFAULT_CONFIG);
//TODO: user can select built-in configuration
Object.freeze(DEFAULT_CONFIG_A);
Object.freeze(DEFAULT_CONFIG_B);