aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Paweł Zuzelski <pawelz@pld-linux.org>2010-03-28 18:19:14 +0200
committerGravatar Paweł Zuzelski <pawelz@pld-linux.org>2010-03-28 18:19:14 +0200
commit22c3109e1a26c2eb37e03d3f7bb86079c2e0874c (patch)
tree48122f272b7b3bcf76c504ef5715e9d464e84011
parent116a0b1459f56c9727bfdf056f37930332dbf6ba (diff)
emit FORM_ACTIVE, when form element follow.js'ed
Due to Uzbl removal it is no longer possible to emit event from js script. So follow.js does not emit FORM_ACTIVE event, when user selects form element using follow.js. Workaround for that is to run follow.js from shell script, set some global variable and next read this variable from shell script.
-rw-r--r--examples/config/config2
-rw-r--r--examples/data/scripts/follow.js10
-rw-r--r--examples/data/scripts/follow.sh26
3 files changed, 36 insertions, 2 deletions
diff --git a/examples/config/config b/examples/config/config
index de01cf3..29e7d16 100644
--- a/examples/config/config
+++ b/examples/config/config
@@ -324,7 +324,7 @@ set follow_hint_keys = 0123456789
#set follow_hint_keys = qwerty
#set follow_hint_keys = asdfghjkl;
#set follow_hint_keys = thsnd-rcgmvwb/;789aefijkopquxyz234
-@cbind fl* = script @scripts_dir/follow.js '@follow_hint_keys %s'
+@cbind ff* = spawn @scripts_dir/follow.sh "%s"
# --- Form filler binds ---
# This script allows you to configure (per domain) values to fill in form
diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js
index a42447c..9236ed4 100644
--- a/examples/data/scripts/follow.js
+++ b/examples/data/scripts/follow.js
@@ -17,6 +17,7 @@ var doc = document;
var win = window;
var links = document.links;
var forms = document.forms;
+var rv = "";
//Make onlick-links "clickable"
try {
HTMLElement.prototype.click = function() {
@@ -131,16 +132,23 @@ function clickElem(item) {
item.click();
window.location = item.href;
} else if (name == 'INPUT') {
- var type = item.getAttribute('type').toUpperCase();
+ var type;
+ try {
+ type = item.getAttribute('type').toUpperCase();
+ } catch(err) {
+ type = 'TEXT';
+ }
if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') {
item.focus();
item.select();
} else {
item.click();
}
+ rv="XXXFORMELEMENTCLICKEDXXX";
} else if (name == 'TEXTAREA' || name == 'SELECT') {
item.focus();
item.select();
+ rv="XXXFORMELEMENTCLICKEDXXX";
} else {
item.click();
window.location = item.href;
diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh
new file mode 100644
index 0000000..44a0d55
--- /dev/null
+++ b/examples/data/scripts/follow.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+config=$1;
+shift
+pid=$1;
+shift
+xid=$1;
+shift
+fifo=$1;
+shift
+socket=$1;
+shift
+url=$1;
+shift
+title=$1;
+shift
+
+echo 'script @scripts_dir/follow.js "@{follow_hint_keys} '$1'"' | socat - unix-connect:$socket
+
+# Read variable set by script. If it equals XXXFORMELEMENTCLICKEDXXX emit
+# FORM_ACTIVE event
+echo 'js rv' \
+ | socat - unix-connect:$socket \
+ | grep -q XXXINPUTELEMENTCLICKEDXXX \
+ && echo 'event FORM_ACTIVE' \
+ | socat - unix-connect:$socket