This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (42 loc) · 1.76 KB
/
index.js
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
$(function() {
var whenSignedIn = function() {
$("#login-signup").empty().append($('<span><a href="#" id="log-out-button" class="btn">Logout</a></span>'));
var name = ""
if (localStorage["name"] == undefined) {
name = "";
} else {
name = localStorage["name"].split(" ")[0];
}
$(".description").empty().append($('<div class="statistic">Welcome back '+ name +'.</div>'
+'<div class="motivation">Take the next step.'
+'<div id="bold" class="stop-smoking-signup-link">Keep going. </div></div>'));
$(".stop-smoking-signup-link").on("click", function() {
location.href="./myprogress.html";
});
$("#log-out-button").on("click", function() {
localStorage["signed-in"] = "false";
whenNotSignedIn();
});
}
var whenNotSignedIn = function() {
$("#login-signup").empty().append($('<span><a href="#" id="log-in-button" class="btn">Log-in </a>| </span><span><a href="#" id="sign-up-button" class="btn">Sign-up</a></span>'));
$(".description").empty().append($('<div class="statistic">8.6 million people in the U.S. have at least one serious illness caused by smoking.</div>'
+'<div class="motivation">Take the first step.'
+'<div id="bold" class="stop-smoking-signup-link">Stop smoking today. </div></div>'));
$(".stop-smoking-signup-link").on("click", function() {
location.href="./StepOne.html";
});
$("#sign-up-button").on("click", function() {
location.href="./StepOne.html";
});
$("#log-in-button").on("click", function() {
localStorage["signed-in"] = "true";
whenSignedIn();
});
}
if (localStorage["signed-in"] == "true") {
whenSignedIn();
} else {
whenNotSignedIn()
}
});