diff options
author | Pawel Tomak <satherot@gmail.com> | 2010-03-27 07:57:26 +0100 |
---|---|---|
committer | Pawel Tomak <satherot@gmail.com> | 2010-03-27 07:57:26 +0100 |
commit | 3dab456619fc0fc306dbb08faafbb18aef0e72e2 (patch) | |
tree | 79aa895772dfced9d7392d7c66c18e0f84468f66 /examples | |
parent | fc50da64fe96da436896aa077ee8a8f807969220 (diff) |
Moved function from formfiller-helper.js into the formfiller.sh
Diffstat (limited to 'examples')
-rw-r--r-- | examples/data/scripts/formfiller-helper.js | 32 | ||||
-rwxr-xr-x | examples/data/scripts/formfiller.sh | 18 |
2 files changed, 17 insertions, 33 deletions
diff --git a/examples/data/scripts/formfiller-helper.js b/examples/data/scripts/formfiller-helper.js deleted file mode 100644 index 999d860..0000000 --- a/examples/data/scripts/formfiller-helper.js +++ /dev/null @@ -1,32 +0,0 @@ -/* 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; -})() diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 9fbe8fc..c00d924 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -75,6 +75,22 @@ then action="new" fi +dumpFunction='function dump() { + var rv=""; + var xp_res=document.evaluate("//input", 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 == "file") { + rv += input.name + "(" + type + "):" + input.value + "\\n"; + } + else if(type == "checkbox" || type == "radio") { + rv += input.name + "[" + input.value + "]" + "(" + type + "):" + (input.checked?"ON":"") + "\\n"; + } + } + return rv; +}; ' + if [ "$action" = 'load' ] then [ -e $keydir/$domain ] || exit 2 @@ -92,7 +108,7 @@ then elif [ "$action" = "once" ] then tmpfile=`mktemp` - echo "script @scripts_dir/formfiller-helper.js" | \ + echo "js "$dumpFunction" dump(); " | \ socat - unix-connect:$socket > $tmpfile ${editor} $tmpfile |