Files
zoff/static/dist/embed.min.js
Kasper Rynning-Tønnesen 5469c00cfa Fixed spotify import even better
2016-09-01 15:16:04 +02:00

1 line
22 KiB
JavaScript
Executable File

!function(){function e(){s.on("np",n.youtube_listener)}function t(){s.on("channel",u.channel_function)}function o(e){$("#volume").slider("value",e),d.setVolume(e)}var n={loaded:!0,before_load:"",after_load:"",ytplayer:"",stopInterval:!1,youtube_listener:function(e){if(n.loaded=!1,"true"===localStorage.debug){console.log("--------youtube_listener--------"),console.log("Received: "),console.log(e),console.log("paused variable: "+m),console.log("mobile_beginning variable: "+C);try{console.log("getVideoUrl(): "+n.ytplayer.getVideoUrl().split("v=")[1])}catch(e){}console.log("video_id variable: "+l),console.log("---------------------------------")}if(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.ytplayer.stopVideo()}catch(e){}}else{void 0===c?c=e[0][0].id:c!=l&&(c=l),l=e[0][0].id,conf=e[1][0],time=e[2],i=time-conf.startTime,p=e[0][0].title,duration=e[0][0].duration,C&&a.mobilecheck()&&0===i&&(i=1);try{full_playlist[0].id==l&&u.song_change(full_playlist[0].added),Suggestions.fetchYoutubeSuggests(l)}catch(e){}if(n.getTitle(p,viewers),n.setBGimage(l),h&&!window.MSStream)try{n.ytplayer.getVideoUrl().split("v=")[1]!=l&&(n.ytplayer.loadVideoById(l),n.notifyUser(l,p),n.ytplayer.seekTo(i),m&&n.ytplayer.pauseVideo()),m||(C||n.ytplayer.playVideo(),S||n.durationSetter()),(n.ytplayer.getDuration()>i||0===n.ytplayer.getDuration())&&n.ytplayer.seekTo(i),n.after_load=l,n.loaded||setTimeout(function(){n.loaded=!0},500)}catch(e){S||n.durationSetter()}else n.getTitle(p,viewers)}},onPlayerStateChange:function(e){if("true"===localStorage.debug){console.log("-------onPlayerStateChange------"),console.log("New state\nState: "),console.log(e);try{console.log("Duration: "+n.ytplayer.getDuration(),"Current time: "+n.ytplayer.getCurrentTime()),console.log("getVideoUrl(): "+n.ytplayer.getVideoUrl().split("v=")[1])}catch(e){}console.log("video_id variable: "+l),console.log("---------------------------------")}switch(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.ytplayer.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.ytplayer.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.ytplayer.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.ytplayer.loadVideoById(l),x&&!a.mobilecheck()&&n.ytplayer.playVideo(),S||n.durationSetter(),w?setTimeout(function(){n.ytplayer.seekTo(i),x||(n.ytplayer.pauseVideo(),d.play_pause_show())},1e3):n.ytplayer.seekTo(i)),n.readyLooks(),d.initYoutubeControls(n.ytplayer),d.initSlider(),n.ytplayer.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(/&quot;/g,"'").replace(/&amp;/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.ytplayer=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.ytplayer.getCurrentTime()?Math.floor(n.ytplayer.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)+" <span id='dash'>/</span> "+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(){1==$("script[src='https://www.youtube.com/iframe_api']").length?n.onYouTubeIframeAPIReady():(tag=document.createElement("script"),tag.src="https://www.youtube.com/iframe_api",firstScriptTag=document.getElementsByTagName("script")[0],firstScriptTag.parentNode.insertBefore(tag,firstScriptTag))}},a={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<t?-1:1},s=function(e,t){var o=i,n=i;return e&&(n=function(t,n){return o(e(t),e(n))}),t?function(e,t){return-1*n(e,t)}:n},l=0;l<a;l++)e=arguments[l],"string"==typeof e?(t=e,o=i):(t=e.name,o=s(e.primer,e.reverse)),n.push({name:t,cmp:o});return function(t,o){for(var i,s,l=0;l<a&&(s=0,e=n[l],i=e.name,s=e.cmp(t[i],o[i]),0===s);l++);return s}},hashCode:function(e){for(var t=0,o=0;o<e.length;o++)t=e.charCodeAt(o)+((t<<5)-t);return t},intToARGB:function(e){return(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<b?6:0);break;case g:o=(b-r)/l+2;break;case b:o=(r-g)/l+4}o/=6}return s>.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: <a title='Open in client' href='mailto:contact@zoff.no?Subject=Contact%20Zoff&Body="+t+"'>contact@zoff.no</a>"),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<t;e++)this[e]&&this[e].parentElement&&this[e].parentElement.removeChild(this[e])},String.prototype.startsWith=function(e,t){return t=t||0,this.indexOf(e,t)===t};var i,s,l,c,d={stopInterval:!1,initYoutubeControls:function(){!a.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||$("#controls").appendTo("#playbar"),d.initControls()},initControls:function(){document.getElementById("volume-button").addEventListener("click",d.mute_video),document.getElementById("playpause").addEventListener("click",d.play_pause),document.getElementById("fullscreen").addEventListener("click",d.fullscreen)},initSlider:function(){try{_=Crypt.get_volume()}catch(e){}$("#volume").slider({min:0,max:100,value:_,range:"min",animate:!0,slide:function(e,t){d.setVolume(t.value);try{Crypt.set_volume(t.value)}catch(e){}}}),d.choose_button(_,!1)},fullscreen:function(){var e=document.getElementById("player"),t=e.requestFullScreen||e.mozRequestFullScreen||e.webkitRequestFullScreen;t&&t.bind(e)()},play_pause:function(){1==n.ytplayer.getPlayerState()?(n.ytplayer.pauseVideo(),!a.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||(document.getElementById("player").style.display="none",$(".video-container").toggleClass("click-through"),$(".page-footer").toggleClass("padding-bottom-extra"))):2!=n.ytplayer.getPlayerState()&&0!==n.ytplayer.getPlayerState()||(n.ytplayer.playVideo(),!a.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||(document.getElementById("player").style.display="block",$(".video-container").toggleClass("click-through"),$(".page-footer").toggleClass("padding-bottom-extra")))},play_pause_show:function(){1==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide"),2==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide")},settings:function(){$("#qS").toggleClass("hide")},changeQuality:function(e){n.ytplayer.getPlaybackQuality!=e&&(n.ytplayer.setPlaybackQuality(e),n.ytplayer.getPlaybackQuality()),$("#qS").toggleClass("hide")},mute_video:function(){n.ytplayer.isMuted()?(n.ytplayer.unMute(),d.choose_button(n.ytplayer.getVolume(),!1)):(d.choose_button(0,!0),n.ytplayer.mute())},setVolume:function(e){n.ytplayer.setVolume(e),d.choose_button(e,!1),n.ytplayer.isMuted()&&n.ytplayer.unMute()},choose_button:function(e,t){t?(1==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"),2==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):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.ytplayer.getPlayerState(),button=document.getElementById("playpause"),1==state?n.ytplayer.pauseVideo():2==state&&n.ytplayer.playVideo()},volumeOptions:function(){n.ytplayer.isMuted()?(n.ytplayer.unMute(),_=n.ytplayer.getVolume(),$("#volume").slider("value",n.ytplayer.getVolume())):(n.ytplayer.mute(),$("#volume").slider("value",0))},hoverMute:function(e){_=n.ytplayer.getVolume()}},u={empty:!1,channel_function:function(e){switch(e[0]){case"list":u.populate_list(e[1]);break;case"added":u.added_song(e[1]);break;case"deleted":u.deleted_song(e[1]);break;case"vote":u.voted_song(e[1],e[2]);break;case"song_change":"/"!=window.location.pathname&&u.song_change(e[1])}},insertAtBeginning:function(e,t){var o=u.generateSong(e,t,!1,!0,!1);$("#wrapper").append(o)},insertAtIndex:function(e,t){var o=u.getIndexOfSong(e.id);if(!e.now_playing){var n=u.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===y&&(y=$("#list-song-html").html()),full_playlist=e,u.sortList(),$("#wrapper").empty(),"true"===localStorage.debug&&(console.log("---------------------------"),console.log("---------FULL PLAYLIST-----"),console.log(full_playlist),console.log("---------------------------")),full_playlist.length>1?($.each(full_playlist,function(e,t){t.now_playing||$("#wrapper").append(u.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))):(u.empty=!0,$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>")),$("#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),u.sortList(),full_playlist.push(now_playing),$("#suggested-"+e.id).remove(),u.empty&&(u.empty=!1),$("#empty-channel-message").remove(),u.insertAtIndex(e,!0)},deleted_song:function(e){var t=u.getIndexOfSong(e),o=$("#wrapper").children()[t];try{o.style.height=0,setTimeout(function(){$("#"+e).remove(),full_playlist.splice(u.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(t){full_playlist.splice(u.getIndexOfSong(e),1),u.empty||$("#wrapper").children()[$("#wrapper").children().length-1].remove()}full_playlist.length<=2&&(u.empty=!0,$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>")),$("#suggested-"+e).remove(),Suggestions.checkUserEmpty()},voted_song:function(e,t){var o=u.getIndexOfSong(e),n=full_playlist[o];full_playlist[o].votes+=1,full_playlist[o].added=t,u.sortList(),$("#"+e).remove(),u.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,"true"===localStorage.debug&&(console.log("---------------------------"),console.log("---SONG ON FIRST INDEX-----"),console.log(full_playlist[0]),console.log("---------------------------"));try{full_playlist.push(full_playlist.shift()),u.empty||$("#wrapper").children()[0].remove(),0===$("#wrapper").children().length&&(u.empty=!0,$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>")),u.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",[T,e,t,k]),!0},skip:function(){return s.emit("skip",{pass:k,id:l}),!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');",u=$("<div>"+y+"</div>"),p="style";return t&&u.find("#list-song").css("height",0),f||u.find(".card-action").removeClass("hide"),1==c&&u.find(".vote-text").text("vote"),o&&(d="//img.youtube.com/vi/"+l+"/mqdefault.jpg",p="data-original"),n?(u.find(".list-votes").text(c),u.find("#list-song").attr("id",l),u.find(".vote-container").attr("title",r),i=".vote-container",s="del"):n||(u.find(".vote-text").text(e.duration),i=".add-suggested",s=a?"del_user_suggested":"del_suggested",u.find(".vote-container").attr("class","clickable add-suggested"),u.find(".add-suggested").attr("title",r),u.find("#del").attr("id",s),u.find(i).attr("data-video-title",r),u.find(i).attr("data-video-length",e.length),u.find("#list-song").attr("id","suggested-"+l),u.find(".list-image").attr("class",u.find(".list-image").attr("class").replace("list-image","list-suggested-image"))),u.find(".list-title").text(r),u.find(".list-title").attr("title",r),u.find(i).attr("data-video-id",l),u.find(".list-image").attr(p,d),u.find(".list-suggested-image").attr(p,d),u.find("#"+s).attr("data-video-id",l),u.html()},getIndexOfSong:function(e){return console.log(full_playlist),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)}},p="",m=!1,h=!1,y=$("#list-song-html").html(),f=!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('<link type="text/css" rel="stylesheet" href="/static/css/embed.css" />'),$("head").append('<link type="text/css" rel="stylesheet" href="/static/css/materialize.min.css" />'),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!==p&&n.getTitle(p,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");u.vote(t,"pos")})}();