-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·467 lines (434 loc) · 20.7 KB
/
index.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Conface</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<!-- Base Css Files -->
<link href="src/jqueryui/ui-lightness/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" />
<link href="src/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="src/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<link href="src/fontello/css/fontello.css" rel="stylesheet" />
<link href="src/animate-css/animate.min.css" rel="stylesheet" />
<link href="src/nifty-modal/css/component.css" rel="stylesheet" />
<link href="src/pace/pace.css" rel="stylesheet" />
<link href="src/jquery-icheck/skins/all.css" rel="stylesheet" />
<!-- Extra CSS Libraries Start -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!-- Extra CSS Libraries End -->
<link href="css/style-responsive.css" rel="stylesheet" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body class="fixed-left login-page">
<script>
//opens modal, onclick is on login button
function openLogin() {
$('#myModalO').modal('show');
}
// This is called with the results from from FB.getLoginStatus().
function LoginToFacebook() {
FB.login(function (response) {
statusChangeCallback(response);
}, { scope: 'public_profile,email' });
}
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
$('#facebookButton').text('Connected');
// send access token to the server
console.log(response.authResponse);
var form_data = {
accessToken: response.authResponse.accessToken,
facebookId: response.authResponse.userID
};
$.ajax({
type: "POST",
url: base_url + "auth/FacebookLogin",
data: form_data,
success: function (response) {
console.log(response.resultCode);
//var json = response;
if (response.resultCode > 0) {
document.cookie = 'token=' + response.password + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
document.cookie = 'fuid=' + response.user + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
// if getConversations -> get convs from server
}
else if (response.resultCode == -1) {
alert('access token not valid');
}
},
dataType: "json"//set to JSON
})
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
window.fbAsyncInit = function () {
FB.init({
appId: '782732791789048',
xfbml: true,
version: 'v2.4'
});
console.log('calling get status');
FB.getLoginStatus(function (response) {
console.log("response")
statusChangeCallback(response);
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
var wantsToSend = 0;
function logout() {
document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
document.cookie = "userId=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
document.cookie = "password=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
}
function sendMessage() {
console.log('inside send message');
wantsToSend = 1;
var response = "";
var maan = $("#maan").val();
var message = $("#message").val();
var userid = getCookie('userId');
var username = getCookie('username');
var password = getCookie('password');
if (username == null || username == '') {
console.log('open modal');
$('#myModalO').modal('show');
return;
}
else {
wantsToSend = 0;
}
$('#message-spinner').show();
var form_data = {
userName: username,
password: password,
userId: userid,
facebookUserName: maan,
messageText: message
};
$.ajax({
type: "POST",
url: base_url + "chat/SendMessageAnonimo",
data: form_data,
success: function (response) {
console.log(response);
//var json = response;
if (response.resultCode > 0) {
// show message - your message was sent!
$("#maan").text('');
$("#message").text('');
$('#message-spinner').hide();
alert("Your message was sent!");
}
},
dataType: "json"//set to JSON
})
}
var resizefunc = [];
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="src/jquery/jquery-1.11.1.min.js"></script>
<script src="src/bootstrap/js/bootstrap.min.js"></script>
<script src="src/jqueryui/jquery-ui-1.10.4.custom.min.js"></script>
<script src="src/fastclick/fastclick.js"></script>
<script src="src/jquery-sparkline/jquery-sparkline.js"></script>
<script src="src/nifty-modal/js/classie.js"></script>
<script src="src/nifty-modal/js/modalEffects.js"></script>
<script src="src/bootstrap-fileinput/bootstrap.file-input.js"></script>
<script src="src/bootstrap-select/bootstrap-select.min.js"></script>
<script src="src/pace/pace.min.js"></script>
<script src="src/jquery-icheck/icheck.min.js"></script>
<!-- Specific JS Libraries -->
<script src="src/prettify/prettify.js"></script>
<script src="js/init.js"></script>
<script>
//var base_url = 'http://rhc.azurewebsites.net/';
var base_url = 'http://b70d7f77.ngrok.io/api/';
function setLoginMenu() {
var username = getCookie('username');
console.log(username)
if (username == null || username == '') {
console.log('not logged in');
$('#facebookLogin').show();
$("#loginMenu").show();
$("#userMenu").hide();
$("#user-name").html("username");
return;
}
console.log('logged in');
$('#facebookLogin').hide();
$("#loginMenu").hide();
$("#userMenu").show();
$("#user-name").html(username);
}
$(document).ready(function () {
setLoginMenu();
$('#message-spinner').hide();
$('#send-message').attr('disabled', true);
$('body').on('keyup', '#maan, #message', function(event) {
if($('#maan').val() === "" || $('#message').val() === "") {
$('#send-message').attr('disabled', true);
} else {
$('#send-message').attr('disabled', false);
}
});
});
function login() {
var response = "";
var username = $("#username").val();
var password = $("#password").val();
var form_data = {
userName: username,
password: password
};
$.ajax({
type: "POST",
url: base_url + "auth/login",
//url: "/auth/login",
data: form_data,
success: function (response) {
console.log(response.resultCode);
//var json = response;
if (response.resultCode > 0)
{
document.cookie = 'username=' + response.userName + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
document.cookie = 'password=' + response.password + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
document.cookie = 'userId=' + response.resultCode + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
$('#myModalO').modal('hide');
// show in UI that we're logged in
showLoggedIn(response.userName);
if (wantsToSend == 1)
sendMessage();
}
else if (response.resultCode == -2)
{
// show message "user does not exist"
alert('user name does not exist');
}
else if (response.resultCode == -3)
{
// show message "wrong password"
alert('wrong password');
}
//var output = "<ul>";
//for (var i in json) {
// output += "<li>" + json.userName + ", " + json.password + "</li>";
//}
//output += "</ul>";
//$('span').html(output);
},
dataType: "json"//set to JSON
})
}
function register() {
var response = "";
var username = $("#userNameRegister").val();
var password = $("#passwordRegister").val();
var email = $("#emailRegister").val();
var form_data = {
userName: username,
password: password,
email: email
};
$.ajax({
type: "POST",
url: base_url + "auth/SignUp",
data: form_data,
success: function (response) {
console.log(response);
if (response.resultCode > 0)
{
document.cookie = 'username=' + response.userName + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
document.cookie = 'password=' + response.password + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
document.cookie = 'userId=' + response.resultCode + '; expires=Thu, 18 Dec 2083 12:00:00 UTC';
console.log('hiding');
$('#myModalO').modal('hide');
// show in UI that we're logged in
showLoggedIn(response.userName);
if (wantsToSend == 1)
sendMessage();
}
else if (response.resultCode == -2)
{
// show message "user already exists"
alert('user already exists');
}
//var json = response;
//var output = "<ul>";
//for (var i in json) {
// output += "<li>" + json.userName + ", " + json.password + "</li>";
//}
// output += "</ul>";
// $('span').html(output);
},
dataType: "json"//set to JSON
})
}
</script>
<!-- Top Bar Start -->
<div class="topbar">
<!-- Button mobile view to collapse sidebar menu -->
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<ul class="nav navbar-nav navbar-left top-navbar">
<li class="dropdown topbar-profile">
<a href="conversations.html"><i class="fa fa-comments"></i> <strong>Conversations</strong></a>
</li>
</ul>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right top-navbar">
<li class="facebook-login">
<div id="facebookLogin" class="fb-login-button" data-max-rows="1" data-size="large" data-show-faces="false" data-auto-logout-link="true"></div>
</li>
<li id="loginMenu">
<a href="#" data-toggle="modal" onclick="openLogin()"><i class="fa fa-user"></i><strong> Login</strong></a>
</li>
<li id="userMenu" class="dropdown topbar-profile">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-user"></i> <strong id="user-name">User</strong></a>
<ul class="dropdown-menu">
<li><a href="index.html"><i class="icon-logout-1"></i> Logout</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<!-- Top Bar End -->
<!-- Begin page -->
<div class="container">
<div class="full-content-center">
<p class="text-center"><img src="img/login-logo.png" alt="Conface"></p>
<div class="login-wrap animated flipInX">
<div class="login-block">
<form role="form" action="#">
<div class="form-group login-input">
<i class="fa fa-user overlay"></i>
<input type="text" id="maan" class="form-control text-input" placeholder="Enter someone's Facebook nickname...">
</div>
<div class="form-group login-input">
<i class="fa fa-envelope overlay"></i>
<textarea type="text" id="message" class="form-control text-input" placeholder="Write your message here..."></textarea>
</div>
<button id="send-message" class="btn btn-success btn-block" data-toggle="modal" onclick="sendMessage()">SEND MESSAGE <i class="fa fa-spinner fa-spin" id="message-spinner"></i></button>
</form>
</div>
</div>
</div>
</div>
<div class="modal md-newspaper" id="myModalO">
<div class="md-dialog modal-dialog md-contentR">
<h3>Login or register to send your message!</h3>
<div>
<ul id="demo1" class="nav nav-tabs">
<li class="active">
<a href="#demo1-home" data-toggle="tab">LOG IN</a>
</li>
<li class="">
<a href="#demo1-profile" data-toggle="tab">REGISTER</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in" id="demo1-home">
<div class="login-wrap">
<div class="login-block">
<form role="form" action="#">
<div class="form-group login-input">
<i class="fa fa-user overlay"></i>
<input type="text" class="form-control text-input" id="username" placeholder="Username..." />
</div>
<div class="form-group login-input">
<i class="fa fa-key overlay"></i>
<input type="password" class="form-control text-input" id="password" placeholder="Password..." />
</div>
<div class="row">
<div class="col-sm-12">
<button type="submit" class="btn btn-success btn-block" onclick="login()" id="logInBtn">LOGIN</button>
</div>
</div>
</form>
</div>
</div>
</div> <!-- / .tab-pane -->
<div class="tab-pane fade" id="demo1-profile">
<div class="login-wrap">
<div class="login-block">
<form role="form" action="">
<div class="form-group login-input">
<i class="fa fa-user overlay"></i>
<input type="text" class="form-control text-input" id= "userNameRegister" placeholder="Username...">
</div>
<div class="form-group login-input">
<i class="fa fa-envelope overlay"></i>
<input type="text" class="form-control text-input" id="emailRegister" placeholder="Email address...">
</div>
<div class="form-group login-input">
<i class="fa fa-key overlay"></i>
<input type="password" class="form-control text-input" id="passwordRegister" placeholder="Password...">
</div>
<div class="checkbox">
<label>
<input type="checkbox" class="form-control" id="checkTerms">I accept the <strong><a href='#'>Terms and Conditions</a></strong>
</label>
</div>
<button type="submit" class="btn btn-default btn-block" onclick="register()">REGISTER</button>
</form>
</div>
</div>
</div> <!-- / .tab-pane -->
</div> <!-- / .tab-content -->
</div>
</div><!-- End div .md-content -->
</div><!-- End div .md-modal .md-newspaper -->
<!-- the overlay modal element -->
<div class="md-overlay"></div>
<!-- End of eoverlay modal -->
</body>
</html>