Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
michael@0 | 1 | <html> |
michael@0 | 2 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Form to sign</title> |
michael@0 | 7 | <script language="javascript"> |
michael@0 | 8 | <!-- |
michael@0 | 9 | function submitSigned(form){ |
michael@0 | 10 | var signature = ""; |
michael@0 | 11 | var dataToSign = ""; |
michael@0 | 12 | var i; |
michael@0 | 13 | |
michael@0 | 14 | form.action='cgi-bin/signedForm.pl'; |
michael@0 | 15 | for (i = 0; i < form.length; i++) |
michael@0 | 16 | if (form.elements[i].type == "text") |
michael@0 | 17 | dataToSign += form.elements[i].value; |
michael@0 | 18 | |
michael@0 | 19 | // alert("Data to sign:\n" + dataToSign); |
michael@0 | 20 | signature = crypto.signText(dataToSign, "ask"); |
michael@0 | 21 | /* alert("You cannot see this alert"); |
michael@0 | 22 | alert("Data signature:\n" + signature); */ |
michael@0 | 23 | |
michael@0 | 24 | if (signature != "error:userCancel") { |
michael@0 | 25 | for (i = 0; i < form.length; i++) { |
michael@0 | 26 | if (form.elements[i].type == "hidden") { |
michael@0 | 27 | if (form.elements[i].name == "dataToSign") |
michael@0 | 28 | form.elements[i].value = dataToSign; |
michael@0 | 29 | if (form.elements[i].name == "dataSignature") |
michael@0 | 30 | form.elements[i].value = signature; |
michael@0 | 31 | } |
michael@0 | 32 | } |
michael@0 | 33 | form.submit(); |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | //--> |
michael@0 | 37 | </script> |
michael@0 | 38 | </head> |
michael@0 | 39 | |
michael@0 | 40 | <body> |
michael@0 | 41 | <form method=post Action="cgi-bin/form.pl"> |
michael@0 | 42 | <input type=hidden size=30 name=dataSignature> |
michael@0 | 43 | <input type=hidden size=30 name=dataToSign> |
michael@0 | 44 | <input type=text size=30 name=p> |
michael@0 | 45 | <BR> |
michael@0 | 46 | <input type=text size=30 name=q> |
michael@0 | 47 | <BR> |
michael@0 | 48 | <input type=text size=30 name=r> |
michael@0 | 49 | <BR> |
michael@0 | 50 | <input type=submit value="Submit Data"> |
michael@0 | 51 | <input type=button value="Sign and Submit Data" onclick=submitSigned(this.form)> |
michael@0 | 52 | <input type=reset value=Reset> |
michael@0 | 53 | </form> |
michael@0 | 54 | </body> |
michael@0 | 55 | </html> |