simple keybinds

This commit is contained in:
James Campos 2011-04-16 18:10:05 -07:00
parent ba4fcf2828
commit 51baf0c1fc
2 changed files with 21 additions and 45 deletions

View File

@ -819,7 +819,8 @@
} }
}, },
normal: function(e) { normal: function(e) {
var thread; var id, thread, url;
thread = nav.getThread();
switch (keybinds.key) { switch (keybinds.key) {
case 'I': case 'I':
break; break;
@ -829,6 +830,10 @@
break; break;
case 'M': case 'M':
break; break;
case 'O':
id = thread.firstChild.id;
url = "http://boards.4chan.org/" + g.BOARD + "/res/" + id;
return location.href = url;
case 'i': case 'i':
break; break;
case 'm': case 'm':
@ -836,22 +841,23 @@
case 'n': case 'n':
return nav.next(); return nav.next();
case 'o': case 'o':
break; id = thread.firstChild.id;
url = "http://boards.4chan.org/" + g.BOARD + "/res/" + id;
return GM_openInTab(url);
case 'p': case 'p':
return nav.prev(); return nav.prev();
case 'u': case 'u':
updater.update();
break; break;
case 'w': case 'w':
thread = nav.getThread();
return watcher.toggle(thread); return watcher.toggle(thread);
case 'x': case 'x':
thread = nav.getThread(); return threadHiding.toggle(thread);
threadHiding.toggle(thread);
} }
} }
}; };
keyModeNormal = function(e) { keyModeNormal = function(e) {
var bot, char, hash, height, href, image, next, prev, qrLink, rect, replies, reply, root, sign, td, thread, top, watchButton, _i, _j, _len, _len2; var bot, char, hash, height, image, next, prev, qrLink, rect, replies, reply, root, td, thread, top, _i, _j, _len, _len2;
if (e.ctrlKey || e.altKey) { if (e.ctrlKey || e.altKey) {
return; return;
} }
@ -950,24 +956,6 @@
} }
return imageToggle(image); return imageToggle(image);
} }
break;
case "N":
sign = e.shiftKey ? -1 : 1;
return scrollThread(sign);
case "O":
href = $("" + hash + " ~ span[id] a:last-of-type").href;
if (e.shiftKey) {
return location.href = href;
} else {
return GM_openInTab(href);
}
break;
case "U":
return updateNow();
case "W":
root = g.REPLY ? null : getThread()[0];
watchButton = $("span.filesize ~ img", root);
return watch.call(watchButton);
} }
}; };
nav = { nav = {

View File

@ -601,6 +601,7 @@ keybinds =
ta.setSelectionRange range, range ta.setSelectionRange range, range
normal: (e) -> normal: (e) ->
thread = nav.getThread()
switch keybinds.key switch keybinds.key
when 'I' when 'I'
#qr no text #qr no text
@ -614,6 +615,10 @@ keybinds =
when 'M' when 'M'
#expand all #expand all
return return
when 'O'
id = thread.firstChild.id
url = "http://boards.4chan.org/#{g.BOARD}/res/#{id}"
location.href = url
when 'i' when 'i'
#qr #qr
return return
@ -623,20 +628,18 @@ keybinds =
when 'n' when 'n'
nav.next() nav.next()
when 'o' when 'o'
#open in new tab id = thread.firstChild.id
return url = "http://boards.4chan.org/#{g.BOARD}/res/#{id}"
GM_openInTab url
when 'p' when 'p'
nav.prev() nav.prev()
when 'u' when 'u'
#update now updater.update()
return return
when 'w' when 'w'
thread = nav.getThread()
watcher.toggle thread watcher.toggle thread
when 'x' when 'x'
thread = nav.getThread()
threadHiding.toggle thread threadHiding.toggle thread
return
keyModeNormal = (e) -> keyModeNormal = (e) ->
return if e.ctrlKey or e.altKey return if e.ctrlKey or e.altKey
@ -708,21 +711,6 @@ keyModeNormal = (e) ->
unless image = $ 'td.replyhl span.filesize ~ a[target]', root unless image = $ 'td.replyhl span.filesize ~ a[target]', root
image = $ 'span.filesize ~ a[target]', root image = $ 'span.filesize ~ a[target]', root
imageToggle image imageToggle image
when "N"
sign = if e.shiftKey then -1 else 1
scrollThread sign
when "O"
href = $("#{hash} ~ span[id] a:last-of-type").href
if e.shiftKey
location.href = href
else
GM_openInTab href
when "U"
updateNow()
when "W"
root = if g.REPLY then null else getThread()[0]
watchButton = $ "span.filesize ~ img", root
watch.call watchButton
nav = nav =
#TODO page nav #TODO page nav