mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Prettier embedded-player on startup
This commit is contained in:
		| @@ -15,7 +15,7 @@ gulp.task('js', function () { | ||||
| }); | ||||
|  | ||||
| gulp.task('embed', function () { | ||||
|     gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/player.js', 'server/public/assets/js/helpers.js', 'server/public/assets/js/playercontrols.js', 'server/public/assets/js/list.js', 'server/public/assets/js/embed.js', '!server/public/assets/js/frontpage*', '!server/public/assets/js/remotecontroller.js', 'server/public/assets/js/hostcontroller.js', 'server/public/assets/js/functions.js']) | ||||
|     gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/player.js', 'server/public/assets/js/helpers.js', 'server/public/assets/js/playercontrols.js', 'server/public/assets/js/list.js', 'server/public/assets/js/embed.js', '!server/public/assets/js/frontpage*', '!server/public/assets/js/remotecontroller.js', 'server/public/assets/js/hostcontroller.js']) | ||||
|         .pipe(uglify({ | ||||
|             mangle: true, | ||||
|             compress: true, | ||||
|   | ||||
| @@ -399,6 +399,10 @@ html { | ||||
|     padding: 0 10px 0 0; | ||||
| } | ||||
|  | ||||
| body { | ||||
|     background: #2d2d2d; | ||||
| } | ||||
|  | ||||
| .vote-container { | ||||
|   height: 100%; | ||||
|   width: 100%; | ||||
|   | ||||
| @@ -68,9 +68,9 @@ $(document).ready(function() { | ||||
|  | ||||
|     if(hash.length >= 3 && hash[2] == "autoplay"){ | ||||
|         autoplay = true; | ||||
|         $("#player").css("visibility", "hidden"); | ||||
|     } else { | ||||
|         paused = true; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     if(hash.indexOf("videoonly") > -1) { | ||||
| @@ -149,6 +149,195 @@ function setVolume(val) { | ||||
|     Playercontrols.setVolume(val); | ||||
| } | ||||
|  | ||||
|  | ||||
| function toast(msg) { | ||||
|     switch(msg) { | ||||
|         case "suggested_thumbnail": | ||||
|             if(embed) return; | ||||
|             msg = "The thumbnail has been suggested!"; | ||||
|             break; | ||||
|         case "faulty_start_end": | ||||
|             if(embed) return; | ||||
|             msg = "You tried to send a faulty start/end value. Try again.."; | ||||
|             break; | ||||
|         case "wait_longer": | ||||
|             if(embed) return; | ||||
|             msg = Helper.rnd(["Have you tried to wait longer between commands?!", "Looks like you're clicking that button too much..", "You need to wait longer between clicks.."]); | ||||
|             break; | ||||
|         case "suggested_description": | ||||
|             if(embed) return; | ||||
|             msg = "The description has been suggested!"; | ||||
|             break; | ||||
|         case "thumbnail_denied": | ||||
|             if(embed) return; | ||||
|             msg = "The thumbnail will be denied"; | ||||
|             break; | ||||
|         case "description_denied": | ||||
|             if(embed) return; | ||||
|             msg = "The description will be denied"; | ||||
|             break; | ||||
|         case "addedsong": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["I added your song", "Your song has been added", "Yay, more songs!", "Thats a cool song!", "I added that song for you", "I see you like adding songs..."]); | ||||
|             break; | ||||
|         case "addedplaylist": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["I added the playlist", "Your playlist has been added", "Yay, many more songs!", "Thats a cool playlist!", "I added all the songs for you", "I see you like adding songs.."]); | ||||
|             document.getElementById("import").disabled = false; | ||||
|             $("#playlist_loader").addClass("hide"); | ||||
|             $("#import").removeClass("hide"); | ||||
|             break; | ||||
|         case "savedsettings": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["I've saved your settings", "I stored all your settings", "Your settings have been stored in a safe place"]); | ||||
|             break; | ||||
|         case "wrongpass": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."]); | ||||
|             Crypt.remove_pass(chan.toLowerCase()); | ||||
|             Admin.display_logged_out(); | ||||
|             $("#thumbnail_form").css("display", "none"); | ||||
|             $("#description_form").css("display", "none"); | ||||
|             if(!Helper.mobilecheck()) { | ||||
|                 $('#chan_thumbnail').tooltip("remove"); | ||||
|             } | ||||
|             w_p = true; | ||||
|             break; | ||||
|         case "deleted_songs": | ||||
|             if(embed) return; | ||||
|             msg="All songs in the channel has been deleted!"; | ||||
|             break; | ||||
|         case "shuffled": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","I vigorously stirred your playlist!", "I hope you like your list stirred, not shaken.", "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.", "100% randomized, for your listening pleasure!", "I hope you enjoy your fresh playlist!"]); | ||||
|             break; | ||||
|         case "deletesong": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["Your song is now in a better place...", "You won't be seeing any more of that video...", "EXTERMINATE! EXTERMINATE! EXTERMINATE!", "I killed it with fire", "Thanks for deleting that song. I didn't like it anyways...", "Removed song securely."]); | ||||
|             break; | ||||
|         case "voted": | ||||
|             msg=Helper.rnd(["You voted!", "You vote like a boss", "Voting is the key to democracy", "May you get your song to the very top!", "I love that song! I vouch for you.", "Only you vote that good", "I like the way you vote...", "Up the video goes!", "Voted Zoff for president", "Only 999 more to go!"]); | ||||
|             break; | ||||
|         case "alreadyvoted": | ||||
|             msg=Helper.rnd(["You can't vote twice on that song!", "I see you have voted on that song before", "One vote per person!", "I know you want to hear your song, but have patience!", "I'm sorry, but I can't let you vote twice, Dave."]); | ||||
|             break; | ||||
|         case "skip": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["The song was skipped", "I have skipped a song", "Skipped to the beat", "Skipmaster3000", "They see me skippin', they hatin'"]); | ||||
|             break; | ||||
|         case "listhaspass": | ||||
|             if(embed) return; | ||||
|             if(!tried_again && lastCommand != undefined && lastCommand.length > 0) { | ||||
|                 if(Crypt.get_pass() != undefined) { | ||||
|                     tried_again = true; | ||||
|                     if(lastCommand.length == 1) { | ||||
|                         socket.emit(lastCommand[0]); | ||||
|                     } else if(lastCommand.length == 2) { | ||||
|                         socket.emit(lastCommand[0], lastCommand[1]); | ||||
|                     } | ||||
|                     lastCommand = []; | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|             tried_again = false; | ||||
|             msg=Helper.rnd(["I'm sorry, but you have to be an admin to do that!", "Only admins can do that", "You're not allowed to do that, try logging in!", "I can't let you do that", "Please log in to do that"]); | ||||
|             Crypt.remove_pass(chan.toLowerCase()); | ||||
|             Admin.display_logged_out(); | ||||
|             $("#thumbnail_form").css("display", "none"); | ||||
|             $("#description_form").css("display", "none"); | ||||
|             if(!Helper.mobilecheck()) { | ||||
|                 $('#chan_thumbnail').tooltip("remove"); | ||||
|             } | ||||
|             w_p = true; | ||||
|             if(!$("#playlist_loader").hasClass("hide")) { | ||||
|                 $("#playlist_loader").addClass("hide"); | ||||
|             } | ||||
|             if(!$("#playlist_loader_spotify").hasClass("hide")) { | ||||
|                 $("#playlist_loader_spotify").addClass("hide"); | ||||
|             } | ||||
|             $("#import_spotify").removeClass("hide"); | ||||
|                     $("#import").removeClass("hide"); | ||||
|             break; | ||||
|         case "noskip": | ||||
|             if(embed) return; | ||||
|             if(!tried_again && lastCommand != undefined && lastCommand.length > 0) { | ||||
|                 if(Crypt.get_pass() != undefined) { | ||||
|                     tried_again = true; | ||||
|                     if(lastCommand.length == 1) { | ||||
|                         socket.emit(lastCommand[0]); | ||||
|                     } else if(lastCommand.length == 2) { | ||||
|                         socket.emit(lastCommand[0], lastCommand[1]); | ||||
|                     } | ||||
|                     lastCommand = []; | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|             tried_again = false; | ||||
|             msg=Helper.rnd(["Only Admins can skip songs, peasant!", "You have to log in to skip songs on this channel", "Try clicking the settings icon and logging in before you skip"]); | ||||
|             break; | ||||
|         case "alreadyskip": | ||||
|             if(embed) return; | ||||
|             msg=Helper.rnd(["Skipping is democratic, only one vote per person!", "More people have to vote to skip, not just you!", "Get someone else to skip too! You can't do it on yourself."]); | ||||
|             break; | ||||
|         case "notyetskip": | ||||
|             if(embed) return; | ||||
|             msg="Skipping is disabled the first 10 seconds."; | ||||
|             break; | ||||
|         case "correctpass": | ||||
|             if(embed) return; | ||||
|             tried_again = false; | ||||
|             adminpass = Crypt.get_pass(chan.toLowerCase()) == undefined ? Crypt.tmp_pass : Crypt.get_pass(chan.toLowerCase()); | ||||
|             msg="Correct password. You now have access to the sacred realm of The Admin."; | ||||
|             $("#thumbnail_form").css("display", "inline-block"); | ||||
|             $("#description_form").css("display", "inline-block"); | ||||
|             if(!Helper.mobilecheck()) { | ||||
|                 $('#chan_thumbnail').tooltip({ | ||||
|                     delay: 5, | ||||
|                     position: "left", | ||||
|                     tooltip: "imgur link" | ||||
|                 }); | ||||
|             } | ||||
|             break; | ||||
|         case "changedpass": | ||||
|             if(embed) return; | ||||
|             msg="Your password has been changed!"; | ||||
|             break; | ||||
|         case "suggested": | ||||
|             if(embed) return; | ||||
|             msg="Your song was suggested!"; | ||||
|             break; | ||||
|         case "alreadyplay": | ||||
|             if(embed) return; | ||||
|             msg="Seems the song you want is already playing. No fooling the system!"; | ||||
|             break; | ||||
|     } | ||||
|     before_toast(); | ||||
|     Materialize.toast(msg, 4000); | ||||
| } | ||||
|  | ||||
| function emit() { | ||||
|     if(!embed) { | ||||
|         lastCommand = []; | ||||
|         for(var i = 0; i < arguments.length; i++) { | ||||
|             lastCommand.push(arguments[i]); | ||||
|         } | ||||
|     } | ||||
|     if(arguments.length == 1) { | ||||
|         socket.emit(arguments[0]); | ||||
|     } else { | ||||
|         socket.emit(arguments[0], arguments[1]); | ||||
|     } | ||||
| } | ||||
|  | ||||
| function before_toast(){ | ||||
|     if($('.toast').length > 0) { | ||||
|         var toastElement = $('.toast').first()[0]; | ||||
|         var toastInstance = toastElement.M_Toast; | ||||
|         toastInstance.remove(); | ||||
|     } | ||||
|     //Materialize.Toast.removeAll(); | ||||
| } | ||||
|  | ||||
| $(document).on( "click", "#zoffbutton", function(e) { | ||||
|     Player.pauseVideo(); | ||||
|     window.open("https://zoff.me/" + chan.toLowerCase() + "/", '_blank'); | ||||
|   | ||||
| @@ -279,6 +279,9 @@ var Player = { | ||||
|                 } | ||||
|                 break; | ||||
|             case YT.PlayerState.PLAYING: | ||||
|                 if(embed) { | ||||
|                     $("#player").css("visibility", "visible"); | ||||
|                 } | ||||
|                 if(embed && !autoplay) autoplay = true; | ||||
|                 if(!window.MSStream) { | ||||
|                     $("#player").css("opacity", "1"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user