aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-05-08 10:21:06 -0600
committerGravatar Brendan Taylor <whateley@gmail.com>2011-05-08 10:21:06 -0600
commit2cfd07b934aa672d36992abe7308d5b497adbbbf (patch)
treea591da4625d5c6d873cc6d5453abe2a445d751f7 /examples
parent76033ba05cad1a2ce720b9b22b3b3f57626ff308 (diff)
parentf39423189b7e564656a241c22ff6eb7fc03bd8c9 (diff)
Merge remote-tracking branch 'mathstuf/dev/improve-follow' into experimental
Diffstat (limited to 'examples')
-rw-r--r--examples/config/config6
-rw-r--r--examples/data/scripts/follow.js28
-rwxr-xr-xexamples/data/scripts/follow.sh20
3 files changed, 46 insertions, 8 deletions
diff --git a/examples/config/config b/examples/config/config
index 8c706df..029ce57 100644
--- a/examples/config/config
+++ b/examples/config/config
@@ -343,8 +343,10 @@ set follow_hint_keys = 0123456789
#set follow_hint_keys = qwerty
#set follow_hint_keys = asdfghjkl;
#set follow_hint_keys = thsnd-rcgmvwb/;789aefijkopquxyz234
-@cbind fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 0) >\@
-@cbind Fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 1) >\@
+@cbind fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'click') >\@
+@cbind Fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'newwindow') >\@
+@cbind fL* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'returnuri') >\@ set
+@cbind FL* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'returnuri') >\@ clipboard
@cbind fi = spawn @scripts_dir/go_input.sh
# Form filler binds
diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js
index b7b0d82..782b1d1 100644
--- a/examples/data/scripts/follow.js
+++ b/examples/data/scripts/follow.js
@@ -16,7 +16,16 @@ uzbldivid = 'uzbl_link_hints';
uzbl.follow = function() {
// Export
charset = arguments[0];
- newwindow = arguments[2];
+ if (arguments[2] == 'click') {
+ newwindow = false;
+ returnuri = false;
+ } else if (arguments[2] == 'newwindow') {
+ newwindow = true;
+ returnuri = false;
+ } else if (arguments[2] == 'returnuri') {
+ newwindow = false;
+ returnuri = true;
+ }
var keypress = arguments[1];
return arguments.callee.followLinks(keypress);
@@ -169,9 +178,13 @@ uzbl.follow.reDrawHints = function(elems, chars) {
elements.forEach(function(el, i) {
var label = labels[i];
var pos = positions[i];
- var doc = uzbl.follow.getDocument(el);
- var h = uzbl.follow.generateHint(doc, el, label, pos[0], pos[1]);
- doc.hintdiv.appendChild(h);
+ try {
+ var doc = uzbl.follow.getDocument(el);
+ var h = uzbl.follow.generateHint(doc, el, label, pos[0], pos[1]);
+ doc.hintdiv.appendChild(h);
+ } catch (err) {
+ // Unable to attach label -> shrug it off and continue
+ }
});
}
@@ -222,7 +235,7 @@ uzbl.follow.followLinks = function(follow) {
//var desc = '*[title], img[alt], applet[alt], area[alt], input[alt]';
//var image = 'img, input[type=image]';
- if(newwindow)
+ if(newwindow || returnuri)
var res = this.query(uri);
else
var res = this.query(followable);
@@ -237,6 +250,11 @@ uzbl.follow.followLinks = function(follow) {
// clear all of our hints
this.clearHints();
+ if (returnuri) {
+ var uri = el.src || el.href;
+ return "XXXRETURNED_URIXXX" + uri
+ }
+
if (newwindow) {
// we're opening a new window using the URL attached to this element
var uri = el.src || el.href;
diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh
index 014793e..f08bd29 100755
--- a/examples/data/scripts/follow.sh
+++ b/examples/data/scripts/follow.sh
@@ -1,7 +1,13 @@
#!/bin/sh
# This scripts acts on the return value of followLinks in follow.js
-case "$1" in
+result=$1
+shift
+
+uriaction=$1
+shift
+
+case "$result" in
XXXEMIT_FORM_ACTIVEXXX)
# a form element was selected
printf 'event FORM_ACTIVE\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO"
@@ -10,4 +16,16 @@ case "$1" in
# a link was selected, reset uzbl's input mode
printf 'set mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO"
;;
+ XXXRETURNED_URIXXX*)
+ uri=${result#XXXRETURNED_URIXXX}
+
+ case "$uriaction" in
+ set)
+ printf 'uri '"$uri"'\n' > "$UZBL_FIFO"
+ ;;
+ clipboard)
+ printf "$uri" | xclip
+ ;;
+ esac
+ printf 'set mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO"
esac