-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
78 lines (63 loc) · 1.68 KB
/
index.html
File metadata and controls
78 lines (63 loc) · 1.68 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html>
<head>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="app">
<div class="people">
<div v-for="person in people">{{ person.name }}, {{ person.age(day) }}</div>
<div class="new-person" >
<input v-model="newName" placeholder="new person name here"/>
<input v-model.number ="newAge" placeholder="new person age here" type="number"/>
<button @click="makePerson()">Add</button>
</div>
</div>
<div>Current Day: {{ day }}</div>
<div><button @click="advanceTime(10)">10 Days</button></div>
<div class="traits">
<div v-for="trait in allTraits">
<div class="name">{{ trait.name }}</div>
<div class="description">{{ trait.description }}</div>
</div>
</div>
</div>
<script>
var yearLength = 365;
var app = new Vue({
el: '#app',
data: {
text: "",
day: 0,
chosenTraits: [
],
allTraits: [
],
people: [
],
},
methods: {
makePerson: function(){
var name = this.newName;
var age = this.newAge;
var newPerson = new Person(name, age, this.day);
this.people.push(newPerson);
this.newName = null;
this.birthdate = null;
},
advanceTime: function(days){
this.day += days;
}
},
});
function Person(name, age, day){
this.name = name;
this.birthdate = day - age * yearLength;
}
Person.prototype = {
age: function(day) {
return (day - this.birthdate) / yearLength;
}
}
</script>
</body>
</html>