-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile.html
150 lines (128 loc) · 7.1 KB
/
profile.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Log In - VegEatable</title>
<!-- Use mobile-aware viewport -->
<meta name="viewport" content= "width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- COMMON LIBRARIES -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!-- need this for arrow Glyphicon to display correctly -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"
integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30="
crossorigin="anonymous"></script>
<!-- ICONS -->
<script src="https://use.fontawesome.com/9f03d0cffe.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.css" integrity="sha256-D3+gw6JE4hEJ9pnCs+BglSfZ2yG5gF+JGdPJ/v183fo=" crossorigin="anonymous" />
<!-- FONTS -->
<link href="https://fonts.googleapis.com/css?family=EB+Garamond" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Nobile" rel="stylesheet">
<!-- MAIN CSS -->
<link rel="stylesheet" href="profile.css">
</head>
<body>
<div id="container">
<style>
#hovertitle:hover { text-decoration: none; }
</style>
<a href='home.html' id='hovertitle'> <div id="header" > VegEatable</div></a>
<a id="login" href="Login.html"> <b> Log In/Sign Up</b></a>
</div>
<div id = "profile" style="Margin-left:10px; font-size:30px;"><b> Profile Information </b></div>
<label for="first_input" style = "Margin-left:10px;">First Name</label>
<div id = "first_input" style="Margin-left:10px; max-width: 300px;"> <input type="text" class="form-control" placeholder="Mark, etc." id="first_name"> </div>
<label for="second_input" style = "Margin-left:10px;">Last Name</label>
<div id = "second_input" style="Margin-left:10px; max-width: 300px;"> <input type="text" class="form-control" placeholder="Wang, etc." id="second_name"> </div><br>
<div id = "change_names_button" style="Margin-left:10px; width: 60%; max-width: 200px; "> <button type="submit" class="btn btn-block" style="background-color: #66ffa5; clear: both;" onclick="changeNames()"><b>Change Name </b> </button> </div><br>
<div id = "Password" style="Margin-left:10px; font-size:30px;"><b> Change Password </b></div>
<div style="Margin:10px; max-width: 300px;"> <input type="password" class="form-control" placeholder="Old Password" id="old_password"> </div>
<div style="Margin:10px; max-width: 300px;"> <input type="password" class="form-control" placeholder="New Password" id="new_password1"> </div>
<div style="Margin:10px; max-width: 300px;"> <input type="password" class="form-control" placeholder="New Password" id="new_password2"> </div>
<div id = "password_button" style="Margin:10px; width: 60%; max-width: 200px; "> <button type="submit" class="btn btn-block" style="background-color: #66ffa5; clear: both;" onclick="changePassword()"><b>Change Password </b> </button> </div><br>
<label for="signout" style = "Margin-left:10px; font-size: 30px">Signout</label>
<div id = "signout" style="Margin-left:10px; width: 60%; max-width: 200px; "> <button type="submit" class="btn btn-block" style="background-color: #66ffa5; clear: both;" onclick="signout()"><b>Signout </b> </button> </div><br>
</div>
</body>
<script>
item = sessionStorage.getItem("current_username");
if (item != null && item.length > 0){
var login = document.getElementById("login");
login.href = "profile.html"
login.innerHTML = "Welcome " + item.toString()
}
function changeNames(){
first_name = document.getElementById("first_name").value;
second_name = document.getElementById("second_name").value;
email_meta_info_dict = JSON.parse(localStorage.getItem("email_password_dict"));
current_dict = email_meta_info_dict[item.toString()]
if (first_name.length > 0 && second_name.length > 0){
current_dict["first_name"] = first_name
current_dict["last_name"] = second_name
localStorage.setItem("email_meta_info_dict", JSON.stringify(email_meta_info_dict));
window.alert("Changed first and last name")
document.getElementById("first_name").value = ""
document.getElementById("second_name").value = ""
}
else if (first_name.length > 0) {
current_dict["first_name"] = first_name
localStorage.setItem("email_meta_info_dict", JSON.stringify(email_meta_info_dict));
window.alert("Changed first name")
document.getElementById("first_name").value = ""
document.getElementById("second_name").value = ""
}
else if (second_name.length > 0){
current_dict["last_name"] = second_name
localStorage.setItem("email_meta_info_dict", JSON.stringify(email_meta_info_dict));
window.alert("Changed last name")
document.getElementById("first_name").value = ""
document.getElementById("second_name").value = ""
}
else{
window.alert("Please fill out either new first name or new last name")
}
}
function changePassword(){
email_password_dict = JSON.parse(localStorage.getItem("email_password_dict"));
old_pass = document.getElementById("old_password").value;
new_pass1 = document.getElementById("new_password1").value;
new_pass2 = document.getElementById("new_password2").value;
if (old_pass == "" || new_pass1 == "" || new_pass2 == ""){
window.alert("Please fill out all fields")
}
else if (email_password_dict[item.toString()] == old_pass){
if (new_pass1 == new_pass2){
email_password_dict[item.toString()] = new_pass1;
localStorage.setItem("email_password_dict", JSON.stringify(email_password_dict));
window.alert("Changed passwords");
document.getElementById("old_password").value = ""
document.getElementById("new_password1").value = ""
document.getElementById("new_password2").value = ""
}
else{
window.alert("New Passwords do not match")
document.getElementById("old_password").value = ""
document.getElementById("new_password1").value = ""
document.getElementById("new_password2").value = ""
}
}
else{
window.alert("Wrong inputted old password")
document.getElementById("old_password").value = ""
document.getElementById("new_password1").value = ""
document.getElementById("new_password2").value = ""
}
}
function signout(){
sessionStorage.setItem("current_username", "");
window.location = "home.html"
}
function addEdit(){
}
</script>
</html>