formfinder.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. function getTextFieldNames()
  2. {
  3. let textFieldsNames=[];
  4. let textFields;
  5. let formsCollection = document.getElementsByTagName("form");
  6. for (let i = 0; i < formsCollection.length; i++) {
  7. // TODO: Check for all input types other than ones which cannot be made to look like text.
  8. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
  9. textFields=formsCollection[i].querySelectorAll("input[type='text']");
  10. for (let j=0; j < textFields.length; j++)
  11. {
  12. textFieldsNames.push(textFields[j].name);
  13. }
  14. }
  15. return textFieldsNames;
  16. }
  17. // Input is of format {name: "", value: ""}
  18. function setTextFieldsWithValues(textFieldNamesValues)
  19. {
  20. let elementsByName;
  21. for (let i = 0; i < textFieldNamesValues.length; i++) {
  22. elementsByName = document.getElementsByName("textFieldNamesValues[i].name");
  23. // TODO: Problematic - it sets the first element of that name to be that value - may be check if it's a text
  24. // TODO: Make sure that only the right elements are set to the ciphertext values.
  25. elementsByName[0] = textFieldNamesValues[i].value;
  26. }
  27. }