From c6d6270c4ac89f37483fcdcd9f6450660b51a5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 5 Sep 2016 13:36:21 +0200 Subject: [PATCH] Added export to youtube and improved importing from YouTube --- .htaccess | 8 +- gulpfile.js | 10 +- index.php | 2 +- php/panel.php | 280 +++++++++++++++++++++++++------------ php/spotify.html | 10 -- static/css/style.css | 12 +- static/dist/embed.min.js | 2 +- static/dist/main.min.js | 6 +- static/dist/spotify.min.js | 2 +- static/js/list.js | 58 ++++++++ static/js/listeners.js | 76 ++++++++-- static/js/player.js | 2 +- static/js/search.js | 58 ++++++-- static/js/spotify.js | 25 ---- 14 files changed, 383 insertions(+), 168 deletions(-) delete mode 100644 php/spotify.html delete mode 100644 static/js/spotify.js diff --git a/.htaccess b/.htaccess index 0ae75e10..64caf4ed 100755 --- a/.htaccess +++ b/.htaccess @@ -18,12 +18,12 @@ RewriteCond %{REQUEST_URI} !/static RewriteRule ^(.*)$ php/bot.php [L,NC,QSA] RewriteCond %{HTTP_HOST} ^zoff.no -RewriteCond %{REQUEST_URI} /spotify_callback -RewriteRule ^(.*)$ php/spotify.html [L,NC,QSA] +RewriteCond %{REQUEST_URI} /o_callback +RewriteRule ^(.*)$ php/callback.html [L,NC,QSA] RewriteCond %{HTTP_HOST} ^localhost -RewriteCond %{REQUEST_URI} /spotify_callback -RewriteRule ^(.*)$ php/spotify.html [L,NC,QSA] +RewriteCond %{REQUEST_URI} /o_callback +RewriteRule ^(.*)$ php/callback.html [L,NC,QSA] #RewriteRule (?i)^remote/(.*) php/controller.php?id=$1 [L] diff --git a/gulpfile.js b/gulpfile.js index 8ef50776..c814f15f 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,7 @@ var gulp = require('gulp'), concat = require('gulp-concat'); gulp.task('js', function () { - gulp.src(['static/js/*.js', '!static/js/embed*', '!static/js/remotecontroller.js', '!static/js/spotify.js']) + gulp.src(['static/js/*.js', '!static/js/embed*', '!static/js/remotecontroller.js', '!static/js/callback.js']) .pipe(uglify({ mangle: true, compress: true, @@ -25,14 +25,14 @@ gulp.task('embed', function () { .pipe(gulp.dest('static/dist')); }); -gulp.task('spotify', function () { - gulp.src(['static/js/spotify.js']) +gulp.task('callback', function () { + gulp.src(['static/js/callback.js']) .pipe(uglify({ mangle: true, compress: true, enclose: true })) - .pipe(concat('spotify.min.js')) + .pipe(concat('callback.min.js')) .pipe(gulp.dest('static/dist')); }); @@ -62,7 +62,7 @@ gulp.task('remotecontroller', function () { gulp.task('default', function(){ gulp.watch('static/js/*.js', ['js']); gulp.watch('static/js/*.js', ['embed']); - gulp.watch(['static/js/spotify.js', 'static/js/helpers.js'], ['spotify']); + gulp.watch(['static/js/callback.js', 'static/js/helpers.js'], ['callback']); //gulp.watch('static/js/*.js', ['nochan']); gulp.watch('static/js/remotecontroller.js', ['remotecontroller']); }); diff --git a/index.php b/index.php index 43efe3e8..b7818575 100755 --- a/index.php +++ b/index.php @@ -100,7 +100,7 @@
  • - + Conf
  • diff --git a/php/panel.php b/php/panel.php index 2d6fa109..598b3302 100755 --- a/php/panel.php +++ b/php/panel.php @@ -91,8 +91,6 @@ Remove - - @@ -100,7 +98,7 @@ -
  • +
  • @@ -133,75 +130,84 @@
  • -
  • + +
  • + +
  • + + + + +
  • + diff --git a/php/spotify.html b/php/spotify.html deleted file mode 100644 index 7c36a79e..00000000 --- a/php/spotify.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - Zöff Spotify Importer - - - - - - diff --git a/static/css/style.css b/static/css/style.css index 91f7433b..9569123d 100755 --- a/static/css/style.css +++ b/static/css/style.css @@ -69,14 +69,14 @@ line-height: 40px !important; } -.import-spotify-auth, .import-youtube{ +.import-spotify-auth, .import-youtube, .export-spotify-auth, .export-youtube, .exported-playlist{ color:white !important; height:40px !important; line-height: 40px !important; margin: 0 4rem 0 0 !important; } -.import-buttons{ +.import-buttons, .export-buttons{ padding:10px; } @@ -424,11 +424,11 @@ display: inline; } .white-bg{ - background-color:white; + background-color:white !important; } .white-bg:hover{ - background-color:white; + background-color:white !important; } .card .card-content { @@ -960,8 +960,9 @@ ul #chat-log{ margin-top:15px; } -#playlist_loader, #playlist_loader_spotify { +#playlist_loader, #playlist_loader_spotify, #playlist_loader_export { padding: 10px 0px 0px 70px; + background-color: white !important; } #search_loader:hover { @@ -1542,6 +1543,7 @@ nav ul li:hover, nav ul li.active { .tabs_height{ height:auto !important; + overflow:initial; } .brand-mobile{ diff --git a/static/dist/embed.min.js b/static/dist/embed.min.js index f40f4a15..5ed62f2f 100755 --- a/static/dist/embed.min.js +++ b/static/dist/embed.min.js @@ -1 +1 @@ -!function(){function e(){s.on("np",n.youtube_listener)}function t(){s.on("channel",p.channel_function)}function o(e){$("#volume").slider("value",e),d.setVolume(e)}var n={loaded:!0,before_load:"",after_load:"",player:"",stopInterval:!1,youtube_listener:function(e){n.loaded=!1,a.log("--------youtube_listener--------"),a.log("Received: "),a.log(e),a.log("paused variable: "+m),a.log("mobile_beginning variable: "+C);try{a.log("getVideoUrl(): "+n.player.getVideoUrl().split("v=")[1])}catch(e){}if(a.log("video_id variable: "+l),a.log("---------------------------------"),0===e.length){document.getElementById("song-title").innerHTML="Empty channel. Add some songs!",$("#player_overlay").height($("#player").height()),window.MSStream||$("#player_overlay").toggleClass("hide");try{n.player.stopVideo()}catch(e){}}else{void 0===c?c=e.np[0].id:c!=l&&(c=l),l=e.np[0].id,conf=e.conf[0],time=e.time,i=time-conf.startTime,u=e.np[0].title,duration=e.np[0].duration,C&&a.mobilecheck()&&0===i&&(i=1);try{full_playlist[0].id==l&&p.song_change(full_playlist[0].added),Suggestions.fetchYoutubeSuggests(l)}catch(e){}if(n.getTitle(u,viewers),n.setBGimage(l),h&&!window.MSStream)try{n.player.getVideoUrl().split("v=")[1]!=l&&(n.player.loadVideoById(l),n.notifyUser(l,u),n.player.seekTo(i),m&&n.player.pauseVideo()),m||(C||n.player.playVideo(),S||n.durationSetter()),(n.player.getDuration()>i||0===n.player.getDuration())&&n.player.seekTo(i),n.after_load=l,n.loaded||setTimeout(function(){n.loaded=!0},500)}catch(e){S||n.durationSetter()}else n.getTitle(u,viewers)}},onPlayerStateChange:function(e){a.log("-------onPlayerStateChange------"),a.log("New state\nState: "),a.log(e);try{a.log("Duration: "+n.player.getDuration(),"Current time: "+n.player.getCurrentTime()),a.log("getVideoUrl(): "+n.player.getVideoUrl().split("v=")[1])}catch(e){}switch(a.log("video_id variable: "+l),a.log("---------------------------------"),e.data){case-1:break;case 0:playing=!1,m=!1,s.emit("end",{id:l,channel:T.toLowerCase()});break;case 1:playing=!0,beginning&&a.mobilecheck()&&(n.player.pauseVideo(),beginning=!1,C=!1),w||"/"==window.location.pathname||a.addClass("#player_overlay","hide"),"/"!=window.location.pathname&&(1==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide"),2==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide")),m&&(s.emit("pos",{channel:T.toLowerCase()}),m=!1);break;case 2:m=!0,"/"!=window.location.pathname&&d.play_pause_show(),C=!0;break;case 3:}},getTitle:function(e,t){var o=t>1?"viewers":"viewer",n=decodeURIComponent(e);if("/"!=window.location.pathname){var a=document.getElementById("song-title"),i=document.getElementById("viewers");a.innerHTML=n,i.innerHTML=t+" "+o,a.title=n}document.title=n+" • Zöff / "+T},errorHandler:function(e){5==e.data||100==e.data||101==e.data||150==e.data?(curr_playing=n.player.getVideoUrl().replace("https://www.youtube.com/watch?v=",""),s.emit("skip",{error:e.data,id:l,pass:k,channel:T.toLowerCase})):void 0!==l&&n.player.loadVideoById(l)},onPlayerReady:function(e){$("#channel-load").css("display","none");try{beginning=!0,h=!0,window.MSStream||($("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),n.player.loadVideoById(l),x&&!a.mobilecheck()&&n.player.playVideo(),S||n.durationSetter(),w?setTimeout(function(){n.player.seekTo(i),x||(n.player.pauseVideo(),d.play_pause_show())},1e3):n.player.seekTo(i)),n.readyLooks(),d.initYoutubeControls(n.player),d.initSlider(),n.player.setVolume(Crypt.get_volume()),$(".video-container").removeClass("no-opacity")}catch(e){}},readyLooks:function(){n.setBGimage(l)},setBGimage:function(e){if(void 0!==e&&!w){var t=new Image;t.onload=function(){var e=new ColorThief,o=e.getColor(t);"/"!=window.location.pathname&&(document.getElementsByTagName("body")[0].style.backgroundColor=a.rgbToHsl(o,!0),$("meta[name=theme-color]").attr("content",a.rgbToHex(o[0],o[1],o[2])))},t.crossOrigin="Anonymous",t.src="https://zoff.no:8080/https://img.youtube.com/vi/"+e+"/mqdefault.jpg"}},set_width:function(e){$(".video-container").width(e)},notifyUser:function(e,t){if(t=t.replace(/\\\'/g,"'").replace(/"/g,"'").replace(/&/g,"&"),"granted"===Notification.permission&&document.hidden){var o=new Notification("Now Playing",{body:t,icon:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg",iconUrl:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg"});o.onclick=function(e){window.focus(),this.cancel()},setTimeout(function(){o.close()},5e3)}},setup_all_listeners:function(){get_list_listener(),e(),setup_admin_listener(),setup_chat_listener(),t()},onYouTubeIframeAPIReady:function(){n.player=new YT.Player("player",{videoId:l,playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",color:"white",showinfo:0},events:{onReady:n.onPlayerReady,onStateChange:n.onPlayerStateChange,onError:n.errorHandler}})},durationSetter:function(){if(void 0!==duration)try{n.stopInterval||(S=!0),dMinutes=Math.floor(duration/60),dSeconds=duration-60*dMinutes,currDurr=void 0!==n.player.getCurrentTime()?Math.floor(n.player.getCurrentTime()):i,currDurr>duration&&(currDurr=duration),minutes=Math.floor(currDurr/60),seconds=currDurr-60*minutes,document.getElementById("duration").innerHTML=a.pad(minutes)+":"+a.pad(seconds)+" / "+a.pad(dMinutes)+":"+a.pad(dSeconds),per=100/duration*currDurr,per>=100?per=100:0===duration&&(per=0),$("#bar").width(per+"%")}catch(e){}n.stopInterval||setTimeout(n.durationSetter,1e3)},loadPlayer:function(){if(1==$("script[src='https://www.youtube.com/iframe_api']").length)try{n.onYouTubeIframeAPIReady()}catch(e){console.error("Seems YouTube iFrame script isn't correctly loaded. Please reload the page.")}else tag=document.createElement("script"),tag.src="https://www.youtube.com/iframe_api",firstScriptTag=document.getElementsByTagName("script")[0],firstScriptTag.parentNode.insertBefore(tag,firstScriptTag)}},a={log:function(e){"true"===localStorage.debug&&console.log(e)},rnd:function(e){return e[Math.floor(Math.random()*e.length)]},mobilecheck:function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},predicate:function(){for(var e,t,o,n=[],a=arguments.length,i=function(e,t){return e===t?0:e>24&255).toString(16)+(e>>16&255).toString(16)+(e>>8&255).toString(16)+(255&e).toString(16)},hexToRgb:function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},pad:function(e){return e<10?"0"+Math.floor(e):Math.floor(e)},contains:function(e,t){for(var o=e.length;o--;)if(e[o]===t)return!0;return!1},sample:function(){Date.now()-lastSample>=2*SAMPLE_RATE&&(s.removeAllListeners(),s.disconnect(),s.connect(),n.setup_all_listeners()),lastSample=Date.now(),setTimeout(a.sample,SAMPLE_RATE)},loadjsfile:function(e){if(filesadded.indexOf("["+e+"]")==-1){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(t),filesadded+="["+e+"]"}},msieversion:function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");return!!(t>0||navigator.userAgent.match(/Trident.*rv\:11\./))},getRandomInt:function(e,t){return Math.floor(Math.random()*(t-e))+e},rgbToHsl:function(e,t){r=e[0],g=e[1],b=e[2],r/=255,g/=255,b/=255;var o,n,a=Math.max(r,g,b),i=Math.min(r,g,b),s=(a+i)/2;if(a==i)o=n=0;else{var l=a-i;switch(n=s>.5?l/(2-a-i):l/(a+i),a){case r:o=(g-b)/l+(g.5&&t?s=.5:s<.65&&!t&&(s=.65),"hsl("+Math.floor(360*o)+", "+Math.floor(100*n)+"%, "+Math.floor(100*s)+"%)"},componentToHex:function(e){var t=e.toString(16);return 1==t.length?"0"+t:t},rgbToHex:function(e,t,o){return"#"+a.componentToHex(e)+a.componentToHex(t)+a.componentToHex(o)},upperFirst:function(e){return e.substring(0,1).toUpperCase()+e.substring(1).toLowerCase()},addClass:function(e,t){a.contains($(e).attr("class").split(" "),t)||$(e).addClass(t)},send_mail:function(e,t){""!==e&&""!==t&&($("#submit-contact-form").addClass("hide"),$("#send-loader").removeClass("hide"),$("#contact-form-from").attr("disabled","true"),$("#contact-form-message").attr("disabled","true"),e=$("#contact-form-from").val(),t=$("#contact-form-message").val(),$("#contact-container").empty(),newWindow=window.open("mailto:contact@zoff.no?Subject=Contact%20Zoff&Body="+t,"_blank"),$("#contact-container").html("Something went wrong, sorry about that. You could instead try with your own mail-client: contact@zoff.no"),setTimeout(function(){newWindow.close()},500))}};$(document).on("submit","#contact-form",function(e){e.preventDefault();var t=$("#contact-form-message").val(),o=$("#contact-form-from").val();a.send_mail(o,t)}),Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=0,t=this.length;e=0&&e<=33?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),2==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=34&&e<=66?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),2==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=67&&e<=100&&(2==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide"))},playPause:function(){state=n.player.getPlayerState(),button=document.getElementById("playpause"),1==state?n.player.pauseVideo():2==state&&n.player.playVideo()},volumeOptions:function(){n.player.isMuted()?(n.player.unMute(),_=n.player.getVolume(),$("#volume").slider("value",n.player.getVolume())):(n.player.mute(),$("#volume").slider("value",0))},hoverMute:function(e){_=n.player.getVolume()}},p={empty:!1,channel_function:function(e){switch(e.type){case"list":p.populate_list(e.playlist);break;case"added":p.added_song(e.value);break;case"deleted":p.deleted_song(e.value);break;case"vote":p.voted_song(e.value,e.time);break;case"song_change":"/"!=window.location.pathname&&p.song_change(e.time)}},insertAtBeginning:function(e,t){var o=p.generateSong(e,t,!1,!0,!1);$("#wrapper").append(o)},insertAtIndex:function(e,t){var o=p.getIndexOfSong(e.id);if(!e.now_playing){var n=p.generateSong(e,t,!1,!0,!1);0===o?$("#wrapper").prepend(n):$("#wrapper > div:nth-child("+o+")").after(n)}var a=$("#wrapper").children()[o];t&&setTimeout(function(){$(a).css("height",66)},5)},populate_list:function(e){void 0===f&&(f=$("#list-song-html").html()),full_playlist=e,p.sortList(),$("#wrapper").empty(),a.log("---------------------------"),a.log("---------FULL PLAYLIST-----"),a.log(full_playlist),a.log("---------------------------"),full_playlist.length>1?($.each(full_playlist,function(e,t){t.now_playing||$("#wrapper").append(p.generateSong(t,!1,v,!0))}),v&&(a.mobilecheck()?$(".list-image").lazyload({}):($(".list-image").lazyload({container:$("#wrapper")}).removeClass("lazy"),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1))):(p.empty=!0,$("#wrapper").append("The playlist is empty.")),$("#settings").css("visibility","visible"),$("#settings").css("opacity","1"),$("#wrapper").css("opacity","1")},added_song:function(e){now_playing=full_playlist.pop(),full_playlist.push(e),p.sortList(),full_playlist.push(now_playing),$("#suggested-"+e.id).remove(),p.empty&&(p.empty=!1),$("#empty-channel-message").remove(),p.insertAtIndex(e,!0)},deleted_song:function(e){var t=p.getIndexOfSong(e),o=$("#wrapper").children()[t];try{o.style.height=0,setTimeout(function(){$("#"+e).remove(),full_playlist.splice(p.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(t){full_playlist.splice(p.getIndexOfSong(e),1),p.empty||$("#wrapper").children()[$("#wrapper").children().length-1].remove()}full_playlist.length<=2&&(p.empty=!0,$("#wrapper").append("The playlist is empty.")),$("#suggested-"+e).remove(),Suggestions.checkUserEmpty()},voted_song:function(e,t){var o=p.getIndexOfSong(e),n=full_playlist[o];full_playlist[o].votes+=1,full_playlist[o].added=t,p.sortList(),$("#"+e).remove(),p.insertAtIndex(n,!1)},song_change:function(e){var t=full_playlist.length-1;full_playlist[0].now_playing=!0,full_playlist[0].votes=0,full_playlist[0].guids=[],full_playlist[0].added=e,full_playlist[t].now_playing=!1,a.log("---------------------------"),a.log("---SONG ON FIRST INDEX-----"),a.log(full_playlist[0]),a.log("---------------------------");try{full_playlist.push(full_playlist.shift()),p.empty||$("#wrapper").children()[0].remove(),0===$("#wrapper").children().length&&(p.empty=!0,$("#wrapper").append("The playlist is empty.")),p.insertAtIndex(full_playlist[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(e){}},vote:function(e,t){return s.emit("vote",{channel:T,id:e,type:t,adminpass:k}),!0},skip:function(){return s.emit("skip",{pass:k,id:l,channel:T.toLowerCase()}),!0},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",list=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(list.songs,function(e,n){t+=n.id+",",o>45&&(Search.addVideos(t),t="",o=0),o++}),Search.addVideos(t),document.getElementById("search").value=""},sortList:function(){full_playlist.sort(a.predicate({name:"votes",reverse:!0},{name:"added",reverse:!1},{name:"title",reverse:!1}))},show:function(){a.mobilecheck()||(showToggle?(showToggle=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+T.toLowerCase())):(showToggle=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(T)))},generateSong:function(e,t,o,n,a){var i,s,l=e.id,r=e.title,c=e.votes,d="background-image:url('//img.youtube.com/vi/"+l+"/mqdefault.jpg');",p=$("
    "+f+"
    "),u="style";return t&&p.find("#list-song").css("height",0),y||p.find(".card-action").removeClass("hide"),1==c&&p.find(".vote-text").text("vote"),o&&(d="//img.youtube.com/vi/"+l+"/mqdefault.jpg",u="data-original"),n?(p.find(".list-votes").text(c),p.find("#list-song").attr("id",l),p.find(".vote-container").attr("title",r),i=".vote-container",s="del"):n||(p.find(".vote-text").text(e.duration),i=".add-suggested",s=a?"del_user_suggested":"del_suggested",p.find(".vote-container").attr("class","clickable add-suggested"),p.find(".add-suggested").attr("title",r),p.find("#del").attr("id",s),p.find(i).attr("data-video-title",r),p.find(i).attr("data-video-length",e.length),p.find("#list-song").attr("id","suggested-"+l),p.find(".list-image").attr("class",p.find(".list-image").attr("class").replace("list-image","list-suggested-image"))),p.find(".list-title").text(r),p.find(".list-title").attr("title",r),p.find(i).attr("data-video-id",l),p.find(".list-image").attr(u,d),p.find(".list-suggested-image").attr(u,d),p.find("#"+s).attr("data-video-id",l),p.html()},getIndexOfSong:function(e){return indexes=$.map(full_playlist,function(t,o){if(t.id==e)return o}),indexes[0]},scrollTop:function(){$("#wrapper").scrollTop(0)},scrollBottom:function(){$("#wrapper").scrollTop($("#wrapper")[0].scrollHeight)}},u="",m=!1,h=!1,f=$("#list-song-html").html(),y=!0,v=!1,w=!0,_=100,k="",C=!1,S=!1,I=window.location.hash.substring(1).split("&"),T=I[0],x=!1,E={"sync disconnect on unload":!0,secure:!0,"force new connection":!0};$(document).ready(function(){2==I.length&&"autoplay"==I[1]?x=!0:m=!0,$("head").append(''),$("head").append(''),add="https://zoff.no",s=io.connect(""+add+":8880",E),s.on("get_list",function(){setTimeout(function(){s.emit("list",T.toLowerCase())},1e3)}),s.on("viewers",function(e){viewers=e,void 0!==u&&n.getTitle(u,viewers)}),e(),t(),window.onYouTubeIframeAPIReady=n.onYouTubeIframeAPIReady,n.loadPlayer(),d.initSlider(),window.setVolume=o}),$(document).on("click","#zoffbutton",function(e){window.open("https://zoff.no/"+T.toLowerCase()+"/","_blank")}),$(document).on("click",".vote-container",function(e){var t=$(this).attr("data-video-id");p.vote(t,"pos")})}(); \ No newline at end of file +!function(){function e(){s.on("np",n.youtube_listener)}function t(){s.on("channel",p.channel_function)}function o(e){$("#volume").slider("value",e),d.setVolume(e)}var n={loaded:!0,before_load:"",after_load:"",player:"",stopInterval:!1,youtube_listener:function(e){n.loaded=!1,a.log("--------youtube_listener--------"),a.log("Received: "),a.log(e),a.log("paused variable: "+m),a.log("mobile_beginning variable: "+C);try{a.log("getVideoUrl(): "+n.player.getVideoUrl().split("v=")[1])}catch(e){}if(a.log("video_id variable: "+l),a.log("---------------------------------"),e.np){void 0===c?c=e.np[0].id:c!=l&&(c=l),l=e.np[0].id,conf=e.conf[0],time=e.time,i=time-conf.startTime,u=e.np[0].title,duration=e.np[0].duration,C&&a.mobilecheck()&&0===i&&(i=1);try{full_playlist[0].id==l&&p.song_change(full_playlist[0].added),Suggestions.fetchYoutubeSuggests(l)}catch(e){}if(n.getTitle(u,viewers),n.setBGimage(l),h&&!window.MSStream)try{n.player.getVideoUrl().split("v=")[1]!=l&&(n.player.loadVideoById(l),n.notifyUser(l,u),n.player.seekTo(i),m&&n.player.pauseVideo()),m||(C||n.player.playVideo(),S||n.durationSetter()),(n.player.getDuration()>i||0===n.player.getDuration())&&n.player.seekTo(i),n.after_load=l,n.loaded||setTimeout(function(){n.loaded=!0},500)}catch(e){S||n.durationSetter()}else n.getTitle(u,viewers)}else{document.getElementById("song-title").innerHTML="Empty channel. Add some songs!",$("#player_overlay").height($("#player").height()),window.MSStream||$("#player_overlay").toggleClass("hide");try{n.player.stopVideo()}catch(e){}}},onPlayerStateChange:function(e){a.log("-------onPlayerStateChange------"),a.log("New state\nState: "),a.log(e);try{a.log("Duration: "+n.player.getDuration(),"Current time: "+n.player.getCurrentTime()),a.log("getVideoUrl(): "+n.player.getVideoUrl().split("v=")[1])}catch(e){}switch(a.log("video_id variable: "+l),a.log("---------------------------------"),e.data){case-1:break;case 0:playing=!1,m=!1,s.emit("end",{id:l,channel:T.toLowerCase()});break;case 1:playing=!0,beginning&&a.mobilecheck()&&(n.player.pauseVideo(),beginning=!1,C=!1),w||"/"==window.location.pathname||a.addClass("#player_overlay","hide"),"/"!=window.location.pathname&&(1==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide"),2==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide")),m&&(s.emit("pos",{channel:T.toLowerCase()}),m=!1);break;case 2:m=!0,"/"!=window.location.pathname&&d.play_pause_show(),C=!0;break;case 3:}},getTitle:function(e,t){var o=t>1?"viewers":"viewer",n=decodeURIComponent(e);if("/"!=window.location.pathname){var a=document.getElementById("song-title"),i=document.getElementById("viewers");a.innerHTML=n,i.innerHTML=t+" "+o,a.title=n}document.title=n+" • Zöff / "+T},errorHandler:function(e){5==e.data||100==e.data||101==e.data||150==e.data?(curr_playing=n.player.getVideoUrl().replace("https://www.youtube.com/watch?v=",""),s.emit("skip",{error:e.data,id:l,pass:k,channel:T.toLowerCase})):void 0!==l&&n.player.loadVideoById(l)},onPlayerReady:function(e){$("#channel-load").css("display","none");try{beginning=!0,h=!0,window.MSStream||($("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),n.player.loadVideoById(l),x&&!a.mobilecheck()&&n.player.playVideo(),S||n.durationSetter(),w?setTimeout(function(){n.player.seekTo(i),x||(n.player.pauseVideo(),d.play_pause_show())},1e3):n.player.seekTo(i)),n.readyLooks(),d.initYoutubeControls(n.player),d.initSlider(),n.player.setVolume(Crypt.get_volume()),$(".video-container").removeClass("no-opacity")}catch(e){}},readyLooks:function(){n.setBGimage(l)},setBGimage:function(e){if(void 0!==e&&!w){var t=new Image;t.onload=function(){var e=new ColorThief,o=e.getColor(t);"/"!=window.location.pathname&&(document.getElementsByTagName("body")[0].style.backgroundColor=a.rgbToHsl(o,!0),$("meta[name=theme-color]").attr("content",a.rgbToHex(o[0],o[1],o[2])))},t.crossOrigin="Anonymous",t.src="https://zoff.no:8080/https://img.youtube.com/vi/"+e+"/mqdefault.jpg"}},set_width:function(e){$(".video-container").width(e)},notifyUser:function(e,t){if(t=t.replace(/\\\'/g,"'").replace(/"/g,"'").replace(/&/g,"&"),"granted"===Notification.permission&&document.hidden){var o=new Notification("Now Playing",{body:t,icon:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg",iconUrl:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg"});o.onclick=function(e){window.focus(),this.cancel()},setTimeout(function(){o.close()},5e3)}},setup_all_listeners:function(){get_list_listener(),e(),setup_admin_listener(),setup_chat_listener(),t()},onYouTubeIframeAPIReady:function(){n.player=new YT.Player("player",{videoId:l,playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",color:"white",showinfo:0},events:{onReady:n.onPlayerReady,onStateChange:n.onPlayerStateChange,onError:n.errorHandler}})},durationSetter:function(){if(void 0!==duration)try{n.stopInterval||(S=!0),dMinutes=Math.floor(duration/60),dSeconds=duration-60*dMinutes,currDurr=void 0!==n.player.getCurrentTime()?Math.floor(n.player.getCurrentTime()):i,currDurr>duration&&(currDurr=duration),minutes=Math.floor(currDurr/60),seconds=currDurr-60*minutes,document.getElementById("duration").innerHTML=a.pad(minutes)+":"+a.pad(seconds)+" / "+a.pad(dMinutes)+":"+a.pad(dSeconds),per=100/duration*currDurr,per>=100?per=100:0===duration&&(per=0),$("#bar").width(per+"%")}catch(e){}n.stopInterval||setTimeout(n.durationSetter,1e3)},loadPlayer:function(){if(1==$("script[src='https://www.youtube.com/iframe_api']").length)try{n.onYouTubeIframeAPIReady()}catch(e){console.error("Seems YouTube iFrame script isn't correctly loaded. Please reload the page.")}else tag=document.createElement("script"),tag.src="https://www.youtube.com/iframe_api",firstScriptTag=document.getElementsByTagName("script")[0],firstScriptTag.parentNode.insertBefore(tag,firstScriptTag)}},a={log:function(e){"true"===localStorage.debug&&console.log(e)},rnd:function(e){return e[Math.floor(Math.random()*e.length)]},mobilecheck:function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},predicate:function(){for(var e,t,o,n=[],a=arguments.length,i=function(e,t){return e===t?0:e>24&255).toString(16)+(e>>16&255).toString(16)+(e>>8&255).toString(16)+(255&e).toString(16)},hexToRgb:function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},pad:function(e){return e<10?"0"+Math.floor(e):Math.floor(e)},contains:function(e,t){for(var o=e.length;o--;)if(e[o]===t)return!0;return!1},sample:function(){Date.now()-lastSample>=2*SAMPLE_RATE&&(s.removeAllListeners(),s.disconnect(),s.connect(),n.setup_all_listeners()),lastSample=Date.now(),setTimeout(a.sample,SAMPLE_RATE)},loadjsfile:function(e){if(filesadded.indexOf("["+e+"]")==-1){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(t),filesadded+="["+e+"]"}},msieversion:function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");return!!(t>0||navigator.userAgent.match(/Trident.*rv\:11\./))},getRandomInt:function(e,t){return Math.floor(Math.random()*(t-e))+e},rgbToHsl:function(e,t){r=e[0],g=e[1],b=e[2],r/=255,g/=255,b/=255;var o,n,a=Math.max(r,g,b),i=Math.min(r,g,b),s=(a+i)/2;if(a==i)o=n=0;else{var l=a-i;switch(n=s>.5?l/(2-a-i):l/(a+i),a){case r:o=(g-b)/l+(g.5&&t?s=.5:s<.65&&!t&&(s=.65),"hsl("+Math.floor(360*o)+", "+Math.floor(100*n)+"%, "+Math.floor(100*s)+"%)"},componentToHex:function(e){var t=e.toString(16);return 1==t.length?"0"+t:t},rgbToHex:function(e,t,o){return"#"+a.componentToHex(e)+a.componentToHex(t)+a.componentToHex(o)},upperFirst:function(e){return e.substring(0,1).toUpperCase()+e.substring(1).toLowerCase()},addClass:function(e,t){a.contains($(e).attr("class").split(" "),t)||$(e).addClass(t)},send_mail:function(e,t){""!==e&&""!==t&&($("#submit-contact-form").addClass("hide"),$("#send-loader").removeClass("hide"),$("#contact-form-from").attr("disabled","true"),$("#contact-form-message").attr("disabled","true"),e=$("#contact-form-from").val(),t=$("#contact-form-message").val(),$("#contact-container").empty(),newWindow=window.open("mailto:contact@zoff.no?Subject=Contact%20Zoff&Body="+t,"_blank"),$("#contact-container").html("Something went wrong, sorry about that. You could instead try with your own mail-client: contact@zoff.no"),setTimeout(function(){newWindow.close()},500))}};$(document).on("submit","#contact-form",function(e){e.preventDefault();var t=$("#contact-form-message").val(),o=$("#contact-form-from").val();a.send_mail(o,t)}),Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=0,t=this.length;e=0&&e<=33?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),2==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=34&&e<=66?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),2==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=67&&e<=100&&(2==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide"))},playPause:function(){state=n.player.getPlayerState(),button=document.getElementById("playpause"),1==state?n.player.pauseVideo():2==state&&n.player.playVideo()},volumeOptions:function(){n.player.isMuted()?(n.player.unMute(),_=n.player.getVolume(),$("#volume").slider("value",n.player.getVolume())):(n.player.mute(),$("#volume").slider("value",0))},hoverMute:function(e){_=n.player.getVolume()}},p={empty:!1,channel_function:function(e){switch(e.type){case"list":p.populate_list(e.playlist);break;case"added":p.added_song(e.value);break;case"deleted":p.deleted_song(e.value);break;case"vote":p.voted_song(e.value,e.time);break;case"song_change":"/"!=window.location.pathname&&p.song_change(e.time)}},insertAtBeginning:function(e,t){var o=p.generateSong(e,t,!1,!0,!1);$("#wrapper").append(o)},insertAtIndex:function(e,t){var o=p.getIndexOfSong(e.id);if(!e.now_playing){var n=p.generateSong(e,t,!1,!0,!1);0===o?$("#wrapper").prepend(n):$("#wrapper > div:nth-child("+o+")").after(n)}var a=$("#wrapper").children()[o];t&&setTimeout(function(){$(a).css("height",66)},5)},populate_list:function(e){void 0===f&&(f=$("#list-song-html").html()),full_playlist=e,p.sortList(),$("#wrapper").empty(),a.log("---------------------------"),a.log("---------FULL PLAYLIST-----"),a.log(full_playlist),a.log("---------------------------"),full_playlist.length>1?($.each(full_playlist,function(e,t){t.now_playing||$("#wrapper").append(p.generateSong(t,!1,v,!0))}),v&&(a.mobilecheck()?$(".list-image").lazyload({}):($(".list-image").lazyload({container:$("#wrapper")}).removeClass("lazy"),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1))):(p.empty=!0,$("#wrapper").append("The playlist is empty.")),$("#settings").css("visibility","visible"),$("#settings").css("opacity","1"),$("#wrapper").css("opacity","1")},added_song:function(e){now_playing=full_playlist.pop(),full_playlist.push(e),p.sortList(),full_playlist.push(now_playing),$("#suggested-"+e.id).remove(),p.empty&&(p.empty=!1),$("#empty-channel-message").remove(),p.insertAtIndex(e,!0)},deleted_song:function(e){var t=p.getIndexOfSong(e),o=$("#wrapper").children()[t];try{o.style.height=0,setTimeout(function(){$("#"+e).remove(),full_playlist.splice(p.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(t){full_playlist.splice(p.getIndexOfSong(e),1),p.empty||$("#wrapper").children()[$("#wrapper").children().length-1].remove()}full_playlist.length<=2&&(p.empty=!0,$("#wrapper").append("The playlist is empty.")),$("#suggested-"+e).remove(),Suggestions.checkUserEmpty()},voted_song:function(e,t){var o=p.getIndexOfSong(e),n=full_playlist[o];full_playlist[o].votes+=1,full_playlist[o].added=t,p.sortList(),$("#"+e).remove(),p.insertAtIndex(n,!1)},song_change:function(e){var t=full_playlist.length-1;full_playlist[0].now_playing=!0,full_playlist[0].votes=0,full_playlist[0].guids=[],full_playlist[0].added=e,full_playlist[t].now_playing=!1,a.log("---------------------------"),a.log("---SONG ON FIRST INDEX-----"),a.log(full_playlist[0]),a.log("---------------------------");try{full_playlist.push(full_playlist.shift()),p.empty||$("#wrapper").children()[0].remove(),0===$("#wrapper").children().length&&(p.empty=!0,$("#wrapper").append("The playlist is empty.")),p.insertAtIndex(full_playlist[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(e){}},vote:function(e,t){return s.emit("vote",{channel:T,id:e,type:t,adminpass:k}),!0},skip:function(){return s.emit("skip",{pass:k,id:l,channel:T.toLowerCase()}),!0},exportToYoutube:function(){var e="https://www.googleapis.com/youtube/v3/playlists?part=snippet";$.ajax({type:"POST",url:e,headers:{Authorization:"Bearer "+access_token_data_youtube.access_token,"Content-Type":"application/json"},data:JSON.stringify({snippet:{title:T.toLowerCase(),description:"Playlist exported from zoff"}}),success:function(e){var t=0,o=e.id;$.each(full_playlist,function(e,n){var i="https://www.googleapis.com/youtube/v3/playlistItems?part=snippet";$.ajax({type:"POST",url:i,headers:{Authorization:"Bearer "+access_token_data_youtube.access_token,"Content-Type":"application/json"},data:JSON.stringify({snippet:{playlistId:o,resourceId:{kind:"youtube#video",videoId:n.id}}}),success:function(e){a.log("Added video: "+n.id+" to playlist id "+o),t==full_playlist.length-1&&(a.log("All videoes added!"),a.log("url: https://www.youtube.com/playlist?list="+o),$(".exported-list").append("
    Exported URL:
    "),$(".exported-list").append(""+T+""),$("#playlist_loader_export").addClass("hide"),$(".exported-list-container").removeClass("hide")),t+=1}})})},error:function(e){a.log(e)}})},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",list=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(list.songs,function(e,n){t+=n.id+",",o>45&&(Search.addVideos(t),t="",o=0),o++}),Search.addVideos(t),document.getElementById("search").value=""},sortList:function(){full_playlist.sort(a.predicate({name:"votes",reverse:!0},{name:"added",reverse:!1},{name:"title",reverse:!1}))},show:function(){a.mobilecheck()||(showToggle?(showToggle=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+T.toLowerCase())):(showToggle=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(T)))},generateSong:function(e,t,o,n,a){var i,s,l=e.id,r=e.title,c=e.votes,d="background-image:url('//img.youtube.com/vi/"+l+"/mqdefault.jpg');",p=$("
    "+f+"
    "),u="style";return t&&p.find("#list-song").css("height",0),y||p.find(".card-action").removeClass("hide"),1==c&&p.find(".vote-text").text("vote"),o&&(d="//img.youtube.com/vi/"+l+"/mqdefault.jpg",u="data-original"),n?(p.find(".list-votes").text(c),p.find("#list-song").attr("id",l),p.find(".vote-container").attr("title",r),i=".vote-container",s="del"):n||(p.find(".vote-text").text(e.duration),i=".add-suggested",s=a?"del_user_suggested":"del_suggested",p.find(".vote-container").attr("class","clickable add-suggested"),p.find(".add-suggested").attr("title",r),p.find("#del").attr("id",s),p.find(i).attr("data-video-title",r),p.find(i).attr("data-video-length",e.length),p.find("#list-song").attr("id","suggested-"+l),p.find(".list-image").attr("class",p.find(".list-image").attr("class").replace("list-image","list-suggested-image"))),p.find(".list-title").text(r),p.find(".list-title").attr("title",r),p.find(i).attr("data-video-id",l),p.find(".list-image").attr(u,d),p.find(".list-suggested-image").attr(u,d),p.find("#"+s).attr("data-video-id",l),p.html()},getIndexOfSong:function(e){return indexes=$.map(full_playlist,function(t,o){if(t.id==e)return o}),indexes[0]},scrollTop:function(){$("#wrapper").scrollTop(0)},scrollBottom:function(){$("#wrapper").scrollTop($("#wrapper")[0].scrollHeight)}},u="",m=!1,h=!1,f=$("#list-song-html").html(),y=!0,v=!1,w=!0,_=100,k="",C=!1,S=!1,I=window.location.hash.substring(1).split("&"),T=I[0],x=!1,E={"sync disconnect on unload":!0,secure:!0,"force new connection":!0};$(document).ready(function(){2==I.length&&"autoplay"==I[1]?x=!0:m=!0,$("head").append(''),$("head").append(''),add="https://zoff.no",s=io.connect(""+add+":8880",E),s.on("get_list",function(){setTimeout(function(){s.emit("list",T.toLowerCase())},1e3)}),s.on("viewers",function(e){viewers=e,void 0!==u&&n.getTitle(u,viewers)}),e(),t(),window.onYouTubeIframeAPIReady=n.onYouTubeIframeAPIReady,n.loadPlayer(),d.initSlider(),window.setVolume=o}),$(document).on("click","#zoffbutton",function(e){window.open("https://zoff.no/"+T.toLowerCase()+"/","_blank")}),$(document).on("click",".vote-container",function(e){var t=$(this).attr("data-video-id");p.vote(t,"pos")})}(); \ No newline at end of file diff --git a/static/dist/main.min.js b/static/dist/main.min.js index 0358a19a..2f47594f 100755 --- a/static/dist/main.min.js +++ b/static/dist/main.min.js @@ -1,3 +1,3 @@ -!function(){function e(){var e=!0;M=$("#chan").html(),ve=E.mobilecheck();var t=E.mobilecheck()?"left":"right";if(window.onpopstate=function(e){_()},w(),"zoff.no"==window.location.hostname?add="https://zoff.no":add=window.location.hostname,void 0!==Oe&&(Oe.stopInterval=!1),$("ul.playlist-tabs").tabs(),$("ul.playlist-tabs-loggedIn").tabs(),$(".chatTabs").tabs(),$("#settings").sideNav({menuWidth:300,edge:t,closeOnClick:!1}),$(".collapsible").collapsible({accordion:!0}),y(ce),fe=$("#temp-results-container"),ye=$("#empty-results-container").html(),de=$(".not-imported-container").html(),$(".not-imported-container").empty(),$(".video-container").resizable({start:function(e,t){$("iframe").css("pointer-events","none")},stop:function(e,t){$("iframe").css("pointer-events","auto"),T.set_width($(this).width())},handles:"e",minWidth:350}),(void 0===Le||E.mobilecheck())&&(e=!1,Le=io.connect(""+add+":8880",Me)),0===$("#alreadychannel").length||E.mobilecheck())E.log("ISAJODIJOQIJW"),o(),n(),a(),i();else{$("#channel-load").css("display","none"),$("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),Oe.readyLooks(),Re.initYoutubeControls(Oe.player),Re.initSlider(),Oe.player.setVolume(T.get_volume()),$(".video-container").removeClass("no-opacity");var r="https://remote."+window.location.hostname+"/"+be;$("#code-text").text(be),$("#code-qr").attr("src","https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+r),$("#code-link").attr("href",r)}e&&Le.emit("list",M.toLowerCase()),/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream?(document.getElementById("search").blur(),$("#channel-load").css("display","none")):(window.onYouTubeIframeAPIReady=Oe.onYouTubeIframeAPIReady,(""===Oe.player||void 0===Oe.player||E.mobilecheck())&&Oe.loadPlayer()),E.mobilecheck()&&je.initiate_volume(),s(),c(),l(),E.mobilecheck()||0!==$("#alreadychannel").length||p(),E.msieversion()||Notification.requestPermission(),$(".search_input").focus(),E.sample(),$("#results").hover(function(){$("div.result").removeClass("hoverResults"),ee=0},function(){}),$("#search").focus(),$("#embed-button").css("display","inline-block"),$("#embed-area").val(f(me,ue,pe)),$("#search").attr("placeholder","Find song on YouTube...")}function t(){Le.on("connect_failed",function(){E.log("Connection Failed"),ge||(ge=!0,Materialize.toast("Error connecting to server, please wait..",1e8,"red lighten connect_error"))}),Le.on("connect_error",function(){E.log("Connection Failed."),ge||(ge=!0,Materialize.toast("Error connecting to server, please wait..",1e8,"red lighten connect_error"))})}function o(){Le.on("np",Oe.youtube_listener)}function n(){Le.on("get_list",function(){Le.emit("list",M.toLowerCase())})}function a(){Le.on("suggested",function(e){var t=!0;void 0===e.id&&(t=!1),Ye.catchUserSuggests(e,t)})}function i(){Le.on("viewers",function(e){G=e,void 0!==Ee&&Oe.getTitle(Ee,G)})}function s(){Le.on("toast",S.toast),Le.on("pw",S.pw),Le.on("conf",S.conf)}function l(){Le.on("chat.all",I.allchat),Le.on("chat",I.channelchat)}function c(){Le.on("channel",L.channel_function)}function d(){Le.on("playlists",Ve.frontpage_function)}function p(){Le.on("id",B.host_listener)}function u(e){Le.on(e,B.host_on_action)}function m(){localStorage.debug=!0}function h(){localStorage.debug=!1}function f(e,t,o){return''}function y(e){e?(E.log("------------------------"),E.log("Spotify is authenticated"),E.log("access_token: "+re.access_token),E.log("token_type:"+re.token_type),E.log("expires_in: "+re.expires_in),E.log("------------------------"),$(".spotify_authenticated").css("display","block"),$(".spotify_unauthenticated").css("display","none")):(E.log("----------------------------"),E.log("Spotify is not authenticated"),E.log("----------------------------"),$(".spotify_authenticated").css("display","none"),$(".spotify_unauthenticated").css("display","block"))}function v(e){search_input=$(".search_input").val(),code=e.keyCode||e.which,40!=code&&38!=code&&13!=code&&39!=code&&37!=code&&17!=code&&16!=code&&225!=code&&18!=code&&(clearTimeout($e),search_input.length<3&&$("#results").html(""),13==code?qe.search(search_input):$e=setTimeout(function(){qe.search(search_input)},1e3))}function w(){$("#facebook-code-link").attr("href","https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+M.toLowerCase()),$("#facebook-code-link").attr("onclick","window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+M.toLowerCase()+"', 'Share Playlist','width=600,height=300'); return false;"),$("#twitter-code-link").attr("href","http://twitter.com/intent/tweet?url=https://zoff.no/"+M.toLowerCase()+"&text=Check%20out%20this%20playlist%20"+M.toLowerCase()+"%20on%20Zöff!&via=zoffmusic"),$("#twitter-code-link").attr("onclick","window.open('http://twitter.com/intent/tweet?url=https://zoff.no/"+M.toLowerCase()+"/&text=Check%20out%20this%20playlist%20"+M.toLowerCase()+"%20on%20Zöff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;"),$("#qr-code-link").attr("href","//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.no/"+M.toLowerCase()+"&choe=UTF-8&chld=L%7C1"),$("#qr-code-image-link").attr("src","//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.no/"+M.toLowerCase()+"&choe=UTF-8&chld=L%7C1")}function _(){var e=window.location.href.split("/");"#!"==e[3].substr(0,1)||""===e[3]||5==e.length&&"#"==e[4].substr(0,1)?""===e[3]&&($("#channel-load").css("display","block"),window.scrollTo(0,0),Oe.stopInterval=!0,S.display_logged_out(),S.beginning=!0,K=!1,ae=!1,$("#embed-button").css("display","none"),$.ajax({url:"php/nochan.php",success:function(e){if(E.mobilecheck()?(Le.removeAllListeners(),Le.disconnect()):(Le.removeEventListener("chat.all"),Le.removeEventListener("chat"),Le.removeEventListener("conf"),Le.removeEventListener("pw"),Le.removeEventListener("toast"),Le.removeEventListener("channel")),document.getElementById("volume-button").removeEventListener("click",Re.mute_video),document.getElementById("playpause").removeEventListener("click",Re.play_pause),document.getElementById("fullscreen").removeEventListener("click",Re.fullscreen),E.mobilecheck()&&(Ie="",Ee=""),$("meta[name=theme-color]").attr("content","#2D2D2D"),E.mobilecheck()){try{Oe.player.destroy()}catch(e){}Oe.player="",document.title="Zöff"}else $("main").append("X"),$("#playbar").remove(),$("#playlist").remove(),$(".ui-resizable-handle").remove(),$("#main_components").remove(),$("#player").addClass("player_bottom"),$("#main-row").addClass("frontpage_modified_heights"),$("#player").css("opacity","1"),$("#video-container").removeClass("no-opacity"),$("#main-row").prepend("
    ");$(".drag-target").remove(),$("#sidenav-overlay").remove(),$("main").attr("class","center-align container"),$("body").attr("id",""),$("body").attr("style",""),$("header").html($($(e)[59]).html()),$($(e)[61]).insertAfter("header"),$($(e)[63]).insertAfter(".mega"),E.mobilecheck()?$("main").html($($(e)[67]).html()):$("main").append($($($(e)[67]).html())[0]),$(".page-footer").removeClass("padding-bottom-extra"),$(".page-footer").removeClass("padding-bottom-novideo"),$("#favicon").attr("href","static/images/favicon.png"),1==$("#alreadyfp").length?C():(Ae=!0,H=!0,C()),0===$("#alreadychannel").length&&$("head").append("
    ok",1e4);var o=0;document.getElementById("zicon").addEventListener("click",function(){o+=10,document.getElementById("zicon").style.paddingLeft=o+"%",o>=100&&(window.location.href="http://etys.no")}),!E.mobilecheck()&&Ve.winter&&Ve.start_snowfall()}var S={beginning:!0,toast:function(e){switch(e){case"addedsong":e=E.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":e=E.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=!1,$("#playlist_loader").addClass("hide"),$("#import").removeClass("hide");break;case"savedsettings":e=E.rnd(["I've saved your settings","I stored all your settings","Your settings have been stored in a safe place"]);break;case"wrongpass":e=E.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."]),T.remove_pass(M.toLowerCase()),S.display_logged_out(),P=!0;break;case"shuffled":e=E.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":e=E.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":e=E.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 Zöff for president","Only 999 more to go!"]);break;case"alreadyvoted":e=E.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":e=E.rnd(["The song was skipped","I have skipped a song","Skipped to the beat","Skipmaster3000","They see me skippin', they hatin'"]);break;case"listhaspass":e=E.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"]),T.remove_pass(M.toLowerCase()),S.display_logged_out(),P=!0;break;case"noskip":e=E.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":e=E.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":e="Skipping is disabled the first 10 seconds.";break;case"correctpass":e="Correct password. You now have access to the sacred realm of The Admin.";break;case"changedpass":e="Your password has been changed!";break;case"suggested":e="Your song was suggested!";break;case"alreadyplay":e="Seems the song you want is already playing. No fooling the system!"}Materialize.toast(e,4e3)},pw:function(e){P=!1,U=e,names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],T.set_pass(M.toLowerCase(),T.decrypt_pass(e));for(var t=0;t150||(e.value.startsWith("/name ")?I.namechange(e.value.substring(6)):e.value.startsWith("/removename")?I.removename():"#all_chat"==$(".chat-tab-li a.active").attr("href")?Le.emit("all,chat",e.value):Le.emit("chat",e.value),e.value="")},allchat:function(e){D||":"!=e.msg.substring(0,1)||ie||($("#favicon").attr("href","static/images/highlogo.png"),D=!0,j=!0,se=!0,le||I.chat_blink()),document.hidden&&$("#favicon").attr("href","static/images/highlogo.png");var t=E.intToARGB(E.hashCode(e.from));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=E.hexToRgb(t.substring(0,6));var o=E.rgbToHsl([t.r,t.g,t.b],!1);$("#chatall").append("
  • "+e.from+"
  • ");var n=document.createTextNode(e.msg);$("#chatall li:last")[0].appendChild(n),document.getElementById("chatall").scrollTop=document.getElementById("chatall").scrollHeight},channelchat:function(e){D||":"!=e.msg.substring(0,1)||ie||($("#favicon").attr("href","static/images/highlogo.png"),j=!0,se=!0,le||I.chat_blink());var t=E.intToARGB(E.hashCode(e.from));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=E.hexToRgb(t.substring(0,6));var o=E.rgbToHsl([t.r,t.g,t.b],!1);$("#chatchannel").append("
  • "+e.from+"
  • ");var n=document.createTextNode(e.msg);$("#chatchannel li:last")[0].appendChild(n),document.getElementById("chatchannel").scrollTop=document.getElementById("chatchannel").scrollHeight},chat_blink:function(){le=!0,$(".chat-link").attr("style","color: grey !important;"),setTimeout(function(){$(".chat-link").attr("style","color: white !important;"),setTimeout(function(){le&&I.chat_blink()},1e3)},1e3)}},T={conf_pass:void 0,init:function(){document.cookie=M.toLowerCase()+"=; path=/"+M.toLowerCase()+"; expires="+new Date(0).toUTCString();try{conf_arr=T.decrypt(T.getCookie("_opt"),"_opt")}catch(e){conf_arr=T.decrypt(T.create_cookie("_opt"),"_opt")}try{T.conf_pass=T.decrypt(T.getCookie(M.toLowerCase()),M.toLowerCase())}catch(e){T.conf_pass=T.decrypt(T.create_cookie(M.toLowerCase()),M.toLowerCase())}B.change_enabled(conf_arr.remote),100!=conf_arr.width&&Oe.set_width(conf_arr.width),void 0!==conf_arr.name&&""!==conf_arr.name&&I.namechange(conf_arr.name)},decrypt:function(e,t){void 0===T.getCookie(t)&&(e=T.create_cookie(t));var o=CryptoJS.AES.decrypt(e,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return $.parseJSON(o.toString(CryptoJS.enc.Utf8))},decrypt_pass:function(e){var t=CryptoJS.AES.decrypt(e,Le.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString(CryptoJS.enc.Utf8)},encrypt:function(e,t){var o=JSON.stringify(e),n=CryptoJS.AES.encrypt(o,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),a=new Date;a.setFullYear(a.getFullYear()+1),document.cookie=t+"="+n.toString()+";expires="+a.toGMTString()+";path=/;"},encrypt_string:function(e){var t=CryptoJS.AES.encrypt(e,Le.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString()},get_volume:function(){return T.decrypt(T.getCookie("_opt"),"_opt").volume},set_volume:function(e){conf_arr.volume=e,T.encrypt(conf_arr,"_opt")},create_cookie:function(e){"_opt"==e?cookie_object={volume:100,width:100,remote:!0,name:""}:cookie_object={passwords:{}};var t=JSON.stringify(cookie_object),o=CryptoJS.AES.encrypt(t,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),n=new Date;return n.setFullYear(n.getFullYear()+1),document.cookie=e+"="+o.toString()+";expires="+n.toGMTString()+";path=/;",T.getCookie(e)},set_pass:function(e,t){T.conf_pass.passwords[e]=t,T.encrypt(T.conf_pass,e)},remove_pass:function(e){delete T.conf_pass.passwords[e],T.encrypt(T.conf_pass,e.toLowerCase())},set_name:function(e){conf_arr.name=encodeURIComponent(e).replace(/\W/g,""),T.encrypt(conf_arr,"_opt")},remove_name:function(){conf_arr.name="",T.encrypt(conf_arr,"_opt")},get_pass:function(e){if(void 0!==T.conf_pass)return T.conf_pass.passwords[e]},set_remote:function(e){conf_arr.remote=e,T.encrypt(conf_arr,"_opt")},get_remote:function(e){return conf_arr.remote},crypt_pass:function(e){var t=CryptoJS.AES.encrypt(e,Le.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString()},get_width:function(){return conf_arr.width},set_width:function(e){conf_arr.width=e,T.encrypt(conf_arr,"_opt")},getCookie:function(e){var t="; "+document.cookie,o=t.split("; "+e+"=");if(2==o.length)return o.pop().split(";").shift()}},E={log:function(e){"true"===localStorage.debug&&console.log(e)},rnd:function(e){return e[Math.floor(Math.random()*e.length)]},mobilecheck:function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},predicate:function(){for(var e,t,o,n=[],a=arguments.length,i=function(e,t){return e===t?0:e>24&255).toString(16)+(e>>16&255).toString(16)+(e>>8&255).toString(16)+(255&e).toString(16)},hexToRgb:function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},pad:function(e){return e<10?"0"+Math.floor(e):Math.floor(e)},contains:function(e,t){for(var o=e.length;o--;)if(e[o]===t)return!0;return!1},sample:function(){Date.now()-X>=2*Q&&(Le.removeAllListeners(),Le.disconnect(),Le.connect(),Oe.setup_all_listeners()),X=Date.now(),setTimeout(E.sample,Q)},loadjsfile:function(e){if(F.indexOf("["+e+"]")==-1){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(t),F+="["+e+"]"}},msieversion:function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");return!!(t>0||navigator.userAgent.match(/Trident.*rv\:11\./))},getRandomInt:function(e,t){return Math.floor(Math.random()*(t-e))+e},rgbToHsl:function(e,t){r=e[0],g=e[1],b=e[2],r/=255,g/=255,b/=255;var o,n,a=Math.max(r,g,b),i=Math.min(r,g,b),s=(a+i)/2;if(a==i)o=n=0;else{var l=a-i;switch(n=s>.5?l/(2-a-i):l/(a+i),a){case r:o=(g-b)/l+(g.5&&t?s=.5:s<.65&&!t&&(s=.65),"hsl("+Math.floor(360*o)+", "+Math.floor(100*n)+"%, "+Math.floor(100*s)+"%)"},componentToHex:function(e){var t=e.toString(16);return 1==t.length?"0"+t:t},rgbToHex:function(e,t,o){return"#"+E.componentToHex(e)+E.componentToHex(t)+E.componentToHex(o)},upperFirst:function(e){return e.substring(0,1).toUpperCase()+e.substring(1).toLowerCase()},addClass:function(e,t){E.contains($(e).attr("class").split(" "),t)||$(e).addClass(t)},send_mail:function(e,t){""!==e&&""!==t&&($("#submit-contact-form").addClass("hide"),$("#send-loader").removeClass("hide"),$("#contact-form-from").attr("disabled","true"),$("#contact-form-message").attr("disabled","true"),e=$("#contact-form-from").val(),t=$("#contact-form-message").val(),$("#contact-container").empty(),newWindow=window.open("mailto:contact@zoff.no?Subject=Contact%20Zoff&Body="+t,"_blank"),$("#contact-container").html("Something went wrong, sorry about that. You could instead try with your own mail-client: contact@zoff.no"),setTimeout(function(){newWindow.close()},500))}};$(document).on("submit","#contact-form",function(e){e.preventDefault();var t=$("#contact-form-message").val(),o=$("#contact-form-from").val();E.send_mail(o,t)}),Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=0,t=this.length;e div:nth-child("+o+")").after(n)}var a=$("#wrapper").children()[o];t&&setTimeout(function(){$(a).css("height",66)},5)},populate_list:function(e){void 0===N&&(N=$("#list-song-html").html()),we=e,L.sortList(),$("#wrapper").empty(),E.log("---------------------------"),E.log("---------FULL PLAYLIST-----"),E.log(we),E.log("---------------------------"),we.length>1?($.each(we,function(e,t){t.now_playing||$("#wrapper").append(L.generateSong(t,!1,te,!0))}),te&&(E.mobilecheck()?$(".list-image").lazyload({}):($(".list-image").lazyload({container:$("#wrapper")}).removeClass("lazy"),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1))):(L.empty=!0,$("#wrapper").append("The playlist is empty.")),$("#settings").css("visibility","visible"),$("#settings").css("opacity","1"),$("#wrapper").css("opacity","1")},added_song:function(e){now_playing=we.pop(),we.push(e),L.sortList(),we.push(now_playing),$("#suggested-"+e.id).remove(),L.empty&&(L.empty=!1),$("#empty-channel-message").remove(),L.insertAtIndex(e,!0)},deleted_song:function(e){var t=L.getIndexOfSong(e),o=$("#wrapper").children()[t];try{o.style.height=0,setTimeout(function(){$("#"+e).remove(),we.splice(L.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(t){we.splice(L.getIndexOfSong(e),1),L.empty||$("#wrapper").children()[$("#wrapper").children().length-1].remove()}we.length<=2&&(L.empty=!0,$("#wrapper").append("The playlist is empty.")),$("#suggested-"+e).remove(),Ye.checkUserEmpty()},voted_song:function(e,t){var o=L.getIndexOfSong(e),n=we[o];we[o].votes+=1,we[o].added=t,L.sortList(),$("#"+e).remove(),L.insertAtIndex(n,!1)},song_change:function(e){var t=we.length-1;we[0].now_playing=!0,we[0].votes=0,we[0].guids=[],we[0].added=e,we[t].now_playing=!1,E.log("---------------------------"),E.log("---SONG ON FIRST INDEX-----"),E.log(we[0]),E.log("---------------------------");try{we.push(we.shift()),L.empty||$("#wrapper").children()[0].remove(),0===$("#wrapper").children().length&&(L.empty=!0,$("#wrapper").append("The playlist is empty.")),L.insertAtIndex(we[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(e){}},vote:function(e,t){return Le.emit("vote",{channel:M,id:e,type:t,adminpass:U}),!0},skip:function(){return Le.emit("skip",{pass:U,id:Ie,channel:M.toLowerCase()}),!0},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",Te=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(Te.songs,function(e,n){t+=n.id+",",o>45&&(qe.addVideos(t),t="",o=0),o++}),qe.addVideos(t),document.getElementById("search").value=""},sortList:function(){we.sort(E.predicate({name:"votes",reverse:!0},{name:"added",reverse:!1},{name:"title",reverse:!1}))},show:function(){E.mobilecheck()||(z?(z=!1,$("#toptitle").empty(), -$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+M.toLowerCase())):(z=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(M)))},generateSong:function(e,t,o,n,a){var i,s,l=e.id,r=e.title,c=e.votes,d="background-image:url('//img.youtube.com/vi/"+l+"/mqdefault.jpg');",p=$("
    "+N+"
    "),u="style";return t&&p.find("#list-song").css("height",0),P||p.find(".card-action").removeClass("hide"),1==c&&p.find(".vote-text").text("vote"),o&&(d="//img.youtube.com/vi/"+l+"/mqdefault.jpg",u="data-original"),n?(p.find(".list-votes").text(c),p.find("#list-song").attr("id",l),p.find(".vote-container").attr("title",r),i=".vote-container",s="del"):n||(p.find(".vote-text").text(e.duration),i=".add-suggested",s=a?"del_user_suggested":"del_suggested",p.find(".vote-container").attr("class","clickable add-suggested"),p.find(".add-suggested").attr("title",r),p.find("#del").attr("id",s),p.find(i).attr("data-video-title",r),p.find(i).attr("data-video-length",e.length),p.find("#list-song").attr("id","suggested-"+l),p.find(".list-image").attr("class",p.find(".list-image").attr("class").replace("list-image","list-suggested-image"))),p.find(".list-title").text(r),p.find(".list-title").attr("title",r),p.find(i).attr("data-video-id",l),p.find(".list-image").attr(u,d),p.find(".list-suggested-image").attr(u,d),p.find("#"+s).attr("data-video-id",l),p.html()},getIndexOfSong:function(e){return indexes=$.map(we,function(t,o){if(t.id==e)return o}),indexes[0]},scrollTop:function(){$("#wrapper").scrollTop(0)},scrollBottom:function(){$("#wrapper").scrollTop($("#wrapper")[0].scrollHeight)}},M=void 0===window.chan?$("#chan").html():window.chan,P=!0,A=0,z=!0,N=$("#list-song-html").html(),D=!1,j=!1,V="***REMOVED***",O=!1,R=/P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/,q=[],Y=0,H=1,U="",F="",J=!1,G=1,W=!1,Z=!1,Q=6e3,X=Date.now(),K=!1,ee=-1,te=!0,oe=!1,ne=!0,ae=!1,ie=!1,se=!1,le=!1,re={},ce=!1,de="",pe=300,ue=600,me="&autoplay",ge=!1;if(void 0===localStorage.debug){var he=!1;localStorage.debug=he}var fe,ye,ve,$e,be,we,q,_e,ke,Ce,Se,G,Ie,Te,xe,Ee,Be,Le,Me={"sync disconnect on unload":!0,secure:!0,"force new connection":!0},Pe=!1,Ae=!1;navigator.serviceWorker?navigator.serviceWorker.register("/service-worker.js",{scope:"/"}).then(function(e){E.log(e)}).catch(function(e){console.error(e)}):E.log("Service Worker is not supported in this browser."),$().ready(function(){Pe||"/"==window.location.pathname?Ae||"/"!=window.location.pathname||C():e(),Le.on("connect",function(){ge&&(ge=!1,$(".connect_error").fadeOut(function(){$(".connect_error").remove(),Materialize.toast("Connected!",2e3,"green lighten")}))}),t();try{Ne=$.ajax({type:"GET",url:"https://api.github.com/repos/zoff-music/zoff/commits",async:!1}).responseText,Ne=$.parseJSON(Ne),$("#latest-commit").html("Latest Commit:
    "+Ne[0].commit.author.date.substring(0,10)+": "+Ne[0].committer.login+"
    "+Ne[0].sha.substring(0,10)+": "+Ne[0].commit.message+"=48&&$("#wrapper").scrollTop()>0?($("#top-button").removeClass("hide"),E.addClass("#bottom-button","hide")):t>=$("#playlist").height()-18&&$("#wrapper").scrollTop()<$("#wrapper")[0].scrollHeight-$("#wrapper").height()-1?($("#bottom-button").removeClass("hide"),E.addClass("#top-button","hide")):(E.addClass("#bottom-button","hide"),E.addClass("#top-button","hide"))}),$(document).on("mouseleave","#playlist",function(){E.addClass("#bottom-button","hide"),E.addClass("#top-button","hide")}),$(document).on("click","#top-button",function(){L.scrollTop()}),$(document).on("click","#bottom-button",function(){L.scrollBottom()});var ze,Ne,Le,De,je={id:"",get_input:function(e){""===je.id?je.set_id(e.toLowerCase()):je.set_channel(e.toLowerCase())},set_id:function(e){je.id=e,$("#pausebutton_remote").attr("disabled",!1),$("#skipbutton_remote").attr("disabled",!1),$("#playbutton_remote").attr("disabled",!1),$("#skipbutton_remote").attr("disabled",!1),$("#remote_channel").val(""),$("#remote_channel").attr("placeholder","Change channel"),$("#remote_header").html("Controlling "+e),$("#volume-control-remote").css("display","block")},set_channel:function(e){Le.emit("id",{id:je.id,type:"channel",value:e})},play_remote:function(){Le.emit("id",{id:je.id,type:"play",value:"mock"})},pause_remote:function(){Le.emit("id",{id:je.id,type:"pause",value:"mock"})},skip_remote:function(){Le.emit("id",{id:je.id,type:"skip",value:"mock"})},initiate_volume:function(){$("#volume-control-remote").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,t){Le.emit("id",{id:je.id,type:"volume",value:t.value}),E.log("volume")}})}},H=!0,Ve={blob_list:[],winter:!1,times_rotated:0,frontpage_function:function(e){$("#channels").empty(),H=!0,Ve.populate_channels(e.channels),Ve.set_viewers(e.viewers)},populate_channels:function(e){var t,o="",n=0;1==e[0][5]&&(t=e.shift()),e.sort(Ve.sortFunction),void 0!==t&&e.unshift(t),pre_card=$(ze),E.mobilecheck()||Ve.add_backdrop(e,0);for(var a in e){var i=e[a][3];if(n<12){var s=e[a][1],l=e[a][0],r="background-image:url('https://img.youtube.com/vi/"+s+"/hqdefault.jpg');",c=e[a][4],d=pre_card;1==e[a][5]?(d.find(".pin").attr("style","display:block;"),d.find(".card").attr("title","Pinned!")):(d.find(".pin").attr("style","display:none;"),d.find(".card").attr("title","")),d.find(".chan-name").text(i),d.find(".chan-name").attr("title",i),d.find(".chan-views").text(l),d.find(".chan-songs").text(c),d.find(".chan-bg").attr("style",r),d.find(".chan-link").attr("href",i),$("#channels").append(d.html())}o+="