====== Go input ======
===== Description =====
Gives the first text input/area focus and switches to insert mode. This is very useful for getting at those search boxes.
===== JavaScript =====
var elements = document.querySelectorAll("textarea, input" + [
":not([type='button'])",
":not([type='checkbox'])",
":not([type='hidden'])",
":not([type='image'])",
":not([type='radio'])",
":not([type='reset'])",
":not([type='submit'])"].join(""));
function gi() {
if (elements) {
var el, i = 0;
while((el = elements[i++])) {
var style=getComputedStyle(el, null);
if (style.display !== 'none' && style.visibility === 'visible') {
if (el.type === "file") {
el.click();
}
else {
el.focus();
}
return "XXXEMIT_FORM_ACTIVEXXX";
}
}
}
}
gi();
===== SHELL =====
#!/bin/sh
config=$1;
shift
pid=$1;
shift
xid=$1;
shift
fifo=$1;
shift
socket=$1;
shift
url=$1;
shift
title=$1;
shift
case $(echo 'script @scripts_dir/go_input.js' | socat - unix-connect:$socket) in
*XXXEMIT_FORM_ACTIVEXXX*) echo 'event FORM_ACTIVE' | socat - unix-connect:$socket ;;
esac
==== Installation ====
Save the the "SHELL" as go_input.sh and "JavaScript" as go_input.js in your scripts directory.
# Focus the first form input and enter insert mode
@cbind gi = spawn @scripts_dir/go_input.sh