keyAct -> keybind

This commit is contained in:
James Campos 2010-11-18 21:09:04 -08:00
parent 5ace92792e
commit 6af0eca109
2 changed files with 35 additions and 36 deletions

View File

@ -200,7 +200,7 @@ autoWatch = ->
closeQR = -> closeQR = ->
div = this.parentNode.parentNode div = this.parentNode.parentNode
remove div remove div
keyActAdd() keybindAdd()
clearHidden = -> clearHidden = ->
#'hidden' might be misleading; it's the number of IDs we're *looking* for, #'hidden' might be misleading; it's the number of IDs we're *looking* for,
@ -279,7 +279,7 @@ formSubmit = (e) ->
recaptcha = $('input[name=recaptcha_response_field]', this) recaptcha = $('input[name=recaptcha_response_field]', this)
if recaptcha.value if recaptcha.value
$('#qr input[title=autohide]:not(:checked)')?.click() $('#qr input[title=autohide]:not(:checked)')?.click()
keyActAdd() keybindAdd()
else else
e.preventDefault() e.preventDefault()
span = n 'span', span = n 'span',
@ -345,7 +345,7 @@ iframeLoad = ->
className: 'error' className: 'error'
addTo qr, span addTo qr, span
$('input[title=autohide]:checked', qr)?.click() $('input[title=autohide]:checked', qr)?.click()
keyActRem() keybindRem()
else if g.REPLY and getConfig 'Persistent QR' else if g.REPLY and getConfig 'Persistent QR'
$('textarea', qr).value = '' $('textarea', qr).value = ''
$('input[name=recaptcha_response_field]', qr).value = '' $('input[name=recaptcha_response_field]', qr).value = ''
@ -361,6 +361,14 @@ iframeLoad = ->
remove qr remove qr
recaptchaReload() recaptchaReload()
keybindAdd = ->
if getConfig 'Keybinds'
d.addEventListener 'keydown', keydown, true
d.addEventListener 'keypress', keypress, true
keybindRem = ->
d.removeEventListener 'keydown', keydown, true
d.removeEventListener 'keypress', keypress, true
keypress = (e) -> keypress = (e) ->
kc = g.keyCode kc = g.keyCode
@ -438,15 +446,6 @@ keydown = (e) ->
else else
g.keyCode = kc g.keyCode = kc
keyActAdd = ->
if getConfig 'Keybinds'
d.addEventListener 'keydown', keydown, true
d.addEventListener 'keypress', keypress, true
keyActRem = ->
d.removeEventListener 'keydown', keydown, true
d.removeEventListener 'keypress', keypress, true
nodeInserted = (e) -> nodeInserted = (e) ->
target = e.target target = e.target
if target.nodeName is 'TABLE' if target.nodeName is 'TABLE'
@ -555,8 +554,8 @@ quickReply = (e) ->
if getConfig 'Keybinds' if getConfig 'Keybinds'
inputs = $$ 'input[type=text], textarea', clone inputs = $$ 'input[type=text], textarea', clone
for input in inputs for input in inputs
input.addEventListener 'focus', keyActRem, true input.addEventListener 'focus', keybindRem, true
input.addEventListener 'blur', keyActAdd, true input.addEventListener 'blur', keybindAdd, true
if not g.REPLY if not g.REPLY
#figure out which thread we're replying to #figure out which thread we're replying to
xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]' xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]'
@ -965,9 +964,9 @@ if getConfig 'Keybinds'
form = $ 'div.postarea > form' form = $ 'div.postarea > form'
inputs = $$ 'input[type=text], textarea', form inputs = $$ 'input[type=text], textarea', form
for input in inputs for input in inputs
input.addEventListener 'focus', keyActRem, true input.addEventListener 'focus', keybindRem, true
input.addEventListener 'blur', keyActAdd, true input.addEventListener 'blur', keybindAdd, true
keyActAdd() keybindAdd()
if g.REPLY if g.REPLY
if getConfig('Quick Reply') and getConfig 'Persistent QR' if getConfig('Quick Reply') and getConfig 'Persistent QR'

View File

