reply keybinds

This commit is contained in:
James Campos 2010-11-17 08:41:41 -08:00
parent c4b80e8113
commit 176e05bd07
2 changed files with 114 additions and 96 deletions

View File

@ -387,39 +387,46 @@ keypress = (e) ->
location.pathname = "/#{g.BOARD}/#{temp}#1" location.pathname = "/#{g.BOARD}/#{temp}#1"
else else
if e.shiftKey if e.shiftKey
location.hash = 10 window.scrollTo 0, 99999
else else
window.scrollTo 0, 0 window.scrollTo 0, 0
location.hash = '' location.hash = ''
count or= 1 count or= 1
switch char if g.REPLY
when "H" switch char
temp = g.PAGENUM - count when "J"
if temp < 0 then temp = 0 window.scrollBy 0, 20 * count
location.pathname = "/#{g.BOARD}/#{temp}#1" when "K"
when "I" window.scrollBy 0, -20 * count
qrLink = $ "#{hash} ~ span[id] a:not(:first-child)" else
quickReply.call qrLink switch char
ta = $ '#qr textarea' when "H"
ta.focus() temp = g.PAGENUM - count
when "J" if temp < 0 then temp = 0
temp = position + count location.pathname = "/#{g.BOARD}/#{temp}#1"
if temp > 9 then temp = 9 when "I"
location.hash = 'p' + temp qrLink = $ "#{hash} ~ span[id] a:not(:first-child)"
when "K" quickReply.call qrLink
temp = position - count ta = $ '#qr textarea'
if temp < 0 then temp = 'navtop' else temp = 'p' + temp ta.focus()
location.hash = temp when "J"
when "L" temp = position + count
temp = g.PAGENUM + count if temp > 9 then temp = 9
if temp > 15 then temp = 15 location.hash = 'p' + temp
location.pathname = "/#{g.BOARD}/#{temp}#0" when "K"
when "M" temp = position - count
img = $("#{hash} ~ img") if temp < 0 then temp = 'navtop' else temp = 'p' + temp
watch.call img location.hash = temp
when "O" when "L"
href = $("#{hash} ~ span[id] a:last-of-type").href temp = g.PAGENUM + count
GM_openInTab href if temp > 15 then temp = 15
location.pathname = "/#{g.BOARD}/#{temp}#0"
when "M"
img = $("#{hash} ~ img")
watch.call img
when "O"
href = $("#{hash} ~ span[id] a:last-of-type").href
GM_openInTab href
g.count = 0 g.count = 0
keydown = (e) -> keydown = (e) ->
@ -434,7 +441,7 @@ keydown = (e) ->
g.keyCode = kc g.keyCode = kc
keyActAdd = -> keyActAdd = ->
if not g.REPLY and getConfig 'Keyboard Actions' if getConfig 'Keyboard Actions'
d.addEventListener 'keydown', keydown, true d.addEventListener 'keydown', keydown, true
d.addEventListener 'keypress', keypress, true d.addEventListener 'keypress', keypress, true
@ -955,6 +962,14 @@ if getConfig 'Reply Navigation'
addTo span, tn(' '), up, tn(' '), down addTo span, tn(' '), up, tn(' '), down
inAfter el, span inAfter el, span
if getConfig 'Keyboard Actions'
form = $ 'div.postarea > form'
inputs = $$ 'input[type=text], textarea', form
for input in inputs
input.addEventListener 'focus', keyActRem, true
input.addEventListener 'blur', keyActAdd, true
keyActAdd()
if g.REPLY if g.REPLY
if getConfig('Quick Reply') and getConfig 'Persistent QR' if getConfig('Quick Reply') and getConfig 'Persistent QR'
quickReply() quickReply()
@ -966,14 +981,6 @@ if g.REPLY
d.title = "/#{g.BOARD}/ - #{text}" d.title = "/#{g.BOARD}/ - #{text}"
else #not reply else #not reply
if getConfig 'Keyboard Actions'
form = $ 'div.postarea > form'
inputs = $$ 'input[type=text], textarea', form
for input in inputs
input.addEventListener 'focus', keyActRem, true
input.addEventListener 'blur', keyActAdd, true
keyActAdd()
if getConfig 'Thread Hiding' if getConfig 'Thread Hiding'
delform = $('form[name=delform]') delform = $('form[name=delform]')
#don't confuse other scripts #don't confuse other scripts

View File

