split keypress into normal and insert modes
This commit is contained in:
parent
516cf60dc2
commit
ac49970879
@ -409,16 +409,29 @@ imageThumb = (thumb) ->
|
|||||||
remove thumb.nextSibling
|
remove thumb.nextSibling
|
||||||
|
|
||||||
keydown = (e) ->
|
keydown = (e) ->
|
||||||
if document.activeElement.nodeName in ['TEXTAREA', 'INPUT']
|
kc = e.keyCode
|
||||||
char = null
|
g.keyCode = kc
|
||||||
else if e.ctrlKey or e.altKey
|
g.char = String.fromCharCode kc
|
||||||
char = null
|
|
||||||
else
|
|
||||||
char = String.fromCharCode e.keyCode
|
|
||||||
g.char = char
|
|
||||||
|
|
||||||
keypress = (e) ->
|
keypress = (e) ->
|
||||||
return unless char = g.char
|
if document.activeElement.nodeName in ['TEXTAREA', 'INPUT']
|
||||||
|
keyModeInsert e
|
||||||
|
else
|
||||||
|
keyModeNormal e
|
||||||
|
|
||||||
|
keyModeInsert = (e) ->
|
||||||
|
kc = g.keyCode
|
||||||
|
char = g.char
|
||||||
|
if kc is 27 #escape
|
||||||
|
remove $ '#qr'
|
||||||
|
e.preventDefault()
|
||||||
|
else if e.ctrlKey and char is "S"
|
||||||
|
console.log 'spoiler'
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
keyModeNormal = (e) ->
|
||||||
|
return if e.ctrlKey or e.altKey
|
||||||
|
char = g.char
|
||||||
hash = location.hash
|
hash = location.hash
|
||||||
count = g.count
|
count = g.count
|
||||||
if char in '1234567890'
|
if char in '1234567890'
|
||||||
|
|||||||
38
4chan_x.js
38
4chan_x.js
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, imageToggle, img, inAfter, inBefore, input, inputs, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, scroll, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _fn, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4;
|
var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, imageToggle, img, inAfter, inBefore, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, scroll, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _fn, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4;
|
||||||
var __slice = Array.prototype.slice, __indexOf = Array.prototype.indexOf || function(item) {
|
var __slice = Array.prototype.slice, __indexOf = Array.prototype.indexOf || function(item) {
|
||||||
for (var i = 0, l = this.length; i < l; i++) {
|
for (var i = 0, l = this.length; i < l; i++) {
|
||||||
if (this[i] === item) return i;
|
if (this[i] === item) return i;
|
||||||
@ -522,21 +522,37 @@
|
|||||||
return remove(thumb.nextSibling);
|
return remove(thumb.nextSibling);
|
||||||
};
|
};
|
||||||
keydown = function(e) {
|
keydown = function(e) {
|
||||||
var char, _ref;
|
var kc;
|
||||||
if ((_ref = document.activeElement.nodeName) === 'TEXTAREA' || _ref === 'INPUT') {
|
kc = e.keyCode;
|
||||||
char = null;
|
g.keyCode = kc;
|
||||||
} else if (e.ctrlKey || e.altKey) {
|
return g.char = String.fromCharCode(kc);
|
||||||
char = null;
|
|
||||||
} else {
|
|
||||||
char = String.fromCharCode(e.keyCode);
|
|
||||||
}
|
|
||||||
return g.char = char;
|
|
||||||
};
|
};
|
||||||
keypress = function(e) {
|
keypress = function(e) {
|
||||||
|
var _ref;
|
||||||
|
if ((_ref = document.activeElement.nodeName) === 'TEXTAREA' || _ref === 'INPUT') {
|
||||||
|
return keyModeInsert(e);
|
||||||
|
} else {
|
||||||
|
return keyModeNormal(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
keyModeInsert = function(e) {
|
||||||
|
var char, kc;
|
||||||
|
kc = g.keyCode;
|
||||||
|
char = g.char;
|
||||||
|
if (kc === 27) {
|
||||||
|
remove($('#qr'));
|
||||||
|
return e.preventDefault();
|
||||||
|
} else if (e.ctrlKey && char === "S") {
|
||||||
|
console.log('spoiler');
|
||||||
|
return e.preventDefault();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
keyModeNormal = function(e) {
|
||||||
var bot, char, count, hash, height, href, i, image, next, prev, qrLink, rect, replies, reply, td, temp, thread, top, watchButton, _i, _j, _len, _len2, _len3, _len4, _ref, _ref2;
|
var bot, char, count, hash, height, href, i, image, next, prev, qrLink, rect, replies, reply, td, temp, thread, top, watchButton, _i, _j, _len, _len2, _len3, _len4, _ref, _ref2;
|
||||||
if (!(char = g.char)) {
|
if (e.ctrlKey || e.altKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
char = g.char;
|
||||||
hash = location.hash;
|
hash = location.hash;
|
||||||
count = g.count;
|
count = g.count;
|
||||||
if (__indexOf.call('1234567890', char) >= 0) {
|
if (__indexOf.call('1234567890', char) >= 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user