|
@@ -1,5 +1,6 @@
|
|
History = new Mongo.Collection("history");
|
|
History = new Mongo.Collection("history");
|
|
Playlists = new Mongo.Collection("playlists");
|
|
Playlists = new Mongo.Collection("playlists");
|
|
|
|
+Rooms = new Mongo.Collection("rooms");
|
|
|
|
|
|
if (Meteor.isClient) {
|
|
if (Meteor.isClient) {
|
|
Meteor.startup(function() {
|
|
Meteor.startup(function() {
|
|
@@ -107,6 +108,11 @@ if (Meteor.isClient) {
|
|
})
|
|
})
|
|
});
|
|
});
|
|
$("#stop").show();
|
|
$("#stop").show();
|
|
|
|
+ },
|
|
|
|
+ "click #croom_create": function(){
|
|
|
|
+ Meteor.call("createRoom", $("#croom").val(), function(err, res) {
|
|
|
|
+ console.log(err, res);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -177,6 +183,9 @@ if (Meteor.isClient) {
|
|
},
|
|
},
|
|
artist: function(){
|
|
artist: function(){
|
|
return Session.get("artist");
|
|
return Session.get("artist");
|
|
|
|
+ },
|
|
|
|
+ loaded: function() {
|
|
|
|
+ return Session.get("loaded");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -324,31 +333,32 @@ if (Meteor.isClient) {
|
|
|
|
|
|
Meteor.subscribe("history");
|
|
Meteor.subscribe("history");
|
|
Meteor.subscribe("playlists");
|
|
Meteor.subscribe("playlists");
|
|
|
|
+ Meteor.subscribe("rooms", function() {
|
|
|
|
+ Session.set("loaded", false);
|
|
|
|
+ if (Rooms.find({type: type}).fetch().length === 1) {
|
|
|
|
+ window.location = "/";
|
|
|
|
+ } else {
|
|
|
|
+ Session.set("loaded", true);
|
|
|
|
+ Meteor.setInterval(function() {
|
|
|
|
+ var data = undefined;
|
|
|
|
+ var dataCursor = History.find({type: type});
|
|
|
|
+ dataCursor.map(function(doc) {
|
|
|
|
+ if (data === undefined) {
|
|
|
|
+ data = doc;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (data !== undefined && data.history.length > size) {
|
|
|
|
+ currentSong = data.history[data.history.length-1];
|
|
|
|
+ size = data.history.length;
|
|
|
|
+ startSong();
|
|
|
|
+ }
|
|
|
|
+ }, 1000);
|
|
|
|
|
|
- var room_types = ["edm", "nightcore"];
|
|
|
|
- if (room_types.indexOf(type) === -1) {
|
|
|
|
- window.location = "/";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Meteor.setInterval(function() {
|
|
|
|
- var data = undefined;
|
|
|
|
- var dataCursor = History.find({type: type});
|
|
|
|
- dataCursor.map(function(doc) {
|
|
|
|
- if (data === undefined) {
|
|
|
|
- data = doc;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- if (data !== undefined && data.history.length > size) {
|
|
|
|
- currentSong = data.history[data.history.length-1];
|
|
|
|
- size = data.history.length;
|
|
|
|
- startSong();
|
|
|
|
|
|
+ Meteor.setInterval(function() {
|
|
|
|
+ resizeSeekerbar();
|
|
|
|
+ }, 50);
|
|
}
|
|
}
|
|
- }, 1000);
|
|
|
|
-
|
|
|
|
- Meteor.setInterval(function() {
|
|
|
|
- resizeSeekerbar();
|
|
|
|
- }, 50);
|
|
|
|
-
|
|
|
|
|
|
+ });
|
|
});
|
|
});
|
|
|
|
|
|
Template.admin.events({
|
|
Template.admin.events({
|
|
@@ -413,11 +423,11 @@ if (Meteor.isServer) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- var room_types = ["edm", "nightcore"];
|
|
|
|
|
|
+ //var room_types = ["edm", "nightcore"];
|
|
var songsArr = [];
|
|
var songsArr = [];
|
|
|
|
|
|
-
|
|
|
|
- room_types.forEach(function(type) {
|
|
|
|
|
|
+ Rooms.find({}).fetch().forEach(function(room) {
|
|
|
|
+ var type = room.type;
|
|
if (Playlists.find({type: type}).fetch().length === 0) {
|
|
if (Playlists.find({type: type}).fetch().length === 0) {
|
|
if (type === "edm") {
|
|
if (type === "edm") {
|
|
Playlists.insert({type: type, songs: [
|
|
Playlists.insert({type: type, songs: [
|
|
@@ -460,8 +470,6 @@ if (Meteor.isServer) {
|
|
songTimer();
|
|
songTimer();
|
|
});
|
|
});
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
ServiceConfiguration.configurations.remove({
|
|
ServiceConfiguration.configurations.remove({
|
|
service: "facebook"
|
|
service: "facebook"
|
|
});
|
|
});
|
|
@@ -490,6 +498,10 @@ if (Meteor.isServer) {
|
|
return Playlists.find({})
|
|
return Playlists.find({})
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ Meteor.publish("rooms", function() {
|
|
|
|
+ return Rooms.find()
|
|
|
|
+ });
|
|
|
|
+
|
|
Meteor.methods({
|
|
Meteor.methods({
|
|
createUserMethod: function(formData, captchaData) {
|
|
createUserMethod: function(formData, captchaData) {
|
|
var verifyCaptchaResponse = reCAPTCHA.verifyCaptcha(this.connection.clientAddress, captchaData);
|
|
var verifyCaptchaResponse = reCAPTCHA.verifyCaptcha(this.connection.clientAddress, captchaData);
|
|
@@ -508,7 +520,7 @@ if (Meteor.isServer) {
|
|
},
|
|
},
|
|
addPlaylistSong: function(type, songData) {
|
|
addPlaylistSong: function(type, songData) {
|
|
type = type.toLowerCase();
|
|
type = type.toLowerCase();
|
|
- if (room_types.indexOf(type) !== -1) {
|
|
|
|
|
|
+ if (Rooms.find({type: type}).fetch().length === 1) {
|
|
if (songData !== undefined && Object.keys(songData).length === 4 && songData.type !== undefined && songData.title !== undefined && songData.title !== undefined && songData.artist !== undefined) {
|
|
if (songData !== undefined && Object.keys(songData).length === 4 && songData.type !== undefined && songData.title !== undefined && songData.title !== undefined && songData.artist !== undefined) {
|
|
songData.duration = getSongDuration(songData.title);
|
|
songData.duration = getSongDuration(songData.title);
|
|
Playlists.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, type: songData.type}}});
|
|
Playlists.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, type: songData.type}}});
|