!function(){function e(){$("#facebook-code-link").attr("href","https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"),$("#facebook-code-link").attr("onclick","window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/', 'Share Zöff','width=600,height=300'); return false;"),$("#twitter-code-link").attr("href","https://twitter.com/intent/tweet?url=https://zoff.no/&text=Check%20out%20Zöff!&via=zoffmusic"),$("#twitter-code-link").attr("onclick","window.open('https://twitter.com/intent/tweet?url=https://zoff.no/&text=Check%20out%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/&choe=UTF-8&chld=L%7C1"),$("#qr-code-image-link").attr("src","//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.no/&choe=UTF-8&chld=L%7C1")}function t(){var t=new Date;j.blob_list=[],3==t.getMonth()&&1==t.getDate()&&($(".mega").css("-webkit-transform","rotate(180deg)"),$(".mega").css("-moz-transform","rotate(180deg)")),window.onpopstate=function(e){var t=window.location.href.split("/");""!==t[3]&&"#"!=t[3].substring(0,1)&&j.to_channel(t[3],!0)},L=$("#channel-list-container").html(),e(),"zoff.no"==window.location.hostname?add="https://zoff.no":add=window.location.hostname,(void 0===N||O.mobilecheck())&&(N=io.connect(""+add+":8080",nt)),0!==$("#alreadyfp").length&&!O.mobilecheck()&&N._callbacks.$playlists||h(),$("#about").modal(),$("#help").modal(),$("#contact").modal(),O.log("----"),O.log("Sending frontpage_lists"),O.log("Socket",N),O.log("-----"),V.init(),V.get_offline()&&S(!0,Ae),N.emit("frontpage_lists"),$("#channel-load").css("display","none"),"#donation"==window.location.hash&&(window.location.hash="#",$("#donation").modal("open")),localStorage.ok_cookie||Materialize.toast("We're using cookies to enhance your experience! ok",1e4);var a=0;document.getElementById("zicon").addEventListener("click",function(){a+=10,document.getElementById("zicon").style.paddingLeft=a+"%",a>=100&&(window.location.href="http://etys.no")}),!O.mobilecheck()&&j.winter&&$(".mega").prepend('
'),window.__onGCastApiAvailable=function(e,t){e&&(De=!0)}}function a(){var e=!0;U=$("#chan").html(),Ue=O.mobilecheck();var t=O.mobilecheck()?"left":"right";if(window.onpopstate=function(e){B()},E(),"zoff.no"==window.location.hostname?add="https://zoff.no":add=window.location.hostname,void 0!==lt&&(lt.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}),$("#help").modal(),$("#contact").modal(),$("#embed").modal(),T(we),qe=$("#temp-results-container"),He=$("#empty-results-container").html(),be=$(".not-imported-container").html(),ke=$(".not-exported-container").html(),$(".not-imported-container").empty(),$(".not-exported-container").empty(),$(".video-container").resizable({start:function(e,t){$("iframe").css("pointer-events","none")},stop:function(e,t){$("iframe").css("pointer-events","auto"),V.set_width($(this).width()),k()},handles:"e",minWidth:350,maxWidth:$(window).width()-241}),(void 0===N||O.mobilecheck())&&(e=!1,N=io.connect(""+add+":8080",nt)),V.init(),V.get_offline()&&($(".offline_switch_class")[0].checked=!0,S(!0,Ae)),0===$("#alreadychannel").length||O.mobilecheck())s(),l(),c(),d();else{$("#channel-load").css("display","none"),$("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),lt.readyLooks(),rt.initYoutubeControls(lt.player),rt.initSlider(),lt.player.setVolume(V.get_volume()),$(".video-container").removeClass("no-opacity");var a="https://remote."+window.location.hostname+"/"+Ye;$("#code-text").text(Ye),$("#code-qr").attr("src","https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+a),$("#code-link").attr("href",a)}e&&N.emit("list",U.toLowerCase()),window.onYouTubeIframeAPIReady=lt.onYouTubeIframeAPIReady,(""===lt.player||void 0===lt.player||O.mobilecheck())&<.loadPlayer(),O.mobilecheck()&&st.initiate_volume(),p(),m(),u(),O.mobilecheck()||0!==$("#alreadychannel").length||f(),O.msieversion()||O.mobilecheck()||Notification.requestPermission(),$(".search_input").focus(),O.sample(),$(".castButton-unactive").tooltip({delay:5,position:"top",tooltip:"Cast Zöff to TV"}),$(".castButton-active").tooltip({delay:5,position:"top",tooltip:"Stop casting"}),$("#results").hover(function(){$("div.result").removeClass("hoverResults"),pe=0},function(){}),$("#search").focus(),$("#embed-button").css("display","inline-block"),$("#embed-area").val(w(Se,xe,Ce,Le)),$("#search").attr("placeholder","Find song on YouTube..."),/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())||O.mobilecheck()||$(".castButton-unactive").css("display","none"),Be?n(1):De?initializeCastApi():window.__onGCastApiAvailable=function(e,t){e?setTimeout(function(){De=!0,initializeCastApi()},1e3):De=!0},O.mobilecheck()||k()}function n(e){if($(".castButton-unactive").toggleClass("hide"),$(".castButton-active").toggleClass("hide"),1==e){$("#duration").toggleClass("hide"),$("#fullscreen").toggleClass("hide");try{lt.player.stopVideo()}catch(e){}lt.stopInterval=!0,$("#player_overlay").removeClass("hide"),$("#player_overlay").css("display","block"),O.mobilecheck()?$("#pause").hasClass("hide")?($("#play").toggleClass("hide"),$("#pause").toggleClass("hide")):$("#play").hasClass("hide")&&($("#play").toggleClass("hide"),$("#pause").toggleClass("hide")):($("#volume").slider("value",100),$("#player_overlay").width($("#player").width()+1)),$("#player_overlay").css("background","url(https://i.ytimg.com/vi/"+Xe+"/maxresdefault.jpg)"),$("#player_overlay").css("background-position","center"),$("#player_overlay").css("background-size","100%"),$("#player_overlay").css("background-color","black"),$("#player_overlay").css("background-repeat","no-repeat"),$("#player_overlay").css("height","calc(100% - 32px)"),$("#playing_on").css("display","flex"),$("#chromecast_text").html("Playing on
"+R.La.friendlyName),lt.player.setVolume(100),$("#player_overlay_text").toggleClass("hide")}else 0==e&&($("#duration").toggleClass("hide"),$("#fullscreen").toggleClass("hide"),lt.player.playVideo(),lt.stopInterval=!1,duration=lt.player.getDuration(),lt.durationSetter(),O.mobilecheck()||(lt.player.setVolume(V.get_volume()),$("#volume").slider("value",V.get_volume())),$("#player_overlay").addClass("hide"),$("#player_overlay_text").toggleClass("hide"),$("#chromecast_text").html(""),$("#playing_on").css("display","none"),Ae?lt.loadVideoById(Xe):N.emit("pos",{channel:U.toLowerCase()}))}function i(e,t){var a=JSON.parse(t);switch(a.type){case-1:Ae?lt.playNext():N.emit("end",{id:a.videoId,channel:U.toLowerCase()});break;case 0:Ae?lt.playNext():N.emit("skip",{error:a.data_code,id:a.videoId,pass:ae,channel:U.toLowerCase})}}function o(){N.on("connect_failed",function(){O.log("Connection Failed"),Te||(Te=!0,Materialize.toast("Error connecting to server, please wait..",1e8,"red lighten connect_error"))}),N.on("connect_error",function(){O.log("Connection Failed."),Te||(Te=!0,Materialize.toast("Error connecting to server, please wait..",1e8,"red lighten connect_error"))})}function s(){N.on("np",lt.youtube_listener)}function l(){N.on("get_list",function(){N.emit("list",U.toLowerCase())})}function c(){N.on("suggested",function(e){var t=!0;void 0===e.id&&(t=!1),dt.catchUserSuggests(e,t)})}function d(){N.on("viewers",function(e){oe=e,void 0!==tt&<.getTitle(tt,oe)})}function p(){N.on("toast",P.toast),N.on("pw",P.pw),N.on("conf",P.conf)}function u(){N.on("chat.all",z.allchat),N.on("chat",z.channelchat)}function m(){N.on("channel",H.channel_function)}function h(){O.log("Setting up playlist_listener"),N.on("playlists",j.frontpage_function)}function f(){N.on("id",q.host_listener)}function y(e){N.on(e,q.host_on_action)}function v(){localStorage.debug=!0}function _(){localStorage.debug=!1}function w(e,t,a,n){return''}function k(e){if($(window).width()>760){var t=$(".brand-logo").outerWidth();e&&(t=.15*$(window).width());var a=$(window).width()-$(".control-list").width()-t-66;title_width=a,$(".title-container").width(title_width)}else $(".title-container").width("100%")}function C(e){for(var t="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_",n=0;n"+J+""),J.find(".list-remove").removeClass("hide"),J=J.html()),$(".list-remove").removeClass("hide"),$("#viewers").addClass("hide"),$("#offline-mode").removeClass("waves-cyan"),$("#offline-mode").addClass("cyan"),void 0!=Fe&&!t){for(var a=0;a"+J+""),Y&&G||J.find(".list-remove").addClass("hide"),J=J.html()),$("#viewers").removeClass("hide"),Y&&G||$(".list-remove").addClass("hide"),$("#offline-mode").addClass("waves-cyan"),$("#offline-mode").removeClass("cyan"),"/"!=window.location.pathname&&(N.emit("pos"),N.emit("list",U.toLowerCase()))}function T(e){e?(O.log("------------------------"),O.log("Spotify is authenticated"),O.log("access_token: "+$e.access_token),O.log("token_type:"+$e.token_type),O.log("expires_in: "+$e.expires_in),O.log("------------------------"),$(".spotify_authenticated").css("display","block"),$(".spotify_unauthenticated").css("display","none")):(O.log("----------------------------"),O.log("Spotify is not authenticated"),O.log("----------------------------"),$(".spotify_authenticated").css("display","none"),$(".spotify_unauthenticated").css("display","block"))}function I(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&&27!=code&&(clearTimeout(Ge),search_input.length<3&&$("#results").html(""),13==code?ct.search(search_input):Ge=setTimeout(function(){ct.search(search_input)},1e3))}function E(){$("#facebook-code-link").attr("href","https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+U.toLowerCase()),$("#facebook-code-link").attr("onclick","window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+U.toLowerCase()+"', 'Share Playlist','width=600,height=300'); return false;"),$("#twitter-code-link").attr("href","https://twitter.com/intent/tweet?url=https://zoff.no/"+U.toLowerCase()+"&text=Check%20out%20this%20playlist%20"+U.toLowerCase()+"%20on%20Zöff!&via=zoffmusic"),$("#twitter-code-link").attr("onclick","window.open('https://twitter.com/intent/tweet?url=https://zoff.no/"+U.toLowerCase()+"/&text=Check%20out%20this%20playlist%20"+U.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/"+U.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/"+U.toLowerCase()+"&choe=UTF-8&chld=L%7C1")}function B(){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),lt.stopInterval=!0,P.display_logged_out(),P.beginning=!0,de=!1,he=!1,$("#embed-button").css("display","none"),$.ajax({url:"public/php/frontpage.php",success:function(e){if(O.mobilecheck()?(O.log("Removing all listeners"),N.removeAllListeners(),N.disconnect()):(N.removeEventListener("chat.all"),N.removeEventListener("chat"),N.removeEventListener("conf"),N.removeEventListener("pw"),N.removeEventListener("toast"),N.removeEventListener("channel")),document.getElementById("volume-button").removeEventListener("click",rt.mute_video),document.getElementById("playpause").removeEventListener("click",rt.play_pause),document.getElementById("fullscreen").removeEventListener("click",rt.fullscreen),O.mobilecheck()&&(Xe="",tt=""),$("meta[name=theme-color]").attr("content","#2D2D2D"),O.mobilecheck()){try{lt.player.destroy()}catch(e){}lt.player="",document.title="Zöff"}else $(".video-container").resizable("destroy"),$("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("
");var a=$("
"+e+"
");$(".drag-target").remove(),$("#sidenav-overlay").remove(),$("main").attr("class","center-align container"),$("body").attr("id",""),$("body").attr("style",""),$("header").html($(a.find("header")).html()),$($(a.find(".section.mega"))).insertAfter("header"),$($(a.find(".section.mobile-search"))).insertAfter(".mega"),O.mobilecheck()?$("main").html($(a.find("main")).html()):$("main").append($(a.find("#main_section_frontpage")).wrap("
").parent().html()),$(".page-footer").removeClass("padding-bottom-extra"),$(".page-footer").removeClass("padding-bottom-novideo"),$("#favicon").attr("href","public/images/favicon.png"),O.log(N),1==$("#alreadyfp").length?t():(ot=!0,D=!0,t()),0===$("#alreadychannel").length&&$("head").append("
"),void 0!=e.description&&""!=e.description&&$("#description_area").html(e.description)},submitAdmin:function(e){voting=e.vote.checked,addsongs=e.addsongs.checked,longsongs=e.longsongs.checked,D=e.frontpage.checked,allvideos=e.allvideos.checked,removeplay=e.removeplay.checked,skipping=e.skip.checked,shuffling=e.shuffle.checked,configs={voting:voting,addsongs:addsongs,longsongs:longsongs,frontpage:D,allvideos:allvideos,removeplay:removeplay,adminpass:ae,skipping:skipping,shuffling:shuffling},N.emit("conf",configs)},hide_settings:function(){$("#settings").sideNav("hide")},shuffle:function(){if(Ae){for(var e=0;e150||(e.value.startsWith("/name ")?z.namechange(e.value.substring(6)):e.value.startsWith("/removename")?z.removename():"#all_chat"==$(".chat-tab-li a.active").attr("href")?N.emit("all,chat",e.value):N.emit("chat",e.value),e.value="")},allchat:function(e){W||":"!=e.msg.substring(0,1)||fe||($("#favicon").attr("href","public/images/highlogo.png"),W=!0,Z=!0,ye=!0,ve||z.chat_blink()),document.hidden&&$("#favicon").attr("href","public/images/highlogo.png");var t=O.intToARGB(O.hashCode(e.from));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=O.hexToRgb(t.substring(0,6));var a=O.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){W||":"!=e.msg.substring(0,1)||fe||($("#favicon").attr("href","public/images/highlogo.png"),Z=!0,ye=!0,ve||z.chat_blink());var t=O.intToARGB(O.hashCode(e.from));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=O.hexToRgb(t.substring(0,6));var a=O.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(){ve=!0,$(".chat-link").attr("style","color: grey !important;"),setTimeout(function(){$(".chat-link").attr("style","color: white !important;"),setTimeout(function(){ve&&z.chat_blink()},1e3)},1e3)}},V={conf_pass:void 0,init:function(){"/"!=window.location.pathname&&("https:"!=location.protocol?document.cookie=U.toLowerCase()+"=;path=/"+U.toLowerCase()+";expires="+new Date(0).toUTCString():document.cookie=U.toLowerCase()+"=;path=/"+U.toLowerCase()+";secure;expires="+new Date(0).toUTCString());try{conf_arr=V.decrypt(V.getCookie("_opt"),"_opt")}catch(e){conf_arr=V.decrypt(V.create_cookie("_opt"),"_opt")}if("/"!=window.location.pathname){try{V.conf_pass=V.decrypt(V.getCookie(U.toLowerCase()),U.toLowerCase())}catch(e){V.conf_pass=V.decrypt(V.create_cookie(U.toLowerCase()),U.toLowerCase())}q.change_enabled(conf_arr.remote),100!=conf_arr.width&<.set_width(conf_arr.width),void 0!==conf_arr.name&&""!==conf_arr.name&&z.namechange(conf_arr.name)}},decrypt:function(e,t){void 0===V.getCookie(t)&&(e=V.create_cookie(t));var a=CryptoJS.AES.decrypt(e,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return $.parseJSON(a.toString(CryptoJS.enc.Utf8))},decrypt_pass:function(e){var t=CryptoJS.AES.decrypt(e,N.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString(CryptoJS.enc.Utf8)},encrypt:function(e,t){var a=JSON.stringify(e),n=CryptoJS.AES.encrypt(a,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),i=new Date;i.setFullYear(i.getFullYear()+1),"https:"!=location.protocol?document.cookie=t+"="+n.toString()+";expires="+i.toGMTString()+";path=/;":document.cookie=t+"="+n.toString()+";secure;expires="+i.toGMTString()+";path=/;"},encrypt_string:function(e){var t=CryptoJS.AES.encrypt(e,N.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString()},get_volume:function(){return V.decrypt(V.getCookie("_opt"),"_opt").volume},get_offline:function(){var e=V.decrypt(V.getCookie("_opt"),"_opt").offline;return void 0!=e?V.decrypt(V.getCookie("_opt"),"_opt").offline:(V.set_offline(!1),!1)},set_volume:function(e){conf_arr.volume=e,V.encrypt(conf_arr,"_opt")},create_cookie:function(e){"_opt"==e?cookie_object={volume:100,width:100,remote:!0,name:"",offline:!1}:cookie_object={passwords:{}};var t=JSON.stringify(cookie_object),a=CryptoJS.AES.encrypt(t,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),n=new Date;return n.setFullYear(n.getFullYear()+1),"https:"!=location.protocol?document.cookie=e+"="+a.toString()+";expires="+n.toGMTString()+";path=/;":document.cookie=e+"="+a.toString()+";secure;expires="+n.toGMTString()+";path=/;",V.getCookie(e)},set_pass:function(e,t){V.conf_pass.passwords[e]=t,V.encrypt(V.conf_pass,e)},remove_pass:function(e){delete V.conf_pass.passwords[e],V.encrypt(V.conf_pass,e.toLowerCase())},set_name:function(e){conf_arr.name=encodeURIComponent(e).replace(/\W/g,""),V.encrypt(conf_arr,"_opt")},set_offline:function(e){conf_arr.offline=e,V.encrypt(conf_arr,"_opt")},remove_name:function(){conf_arr.name="",V.encrypt(conf_arr,"_opt")},get_pass:function(e){if(void 0!==V.conf_pass)return V.conf_pass.passwords[e]},set_remote:function(e){conf_arr.remote=e,V.encrypt(conf_arr,"_opt")},get_remote:function(e){return conf_arr.remote},crypt_pass:function(e){var t=CryptoJS.AES.encrypt(e,N.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,V.encrypt(conf_arr,"_opt")},getCookie:function(e){var t="; "+document.cookie,a=t.split("; "+e+"=");if(2==a.length)return a.pop().split(";").shift()}},D=!0,j={blob_list:[],winter:(new Date).getMonth()>=10,times_rotated:0,frontpage_function:function(e){$("#channels").empty(),D=!0,O.log("-----------"),O.log("Frontpage fetch"),O.log(e),O.log("------------"),j.populate_channels(e.channels),j.set_viewers(e.viewers)},populate_channels:function(e){var t,a="",n=0;1==e[0].pinned&&(t=e.shift()),e.sort(j.sortFunction),void 0!==t&&e.unshift(t),O.mobilecheck()||j.add_backdrop(e,0),pre_card=$(L),O.log("------------"),O.log(pre_card),O.log("-------------");for(var i in e){var o=e[i].channel;if(n<12){var s=e[i].id,l=e[i].viewers,r="background-image:url('https://img.youtube.com/vi/"+s+"/hqdefault.jpg');";e[i].thumbnail&&(r="background-image:url('"+e[i].thumbnail+"');");var c=e[i].count,d=pre_card;1==e[i].pinned?(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(o),d.find(".chan-name").attr("title",o),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",o),$("#channels").append(d.html())}n++}var p=e.slice();p=p.sort(j.sortFunction_active);for(var i in p)if(p[i].count>5&&Math.floor((new Date).getTime()/1e3)-p[i].accessed<604800){var o=p[i].channel;a+="