-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.html
64 lines (48 loc) · 1.72 KB
/
main.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Local Storage</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS dependencies -->
<link href="libs/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">Local Storage</a>
</div>
</div>
</div>
<div class="container">
<p>Please enter your name</p>
<p>
<input type="text" id="studentName" size="40" value="John Doe" />
<span id="lastSaved"></span>
</p>
<p><a id="btn-save" class="btn btn-primary btn-large">Save Data</a></p>
</div>
<!-- ================================================== -->
<!-- Javascript placed at the end of the document so the pages load faster -->
<!-- jQuery, needed both for activity and boostrap -->
<script language="javascript" type="text/javascript" src="libs/jquery.js"></script>
<!-- Bootstrap, for the nice looking interface -->
<script src="libs/bootstrap/js/bootstrap-button.js"></script>
<!-- Custom activity script -->
<script language="javascript" type="text/javascript">
var $input = $("input#studentName");
if(localStorage.studentName) {
$('span#lastSaved').html('(last saved: ' + localStorage.studentName + ")")
}
$('#btn-save').click(function () {
var studentName = $input.val();
localStorage.studentName=studentName;
localStorage.completedActivity1=true;
});
</script>
</body>
</html>