-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.htm
52 lines (51 loc) · 1.96 KB
/
index.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple Session Object Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- script type="text/javascript" src="https://cdn.rawgit.com/js-cookie/js-cookie/master/src/js.cookie.js"></script -->
<script type="text/javascript" src="js/js.cookie.js"></script>
<script type="text/javascript" src="js/simple-session-by-js-cookie.js"></script>
<script type="text/javascript" src="js/user-session-handler.js"></script>
<script type="text/javascript" src="js/wms-login-execute-handler.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
var session;
var loginSuccessCallback=function(pUsh){
console.log('login success');
pUsh.getJQuery()('#myHd1').html('User Logged in ['+pUsh.getLoggedinUserId()+'] welcome '+pUsh.getUserData().nickname+'! <a id="logout" href="#">Logout</span>');
};
var logoutDoneCallback=function(pUsh){
console.log('logout done');
pUsh.getJQuery()('#myHd1').html('User logged out <a id="login" href="#">Login</span>');
};
try{
session=UserSessionHandler.create($, 'cms', WmsLoginExecuteHandler.create('http://rrs.shahadat.web/cms/')).setCallback(loginSuccessCallback, logoutDoneCallback);
}catch(e){
alert('ERR: '+e);
}
$('#myHd1').on('click', 'a#logout', function(e){
e.preventDefault();
session.logout();
}.bind(session));
$('#myHd1').on('click', 'a#login', function(e){
e.preventDefault();
$(this).html('please wait, logging in...');
try{
session.login('shkhan', '123456', function(pWleh, pData){
console.log('login deny! user logged status: '+(pWleh.getUserSessionHandler().isLoggedIn()?'Yes':'NO'));
pWleh.getJQuery()('#myHd1').html('login deny!');
});
}catch(e){
alert('ERR: '+e);
}
}.bind(session));
});
</script>
</head>
<body>
<h1>pg # 1: <span id="myHd1"></span></h1>
<div><a href="idx.htm">Page # 2 [secured]</a></div>
</body>
</html>