|
@@ -13,6 +13,32 @@ Meteor.startup(function() {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+/* Global Helpers */
|
|
|
|
+Handlebars.registerHelper("isAdmin", function(argument){
|
|
|
|
+ if (Meteor.user() && Meteor.user().profile) {
|
|
|
|
+ return Meteor.user().profile.rank === "admin";
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+Handlebars.registerHelper("isModerator", function(argument){
|
|
|
|
+ if (Meteor.user() && Meteor.user().profile && (Meteor.user().profile.rank === "admin" || Meteor.user().profile.rank === "moderator")) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+Handlebars.registerHelper("initials", function(argument){
|
|
|
|
+ var user = Meteor.user();
|
|
|
|
+ if (user !== undefined) {
|
|
|
|
+ return user.profile.username[0].toUpperCase();
|
|
|
|
+ } else {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+
|
|
Deps.autorun(function() {
|
|
Deps.autorun(function() {
|
|
Meteor.subscribe("queues");
|
|
Meteor.subscribe("queues");
|
|
Meteor.subscribe("reports");
|
|
Meteor.subscribe("reports");
|
|
@@ -125,7 +151,7 @@ Template.settings.events({
|
|
});
|
|
});
|
|
|
|
|
|
Template.profile.events({
|
|
Template.profile.events({
|
|
- //Edit reak name
|
|
|
|
|
|
+ //Edit real name
|
|
"click #edit-name": function(){
|
|
"click #edit-name": function(){
|
|
$("#name").hide();
|
|
$("#name").hide();
|
|
$("#name-div").show();
|
|
$("#name-div").show();
|
|
@@ -170,6 +196,7 @@ Template.profile.events({
|
|
$("#username").text("Username: " + newUserName);
|
|
$("#username").text("Username: " + newUserName);
|
|
$("#input-username").val("")
|
|
$("#input-username").val("")
|
|
Meteor.call("updateUserName", username, newUserName);
|
|
Meteor.call("updateUserName", username, newUserName);
|
|
|
|
+ window.location = "/u/" + newUserName;
|
|
},
|
|
},
|
|
"click #cancel-username": function(){
|
|
"click #cancel-username": function(){
|
|
$("#username").show();
|
|
$("#username").show();
|
|
@@ -177,6 +204,28 @@ Template.profile.events({
|
|
$("#edit-username").show();
|
|
$("#edit-username").show();
|
|
$("#cancel-username").hide();
|
|
$("#cancel-username").hide();
|
|
$("#input-username").val("");
|
|
$("#input-username").val("");
|
|
|
|
+ },
|
|
|
|
+ // Admins only Edit Rank
|
|
|
|
+ "click #edit-rank": function() {
|
|
|
|
+ $("#rank").hide();
|
|
|
|
+ $("#rank-div").show();
|
|
|
|
+ $("#edit-rank").hide();
|
|
|
|
+ $("#cancel-rank").show();
|
|
|
|
+ },
|
|
|
|
+ "click #submit-rank": function() {
|
|
|
|
+ $("#rank").show();
|
|
|
|
+ $("#rank-div").hide();
|
|
|
|
+ $("#edit-rank").show();
|
|
|
|
+ $("#cancel-rank").hide();
|
|
|
|
+ var newRank = $("#select-rank option:selected").val();
|
|
|
|
+ var username = Session.get("username");
|
|
|
|
+ console.log(username, newRank);
|
|
|
|
+ },
|
|
|
|
+ "click #cancel-rank": function() {
|
|
|
|
+ $("#rank").show();
|
|
|
|
+ $("#rank-div").hide();
|
|
|
|
+ $("#edit-rank").show();
|
|
|
|
+ $("#cancel-rank").hide();
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
@@ -226,13 +275,6 @@ Template.profile.helpers({
|
|
});
|
|
});
|
|
return dislikedArr;
|
|
return dislikedArr;
|
|
},
|
|
},
|
|
- initials: function() {
|
|
|
|
- if (Session.get("username") !== undefined) {
|
|
|
|
- return Session.get("username")[0].toUpperCase();
|
|
|
|
- } else {
|
|
|
|
- return "";
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
isUser: function(){
|
|
isUser: function(){
|
|
var parts = Router.current().url.split('/');
|
|
var parts = Router.current().url.split('/');
|
|
var username = parts.pop();
|
|
var username = parts.pop();
|
|
@@ -305,33 +347,8 @@ Handlebars.registerHelper('active', function(path) {
|
|
});
|
|
});
|
|
|
|
|
|
Template.header.helpers({
|
|
Template.header.helpers({
|
|
- currentUser: function() {
|
|
|
|
- return Meteor.user();
|
|
|
|
- },
|
|
|
|
userId: function() {
|
|
userId: function() {
|
|
return Meteor.userId();
|
|
return Meteor.userId();
|
|
- },
|
|
|
|
- initials: function() {
|
|
|
|
- var user = Meteor.user();
|
|
|
|
- if (user !== undefined) {
|
|
|
|
- return user.profile.username[0].toUpperCase();
|
|
|
|
- } else {
|
|
|
|
- return "";
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- isAdmin: function() {
|
|
|
|
- if (Meteor.user() && Meteor.user().profile) {
|
|
|
|
- return Meteor.user().profile.rank === "admin";
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- isModerator: function() {
|
|
|
|
- if (Meteor.user() && Meteor.user().profile && (Meteor.user().profile.rank === "admin" || Meteor.user().profile.rank === "moderator")) {
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -342,6 +359,9 @@ Template.header.events({
|
|
if (hpSound !== undefined) {
|
|
if (hpSound !== undefined) {
|
|
hpSound.stop();
|
|
hpSound.stop();
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ "click #profile": function(){
|
|
|
|
+ window.location = "/u/" + Meteor.user().profile.username;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -448,20 +468,6 @@ Template.dashboard.helpers({
|
|
} else {
|
|
} else {
|
|
return {};
|
|
return {};
|
|
}
|
|
}
|
|
- },
|
|
|
|
- isAdmin: function() {
|
|
|
|
- if (Meteor.user() && Meteor.user().profile) {
|
|
|
|
- return Meteor.user().profile.rank === "admin";
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- isModerator: function() {
|
|
|
|
- if (Meteor.user() && Meteor.user().profile && (Meteor.user().profile.rank === "admin" || Meteor.user().profile.rank === "moderator")) {
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -1111,20 +1117,6 @@ Template.room.helpers({
|
|
loaded: function() {
|
|
loaded: function() {
|
|
return Session.get("loaded");
|
|
return Session.get("loaded");
|
|
},
|
|
},
|
|
- isAdmin: function() {
|
|
|
|
- if (Meteor.user() && Meteor.user().profile) {
|
|
|
|
- return Meteor.user().profile.rank === "admin";
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- isModerator: function() {
|
|
|
|
- if (Meteor.user() && Meteor.user().profile && (Meteor.user().profile.rank === "admin" || Meteor.user().profile.rank === "moderator")) {
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
paused: function() {
|
|
paused: function() {
|
|
return Session.get("state") === "paused";
|
|
return Session.get("state") === "paused";
|
|
},
|
|
},
|
|
@@ -1256,31 +1248,49 @@ Template.admin.helpers({
|
|
});
|
|
});
|
|
|
|
|
|
Template.admin.events({
|
|
Template.admin.events({
|
|
- "click #croom_create": function() {
|
|
|
|
- Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), function (err, res) {
|
|
|
|
- if (err) {
|
|
|
|
- alert("Error " + err.error + ": " + err.reason);
|
|
|
|
- } else {
|
|
|
|
- window.location = "/" + $("#croom_tag").val();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- "click a": function(e){
|
|
|
|
- var id = e.currentTarget.id;
|
|
|
|
- console.log(id.toLowerCase());
|
|
|
|
- Session.set("playlistToEdit", id);
|
|
|
|
- }
|
|
|
|
|
|
+ "click #croom_create": function() {
|
|
|
|
+ Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), function (err, res) {
|
|
|
|
+ if (err) {
|
|
|
|
+ alert("Error " + err.error + ": " + err.reason);
|
|
|
|
+ } else {
|
|
|
|
+ window.location = "/" + $("#croom_tag").val();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ "click a": function(e){
|
|
|
|
+ var id = e.currentTarget.id;
|
|
|
|
+ console.log(id.toLowerCase());
|
|
|
|
+ Session.set("playlistToEdit", id);
|
|
|
|
+ },
|
|
|
|
+ "click #croom_create": function() {
|
|
|
|
+ Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), $("#two").prop("checked"), function (err, res) {
|
|
|
|
+ if (err) {
|
|
|
|
+ alert("Error " + err.error + ": " + err.reason);
|
|
|
|
+ } else {
|
|
|
|
+ window.location = "/" + $("#croom_tag").val();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ "click #rreset_confirm": function(){
|
|
|
|
+ $('#confirmModal').modal('hide');
|
|
|
|
+ Meteor.call("resetRating");
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
Template.stations.helpers({
|
|
Template.stations.helpers({
|
|
playlist: function() {
|
|
playlist: function() {
|
|
var query = {type: Session.get("playlistToEdit").toLowerCase()};
|
|
var query = {type: Session.get("playlistToEdit").toLowerCase()};
|
|
var playlists = Playlists.find(query).fetch();
|
|
var playlists = Playlists.find(query).fetch();
|
|
- console.log(Session.get("playlistToEdit"), query, playlists);
|
|
|
|
return playlists;
|
|
return playlists;
|
|
},
|
|
},
|
|
whichStation: function(){
|
|
whichStation: function(){
|
|
return Session.get("playlistToEdit");
|
|
return Session.get("playlistToEdit");
|
|
|
|
+ },
|
|
|
|
+ reports: function() {
|
|
|
|
+ var query = {room: Session.get("playlistToEdit").toLowerCase()};
|
|
|
|
+ var reports = Reports.find(query).fetch();
|
|
|
|
+ console.log(reports);
|
|
|
|
+ return reports;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -1340,9 +1350,6 @@ Template.stations.events({
|
|
$("#duration").val(this.duration);
|
|
$("#duration").val(this.duration);
|
|
$("#skip-duration").val(this.skipDuration);
|
|
$("#skip-duration").val(this.skipDuration);
|
|
},
|
|
},
|
|
- "click #rreset_confirm": function(e){
|
|
|
|
- Meteor.call("resetRating");
|
|
|
|
- },
|
|
|
|
"click .add-song-button": function(e){
|
|
"click .add-song-button": function(e){
|
|
var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
|
|
var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
|
|
Meteor.call("addSongToPlaylist", genre, this);
|
|
Meteor.call("addSongToPlaylist", genre, this);
|
|
@@ -1482,15 +1489,6 @@ Template.stations.events({
|
|
}, 10000);
|
|
}, 10000);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- "click #croom_create": function() {
|
|
|
|
- Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), $("#two").prop("checked"), function (err, res) {
|
|
|
|
- if (err) {
|
|
|
|
- alert("Error " + err.error + ": " + err.reason);
|
|
|
|
- } else {
|
|
|
|
- window.location = "/" + $("#croom_tag").val();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
"click #get-spotify-info": function() {
|
|
"click #get-spotify-info": function() {
|
|
var search = $("#title").val();
|
|
var search = $("#title").val();
|
|
var artistName = $("#artist").val();
|
|
var artistName = $("#artist").val();
|