Project

General

Profile

« Previous | Next » 

Revision 3982

Added by berkley over 16 years ago

got ajax calls working to do login/logout for the sms page

View differences:

lib/style/skins/knb/index.jsp
1 1
<html>
2 2
<head>
3 3
  <link rel="stylesheet" type="text/css" href="style/skins/sms/sms.css"/>
4
  <script src="style/skins/sms/jquery-1.2.6.min.js"></script>
5
  <script type="text/javascript">
6
    function login()
7
    {
8
      var user = document.getElementById("un").value;
9
      var org = document.getElementById("org").value;
10
      var pass = document.getElementById("pw").value;
11
      var ldapUsername = 'uid=' + user + ',o=' + org + ',dc=ecoinformatics,dc=org';
12
      
13
      $.get("metacat", {username: ldapUsername, password: pass, action:"login", qformat:"xml"}, 
14
        function(data) {
15
          //alert('user ' + ldapUsername + ' logged in.  data:' + data);
16
          if(data.indexOf('<sessionId>') != -1)
17
          { //login successful
18
            //alert('user logged in');
19
            slideUp("#loginformdiv");
20
            $('#loginheader').replaceWith("<h2 style=\"text-align:center\" id=\"loginheader\">" 
21
              + user + " Logged In <a onclick=\"logout()\">[logout]</a></h2>");
22
          }
23
          else
24
          { //login not successful
25
            alert('user not logged in');
26
          }
27
          
28
        }, "XML");
29
    }
30
    
31
    function logout()
32
    {
33
      $.get("metacat", {action:"logout", qformat:"xml"});
34
      $('#loginheader').replaceWith("<h2 style=\"text-align:center\" id=\"loginheader\">Please Login</h2>");
35
      slideDown('#loginformdiv')
36
    }
37
    
38
    function slideUp(id)
39
    {
40
      $(id).slideUp("slow");
41
    }
42
    
43
    function slideDown(id)
44
    {
45
      $(id).slideDown("slow");
46
    }
47
  </script>
48
  
4 49
  <title>Semantic Mediation System</title>
5 50
</head>
6 51
<body>
......
8 53
  <div style="width: 700px; margin: 0px auto; border:0px; padding:0px;">
9 54
  <img style="position:relative; top: 15px;" src="style/skins/sms/sms-page-top.png"/>
10 55
  <div id="page">
11
    <h1 style="text-align:center">SEEK Semantic Mediation Tools</h1>
12
    <p>test</p>
56
    <div style="width:650px; border:5px; margin:0px auto;">
57
      <h1 style="text-align:center">SEEK Semantic Mediation Tools</h1>
58
    </div>
59
    <div style="width: 650px; border: 5px; margin: 0px auto; background: grey">
60
      <div id="loginheaderdiv">
61
        <h2 style="text-align:center" id="loginheader">Please Login</h2>
62
      </div>
63
      <div id="loginformdiv">
64
      <form action="metacat" name="loginform" method="POST">
65
        <div style="width:300px; margin:0px auto; height: 150px;">
66
        <table>
67
          <tr>
68
            <td>Username:</td><td><input id="un" type="text" name="username"/></td>
69
          </tr>
70
          <tr>
71
            <td>Organization:</td><td><input id="org" type="text" name="organization"/></td>
72
          </tr>
73
          <tr>
74
            <td>Password:</td><td><input id="pw" type="password" name="password"/></td>
75
          </tr>
76
        </table>
77
        <a onclick="login()">[Login]</a>
78
      </form>
79
      </div>
80
      </div>
81
    </div>
13 82
  </div>
14
  <img src="style/skins/sms/sms-page-bottom.png" style="position:relative; bottom: 12px;"/>
83
  <img src="style/skins/sms/sms-page-bottom.png" style="position:relative; bottom: 15px;"/>
15 84
  </div>
16
  
17 85
</body>
18 86
</html>

Also available in: Unified diff