diff --git a/server/server.js b/server/server.js index 341ec323..3a8c703f 100755 --- a/server/server.js +++ b/server/server.js @@ -134,11 +134,11 @@ io.on('connection', function(socket){ }); }); }else{ - vote(coll, id, guid); + vote(coll, id, guid, socket); } }); }else - socket.emit("error_settings", "Password Protected List!"); + socket.emit("toast", "Password Protected List!"); }); }); @@ -155,9 +155,9 @@ io.on('connection', function(socket){ { if((docs[0]["vote"] == "true" && (hash == docs[0]["adminpass"] || docs[0]["adminpass"] == "")) || docs[0]["vote"] == "false") { - vote(coll, id, guid); + vote(coll, id, guid, socket); }else{ - socket.emit("error_settings", "Password Protected List!"); + socket.emit("toast", "Password Protected List!"); } }); } @@ -178,7 +178,7 @@ io.on('connection', function(socket){ }); } }else - socket.emit("error_settings", "No Skipping!"); + socket.emit("sucess_settings", "No Skipping!"); }); }); @@ -209,13 +209,13 @@ io.on('connection', function(socket){ shuffle:shuffling, longsongs:longsongs, adminpass:hash}}, function(err, docs){ - socket.emit("success_settings", "Successfully applied settings!"); + socket.emit("toast", "Successfully applied settings!"); sort_list(coll,undefined,false); }); }else { - socket.emit("error_settings", "Wrong Password!"); + socket.emit("toast", "Wrong Password!"); } }); }); @@ -233,12 +233,12 @@ io.on('connection', function(socket){ num = Math.floor(Math.random()*1000000); db.collection(coll).update({id:docs["id"]}, {$set:{added:num}}, function(err, d) { - socket.emit("success_settings", "Shuffled Playlist!"); + socket.emit("toast", "Shuffled Playlist!"); }); } }); }else - socket.emit("error_settings", "Wrong Password!"); + socket.emit("toast", "Wrong Password!"); }); }); @@ -268,6 +268,7 @@ function del(params) if(docs[0]["adminpass"] == hash_pass(params[4])) { db.collection(coll).remove({id:params[1]}, function(err, docs){ + socket.emit("toast", "The song was deleted."); sort_list(coll, undefined, false); }) } @@ -279,7 +280,7 @@ function hash_pass(adminpass) return crypto.createHash('sha256').update(adminpass).digest('base64'); } -function vote(coll, id, guid) +function vote(coll, id, guid, socket) { db.collection(coll).find({id:id}, function(err, docs){ if(!contains(docs[0]["guids"], guid)) @@ -288,11 +289,15 @@ function vote(coll, id, guid) { db.collection(coll).update({id:id}, {$push :{guids: guid}}, function(err, docs) { + socket.emit("toast", "Voted on song!"); sort_list(coll, undefined, false); }); //sort_list(coll, undefined, false); }); - } + }else + { + socket.emit("toast", "You've already voted on that song!"); + } }); } diff --git a/static/js/admin.js b/static/js/admin.js index 2e3209d4..e5c1bea7 100755 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -1,21 +1,14 @@ var adminTogg = false; var pass_corr = ""; -socket.on("success_settings", function(msg) +socket.on("toast", function(msg) { pass_corr = "correct"; - document.getElementById("sBar").innerHTML = msg; + Materialize.toast(msg, 4000); + /*document.getElementById("sBar").innerHTML = msg; $("#sBar").addClass("opacityFull"); document.getElementById("passbox").value = ""; - remove_bar(); -}); - -socket.on("error_settings", function(msg){ - pass_corr = "wrong"; - document.getElementById("eBar").innerHTML = "Error: " + msg; - $("#eBar").addClass("opacityFull"); - document.getElementById("passbox").value = ""; - remove_bar(); + remove_bar();*/ }); function admin()