@ -1,5 +1,5 @@
(function() { (function() {
var $, $$, AEOS, DAY, _, _i, _len, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expandComment, expandThread, form, formSubmit, g, getConfig, getTime, hide, hideReply, hideThread, href, html, id, iframe, iframeLoad, inAfter, inBefore, input, inputs, keyActAdd, keyActRem, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watcher, watcherUpdate, x; var $, $$, AEOS, DAY, _, _i, _len, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expandComment, expandThread, form, formSubmit, g, getConfig, getTime, hide, hideReply, hideThread, href, html, id, iframe, iframeLoad, inAfter, inBefore, input, inputs, keybindAdd, keybindRem, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watcher, watcherUpdate, x;
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty; var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
config = { config = {
'Thread Hiding': [true, 'Hide entire threads'], 'Thread Hiding': [true, 'Hide entire threads'],
@ -264,7 +264,7 @@
var div; var div;
div = this.parentNode.parentNode; div = this.parentNode.parentNode;
remove(div); remove(div);
return keyActAdd(); return keybindAdd();
}; };
clearHidden = function() { clearHidden = function() {
GM_deleteValue("hiddenReplies/" + (g.BOARD) + "/"); GM_deleteValue("hiddenReplies/" + (g.BOARD) + "/");
@ -349,7 +349,7 @@
recaptcha = $('input[name=recaptcha_response_field]', this); recaptcha = $('input[name=recaptcha_response_field]', this);
if (recaptcha.value) { if (recaptcha.value) {
(typeof (_ref2 = ((_ref = $('#qr input[title=autohide]:not(:checked)')))) === "undefined" || _ref2 === null) ? undefined : _ref2.click(); (typeof (_ref2 = ((_ref = $('#qr input[title=autohide]:not(:checked)')))) === "undefined" || _ref2 === null) ? undefined : _ref2.click();
return keyActAdd(); return keybindAdd();
} else { } else {
e.preventDefault(); e.preventDefault();
span = n('span', { span = n('span', {
@ -429,7 +429,7 @@
}); });
addTo(qr, span); addTo(qr, span);
(typeof (_ref2 = ((_ref = $('input[title=autohide]:checked', qr)))) === "undefined" || _ref2 === null) ? undefined : _ref2.click(); (typeof (_ref2 = ((_ref = $('input[title=autohide]:checked', qr)))) === "undefined" || _ref2 === null) ? undefined : _ref2.click();
keyActRem(); keybindRem();
} else if (g.REPLY && getConfig('Persistent QR')) { } else if (g.REPLY && getConfig('Persistent QR')) {
$('textarea', qr).value = ''; $('textarea', qr).value = '';
$('input[name=recaptcha_response_field]', qr).value = ''; $('input[name=recaptcha_response_field]', qr).value = '';
@ -446,6 +446,16 @@
} }
return recaptchaReload(); return recaptchaReload();
}; };
keybindAdd = function() {
if (getConfig('Keybinds')) {
d.addEventListener('keydown', keydown, true);
return d.addEventListener('keypress', keypress, true);
}
};
keybindRem = function() {
d.removeEventListener('keydown', keydown, true);
return d.removeEventListener('keypress', keypress, true);
};
keypress = function(e) { keypress = function(e) {
var _i, _len, char, count, hash, href, img, kc, position, qrLink, temp; var _i, _len, char, count, hash, href, img, kc, position, qrLink, temp;
kc = g.keyCode; kc = g.keyCode;
@ -553,16 +563,6 @@
return (g.keyCode = kc); return (g.keyCode = kc);
} }
}; };
keyActAdd = function() {
if (getConfig('Keybinds')) {
d.addEventListener('keydown', keydown, true);
return d.addEventListener('keypress', keypress, true);
}
};
keyActRem = function() {
d.removeEventListener('keydown', keydown, true);
return d.removeEventListener('keypress', keypress, true);
};
nodeInserted = function(e) { nodeInserted = function(e) {
var _i, _len, _ref, _result, callback, qr, target; var _i, _len, _ref, _result, callback, qr, target;
target = e.target; target = e.target;
@ -719,8 +719,8 @@
_ref = inputs; _ref = inputs;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = _ref[_i]; input = _ref[_i];
input.addEventListener('focus', keyActRem, true); input.addEventListener('focus', keybindRem, true);
input.addEventListener('blur', keyActAdd, true); input.addEventListener('blur', keybindAdd, true);
} }
} }
if (!g.REPLY) { if (!g.REPLY) {
@ -1249,10 +1249,10 @@
_ref = inputs; _ref = inputs;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = _ref[_i]; input = _ref[_i];
input.addEventListener('focus', keyActRem, true); input.addEventListener('focus', keybindRem, true);
input.addEventListener('blur', keyActAdd, true); input.addEventListener('blur', keybindAdd, true);
} }
keyActAdd(); keybindAdd();
} }
if (g.REPLY) { if (g.REPLY) {
if (getConfig('Quick Reply') && getConfig('Persistent QR')) { if (getConfig('Quick Reply') && getConfig('Persistent QR')) {