backend.js 873 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. .pragma library
  2. // backend.js
  3. /*
  4. Validate the input credential
  5. Return values are..
  6. 0 - Success
  7. 1 - credentials are empty
  8. */
  9. function validateUserCredentials(uname, pword) {
  10. var ret
  11. if (uname === "" || pword === "") {
  12. ret = 1
  13. } else {
  14. ret = 0
  15. }
  16. return ret
  17. }
  18. /*
  19. Validate the input credential to register
  20. Return values are..
  21. 0 - Success
  22. 1 - credentials are empty
  23. 2 - passwords does not match
  24. */
  25. function validateRegisterCredentials(uname, pword, pword2, hint) {
  26. var ret
  27. if (uname === "" || pword === "" || pword2 === "" || hint === "") {
  28. ret = 1
  29. return ret
  30. } else if (pword !== pword2) {
  31. ret = 2
  32. } else {
  33. ret = 0
  34. }
  35. return ret
  36. }
  37. function dot(loadingCount) {
  38. var str = ""
  39. for (var i = 0; i < loadingCount; i++) {
  40. str += "."
  41. }
  42. return str
  43. }