diff options
Diffstat (limited to 'examples/data/scripts/formfiller-helper.js')
-rw-r--r-- | examples/data/scripts/formfiller-helper.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/data/scripts/formfiller-helper.js b/examples/data/scripts/formfiller-helper.js new file mode 100644 index 0000000..999d860 --- /dev/null +++ b/examples/data/scripts/formfiller-helper.js @@ -0,0 +1,32 @@ +/* This script finds all editable input elemnts and generate file for + * formfiller script. It must be invoked from formfiller.sh */ + +(function () { + /* evaluate XPath query */ + var xp_res=document.evaluate("//input", document.documentElement, null, XPathResult.ANY_TYPE,null); + var rv=""; + var input; + + while(input=xp_res.iterateNext()) { + var type=(input.type?input.type:text); + switch (type) { + case "text": + case "password": + case "file": + rv += input.name + "(" + type + "):" + input.value + "\n"; + break; + case "checkbox": + case "radio": + rv += input.name + "[" + input.value + "]" + "(" + type + "):" + (input.checked?"ON":"") + "\n"; + break; + /* Not supported: + * case "button": + * case "image": + * case "reset": + * case "submit": + * case "hidden": + */ + } + } + return rv; +})() |