@ -477,7 +477,7 @@
location.pathname = ("/" + (g.BOARD) + "/" + (temp) + "#1"); location.pathname = ("/" + (g.BOARD) + "/" + (temp) + "#1");
} else { } else {
if (e.shiftKey) { if (e.shiftKey) {
location.hash = 10; window.scrollTo(0, 99999);
} else { } else {
window.scrollTo(0, 0); window.scrollTo(0, 0);
location.hash = ''; location.hash = '';
@ -485,51 +485,62 @@
} }
} }
count || (count = 1); count || (count = 1);
switch (char) { if (g.REPLY) {
case "H": switch (char) {
temp = g.PAGENUM - count; case "J":
if (temp < 0) { window.scrollBy(0, 20 * count);
temp = 0; break;
} case "K":
location.pathname = ("/" + (g.BOARD) + "/" + (temp) + "#1"); window.scrollBy(0, -20 * count);
break; break;
case "I": }
qrLink = $("" + (hash) + " ~ span[id] a:not(:first-child)"); } else {
quickReply.call(qrLink); switch (char) {
ta = $('#qr textarea'); case "H":
ta.focus(); temp = g.PAGENUM - count;
break; if (temp < 0) {
case "J": temp = 0;
temp = position + count; }
if (temp > 9) { location.pathname = ("/" + (g.BOARD) + "/" + (temp) + "#1");
temp = 9; break;
} case "I":
location.hash = 'p' + temp; qrLink = $("" + (hash) + " ~ span[id] a:not(:first-child)");
break; quickReply.call(qrLink);
case "K": ta = $('#qr textarea');
temp = position - count; ta.focus();
if (temp < 0) { break;
temp = 'navtop'; case "J":
} else { temp = position + count;
temp = 'p' + temp; if (temp > 9) {
} temp = 9;
location.hash = temp; }
break; location.hash = 'p' + temp;
case "L": break;
temp = g.PAGENUM + count; case "K":
if (temp > 15) { temp = position - count;
temp = 15; if (temp < 0) {
} temp = 'navtop';
location.pathname = ("/" + (g.BOARD) + "/" + (temp) + "#0"); } else {
break; temp = 'p' + temp;
case "M": }
img = $("" + (hash) + " ~ img"); location.hash = temp;
watch.call(img); break;
break; case "L":
case "O": temp = g.PAGENUM + count;
href = $("" + (hash) + " ~ span[id] a:last-of-type").href; if (temp > 15) {
GM_openInTab(href); temp = 15;
break; }
location.pathname = ("/" + (g.BOARD) + "/" + (temp) + "#0");
break;
case "M":
img = $("" + (hash) + " ~ img");
watch.call(img);
break;
case "O":
href = $("" + (hash) + " ~ span[id] a:last-of-type").href;
GM_openInTab(href);
break;
}
} }
return (g.count = 0); return (g.count = 0);
}; };
@ -545,7 +556,7 @@
} }
}; };
keyActAdd = function() { keyActAdd = function() {
if (!g.REPLY && getConfig('Keyboard Actions')) { if (getConfig('Keyboard Actions')) {
d.addEventListener('keydown', keydown, true); d.addEventListener('keydown', keydown, true);
return d.addEventListener('keypress', keypress, true); return d.addEventListener('keypress', keypress, true);
} }
@ -1233,6 +1244,17 @@
return _result; return _result;
}); });
} }
if (getConfig('Keyboard Actions')) {
form = $('div.postarea > form');
inputs = $$('input[type=text], textarea', form);
_ref = inputs;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = _ref[_i];
input.addEventListener('focus', keyActRem, true);
input.addEventListener('blur', keyActAdd, true);
}
keyActAdd();
}
if (g.REPLY) { if (g.REPLY) {
if (getConfig('Quick Reply') && getConfig('Persistent QR')) { if (getConfig('Quick Reply') && getConfig('Persistent QR')) {
quickReply(); quickReply();
@ -1247,17 +1269,6 @@
} }
} }
} else { } else {
if (getConfig('Keyboard Actions')) {
form = $('div.postarea > form');
inputs = $$('input[type=text], textarea', form);
_ref = inputs;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = _ref[_i];
input.addEventListener('focus', keyActRem, true);
input.addEventListener('blur', keyActAdd, true);
}
keyActAdd();
}
if (getConfig('Thread Hiding')) { if (getConfig('Thread Hiding')) {
delform = $('form[name=delform]'); delform = $('form[name=delform]');
d.addEventListener('DOMNodeInserted', stopPropagation, true); d.addEventListener('DOMNodeInserted', stopPropagation, true);