-
-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathmain.js
48 lines (39 loc) · 1.15 KB
/
main.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
48
var Observable = require("FuseJS/Observable")
var first = [ "Northern", "Red", "Eastern", "Mountain", "Desert", "Nocturnal", "Southern",
"Western", "Lowland", "Highland", "Snowy" ]
var last = [ "Finch", "Swallow", "Crow", "Owl", "Robin", "Pelican", "Stork", "Pidgeon", "Sparrow",
"Crane", "Hawk", "Condor", "Ewe" ]
function Item() {
this.height = 80 + Math.floor(Math.random() * 100)
this.name = first[Math.floor(Math.random() * first.length)] + " " +
last[Math.floor(Math.random() * last.length)]
this.image = "bird" + (i%2)
this.tintColor = [Math.random()*0.5 + 0.5, Math.random()*0.5 + 0.5, Math.random()*0.5 + 0.5, 1]
}
var loading = Observable(false)
var items = Observable()
var loadNew = function() {
for (i=0; i < 40; i++) {
items.add( new Item() )
}
loading.value = false
}
loadNew()
var deleteItem = function(arg) {
items.tryRemove(arg.data)
}
var clear = function() {
while (items.length > 0)
items.removeAt(0)
}
var startLoading = function(a,b) {
loading.value = true
setTimeout( clear, 700 )
setTimeout( loadNew, 1000 )
}
module.exports = {
items: items,
deleteItem: deleteItem,
startLoading: startLoading,
loading: loading,
}