-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex2.html
134 lines (114 loc) · 3.69 KB
/
index2.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!doctype html>
<html>
<head>
<title id="ting"> Kandy.io </title>
<style type="text/css">
table{
color:blue;
font-family: Ariel;
}
body{
background-image: url(ornaments_texture.png);
background-repeat: no-repeat;
background-position: 50% 50%;
background-size:cover;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Welcome to Kandy.io</h1>
<p><a href="mailto:[email protected]" title="Will open outlook"> E-mail Hassaan Hafeez</a> </p>
<table border="1" width="25%" cellspacing="10">
<tr>
<th colspan="2"> <h3> DAK8ae302d0639c4b2bb1e6ddc25b2f4b22 </h3> </th>
<tr>
<th> Users </th>
<th> Passwords </th>
</tr>
<tr>
<td> [email protected] </td>
<td> 1voluptasrepellat1 </td>
</tr>
<tr>
<td> [email protected] </td>
<td> 2quisedest2 </td>
</tr>
<table>
<hr />
<input type ="submit" value="Login/Logout" onClick="toggleLogin()"/>
<div id="messages"> </div>
<!-- MESSAGES -->
<fieldset>
<legend> Send Messages </legend>
Recipient: <input type="text" id="recipient"/>
Message: <textarea id="messageBox"> </textarea>
<input type="button" value="Send Message" onclick ="sendMessage();"/>
</fieldset>
<fieldset>
<legend>Chat</legend>
<div id="chat-messages"> </div>
</fieldset>
<!-- END MESSAGES HTML -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script src="https://kandy-portal.s3.amazonaws.com/public/javascript/kandy/2.5.0/kandy.js"></script>
<script type="text/javascript">
kandy.setup({
listeners: {
message: onMessageReceived
}
});
var projectAPIKey = "DAK8ae302d0639c4b2bb1e6ddc25b2f4b22";
var username = "user2";
var password = "2quisedest2";
var isLoggedIn = false;
function toggleLogin(){
if(isLoggedIn) {
kandy.logout(onLogoutSuccess);
} else {
kandy.login(projectAPIKey, username, password, onLoginSuccess, onLoginFailure);
}
}
function log(message){
document.getElementById("messages").innerHTML += "<div>" + message + "</div>";
}
function onLoginSuccess(){
log("LogIn was successful.");
isLoggedIn = true;
}
function onLoginFailure(){
log("Login failed.");
isLoggedIn = false;
}
function onLogoutSuccess(){
log("Logout was successful.");
isLoggedIn = false;
}
function sendMessage(){
var recipient = document.getElementById("recipient").value;
var message = document.getElementById("messageBox").value;
kandy.messaging.sendIm(recipient, message, onSendSuccess, onSendFailure);
}
function onSendSuccess(message){
var recipient = message.destination.split("@")[0];
var element = "<div>Outgoing (" + recipient + "): " + _.escape(message.message.text) + "</div>";
document.getElementById("chat-messages").innerHTML += element;
log("Send Message Successful");
}
function onSendFailure(){
log("Send Message failed.");
}
function onMessageReceived(message){
var sender = message.sender.user_id;
var element = "<div>Incoming (" + sender + "): " + _.escape(message.message.text) + "</div>"
document.getElementById("chat-messages").innerHTML += element;
log(""+message.sender.user_id + " has just messaged you!");
document.getElementById("ting").innerHTML = message.sender.user_id + " messaged you";
setTimeout(clearTitle, 3000);
}
function clearTitle(){
document.getElementById("ting").innerHTML = "Kandy.io";
}
</script>
</body>
</html>