summaryrefslogtreecommitdiff
path: root/UI/login.js
blob: 7756788c8710826141f28e8e44182539460f7e08 (plain)
  1. // Note: we do not heed to try other interfaces since we don't support IE 6 or
  2. // lower. If we need to support other interfaces later, we can add them.
  3. // --CT
  4. function get_http_request_object(){
  5. if (typeof XMLHttpRequest == undefined){
  6. return false;
  7. } else {
  8. return new XMLHttpRequest();
  9. }
  10. }
  11. function submit_form() {
  12. var http = get_http_request_object();
  13. var username = document.login.login.value;
  14. var password = document.login.password.value;
  15. http.open("get", 'login.pl?action=authenticate&company='
  16. + document.login.company.value, false,
  17. username, password);
  18. http.send("");
  19. if (http.status != 200){
  20. alert("Access Denied: Bad username/Password");
  21. return false;
  22. }
  23. document.location = document.login.action + "?action=login&company="+
  24. documnet.login.company.value;
  25. }
  26. function check_auth() {
  27. var http = get_http_request_object();
  28. var username = "admin";
  29. var password = document.login.password.value;
  30. http.open("get", "login.pl?action=authenticate&company="
  31. + document.login.company.value, false,
  32. username, password
  33. );
  34. }
  35. function setup_page(login_label, password_label) {
  36. var credential_html;
  37. var cred_div = document.getElementById("credentials");
  38. credential_html =
  39. '<div class="labelledinput">' +
  40. '<div class="label">' +
  41. '<label for="login">' +
  42. login_label+
  43. "</label>" +
  44. '</div>' +
  45. '<div class="input">' +
  46. '<input class="login" ' +
  47. 'name="login" size="30" ' +
  48. 'value="" id="login" '+
  49. 'accesskey="n" />' +
  50. '</div>' +
  51. '</div>' +
  52. '<div class="labelledinput">' +
  53. '<div class="label">' +
  54. '<label for="password">' +
  55. password_label +
  56. '</label>' +
  57. '</div>' +
  58. '<div class="input">' +
  59. '<input class="login" ' +
  60. 'type="password" ' +
  61. 'name="password" ' +
  62. 'size="30" ' +
  63. 'id="password" ' +
  64. 'accesskey="p" />' +
  65. '</div>' +
  66. '</div>';
  67. if (!document.login.blacklisted.value && get_http_request_object()){
  68. cred_div.innerHTML = credential_html;
  69. document.login.login.focus();
  70. }
  71. else {
  72. document.login.company.focus();
  73. }
  74. }