!function(){function e(){var e=!0;L=$("#chan").html(),ue=T.mobilecheck();var t=T.mobilecheck()?"left":"right";if(window.onpopstate=function(e){w()},v(),"zoff.no"==window.location.hostname?add="https://zoff.no":add=window.location.hostname,void 0!==Ne&&(Ne.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(re),de=$("#temp-results-container"),pe=$("#empty-results-container").html(),$(".video-container").resizable({start:function(e,t){$("iframe").css("pointer-events","none")},stop:function(e,t){$("iframe").css("pointer-events","auto"),I.set_width($(this).width())},handles:"e",minWidth:350}),(void 0===Se||T.mobilecheck())&&(e=!1,Se=io.connect(""+add+":8880",Ie)),0===$("#alreadychannel").length||T.mobilecheck())o(),n(),a(),i();else{$("#channel-load").css("display","none"),$("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),Ne.readyLooks(),ze.initYoutubeControls(Ne.ytplayer),ze.initSlider(),Ne.ytplayer.setVolume(I.get_volume()),$(".video-container").removeClass("no-opacity");var r="https://remote."+window.location.hostname+"/"+ge;$("#code-text").text(ge),$("#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&&Se.emit("list",L.toLowerCase()),/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream?(document.getElementById("search").blur(),$("#channel-load").css("display","none")):(window.onYouTubeIframeAPIReady=Ne.onYouTubeIframeAPIReady,(""===Ne.ytplayer||void 0===Ne.ytplayer||T.mobilecheck())&&Ne.loadPlayer()),T.mobilecheck()&&Pe.initiate_volume(),s(),c(),l(),T.mobilecheck()||0!==$("#alreadychannel").length||p(),T.msieversion()||Notification.requestPermission(),$(".search_input").focus(),T.sample(),$("#results").hover(function(){$("div.result").removeClass("hoverResults"),K=0},function(){}),$("#search").focus(),$("#embed-button").css("display","inline-block"),$("#embed-area").val(''),$("#search").attr("placeholder","Find song on YouTube...")}function t(){Se.on("connect_failed",function(){console.log("Connection Failed")}),Se.on("connect_error",function(){console.log("Connection failed.")})}function o(){Se.on("np",Ne.youtube_listener)}function n(){Se.on("get_list",function(){Se.emit("list",L.toLowerCase())})}function a(){Se.on("suggested",function(e){var t=!0;void 0===e.id&&(t=!1),De.catchUserSuggests(e,t)})}function i(){Se.on("viewers",function(e){J=e,void 0!==ke&&Ne.getTitle(ke,J)})}function s(){Se.on("toast",C.toast),Se.on("pw",C.pw),Se.on("conf",C.conf)}function l(){Se.on("chat.all",S.allchat),Se.on("chat",S.channelchat)}function c(){Se.on("channel",B.channel_function)}function d(){Se.on("playlists",Me.frontpage_function)}function p(){Se.on("id",E.host_listener)}function u(e){Se.on(e,E.host_on_action)}function m(){localStorage.debug=!0}function h(){localStorage.debug=!1}function y(e){e?("true"===localStorage.debug&&(console.log("------------------------"),console.log("Spotify is authenticated"),console.log("access_token: "+le.access_token),console.log("token_type:"+le.token_type),console.log("expires_in: "+le.expires_in),console.log("------------------------")),$(".spotify_authenticated").css("display","block"),$(".spotify_unauthenticated").css("display","none")):"true"===localStorage.debug&&(console.log("----------------------------"),console.log("Spotify is not authenticated"),console.log("----------------------------"),$(".spotify_authenticated").css("display","none"),$(".spotify_unauthenticated").css("display","block"))}function f(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(me),search_input.length<3&&$("#results").html(""),13==code?Ae.search(search_input):me=setTimeout(function(){Ae.search(search_input)},1e3))}function v(){$("#facebook-code-link").attr("href","https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+L.toLowerCase()),$("#facebook-code-link").attr("onclick","window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+L.toLowerCase()+"', 'Share Playlist','width=600,height=300'); return false;"),$("#twitter-code-link").attr("href","http://twitter.com/intent/tweet?url=https://zoff.no/"+L.toLowerCase()+"&text=Check%20out%20this%20playlist%20"+L.toLowerCase()+"%20on%20Zöff!&via=zoffmusic"),$("#twitter-code-link").attr("onclick","window.open('http://twitter.com/intent/tweet?url=https://zoff.no/"+L.toLowerCase()+"/&text=Check%20out%20this%20playlist%20"+L.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/"+L.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/"+L.toLowerCase()+"&choe=UTF-8&chld=L%7C1")}function w(){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),Ne.stopInterval=!0,C.display_logged_out(),C.beginning=!0,X=!1,ne=!1,$("#embed-button").css("display","none"),$.ajax({url:"php/nochan.php",success:function(e){if(T.mobilecheck()?(Se.removeAllListeners(),Se.disconnect()):(Se.removeEventListener("chat.all"),Se.removeEventListener("chat"),Se.removeEventListener("conf"),Se.removeEventListener("pw"),Se.removeEventListener("toast"),Se.removeEventListener("channel")),document.getElementById("volume-button").removeEventListener("click",ze.mute_video),document.getElementById("playpause").removeEventListener("click",ze.play_pause),document.getElementById("fullscreen").removeEventListener("click",ze.fullscreen),T.mobilecheck()&&(be="",ke=""),$("meta[name=theme-color]").attr("content","#2D2D2D"),T.mobilecheck()){try{Ne.ytplayer.destroy()}catch(e){}Ne.ytplayer="",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"),T.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?k():(Ee=!0,Y=!0,k()),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")}),!T.mobilecheck()&&Me.winter&&Me.start_snowfall()}var C={beginning:!0,toast:function(e){switch(e){case"addedsong":e=T.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=T.rnd(["I added the playlist","Your playlist has been added","Yay, many more songes!","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=T.rnd(["I've saved your settings","I stored all your settings","Your settings have been stored in a safe place"]);break;case"wrongpass":e=T.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."]),I.remove_pass(L.toLowerCase()),C.display_logged_out(),P=!0;break;case"shuffled":e=T.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=T.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=T.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=T.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=T.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=T.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"]),I.remove_pass(L.toLowerCase()),C.display_logged_out(),P=!0;break;case"noskip":e=T.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=T.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,H=e,names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],I.set_pass(L.toLowerCase(),I.decrypt_pass(e));for(var t=0;t150||(e.value.startsWith("/name ")?S.namechange(e.value.substring(6)):e.value.startsWith("/removename")?S.removename():"#all_chat"==$(".chat-tab-li a.active").attr("href")?Se.emit("all,chat",e.value):Se.emit("chat",e.value),e.value="")},allchat:function(e){A||":"!=e[1].substring(0,1)||ae||($("#favicon").attr("href","static/images/highlogo.png"),A=!0,D=!0,ie=!0,se||S.chat_blink()),document.hidden&&$("#favicon").attr("href","static/images/highlogo.png");var t=T.intToARGB(T.hashCode(e[0]));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=T.hexToRgb(t.substring(0,6));var o=T.rgbToHsl([t.r,t.g,t.b],!1);$("#chatall").append("
  • "+e[0]+"
  • ");var n=document.createTextNode(e[1]);$("#chatall li:last")[0].appendChild(n),document.getElementById("chatall").scrollTop=document.getElementById("chatall").scrollHeight},channelchat:function(e){A||":"!=e[1].substring(0,1)||ae||($("#favicon").attr("href","static/images/highlogo.png"),D=!0,ie=!0,se||S.chat_blink());var t=T.intToARGB(T.hashCode(e[0]));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=T.hexToRgb(t.substring(0,6));var o=T.rgbToHsl([t.r,t.g,t.b],!1);$("#chatchannel").append("
  • "+e[0]+"
  • ");var n=document.createTextNode(e[1]);$("#chatchannel li:last")[0].appendChild(n),document.getElementById("chatchannel").scrollTop=document.getElementById("chatchannel").scrollHeight},chat_blink:function(){se=!0,$(".chat-link").attr("style","color: grey !important;"),setTimeout(function(){$(".chat-link").attr("style","color: white !important;"),setTimeout(function(){se&&S.chat_blink()},1e3)},1e3)}},I={conf_pass:void 0,init:function(){document.cookie=L.toLowerCase()+"=; path=/"+L.toLowerCase()+"; expires="+new Date(0).toUTCString();try{conf_arr=I.decrypt(I.getCookie("_opt"),"_opt")}catch(e){conf_arr=I.decrypt(I.create_cookie("_opt"),"_opt")}try{I.conf_pass=I.decrypt(I.getCookie(L.toLowerCase()),L.toLowerCase())}catch(e){I.conf_pass=I.decrypt(I.create_cookie(L.toLowerCase()),L.toLowerCase())}E.change_enabled(conf_arr.remote),100!=conf_arr.width&&Ne.set_width(conf_arr.width),void 0!==conf_arr.name&&""!==conf_arr.name&&S.namechange(conf_arr.name)},decrypt:function(e,t){void 0===I.getCookie(t)&&(e=I.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,Se.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,Se.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString()},get_volume:function(){return I.decrypt(I.getCookie("_opt"),"_opt").volume},set_volume:function(e){conf_arr.volume=e,I.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=/;",I.getCookie(e)},set_pass:function(e,t){I.conf_pass.passwords[e]=t,I.encrypt(I.conf_pass,e)},remove_pass:function(e){delete I.conf_pass.passwords[e],I.encrypt(I.conf_pass,e.toLowerCase())},set_name:function(e){conf_arr.name=encodeURIComponent(e).replace(/\W/g,""),I.encrypt(conf_arr,"_opt")},remove_name:function(){conf_arr.name="",I.encrypt(conf_arr,"_opt")},get_pass:function(e){if(void 0!==I.conf_pass)return I.conf_pass.passwords[e]},set_remote:function(e){conf_arr.remote=e,I.encrypt(conf_arr,"_opt")},get_remote:function(e){return conf_arr.remote},crypt_pass:function(e){var t=CryptoJS.AES.encrypt(e,Se.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,I.encrypt(conf_arr,"_opt")},getCookie:function(e){var t="; "+document.cookie,o=t.split("; "+e+"=");if(2==o.length)return o.pop().split(";").shift()}},T={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()-Q>=2*Z&&(Se.removeAllListeners(),Se.disconnect(),Se.connect(),Ne.setup_all_listeners()),Q=Date.now(),setTimeout(T.sample,Z)},loadjsfile:function(e){if(U.indexOf("["+e+"]")==-1){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(t),U+="["+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"#"+T.componentToHex(e)+T.componentToHex(t)+T.componentToHex(o)},upperFirst:function(e){return e.substring(0,1).toUpperCase()+e.substring(1).toLowerCase()},addClass:function(e,t){T.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();T.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===z&&(z=$("#list-song-html").html()),he=e,B.sortList(),$("#wrapper").empty(),"true"===localStorage.debug&&(console.log("---------------------------"),console.log("---------FULL PLAYLIST-----"),console.log(he),console.log("---------------------------")),he.length>1?($.each(he,function(e,t){t.now_playing||$("#wrapper").append(B.generateSong(t,!1,ee,!0))}),ee&&(T.mobilecheck()?$(".list-image").lazyload({}):($(".list-image").lazyload({container:$("#wrapper")}).removeClass("lazy"),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1))):(B.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=he.pop(),he.push(e),B.sortList(),he.push(now_playing),$("#suggested-"+e.id).remove(),B.empty&&(B.empty=!1),$("#empty-channel-message").remove(),B.insertAtIndex(e,!0)},deleted_song:function(e){var t=B.getIndexOfSong(e),o=$("#wrapper").children()[t];try{o.style.height=0,setTimeout(function(){$("#"+e).remove(),he.splice(B.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(t){he.splice(B.getIndexOfSong(e),1),B.empty||$("#wrapper").children()[$("#wrapper").children().length-1].remove()}he.length<=2&&(B.empty=!0,$("#wrapper").append("The playlist is empty.")),$("#suggested-"+e).remove(),De.checkUserEmpty()},voted_song:function(e,t){var o=B.getIndexOfSong(e),n=he[o];he[o].votes+=1,he[o].added=t,B.sortList(),$("#"+e).remove(),B.insertAtIndex(n,!1)},song_change:function(e){var t=he.length-1;he[0].now_playing=!0,he[0].votes=0,he[0].guids=[],he[0].added=e,he[t].now_playing=!1,"true"===localStorage.debug&&(console.log("---------------------------"),console.log("---SONG ON FIRST INDEX-----"),console.log(he[0]),console.log("---------------------------"));try{he.push(he.shift()),B.empty||$("#wrapper").children()[0].remove(),0===$("#wrapper").children().length&&(B.empty=!0,$("#wrapper").append("The playlist is empty.")),B.insertAtIndex(he[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(e){}},vote:function(e,t){return Se.emit("vote",[L,e,t,H]),!0},skip:function(){return Se.emit("skip",{pass:H,id:be}),!0},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",$e=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each($e.songs,function(e,n){t+=n.id+",",o>45&&(Ae.addVideos(t),t="",o=0),o++}),Ae.addVideos(t),document.getElementById("search").value=""},sortList:function(){he.sort(T.predicate({name:"votes",reverse:!0},"added"))},show:function(){T.mobilecheck()||(N?(N=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+L.toLowerCase())):(N=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(L)))},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=$("
    "+z+"
    "),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(he,function(t,o){if(t.id==e)return o}),indexes[0]},scrollTop:function(){$("#wrapper").scrollTop(0)},scrollBottom:function(){$("#wrapper").scrollTop($("#wrapper")[0].scrollHeight)}},L=void 0===window.chan?$("#chan").html():window.chan,P=!0,M=0,N=!0,z=$("#list-song-html").html(),A=!1,D=!1,V="***REMOVED***",j=!1,O=/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)?)?/,R=[],q=0,Y=1,H="",U="",F=!1,J=1,G=!1,W=!1,Z=6e3,Q=Date.now(),X=!1,K=-1,ee=!0,te=!1,oe=!0,ne=!1,ae=!1,ie=!1,se=!1,le={},re=!1;if(void 0===localStorage.debug){var ce=!1;localStorage.debug=ce}var de,pe,ue,me,ge,he,R,ye,fe,ve,we,J,be,$e,_e,ke,Ce,Se,Ie={"sync disconnect on unload":!0,secure:!0,"force new connection":!0},Te=!1,Ee=!1;navigator.serviceWorker?navigator.serviceWorker.register("/service-worker.js",{scope:"/"}).then(function(e){console.log(e)}).catch(function(e){console.error(e)}):console.log("Service Worker is not supported in this browser."),$().ready(function(){Te||"/"==window.location.pathname?Ee||"/"!=window.location.pathname||k():e(),t(),Be=$.ajax({type:"GET",url:"https://api.github.com/repos/zoff-music/zoff/commits",async:!1}).responseText,Be=$.parseJSON(Be),$("#latest-commit").html("Latest Commit:
    "+Be[0].commit.author.date.substring(0,10)+": "+Be[0].committer.login+"
    "+Be[0].sha.substring(0,10)+": "+Be[0].commit.message+"'):$("#embed-area").val('')}),$(document).on("click","#playbutton_remote",function(e){e.preventDefault(),Pe.play_remote()}),$(document).on("click","#pausebutton_remote",function(e){e.preventDefault(),Pe.pause_remote()}),$(document).on("click","#skipbutton_remote",function(e){e.preventDefault(),Pe.skip_remote()}),$(document).on("submit","#remoteform",function(e){e.preventDefault(),Pe.get_input($("#remote_channel").val())}),$(document).on("click","#chat-btn",function(){$("#text-chat-input").focus(),$("#chat-btn i").css("opacity",1),clearInterval(ye),A=!1,D=!1,$("#favicon").attr("href","static/images/favicon.png")}),/iPad|iPhone|iPod/.test(navigator.userAgent)?$(document).on("keydown",".search_input",function(e){f(e)}):$(document).on("keyup",".search_input",function(e){f(e)}),$(document).on("click",".chat-tab",function(){$("#text-chat-input").focus()}),$(document).on("click","#skip",function(e){e.preventDefault(),B.skip()}),$(document).on("click","#chan",function(e){e.preventDefault(),B.show()}),$(document).on("submit","#adminForm",function(e){e.preventDefault(),C.pass_save()}),$(document).on("click",".chat-link",function(e){ae=!0,D=!1,ie=!1,$(".chat-link").attr("style","color: white !important;"),se=!1,$("#favicon").attr("href","static/images/favicon.png"),$("#chatPlaylist").css("display","block"),$("#wrapper").css("display","none"),$("#suggestions").css("display","none"),$("#text-chat-input").focus()}),$(document).on("click",".playlist-link",function(e){ae=!1,$("#chatPlaylist").css("display","none"),$("#wrapper").css("display","block"),$("#suggestions").css("display","none")}),$(document).on("click",".suggested-link",function(e){ae=!1,$("#chatPlaylist").css("display","none"),$("#wrapper").css("display","none"),$("#suggestions").css("display","block")}),$(document).on("click",".import-spotify-auth",function(e){e.preventDefault(),window.callback=function(e){le=e,re=!0,y(!0),setTimeout(function(){re=!1,y(!1),$(".spotify_authenticated").css("display","none"),$(".spotify_unauthenticated").css("display","block")},1e3*le.expires_in),spotify_window.close(),window.callback=""},spotify_window=window.open("/spotify_callback","","width=600, height=600")}),$(document).on("click",".import-youtube",function(e){e.preventDefault(),$(".youtube_unclicked").css("display","none"),$(".youtube_clicked").css("display","block")}),$(document).on("submit","#chatForm",function(e){e.preventDefault(),S.chat(document.getElementById("chatForm").input)}),$(document).on("click","#shuffle",function(e){e.preventDefault(),C.shuffle()}),$(document).on("click","#search-btn",function(e){e.preventDefault(),Ae.showSearch()}),$(document).on("click","#song-title",function(e){e.preventDefault(),Ae.showSearch()}),$(document).on("click","#admin-lock",function(e){e.preventDefault(),C.log_out()}),$(document).on("click","#closeSettings",function(e){e.preventDefault(),C.hide_settings()}),$(document).on("click",".result-object",function(e){var t=$(e.target),o=t.prop("outerHTML").substring(0,4);if("=48&&$("#wrapper").scrollTop()>0?($("#top-button").removeClass("hide"),T.addClass("#bottom-button","hide")):t>=$("#playlist").height()-18&&$("#wrapper").scrollTop()<$("#wrapper")[0].scrollHeight-$("#wrapper").height()-1?($("#bottom-button").removeClass("hide"),T.addClass("#top-button","hide")):(T.addClass("#bottom-button","hide"),T.addClass("#top-button","hide"))}),$(document).on("mouseleave","#playlist",function(){T.addClass("#bottom-button","hide"),T.addClass("#top-button","hide")}),$(document).on("click","#top-button",function(){B.scrollTop()}),$(document).on("click","#bottom-button",function(){B.scrollBottom()});var xe,Be,Se,Le,Pe={id:"",get_input:function(e){""===Pe.id?Pe.set_id(e.toLowerCase()):Pe.set_channel(e.toLowerCase())},set_id:function(e){Pe.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){Se.emit("id",[Pe.id,"channel",e])},play_remote:function(){Se.emit("id",[Pe.id,"play","mock"])},pause_remote:function(){Se.emit("id",[Pe.id,"pause","mock"])},skip_remote:function(){Se.emit("id",[Pe.id,"skip","mock"])},initiate_volume:function(){$("#volume-control-remote").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,t){Se.emit("id",[Pe.id,"volume",t.value]),console.log("volume")}})}},Y=!0,Me={blob_list:[],winter:!1,times_rotated:0,frontpage_function:function(e){$("#channels").empty(),Y=!0,Me.populate_channels(e.channels),Me.set_viewers(e.viewers)},populate_channels:function(e){var t,o="",n=0;1==e[0][5]&&(t=e.shift()),e.sort(Me.sortFunction),void 0!==t&&e.unshift(t),pre_card=$(xe),T.mobilecheck()||Me.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+="