Skip to content

Commit

Permalink
Merge branch 'experimental' of github.com:Dieterbe/uzbl
Browse files Browse the repository at this point in the history
  • Loading branch information
bct committed Jul 25, 2011
2 parents 7180bed + 4503386 commit 9b73b93
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
35 changes: 24 additions & 11 deletions 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(
Expand All @@ -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' ) {
Expand Down
11 changes: 6 additions & 5 deletions examples/data/scripts/formfiller.sh
Expand Up @@ -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 )
Expand All @@ -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 )
}'
}

Expand Down

0 comments on commit 9b73b93

Please sign in to comment.