Revision 3989
Added by berkley over 16 years ago
lib/style/skins/knb/index.jsp | ||
---|---|---|
2 | 2 |
<head> |
3 | 3 |
<link rel="stylesheet" type="text/css" href="style/skins/sms/sms.css"/> |
4 | 4 |
<script src="style/skins/sms/jquery-1.2.6.min.js"></script> |
5 |
<script src="style/skins/sms/util.js"></script> |
|
5 | 6 |
<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()\" style=\"font-size:70%\">[logout]</a></h2>"); |
|
22 |
} |
|
23 |
else |
|
24 |
{ //login not successful |
|
25 |
alert('Sorry, your login failed. Please try again. If you need a username, please go to http://knb.ecoinformatics.org.'); |
|
26 |
} |
|
27 |
|
|
28 |
}, "XML"); |
|
29 |
} |
|
30 | 7 |
|
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 | 8 |
</script> |
48 | 9 |
|
49 | 10 |
<title>Semantic Mediation System</title> |
50 | 11 |
</head> |
51 |
<body> |
|
12 |
<body onload="checkLogin()">
|
|
52 | 13 |
|
53 | 14 |
<div style="width: 700px; margin: 0px auto; border:0px; padding:0px;"> |
54 | 15 |
<img style="position:relative; top: 15px;" src="style/skins/sms/sms-page-top.png"/> |
... | ... | |
78 | 39 |
</form> |
79 | 40 |
</div> |
80 | 41 |
</div> |
42 |
|
|
43 |
<!--<div id="maindiv" style="width:625px; margin:0px auto;"> |
|
44 |
<div id="leftspan" style="display:inline; background:grey; border:1px solid"> |
|
45 |
<p>span1</p> |
|
46 |
</div> |
|
47 |
<div id="rightspan" style="display:inline; background:grey; border:1px solid"> |
|
48 |
<p>span2</p> |
|
49 |
</div> |
|
50 |
</div>--> |
|
51 |
|
|
52 |
<div id="maindiv" style="display:none; width:625px; margin:0px auto;"> |
|
53 |
<table style="width:625px"> |
|
54 |
<tr> |
|
55 |
<td> |
|
56 |
<div id="leftspan" style="background:grey; border:1px solid"> |
|
57 |
<p>span1</p> |
|
58 |
</div> |
|
59 |
</td> |
|
60 |
|
|
61 |
<td> |
|
62 |
<div id="rightspan" style="background:grey; border:1px solid"> |
|
63 |
<p>span2</p> |
|
64 |
</div> |
|
65 |
</td> |
|
66 |
</tr> |
|
67 |
</table> |
|
68 |
</div> |
|
69 |
|
|
81 | 70 |
</div> |
82 | 71 |
</div> |
83 |
<img src="style/skins/sms/sms-page-bottom.png" style="position:relative; bottom: 15px;"/>
|
|
72 |
<img id="bottomimg" src="style/skins/sms/sms-page-bottom.png" style="position:relative; bottom: 0px;"/>
|
|
84 | 73 |
</div> |
85 | 74 |
</body> |
86 | 75 |
</html> |
lib/style/skins/knb/util.js | ||
---|---|---|
1 |
function login() |
|
2 |
{ |
|
3 |
var user = document.getElementById("un").value; |
|
4 |
var org = document.getElementById("org").value; |
|
5 |
var pass = document.getElementById("pw").value; |
|
6 |
var ldapUsername = 'uid=' + user + ',o=' + org + ',dc=ecoinformatics,dc=org'; |
|
7 |
|
|
8 |
$.get("metacat", {username: ldapUsername, password: pass, action:"login", qformat:"xml"}, |
|
9 |
function(data) { |
|
10 |
//alert('user ' + ldapUsername + ' logged in. data:' + data); |
|
11 |
if(data.indexOf('<sessionId>') != -1) |
|
12 |
{ //login successful |
|
13 |
//alert('user logged in'); |
|
14 |
slideUp("#loginformdiv"); |
|
15 |
setCookie("sms-login", true); |
|
16 |
setCookie("sms-user", user); |
|
17 |
setCookie("sms-org", org); |
|
18 |
setLoginHeader(true); |
|
19 |
} |
|
20 |
else |
|
21 |
{ //login not successful |
|
22 |
alert('Sorry, your login failed. Please try again. If you need a username, please go to http://knb.ecoinformatics.org.'); |
|
23 |
setCookie("sms-login", false); |
|
24 |
} |
|
25 |
|
|
26 |
}, "XML"); |
|
27 |
} |
|
28 |
|
|
29 |
function setLoginHeader(loggedin) |
|
30 |
{ |
|
31 |
if(loggedin) |
|
32 |
{ |
|
33 |
var user = getCookie("sms-user"); |
|
34 |
$('#loginheader').replaceWith("<h2 style=\"text-align:center\" id=\"loginheader\">" |
|
35 |
+ user + " Logged In <a onclick=\"logout()\" style=\"font-size:70%\">[logout]</a></h2>"); |
|
36 |
slideUp("#loginformdiv"); |
|
37 |
$('#maindiv').css("display", "block"); |
|
38 |
$('#bottomimg').css("bottom", "0px"); |
|
39 |
} |
|
40 |
else |
|
41 |
{ |
|
42 |
$('#loginheader').replaceWith("<h2 style=\"text-align:center\" id=\"loginheader\">" |
|
43 |
+ "Please Log In</h2>"); |
|
44 |
slideDown("#loginformdiv"); |
|
45 |
$('#maindiv').css("display", "none"); |
|
46 |
$('#bottomimg').css("bottom", "15px"); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
function logout() |
|
51 |
{ |
|
52 |
$.get("metacat", {action:"logout", qformat:"xml"}); |
|
53 |
setLoginHeader(false); |
|
54 |
setCookie("sms-login", false); |
|
55 |
} |
|
56 |
|
|
57 |
function checkLogin() |
|
58 |
{ |
|
59 |
if(getCookie("sms-login") == "true") |
|
60 |
{ |
|
61 |
setLoginHeader(true); |
|
62 |
} |
|
63 |
else |
|
64 |
{ |
|
65 |
setLoginHeader(false); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
function slideUp(id) |
|
70 |
{ |
|
71 |
$(id).slideUp("slow"); |
|
72 |
} |
|
73 |
|
|
74 |
function slideDown(id) |
|
75 |
{ |
|
76 |
$(id).slideDown("slow"); |
|
77 |
} |
|
78 |
|
|
79 |
function setCookie( name, value, expires, path, domain, secure ) |
|
80 |
{ |
|
81 |
// set time, it's in milliseconds |
|
82 |
var today = new Date(); |
|
83 |
today.setTime( today.getTime() ); |
|
84 |
|
|
85 |
/* |
|
86 |
if the expires variable is set, make the correct |
|
87 |
expires time, the current script below will set |
|
88 |
it for x number of days, to make it for hours, |
|
89 |
delete * 24, for minutes, delete * 60 * 24 |
|
90 |
*/ |
|
91 |
if ( expires ) |
|
92 |
{ |
|
93 |
expires = expires * 1000 * 60 * 60 * 24; |
|
94 |
} |
|
95 |
var expires_date = new Date( today.getTime() + (expires) ); |
|
96 |
|
|
97 |
document.cookie = name + "=" +escape( value ) + |
|
98 |
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + |
|
99 |
( ( path ) ? ";path=" + path : "" ) + |
|
100 |
( ( domain ) ? ";domain=" + domain : "" ) + |
|
101 |
( ( secure ) ? ";secure" : "" ); |
|
102 |
} |
|
103 |
|
|
104 |
function getCookie( check_name ) { |
|
105 |
// first we'll split this cookie up into name/value pairs |
|
106 |
// note: document.cookie only returns name=value, not the other components |
|
107 |
var a_all_cookies = document.cookie.split( ';' ); |
|
108 |
var a_temp_cookie = ''; |
|
109 |
var cookie_name = ''; |
|
110 |
var cookie_value = ''; |
|
111 |
var b_cookie_found = false; // set boolean t/f default f |
|
112 |
|
|
113 |
for ( i = 0; i < a_all_cookies.length; i++ ) |
|
114 |
{ |
|
115 |
// now we'll split apart each name=value pair |
|
116 |
a_temp_cookie = a_all_cookies[i].split( '=' ); |
|
117 |
|
|
118 |
// and trim left/right whitespace while we're at it |
|
119 |
cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); |
|
120 |
|
|
121 |
// if the extracted name matches passed check_name |
|
122 |
if ( cookie_name == check_name ) |
|
123 |
{ |
|
124 |
b_cookie_found = true; |
|
125 |
// we need to handle case where cookie has no value but exists (no = sign, that is): |
|
126 |
if ( a_temp_cookie.length > 1 ) |
|
127 |
{ |
|
128 |
cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); |
|
129 |
} |
|
130 |
// note that in cases where cookie is initialized but no value, null is returned |
|
131 |
return cookie_value; |
|
132 |
break; |
|
133 |
} |
|
134 |
a_temp_cookie = null; |
|
135 |
cookie_name = ''; |
|
136 |
} |
|
137 |
if ( !b_cookie_found ) |
|
138 |
{ |
|
139 |
return null; |
|
140 |
} |
|
141 |
} |
|
0 | 142 |
Also available in: Unified diff
adding content to the skin and fixing some login errors