aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <brendan@inkdit.com>2011-07-18 10:46:57 -0600
committerGravatar Brendan Taylor <brendan@inkdit.com>2011-07-18 10:46:57 -0600
commit4503386b01c9560844df2d8d3507614c77066c43 (patch)
treeceb68dc52242bb8cfc616c1d196645827edea721 /examples
parent91da964076912a556a68a38b0f095f2f747ada25 (diff)
handle html5 input types in the formfiller
Diffstat (limited to 'examples')
-rw-r--r--examples/data/scripts/formfiller.js35
-rwxr-xr-xexamples/data/scripts/formfiller.sh11
2 files changed, 30 insertions, 16 deletions
diff --git a/examples/data/scripts/formfiller.js b/examples/data/scripts/formfiller.js
index abf0162..a5fc9ee 100644
--- a/examples/data/scripts/formfiller.js
+++ b/examples/data/scripts/formfiller.js
@@ -1,24 +1,37 @@
uzbl.formfiller = {
+ inputTypeIsText: function(type) {
+ var types = [ 'text', 'password', 'search', 'email', 'url',
+ 'number', 'range', 'color', 'date', 'month',
+ 'week', 'time', 'datetime', 'datetime-local' ];
+
+ for(var i = 0; i < types.length; ++i)
+ if(types[i] == type) return true;
+
+ return false;
+ }
+
+ ,
+
dump: function() {
var rv = '';
var allFrames = new Array(window);
- for ( f=0; f<window.frames.length; ++f ) {
+
+ for ( var f = 0; f < window.frames.length; ++f ) {
allFrames.push(window.frames[f]);
}
- for ( j=0; j<allFrames.length; ++j ) {
+
+ for ( var j = 0; j < allFrames.length; ++j ) {
try {
var xp_res = allFrames[j].document.evaluate(
'//input', allFrames[j].document.documentElement, null, XPathResult.ANY_TYPE,null
);
var input;
while ( input = xp_res.iterateNext() ) {
- var type = (input.type?input.type:text);
- if ( type == 'text' || type == 'password' || type == 'search' ) {
- rv += '%' + escape(input.name) + '(' + type + '):' + input.value + '\n';
- }
- else if ( type == 'checkbox' || type == 'radio' ) {
- rv += '%' + escape(input.name) + '(' + type + '){' + escape(input.value) + '}:' + (input.checked?'1':'0') + '\n';
+ if ( inputTypeIsText(input.type) ) {
+ rv += '%' + escape(input.name) + '(' + input.type + '):' + input.value + '\n';
+ } else if ( input.type == 'checkbox' || input.type == 'radio' ) {
+ rv += '%' + escape(input.name) + '(' + input.type + '){' + escape(input.value) + '}:' + (input.checked?'1':'0') + '\n';
}
}
xp_res = allFrames[j].document.evaluate(
@@ -39,12 +52,12 @@ uzbl.formfiller = {
insert: function(fname, ftype, fvalue, fchecked) {
fname = unescape(fname);
var allFrames = new Array(window);
- for ( f=0; f<window.frames.length; ++f ) {
+ for ( var f = 0; f < window.frames.length; ++f ) {
allFrames.push(window.frames[f]);
}
- for ( j=0; j<allFrames.length; ++j ) {
+ for ( var j = 0; j < allFrames.length; ++j ) {
try {
- if ( ftype == 'text' || ftype == 'password' || ftype == 'search' || ftype == 'textarea' ) {
+ if ( uzbl.formfiller.inputTypeIsText(ftype) || ftype == 'textarea' ) {
allFrames[j].document.getElementsByName(fname)[0].value = fvalue;
}
else if ( ftype == 'checkbox' ) {
diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh
index beab011..394bfbd 100755
--- a/examples/data/scripts/formfiller.sh
+++ b/examples/data/scripts/formfiller.sh
@@ -69,11 +69,7 @@ ParseFields ()
field = $0
sub ( /[^:]*:/, "", field )
- if ( parts[2] ~ /^(text|password|search)$/ )
- printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",0);\n",
- parts[1], parts[2], field )
-
- else if ( parts[2] ~ /^(checkbox|radio)$/ )
+ if ( parts[2] ~ /^(checkbox|radio)$/ )
printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",%s);\n",
parts[1], parts[2], parts[3], field )
@@ -90,6 +86,11 @@ ParseFields ()
parts[1], parts[2], field )
}
+ else
+ printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",0);\n",
+ parts[1], parts[2], field )
+
+
}'
}