forked from alkaza/oscar-pages
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadminprocessing.js
More file actions
executable file
·58 lines (45 loc) · 1.71 KB
/
adminprocessing.js
File metadata and controls
executable file
·58 lines (45 loc) · 1.71 KB
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
// adminprocessing.js
// Log into the admin page.
var myServer = new XMLHttpRequest();
String.prototype.hashCode = function (){
var hash = 0;
if (this.length == 0) return hash;
for (i=0; i < this.length; i++){
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash;
}
return hash;
}
$(document).ready(function(){
$("button").click(function(event){
event.preventDefault();
//Get form data from calendar.html
var formData = {
'name' :$('input[id=inputUsername]').val(),
'password' :$('input[id=inputPassword]').val(),
};
localStorage.setItem("name", formData['name']);
// if one of the fields are not filled in
if (formData['name'] == '' || formData['password']==''){
alert("Both fields are required to login.");
window.location.reload();
}
// check whether the login or the signup button is pressed
if ($(this).val() == 'login') {
var hash_name = formData.name.toString().hashCode();
var hash_pass = formData.password.toString().hashCode();
console.log(hash_name + '**********' + hash_pass);
if ((hash_name == 108864489)&&(hash_pass == 481733867)){
localStorage.setItem("hash_name", hash_name);
localStorage.setItem("hash_pass", hash_pass);
alert("Admin login success.");
window.location.assign(window.location.href.replace("admin", "adminpage"));
}
else{
alert("Incorrect login. Try again.");
window.location.reload();
}
}
});
});