aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/formfiller.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/data/scripts/formfiller.js')
-rw-r--r--examples/data/scripts/formfiller.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/examples/data/scripts/formfiller.js b/examples/data/scripts/formfiller.js
index 4470661..06db648 100644
--- a/examples/data/scripts/formfiller.js
+++ b/examples/data/scripts/formfiller.js
@@ -1,14 +1,16 @@
uzbl.formfiller = {
- inputTypeIsText: function(type) {
- var types = [ 'text', 'password', 'search', 'email', 'url',
- 'number', 'range', 'color', 'date', 'month',
- 'week', 'time', 'datetime', 'datetime-local' ];
+ // this is pointlessly duplicated in uzbl.follow
+ textInputTypes: [
+ '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;
+ // this is pointlessly duplicated in uzbl.follow
+ inputTypeIsText: function(type) {
+ return uzbl.formfiller.textInputTypes.indexOf(type) >= 0;
}
,
@@ -27,6 +29,9 @@ uzbl.formfiller = {
for( var k = 0; k < inputs.length; ++k ) {
var input = inputs[k];
+ if ( ! input.name ) {
+ continue
+ }
if ( uzbl.formfiller.inputTypeIsText(input.type) ) {
rv += '%' + escape(input.name) + '(' + input.type + '):' + input.value + '\n';
} else if ( input.type == 'checkbox' || input.type == 'radio' ) {
@@ -37,8 +42,10 @@ uzbl.formfiller = {
var textareas = allFrames[j].document.getElementsByTagName("textarea");
for( var k = 0; k < textareas.length; ++k ) {
var textarea = textareas[k];
- rv += '%' + escape(textarea.name) + '(textarea):\n' + textarea.value.replace(/\n%/g,"\n\\%") + '\n%\n';
- rv += '%' + escape(textarea.name) + '(textarea):\n' + textarea.value.replace(/\n\\/g,"\n\\\\").replace(/\n%/g,"\n\\%") + '%\n';
+ if ( ! textarea.name ) {
+ continue
+ }
+ rv += '%' + escape(textarea.name) + '(textarea):\n' + textarea.value.replace(/(^|\n)\\/g,"$1\\\\").replace(/(^|\n)%/g,"$1\\%") + '\n%\n';
}
}
catch (err) { }