-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplaylist.js
62 lines (54 loc) · 1.24 KB
/
playlist.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Songs = new Meteor.Collection("songs");
if (Meteor.is_client) {
Template.playlist.songs = function () {
return Songs.find();
};
Template.navbar.events = {
'click div#addSong': function () {
Songs.insert({
title: "Click to edit title"
, lyrics: "Click to edit lyrics"
});
}
};
Template.song.events = {
'click': function () {
var $song = $("div#"+this._id);
$song
.find("div.edit, h2")
.hallo();
},
'click button#save': function () {
var $song = $("div#"+this._id);
Songs.update({_id: this._id},
{$set: {
title: $song.find("h2").html()
, lyrics: $song.find(".edit").html()
}}
);
},
'click button#del': function () {
Songs.remove({_id: this._id});
}
};
};
if (Meteor.is_server) {
Meteor.startup(function () {
if (Songs.find().count() === 0) {
Songs.insert({
title: "Curbside Prophet"
, lyrics: "I'm a curbside prophet <br> \
with my hand in my pocket <br> \
and I'm waiting for <br> \
my rocket to come."
});
Songs.insert({
title: "Let it Be"
, lyrics: "When I find myself in times of trouble <br> \
Mother Mary calls to me, <br> \
Speaking words of wisdom<br> \
Let it be."
});
}
});
};