Convert hotkeys too.

This commit is contained in:
Nicolas Stepien 2013-02-21 22:07:19 +01:00
parent 0f0d08ecd4
commit c925959370
2 changed files with 28 additions and 14 deletions

View File

@ -1341,7 +1341,7 @@
return reader.readAsText(file); return reader.readAsText(file);
}, },
loadSettings: function(data) { loadSettings: function(data) {
var key, val, version, _ref; var key, val, version, _ref, _ref1;
version = data.version.split('.'); version = data.version.split('.');
if (version[0] === '2') { if (version[0] === '2') {
data = Settings.convertSettings(data, { data = Settings.convertSettings(data, {
@ -1372,8 +1372,8 @@
'watch': 'Watch', 'watch': 'Watch',
'update': 'Update', 'update': 'Update',
'unreadCountTo0': '', 'unreadCountTo0': '',
'expandAllImages': 'Expand image', 'expandAllImages': 'Expand images',
'expandImage': 'Expand images', 'expandImage': 'Expand image',
'zero': 'Front page', 'zero': 'Front page',
'nextPage': 'Next page', 'nextPage': 'Next page',
'previousPage': 'Previous page', 'previousPage': 'Previous page',
@ -1389,7 +1389,6 @@
'Verbose': '' 'Verbose': ''
}); });
data.Conf.sauces = data.Conf.sauces.replace(/\$\d/g, function(c) { data.Conf.sauces = data.Conf.sauces.replace(/\$\d/g, function(c) {
$.log(c);
switch (c) { switch (c) {
case '$1': case '$1':
return '%turl'; return '%turl';
@ -1403,10 +1402,22 @@
return c; return c;
} }
}); });
_ref = Config.hotkeys;
for (key in _ref) {
val = _ref[key];
if (!(key in data.Conf)) {
continue;
}
data.Conf[key] = data.Conf[key].replace(/ctrl|alt|meta/g, function(s) {
return "" + (s[0].toUpperCase()) + s.slice(1);
}).replace(/(^|.+\+)[A-Z]$/g, function(s) {
return "Shift+" + s.slice(0, -1) + (s.slice(-1).toLowerCase());
});
}
} }
_ref = data.Conf; _ref1 = data.Conf;
for (key in _ref) { for (key in _ref1) {
val = _ref[key]; val = _ref1[key];
$.set(key, val); $.set(key, val);
} }
return $.set('WatchedThreads', data.WatchedThreads); return $.set('WatchedThreads', data.WatchedThreads);
@ -2694,7 +2705,7 @@
} }
target = e.target; target = e.target;
if ((_ref = target.nodeName) === 'INPUT' || _ref === 'TEXTAREA') { if ((_ref = target.nodeName) === 'INPUT' || _ref === 'TEXTAREA') {
if (!((key === 'Esc') || (/(Alt|Ctrl|Meta)\+/.test(key)))) { if (!/(Esc|Alt|Ctrl|Meta)/.test(key)) {
return; return;
} }
} }
@ -2707,7 +2718,7 @@
case Conf['Open QR']: case Conf['Open QR']:
Keybinds.qr(threadRoot, true); Keybinds.qr(threadRoot, true);
break; break;
case Conf['Open options']: case Conf['Open settings']:
Settings.open(); Settings.open();
break; break;
case Conf['Close']: case Conf['Close']:

View File

@ -337,8 +337,8 @@ Settings =
'watch': 'Watch' 'watch': 'Watch'
'update': 'Update' 'update': 'Update'
'unreadCountTo0': '' 'unreadCountTo0': ''
'expandAllImages': 'Expand image' 'expandAllImages': 'Expand images'
'expandImage': 'Expand images' 'expandImage': 'Expand image'
'zero': 'Front page' 'zero': 'Front page'
'nextPage': 'Next page' 'nextPage': 'Next page'
'previousPage': 'Previous page' 'previousPage': 'Previous page'
@ -354,7 +354,6 @@ Settings =
'Scrolling': 'Auto Scroll' 'Scrolling': 'Auto Scroll'
'Verbose': '' 'Verbose': ''
data.Conf.sauces = data.Conf.sauces.replace /\$\d/g, (c) -> data.Conf.sauces = data.Conf.sauces.replace /\$\d/g, (c) ->
$.log c
switch c switch c
when '$1' when '$1'
'%turl' '%turl'
@ -366,6 +365,10 @@ Settings =
'%board' '%board'
else else
c c
for key, val of Config.hotkeys
continue unless key of data.Conf
data.Conf[key] = data.Conf[key].replace(/ctrl|alt|meta/g, (s) -> "#{s[0].toUpperCase()}#{s[1..]}").replace /(^|.+\+)[A-Z]$/g, (s) ->
"Shift+#{s[0...-1]}#{s[-1..].toLowerCase()}"
for key, val of data.Conf for key, val of data.Conf
$.set key, val $.set key, val
$.set 'WatchedThreads', data.WatchedThreads $.set 'WatchedThreads', data.WatchedThreads
@ -1481,7 +1484,7 @@ Keybinds =
return unless key = Keybinds.keyCode e return unless key = Keybinds.keyCode e
{target} = e {target} = e
if target.nodeName in ['INPUT', 'TEXTAREA'] if target.nodeName in ['INPUT', 'TEXTAREA']
return unless (key is 'Esc') or (/(Alt|Ctrl|Meta)\+/.test key) return unless /(Esc|Alt|Ctrl|Meta)/.test key
threadRoot = Nav.getThread() threadRoot = Nav.getThread()
thread = Get.postFromNode($('.op', threadRoot)).thread thread = Get.postFromNode($('.op', threadRoot)).thread
@ -1491,7 +1494,7 @@ Keybinds =
Keybinds.qr threadRoot Keybinds.qr threadRoot
when Conf['Open QR'] when Conf['Open QR']
Keybinds.qr threadRoot, true Keybinds.qr threadRoot, true
when Conf['Open options'] when Conf['Open settings']
Settings.open() Settings.open()
when Conf['Close'] when Conf['Close']
if $.id 'settings' if $.id 'settings'