From c71e5dd642981b7fdf2d644b19e73caf0840adae Mon Sep 17 00:00:00 2001 From: keis Date: Sat, 14 May 2011 18:28:10 +0200 Subject: check input field type using type property this field is set even when no type attribute is set on the element --- examples/data/scripts/follow.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index 2d65489..ced13aa 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -138,8 +138,8 @@ uzbl.follow.clickElem = function(item) { var name = item.tagName; if (name == 'INPUT') { - var type = item.getAttribute('type').toUpperCase(); - if (type == 'TEXT' || type == 'FILE' || type == 'PASSWORD') { + var type = item.type; + if (type == 'text' || type == 'file' || type == 'password') { item.focus(); item.select(); return "XXXEMIT_FORM_ACTIVEXXX"; -- cgit v1.2.3 From b8ba98602eb01975850f0bf26c9efff0ca82e976 Mon Sep 17 00:00:00 2001 From: keis Date: Sat, 14 May 2011 18:36:24 +0200 Subject: use instanceof to check element type --- examples/data/scripts/follow.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index ced13aa..aa4ed72 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -135,9 +135,8 @@ uzbl.follow.generateHint = function(doc, el, label, top, left) { // but at least set the href of the link. (needs some improvements) uzbl.follow.clickElem = function(item) { if(!item) return; - var name = item.tagName; - if (name == 'INPUT') { + if (item instanceof HTMLInputElement) { var type = item.type; if (type == 'text' || type == 'file' || type == 'password') { item.focus(); @@ -145,7 +144,7 @@ uzbl.follow.clickElem = function(item) { return "XXXEMIT_FORM_ACTIVEXXX"; } // otherwise fall through to a simulated mouseclick. - } else if (name == 'TEXTAREA' || name == 'SELECT') { + } else if (item instanceof HTMLTextAreaElement || item instanceof HTMLSelectElement) { item.focus(); item.select(); return "XXXEMIT_FORM_ACTIVEXXX"; -- cgit v1.2.3 From 6ac403eb4c344db1335574fc40a4a873c469bf8c Mon Sep 17 00:00:00 2001 From: keis Date: Sat, 14 May 2011 19:03:25 +0200 Subject: don't try to call select on select elements --- examples/data/scripts/follow.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index aa4ed72..5ecdcef 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -146,7 +146,8 @@ uzbl.follow.clickElem = function(item) { // otherwise fall through to a simulated mouseclick. } else if (item instanceof HTMLTextAreaElement || item instanceof HTMLSelectElement) { item.focus(); - item.select(); + if(typeof item.select != 'undefined') + item.select(); return "XXXEMIT_FORM_ACTIVEXXX"; } -- cgit v1.2.3 From d8cd0405b206fefecd30ee6c03fe8a4583f2eab2 Mon Sep 17 00:00:00 2001 From: keis Date: Sat, 14 May 2011 19:04:32 +0200 Subject: ins mode on focus_element for textarea/insert --- examples/config/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/config/config b/examples/config/config index 9507b95..8ae9cb3 100644 --- a/examples/config/config +++ b/examples/config/config @@ -83,7 +83,7 @@ set download_handler = sync_spawn @scripts_dir/download.sh @on_event LOAD_FINISH spawn @scripts_dir/history.sh # Switch to insert mode if a (editable) html form is clicked -@on_event FOCUS_ELEMENT sh 'if [ "$1" == INPUT ]; then echo "@set_mode insert" > $UZBL_FIFO; fi' %s +@on_event FOCUS_ELEMENT sh 'if [ "$1" = INPUT -o "$1" = TEXTAREA -o "$1" = SELECT ]; then echo "@set_mode insert" > $UZBL_FIFO; fi' %s # Switch to command mode if anything else is clicked @on_event ROOT_ACTIVE @set_mode command -- cgit v1.2.3