-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_account1.html
718 lines (616 loc) · 31.7 KB
/
create_account1.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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Create Account</title>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/fonts/ionicons.min.css">
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css"> -->
<link rel="stylesheet" href="assets/css/Login-Form-Clean-1.css">
<link rel="stylesheet" href="assets/css/Login-Form-Clean.css">
<link rel="stylesheet" href="assets/css/styles.css">
<link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
</head>
<body>
<div class="login-clean part_1">
<form class="form" name="create_account_1">
<h2 class="sr-only">Create Account 1</h2><label></label>
<div class="illustration">
<h3 class="text-center text-muted">Create AcademicKe Account</h3>
</div>
<div class="form-group">
<input class="border rounded form-control form-control-sm" id="username" type="text" name="username"
placeholder="Enter Username" required="" onchange="survey_username(this.value)"
oninput="match_username(this.value)">
<span class="update_response" id="username_feedback"></span>
</div>
<div class="form-group">
<input class="border rounded form-control form-control-sm" id="email" type="email" name="email"
placeholder="e.g. johndoe@pu.ac.ke" required="" data-toggle="tooltip" data-placement="top"
title="Use institution email address">
<span class="update_response" id="email_feedback"></span>
</div>
<div class="form-group">
<input class="border rounded form-control form-control-sm" id="institution" type="text"
name="institution" placeholder="e.g. Pwani University" required="" data-toggle="tooltip"
data-placement="top" title="Use institution email address" disabled>
<span class="update_response" id="institution_feedback"></span>
</div>
<div class="form-group">
<select class="browser-default custom-select form-control-sm" id="designation" name='designation'
required="">
<option class="form-control-sm" value="" disable selected>Select your designation</option>
<option class="form-control-sm" value='undergraduate Student'>Undergraduate Student</option>
<option class="form-control-sm" value='graduate student'>Graduate Student</option>
<option class="form-control-sm" value='lecturer'>Lecturer/Researcher</option>
</select>
<span class="update_response" id="designation_feedback"></span>
</div>
<div class="form-group">
<input class="border rounded form-control form-control-sm" id="specialty" type="text" name="specialty"
placeholder="Your field(s) of specialization">
<span class="update_response" id="specialty_feedback"></span>
</div>
<div class="form-group d-flex p-0 flex-fill align-items-end">
<button class="btn btn-sm text-right ml-auto border rounded" type="button" id="next">
Next >>
</button>
</div>
<a class="forgot" href="login.html">
Already got an account? Click here.
</a>
</form>
</div>
<div class="login-clean part_2">
<form name="create_account_2">
<h2 class="sr-only">Create Account Final</h2>
<div class="illustration">
<h3 class="text-center text-muted">Complete Sign-up</h3>
</div>
<div class="form-group">
<input class="border rounded form-control form-control-sm" type="password" id="password1"
name="password1" placeholder="Set Password" onchange="password_response(this.value)">
<span class="update_response" id="password_1_feedback"></span>
<input class="border rounded form-control form-control-sm" type="password" id="password2"
name="password2" placeholder="Confirm Password">
<span class="update_response" id="password_feedback"></span>
</div>
<div class="form-group">
<span id="request_sent" class="p-1">
<button class="btn btn-success btn-block border rounded" id="create_account" type="button">Create
Account</button>
<button class="btn btn-sm border rounded" type="button" id="back"><<
Back</button>
</span>
</div>
<a class="forgot" href="login.html">Already got an account? Click here.</a>
</form>
</div>
<div class="login-clean part_3" id="part_3">
<div class="login-clean part_3">
<form method="POST" enctype="multipart/form-data">
<div class="illustration">
<h3 class="text-center text-muted">Upload Profile Picture</h3>
</div>
<div class="form-group flex-column p-1 d-flex align-content-center ">
<!-- <input type="file" id="profile_img_signup_form" name="profile_image" value="Select Profile Picture">
<input id="profile_img_signup_submit" value="Upload Profile Picture"> -->
<div id="upload_img_signup">
<img id="profile_img_edit_profile_page" src="files\\profile\\img\\default.png"
class="profile_image rounded-circle border img-responsive shadow-sm visible flex-fill"
loading=" lazy" />
<input type="file" id="edit_profile_img" onchange="show_image(this)" name="edit_profile_img"
style="opacity:0;">
</div>
<button class="btn btn-success btn-block border rounded" id="complete_signup" type="button">Complete
Signup</button>
</div>
</form>
</div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/common_functions.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/bs-init.js"></script>
<style>
#next {
margin-top: 1vh;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$('.part_2').css({ "display": "none" })
$('.part_3').css({ "display": "none" })
})
$('#email').on('input', function () {
$('#email_feedback').html('');
})
$('#email').on('change', function () {
var email = $("#email").val();
$.ajax({
method: 'GET',
url: 'REST_api/emails?email=' + email,
processData: false,
contentType: 'application/json',
data: '',
success: function (res) {
console.log(res);
if (res == "email in use") {
$('#email_feedback').html('<i class = "fa fa-times"></i>email address already in use. Please use another address or <a href = "login.html">Click here to Log in</a>.');
document.create_account_1.email.value = "";
document.create_account_1.email.focus();
}
var domain = email.substr(email.indexOf('@') + 1);
atpos = email.indexOf("@");
dotpos = email.lastIndexOf(".");
if (atpos < 1 || (dotpos - atpos < 2)) {
$('#email_feedback').html('<i class = "fa fa-times"></i>please provide a valid organization email address.');
document.create_account_1.email.focus();
}
domain = domain.split('.');
domain = domain[0];
switch (domain) {
case "pu":
$('#institution').val("Pwani University");
break;
case "jkuat":
$('#institution').val("Jomo Kenyatta University of Agriculture and Technology");
break;
case "ku":
$('#institution').val("Kenyatta University");
break;
case "uonbi":
$('#institution').val("University of Nairobi");
break;
case "tukenya":
$('#institution').val("Technical University of Kenya");
break;
case "mku":
$('#institution').val("Mount Kenya University");
break;
case "aua":
$('#institution').val("Adventist University of Africa");
break;
case "africainternational":
$('#institution').val("Africa International University");
break;
case "anu":
$('#institution').val("Africa Nazarene University");
break;
case "airads":
$('#institution').val("African Institute of Research and Development Studies");
break;
case "airtravelcentre":
$('#institution').val("Air Travel and Related Studies Centre");
break;
case "alphax":
$('#institution').val("Alphax College");
break;
case "chuka":
$('#institution').val("Chuka University");
break;
case "cit":
$('#institution').val("Coast Institute of Technology");
break;
case "chrm":
$('#institution').val("College of Human Resource Management");
break;
case "daystar":
$('#institution').val("Daystar University");
break;
case "dkut":
$('#institution').val("Dedan Kimathi University of Technology");
break;
case "dimacollege":
$('#institution').val("Dima College");
break;
case "easm":
$('#institution').val("East Africa School of Management");
break;
case "east":
$('#institution').val("East Africa School of Technology");
break;
case "eaics":
$('#institution').val("East African Institute of Certified Studies");
break;
case "egerton":
$('#institution').val("Egerton University");
break;
case "eati":
$('#institution').val("Eldoret Aviation Training Institute");
break;
case "embuni":
$('#institution').val("Embu University College");
break;
case "gluk":
$('#institution').val("Great Lakes University of Kisumu");
break;
case "git":
$('#institution').val("Gusii Institute of Technology");
break;
case "hekima":
$('#institution').val("Hekima University College");
break;
case "iat":
$('#institution').val("Institute of Advanced Technology");
break;
case "ict":
$('#institution').val("International Centre of Technology");
break;
case "iu":
$('#institution').val("International University of Professional Studies");
break;
case "iti":
$('#institution').val("Intraglobal Training Institute");
break;
case "jooust":
$('#institution').val("Jaramogi Oginga Odinga University of Science and Technology");
break;
case "kabarak":
$('#institution').val("Kabarak University");
break;
case "kca":
$('#institution').val("Kenya College of Accountancy");
break;
case "kheu":
$('#institution').val("Kenya Highlands Evangelical University");
break;
case "kias":
$('#institution').val("Kenya Institute of Applied Sciences");
break;
case "kibco":
$('#institution').val("Kenya Institute of Business and Counselling Studies");
break;
case "kidstudies":
$('#institution').val("Kenya Institute of Development Studies");
break;
case "kim":
$('#institution').val("Kenya Institute of Management");
break;
case "kips":
$('#institution').val("Kenya Institute of Professional Studies");
break;
case "kiswcd":
$('#institution').val("Kenya Institute of Social Work and Community Develoment");
break;
case "kmtc":
$('#institution').val("Kenya Medical Training College");
break;
case "kemu":
$('#institution').val("Kenya Methodist University");
break;
case "ksg":
$('#institution').val("Kenya School of Government");
break;
case "ksms":
$('#institution').val("Kenya School of Monetary Studies");
break;
case "kttc":
$('#institution').val("Kenya Technical Training College");
break;
case "kist":
$('#institution').val("Kiambu Institute of Science and Technology");
break;
case "kababiiuniversity":
$('#institution').val("Kababii University College");
break;
case "kyuc":
$('#institution').val("Kirinyaga University College");
break;
case "kwust":
$('#institution').val("Kiriri University of Science and Technology");
break;
case "kisiiuniversity":
$('#institution').val("Kisii University");
break;
case "kisunupoly":
$('#institution').val("Kisumu Polytechnic");
break;
case "laikipia":
$('#institution').val("Laikipia Univeristy");
break;
case "lukenyauniversity":
$('#institution').val("Lukenya Univeristy");
break;
case "mmarau":
$('#institution').val("Maasai Mara Univeristy");
break;
case "mit":
$('#institution').val("Machakos Institute of Technology");
break;
case "machakosuniversity":
$('#institution').val("Machakos University");
break;
case "miuc":
$('#institution').val("Maarist International University College");
break;
case "maseno":
$('#institution').val("Maseno University");
break;
case "mmust":
$('#institution').val("Masinde Muliro University of Science and Technology");
break;
case "mu":
$('#institution').val("Moi University");
break;
case "mru":
$('#institution').val("Murang'a University");
break;
case "pacuniversity":
$('#institution').val("Pan African Christian University");
break;
case "piu":
$('#institution').val("Pioneer International University");
break;
case "rti":
$('#institution').val("Railway Training Institute");
break;
case "riarauniversity":
$('#institution').val("Riara University");
break;
case "rvist":
$('#institution').val("Rift Valley Institute of Science and Technology");
break;
case "ruc":
$('#institution').val("Rongo University College");
break;
case "spu":
$('#institution').val("Saint Pauls University");
break;
case "strathmore":
$('#institution').val("Strathmore University");
break;
case "ttuc":
$('#institution').val("Taita Taveta University");
break;
case "tum":
$('#institution').val("Technical University of Mombasa");
break;
case "cuea":
$('#institution').val("Catholic University of Eastern Africa");
break;
case "teau":
$('#institution').val("The East African University");
break;
case "puea":
$('#institution').val("Presbyterian University of Eastern Africa");
break;
case "usiu":
$('#institution').val("United States International University");
break;
case "uoeld":
$('#institution').val("University of Eldoret");
break;
case "kabianga":
$('#institution').val("University of Kabianga");
break;
case "zetech":
$('#institution').val("Zetech University");
break;
default:
$('#email_feedback').html('<i class = "fa fa-times"></i>please provide a valid organization email address.');
}
}
});
});
$('#create_account').click(function () {
if (validate_2()) {
$.ajax({
method: "POST",
url: "REST_api/users",
processData: false,
contentType: "application/json",
data: '{ "username": "' + $("#username").val() + '", "email": "' + $("#email").val() + '", "designation": "' + $("#designation").val() + '", "institution": "' + $("#institution").val() + '","specialty": "' + $("#specialty").val() + '", "password1": "' + $("#password1").val() + '", "password2": "' + $("#password2").val() + '"}',
success: function (r) {
console.log(r)
var res = JSON.parse(r);
//to check whether the user has gotten their account verified
var get_verified = setInterval(function () {
$.ajax({
method: "GET",
url: "REST_api/verify?user_id=" + res.Id + "&check",
processData: false,
contentType: "application/json",
data: '',
success: function (r) {
if (r == "verified") {
//stop timer and stop sending verify requests and go to next page
clearInterval(timer);
$('.part_3').css({ "display": "block" });
$('.part_2').css({ "display": "none" });
clearInterval(get_verified);
}
},
error: function (r) {
console.log(r);
}
});
}, 5000);
verify(res.Id, get_verified);
//when the timer runs out and the user requests a new verification email
$('#resend_email').click(function () {
verify(res.Id);
});
$('#cancel_request').click(function () {
$.ajax({
method: "GET",
url: "REST_api/verify?user_id=" + res.Id + "&cancel",
processData: false,
contentType: "application/json",
data: '',
success: function (r) {
//stop timer and stop sending verify requests and go to next page
location.reload();
},
error: function (r) {
console.log(r);
}
});
})
$('#complete_signup').on('click', function () {
var file_data = $('#edit_profile_img').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
alert(form_data);
$.ajax({
method: 'POST',
url: 'REST_api/profile_image?id=' + res.Id,
processData: false,
dataType: 'text',
cache: 'false',
contentType: false,
data: form_data,
success: function (php_script_response) {
alert(php_script_response);
}
});
window.location.href = "users.html";
})
},
error: function (r) {
console.log(r)
}
});
}
});
$('#profile_img_edit_profile_page').click(function () {
$('#edit_profile_img').click();
});
$('#back').click(function () {
$('.part_1').css({ "display": "block" })
$('.part_2').css({ "display": "none" })
});
$('#next').click(function () {
if (validate()) {
$('.part_2').css({ "display": "block" })
$('.part_1').css({ "display": "none" })
}
});
$(function () {
$("[data-toggle = 'tooltip']").tooltip();
})
// Form validation code will come here.
function validate() {
if (document.create_account_1.username.value == "") {
$('#username_feedback').html('<i class = "fa fa-times"></i>please enter a username.');
document.create_account_1.username.focus();
return false;
} else if (!match_username(document.create_account_1.username.value)) {
return false
}
if (document.create_account_1.email.value == "") {
$('#email_feedback').html('<i class = "fa fa-times"></i>please provide a valid organization email address.');
document.create_account_1.email.focus();
return false;
}
if (document.create_account_1.institution.value == "") {
$('#institution_feedback').html('<i class = "fa fa-times"></i>please select your institution from the list.');
document.create_account_1.institution.focus();
return false;
}
if (document.create_account_1.designation.value == "") {
$('#designation_feedback').html('<i class = "fa fa-times"></i>please select your designation from the list.');
return false;
}
if (document.create_account_1.specialty.value == "") {
$('#specialty_feedback').html('<i class = "fa fa-times"></i>please enter your field of specialization.');
document.create_account_1.specialty.focus();
return false;
}
return (true);
}
//validating the passwords
function validate_2() {
if ((document.create_account_2.password1.value != document.create_account_2.password2.value) || (document.create_account_2.password1.value == "")) {
$('#password_feedback').html('<i class = "fa fa-times"></i>passwords don\'t match');
return false;
} else if (document.create_account_2.password1.value.length < 6) {
$('#password_feedback').html('<i class = "fa fa-times"></i>minimum password length is 6 characters');
return false;
}
return true;
}
function password_response(password) {
if (password.length < 6) {
$('#password_1_feedback').html('<i class = "fa fa-times"></i>minimum password length is 6 characters');
}
}
//making sure the username doesnt contain illegal characters
function match_username(value) {
$('#username_feedback').html('');
if (value.match(/[^a-zA-Z0-9_ ]+/)) {
$('#username_feedback').html('<i class = "fa fa-times"></i>only alphabets(a-z, A-Z), numerals(1-9) and underscores(_) allowed.');
return false;
} else {
return true;
}
}
//verify a new user account
function verify(user_id, get_verified) {
$.ajax({
method: 'GET',
url: 'REST_api/verify?user_id=' + user_id,
data: '',
processData: false,
contentType: 'application/json',
success: function (r) {
console.log('inside verify');
if (r == "not verified") {
$('#request_sent').html('<span>A verification email has been sent to the email address you provided. Please verify your account within 5 minutes.</span><br> <span id = "timer"></span>');
var minutes = 0, seconds = 60;
//for the countdown
var timer = setInterval(function () {
seconds--;
if (seconds < 10) {
$('#timer').html('' + minutes + ' : 0' + seconds + '');
} else {
$('#timer').html('' + minutes + ' : ' + seconds + '');
}
if (minutes == 00) {
$('#timer').html('0 : ' + seconds + '');
if (seconds < 10) {
$('#timer').html('' + minutes + ' : 0' + seconds + '');
}
//when timer elapses, stop sending verification requests and display button to resend activation link
if (seconds == 00) {
clearInterval(timer);
clearInterval(get_verified);
$('#request_sent').html('<span><button class="btn-success" id="resend_email">Resend Email</button></span> <span><button class = "btn-danger" id = "cancel_request">Cancel</button></span>');
}
}
if (seconds == 00) {
minutes--;
seconds = 60;
}
}, 1000);
}
}
});
}
//check username availability
function survey_username(username) {
$.ajax({
method: 'GET',
url: 'REST_api/usernames?username=' + username,
contentType: 'application/json',
data: '',
success: function (r) {
console.log(r);
if (r == 'username unavailable') {
$('#username_feedback').html('<i class = "fa fa-times"></i>That username is already in use.');
document.create_account_1.username.value = "";
}
}
})
}
$('.form-group').change(function () {
$('.update_response').text('');
})
//this guy displays the tooltips
$(function () {
$("[data-toggle = 'tooltip']").tooltip();
})
</script>
</body>
</html>