-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotkey_storage.js
More file actions
56 lines (48 loc) · 1.52 KB
/
hotkey_storage.js
File metadata and controls
56 lines (48 loc) · 1.52 KB
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
var HotKey = (function() {
return {
setup: function(plugin) {
// Default enable hot key for capture.
if (!localStorage.getItem('hot_key_enabled'))
localStorage.setItem('hot_key_enabled', true);
// Set default hot key of capture, R V H P.
if (!this.get('area'))
this.set('area', 'R');
if (!this.get('viewport'))
this.set('viewport', 'V');
if (!this.get('fullpage'))
this.set('fullpage', 'H');
if (!this.get('screen'))
this.set('screen', 'P');
var screenCaptureHotKey = this.get('screen');
if (this.isEnabled() &&
!plugin.setHotKey(screenCaptureHotKey.charCodeAt(0))) {
this.set('screen', '@'); // Disable hot key for screen capture.
}
},
/**
* Set hot key by type.
* @param {String} type Hot key type, must be area/viewport/fullpage/screen.
* @param {String} value
*/
set: function(type, value) {
var key = type + '_capture_hot_key';
localStorage.setItem(key, value);
},
get: function(type) {
return localStorage.getItem(type + '_capture_hot_key');
},
getCharCode: function(type) {
return this.get(type).charCodeAt(0);
},
enable: function() {
localStorage.setItem('hot_key_enabled', true);
},
disable: function(bg) {
localStorage.setItem('hot_key_enabled', false);
bg.plugin.disableScreenCaptureHotKey();
},
isEnabled: function() {
return localStorage.getItem('hot_key_enabled') == 'true';
}
}
})();