Files
zoff/static/dist/main.min.js

3 lines
78 KiB
JavaScript
Executable File

!function(){function e(){var e=!0;z=$("#chan").html(),xe=A.mobilecheck();var t=A.mobilecheck()?"left":"right";if(window.onpopstate=function(e){S()},C(),"zoff.no"==window.location.hostname?add="https://zoff.no":add=window.location.hostname,void 0!==Je&&(Je.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}),_(ge),ke=$("#temp-results-container"),Ce=$("#empty-results-container").html(),me=$(".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"),L.set_width($(this).width())},handles:"e",minWidth:350,maxWidth:$(window).width()-221}),(void 0===De||A.mobilecheck())&&(e=!1,De=io.connect(""+add+":8880",je)),0===$("#alreadychannel").length||A.mobilecheck())n(),i(),s(),l();else{$("#channel-load").css("display","none"),$("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),Je.readyLooks(),Ge.initYoutubeControls(Je.player),Ge.initSlider(),Je.player.setVolume(L.get_volume()),$(".video-container").removeClass("no-opacity");var a="https://remote."+window.location.hostname+"/"+Ie;$("#code-text").text(Ie),$("#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&&De.emit("list",z.toLowerCase()),/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream?(document.getElementById("search").blur(),$("#channel-load").css("display","none")):(window.onYouTubeIframeAPIReady=Je.onYouTubeIframeAPIReady,(""===Je.player||void 0===Je.player||A.mobilecheck())&&Je.loadPlayer()),A.mobilecheck()&&qe.initiate_volume(),c(),p(),d(),A.mobilecheck()||0!==$("#alreadychannel").length||m(),A.msieversion()||Notification.requestPermission(),$(".search_input").focus(),A.sample(),$("#results").hover(function(){$("div.result").removeClass("hoverResults"),ne=0},function(){}),$("#search").focus(),$("#embed-button").css("display","inline-block"),$("#embed-area").val(v(ye,fe,he)),$("#search").attr("placeholder","Find song on YouTube..."),window.__onGCastApiAvailable=function(e){e&&initializeCastApi()}}function t(e){1==e?($("#controls").toggleClass("hide"),Je.player.stopVideo(),Je.stopInterval=!0,$("#player").toggleClass("hide"),$("#player_overlay").toggleClass("hide"),$("#player_overlay").css("height","100%"),$("#player_overlay_text").toggleClass("hide"),$("#player_overlay_controls").css("display","inherit")):0==e&&($("#controls").toggleClass("hide"),Je.player.playVideo(),Je.stopInterval=!1,Je.durationSetter(),$("#player").toggleClass("hide"),$("#player_overlay").toggleClass("hide"),$("#player_overlay").css("height","100%"),$("#player_overlay_text").toggleClass("hide"),$("#player_overlay_controls").css("display","none"),De.emit("pos",{channel:z.toLowerCase()}))}function a(e){switch(e.data.type){case-1:De.emit("end",{id:e.data.videoId,channel:z.toLowerCase()})}}function o(){De.on("connect_failed",function(){A.log("Connection Failed"),ve||(ve=!0,Materialize.toast("Error connecting to server, please wait..",1e8,"red lighten connect_error"))}),De.on("connect_error",function(){A.log("Connection Failed."),ve||(ve=!0,Materialize.toast("Error connecting to server, please wait..",1e8,"red lighten connect_error"))})}function n(){De.on("np",Je.youtube_listener)}function i(){De.on("get_list",function(){De.emit("list",z.toLowerCase())})}function s(){De.on("suggested",function(e){var t=!0;void 0===e.id&&(t=!1),Ze.catchUserSuggests(e,t)})}function l(){De.on("viewers",function(e){X=e,void 0!==ze&&Je.getTitle(ze,X)})}function c(){De.on("toast",E.toast),De.on("pw",E.pw),De.on("conf",E.conf)}function d(){De.on("chat.all",B.allchat),De.on("chat",B.channelchat)}function p(){De.on("channel",N.channel_function)}function u(){De.on("playlists",Fe.frontpage_function)}function m(){De.on("id",M.host_listener)}function h(e){De.on(e,M.host_on_action)}function f(){localStorage.debug=!0}function y(){localStorage.debug=!1}function v(e,t,a){return'<embed src="https://zoff.no/embed.html#'+z.toLowerCase()+e+'" width="'+t+'px" height="'+a+'px">'}function w(e){for(var t="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_",o=0;o<e;o++)t+=a.charAt(Math.floor(Math.random()*a.length));return t}function _(e){e?(A.log("------------------------"),A.log("Spotify is authenticated"),A.log("access_token: "+ue.access_token),A.log("token_type:"+ue.token_type),A.log("expires_in: "+ue.expires_in),A.log("------------------------"),$(".spotify_authenticated").css("display","block"),$(".spotify_unauthenticated").css("display","none")):(A.log("----------------------------"),A.log("Spotify is not authenticated"),A.log("----------------------------"),$(".spotify_authenticated").css("display","none"),$(".spotify_unauthenticated").css("display","block"))}function k(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(Se),search_input.length<3&&$("#results").html(""),13==code?We.search(search_input):Se=setTimeout(function(){We.search(search_input)},1e3))}function C(){$("#facebook-code-link").attr("href","https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+z.toLowerCase()),$("#facebook-code-link").attr("onclick","window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/"+z.toLowerCase()+"', 'Share Playlist','width=600,height=300'); return false;"),$("#twitter-code-link").attr("href","https://twitter.com/intent/tweet?url=https://zoff.no/"+z.toLowerCase()+"&amp;text=Check%20out%20this%20playlist%20"+z.toLowerCase()+"%20on%20Zöff!&amp;via=zoffmusic"),$("#twitter-code-link").attr("onclick","window.open('https://twitter.com/intent/tweet?url=https://zoff.no/"+z.toLowerCase()+"/&amp;text=Check%20out%20this%20playlist%20"+z.toLowerCase()+"%20on%20Zöff!&amp;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/"+z.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/"+z.toLowerCase()+"&choe=UTF-8&chld=L%7C1")}function S(){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),Je.stopInterval=!0,E.display_logged_out(),E.beginning=!0,oe=!1,re=!1,$("#embed-button").css("display","none"),$.ajax({url:"php/nochan.php",success:function(e){if(A.mobilecheck()?(De.removeAllListeners(),De.disconnect()):(De.removeEventListener("chat.all"),De.removeEventListener("chat"),De.removeEventListener("conf"),De.removeEventListener("pw"),De.removeEventListener("toast"),De.removeEventListener("channel")),document.getElementById("volume-button").removeEventListener("click",Ge.mute_video),document.getElementById("playpause").removeEventListener("click",Ge.play_pause),document.getElementById("fullscreen").removeEventListener("click",Ge.fullscreen),A.mobilecheck()&&(Pe="",ze=""),$("meta[name=theme-color]").attr("content","#2D2D2D"),A.mobilecheck()){try{Je.player.destroy()}catch(e){}Je.player="",document.title="Zöff"}else $("main").append("<a id='closePlayer' title='Close Player'>X</a>"),$("#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("<div id='player_bottom_overlay' title='To Channel' class='player player_bottom'></div>");$(".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"),A.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?T():(Re=!0,G=!0,T()),0===$("#alreadychannel").length&&$("head").append("<div id='alreadychannel'></div"),$("#channel-load").css("display","none")}})):(De.emit("change_channel"),E.beginning=!0,z=e[3].replace("#",""),$("#chan").html(A.upperFirst(z)),V=!0,De.emit("list",z.toLowerCase()))}function I(){$("#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/&amp;text=Check%20out%20Zöff!&amp;via=zoffmusic"),$("#twitter-code-link").attr("onclick","window.open('https://twitter.com/intent/tweet?url=https://zoff.no/&amp;text=Check%20out%20Zöff!&amp;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 e=new Date;Fe.blob_list=[],3==e.getMonth()&&1==e.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)&&Fe.to_channel(t[3],!0)},Ye=$("#channel-list-container").html(),I();var t={secure:!0,"force new connection":!0};"zoff.no"==window.location.hostname?add="https://zoff.no":add=window.location.hostname,(void 0===De||A.mobilecheck())&&(De=io.connect(""+add+":8880",t)),(0===$("#alreadyfp").length||A.mobilecheck())&&u(),window.socket=De,De.emit("frontpage_lists"),$("#channel-load").css("display","none"),"#donation"==window.location.hash&&(window.location.hash="#",$("#donation").openModal()),localStorage.ok_cookie||Materialize.toast("We're using cookies to enhance your experience! <a class='waves-effect waves-light btn light-green' href='#' id='cookieok' style='cursor:pointer;pointer-events:all;'> ok</a>",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")}),!A.mobilecheck()&&Fe.winter&&Fe.start_snowfall()}var E={beginning:!0,toast:function(e){switch(e){case"addedsong":e=A.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=A.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=A.rnd(["I've saved your settings","I stored all your settings","Your settings have been stored in a safe place"]);break;case"wrongpass":e=A.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."]),L.remove_pass(z.toLowerCase()),E.display_logged_out(),V=!0;break;case"shuffled":e=A.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=A.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=A.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=A.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=A.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=A.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"]),L.remove_pass(z.toLowerCase()),E.display_logged_out(),V=!0;break;case"noskip":e=A.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=A.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){V=!1,W=e,names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],L.set_pass(z.toLowerCase(),L.decrypt_pass(e));for(var t=0;t<names.length;t++)$("input[name="+names[t]+"]").attr("disabled",!1);$(".card-action").removeClass("hide"),$("#admin-lock").removeClass("mdi-action-lock"),$("#password").val(""),$("#password").attr("placeholder","Change channel password"),A.contains($(".playlist-tabs").attr("class").split(" "),"hide")||($(".playlist-tabs-loggedIn").removeClass("hide"),$(".playlist-tabs").addClass("hide")),A.contains($("#admin-lock").attr("class").split(" "),"mdi-action-lock-open")||$("#admin-lock").addClass("mdi-action-lock-open clickable"),$("ul.playlist-tabs-loggedIn").tabs("select_tab",$(".playlist-tabs li a.active").attr("href").substring(1))},conf:function(e){L.init(),E.set_conf(e[0]),void 0!==L.get_pass(z.toLowerCase())&&E.beginning&&""!==L.get_pass(z.toLowerCase())&&(De.emit("password",{password:L.crypt_pass(L.get_pass(z.toLowerCase())),channel:z.toLowerCase()}),E.beginning=!1)},pass_save:function(){V?De.emit("password",{password:L.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()),channel:z.toLowerCase()}):De.emit("password",{password:L.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()),channel:z.toLowerCase(),oldpass:L.crypt_pass(L.get_pass(z.toLowerCase()))})},log_out:function(){L.get_pass(z.toLowerCase())?(L.remove_pass(z.toLowerCase()),E.display_logged_out(),Materialize.toast("Logged out",4e3)):Materialize.toast("Not logged in",4e3)},display_logged_out:function(){for(V=!0,W="",names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],document.getElementById("password").value="",ne=0;ne<names.length;ne++)$("input[name="+names[ne]+"]").attr("disabled",!0);A.contains($("#admin-lock").attr("class").split(" "),"mdi-action-lock")||$("#admin-lock").addClass("mdi-action-lock"),A.contains($(".playlist-tabs-loggedIn").attr("class").split(" "),"hide")||($(".playlist-tabs-loggedIn").addClass("hide"),$(".playlist-tabs").removeClass("hide")),0===$(".card-action").length||A.contains($(".card-action").attr("class").split(" "),"hide")||$(".card-action").addClass("hide"),"#suggestions"==$("ul.playlist-tabs-loggedIn .playlist-tab-links.active").attr("href")?($("ul.playlist-tabs").tabs("select_tab","wrapper"),$("ul.playlist-tabs-loggedIn").tabs("select_tab","wrapper")):$("ul.playlist-tabs").tabs("select_tab",$(".playlist-tabs-loggedIn li a.active").attr("href").substring(1)),$("#admin-lock").removeClass("mdi-action-lock-open clickable"),$("#password").attr("placeholder","Enter channel password")},save:function(){E.submitAdmin(document.getElementById("adminForm").elements)},set_conf:function(e){J=e.allvideos,longsongs=e.longsongs,names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],""!==e.adminpass&&V?D=!0:(D=!1,!A.mobilecheck());for(var t=0;t<names.length;t++)document.getElementsByName(names[t])[0].checked=e[names[t]]===!0,$("input[name="+names[t]+"]").attr("disabled",D);D?0===$(".mdi-action-lock").length&&E.display_logged_out():D||void 0!==L.get_pass(z.toLowerCase())||(A.contains($(".playlist-tabs").attr("class").split(" "),"hide")||($(".playlist-tabs-loggedIn").removeClass("hide"),$(".playlist-tabs").addClass("hide")),$("#password").attr("placeholder","Create channel password"))},submitAdmin:function(e){voting=e.vote.checked,addsongs=e.addsongs.checked,longsongs=e.longsongs.checked,G=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:G,allvideos:allvideos,removeplay:removeplay,adminpass:W,skipping:skipping,shuffling:shuffling},De.emit("conf",configs)},hide_settings:function(){$("#settings").sideNav("hide")},shuffle:function(){De.emit("shuffle",void 0!==W?W:"")},get_admin:function(){return[V,D]}},B={namechange:function(e){De.emit("namechange",e),L.set_name(e)},removename:function(){De.emit("removename"),L.remove_name()},chat:function(e){e.value.length>150||(e.value.startsWith("/name ")?B.namechange(e.value.substring(6)):e.value.startsWith("/removename")?B.removename():"#all_chat"==$(".chat-tab-li a.active").attr("href")?De.emit("all,chat",e.value):De.emit("chat",e.value),e.value="")},allchat:function(e){R||":"!=e.msg.substring(0,1)||ce||($("#favicon").attr("href","static/images/highlogo.png"),R=!0,Y=!0,de=!0,pe||B.chat_blink()),document.hidden&&$("#favicon").attr("href","static/images/highlogo.png");var t=A.intToARGB(A.hashCode(e.from));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=A.hexToRgb(t.substring(0,6));var a=A.rgbToHsl([t.r,t.g,t.b],!1);$("#chatall").append("<li title='"+e.channel+"''><span style='color:"+a+";'>"+e.from+"</span></li>");var o=document.createTextNode(e.msg);$("#chatall li:last")[0].appendChild(o),document.getElementById("chatall").scrollTop=document.getElementById("chatall").scrollHeight},channelchat:function(e){R||":"!=e.msg.substring(0,1)||ce||($("#favicon").attr("href","static/images/highlogo.png"),Y=!0,de=!0,pe||B.chat_blink());var t=A.intToARGB(A.hashCode(e.from));if(t.length<6)for(x=t.length;x<6;x++)t="0"+t;t=A.hexToRgb(t.substring(0,6));var a=A.rgbToHsl([t.r,t.g,t.b],!1);$("#chatchannel").append("<li><span style='color:"+a+";'>"+e.from+"</span></li>");var o=document.createTextNode(e.msg);$("#chatchannel li:last")[0].appendChild(o),document.getElementById("chatchannel").scrollTop=document.getElementById("chatchannel").scrollHeight},chat_blink:function(){pe=!0,$(".chat-link").attr("style","color: grey !important;"),setTimeout(function(){$(".chat-link").attr("style","color: white !important;"),setTimeout(function(){pe&&B.chat_blink()},1e3)},1e3)}},L={conf_pass:void 0,init:function(){document.cookie=z.toLowerCase()+"=; path=/"+z.toLowerCase()+"; expires="+new Date(0).toUTCString();try{conf_arr=L.decrypt(L.getCookie("_opt"),"_opt")}catch(e){conf_arr=L.decrypt(L.create_cookie("_opt"),"_opt")}try{L.conf_pass=L.decrypt(L.getCookie(z.toLowerCase()),z.toLowerCase())}catch(e){L.conf_pass=L.decrypt(L.create_cookie(z.toLowerCase()),z.toLowerCase())}M.change_enabled(conf_arr.remote),100!=conf_arr.width&&Je.set_width(conf_arr.width),void 0!==conf_arr.name&&""!==conf_arr.name&&B.namechange(conf_arr.name)},decrypt:function(e,t){void 0===L.getCookie(t)&&(e=L.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,De.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString(CryptoJS.enc.Utf8)},encrypt:function(e,t){var a=JSON.stringify(e),o=CryptoJS.AES.encrypt(a,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),n=new Date;n.setFullYear(n.getFullYear()+1),document.cookie=t+"="+o.toString()+";expires="+n.toGMTString()+";path=/;"},encrypt_string:function(e){var t=CryptoJS.AES.encrypt(e,De.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString()},get_volume:function(){return L.decrypt(L.getCookie("_opt"),"_opt").volume},set_volume:function(e){conf_arr.volume=e,L.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),a=CryptoJS.AES.encrypt(t,"0103060703080703080701",{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),o=new Date;return o.setFullYear(o.getFullYear()+1),document.cookie=e+"="+a.toString()+";expires="+o.toGMTString()+";path=/;",L.getCookie(e)},set_pass:function(e,t){L.conf_pass.passwords[e]=t,L.encrypt(L.conf_pass,e)},remove_pass:function(e){delete L.conf_pass.passwords[e],L.encrypt(L.conf_pass,e.toLowerCase())},set_name:function(e){conf_arr.name=encodeURIComponent(e).replace(/\W/g,""),L.encrypt(conf_arr,"_opt")},remove_name:function(){conf_arr.name="",L.encrypt(conf_arr,"_opt")},get_pass:function(e){if(void 0!==L.conf_pass)return L.conf_pass.passwords[e]},set_remote:function(e){conf_arr.remote=e,L.encrypt(conf_arr,"_opt")},get_remote:function(e){return conf_arr.remote},crypt_pass:function(e){var t=CryptoJS.AES.encrypt(e,De.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,L.encrypt(conf_arr,"_opt")},getCookie:function(e){var t="; "+document.cookie,a=t.split("; "+e+"=");if(2==a.length)return a.pop().split(";").shift()}},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,a,o=[],n=arguments.length,i=function(e,t){return e===t?0:e<t?-1:1},s=function(e,t){var a=i,o=i;return e&&(o=function(t,o){return a(e(t),e(o))}),t?function(e,t){return-1*o(e,t)}:o},l=0;l<n;l++)e=arguments[l],"string"==typeof e?(t=e,a=i):(t=e.name,a=s(e.primer,e.reverse)),o.push({name:t,cmp:a});return function(t,a){for(var i,s,l=0;l<n&&(s=0,e=o[l],i=e.name,s=e.cmp(t[i],a[i]),0===s);l++);return s}},hashCode:function(e){for(var t=0,a=0;a<e.length;a++)t=e.charCodeAt(a)+((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 a=e.length;a--;)if(e[a]===t)return!0;return!1},sample:function(){Date.now()-ae>=2*te&&(De.removeAllListeners(),De.disconnect(),De.connect(),Je.setup_all_listeners()),ae=Date.now(),setTimeout(A.sample,te)},loadjsfile:function(e){if(Z.indexOf("["+e+"]")==-1){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(t),Z+="["+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 a,o,n=Math.max(r,g,b),i=Math.min(r,g,b),s=(n+i)/2;if(n==i)a=o=0;else{var l=n-i;switch(o=s>.5?l/(2-n-i):l/(n+i),n){case r:a=(g-b)/l+(g<b?6:0);break;case g:a=(b-r)/l+2;break;case b:a=(r-g)/l+4}a/=6}return s>.5&&t?s=.5:s<.65&&!t&&(s=.65),"hsl("+Math.floor(360*a)+", "+Math.floor(100*o)+"%, "+Math.floor(100*s)+"%)"},componentToHex:function(e){var t=e.toString(16);return 1==t.length?"0"+t:t},rgbToHex:function(e,t,a){return"#"+A.componentToHex(e)+A.componentToHex(t)+A.componentToHex(a)},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(),a=$("#contact-form-from").val();A.send_mail(a,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 P,M={enabled:!0,old_id:null,host_listener:function(e){null===M.old_id?M.old_id=e:(De.removeAllListeners(e),oe=!1,M.old_id=e);var t="https://remote."+window.location.hostname+"/"+e;$("#code-text").text(e),$("#code-qr").attr("src","https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+t),$("#code-link").attr("href",t),oe||(oe=!0,h(e))},host_on_action:function(e){enabled&&("volume"==e.type?($("#volume").slider("value",e.value),Je.player.setVolume(e.value),localStorage.setItem("volume",e.value),Ge.choose_button(e.value,!1)):"channel"==e.type?(De.emit("change_channel"),E.beginning=!0,z=e.value.toLowerCase(),$("#chan").html(A.upperFirst(z)),V=!0,De.emit("list",z.toLowerCase()),window.history.pushState("object or string","Title","/"+z.toLowerCase())):"pause"==e.type?Je.pauseVideo():"play"==e.type?Je.playVideo():"skip"==e.type&&N.skip())},change_enabled:function(e){enabled=e,document.getElementsByName("remote_switch")[0].checked=enabled}},N={empty:!1,page:0,channel_function:function(e){switch(e.type){case"list":N.populate_list(e.playlist);break;case"added":N.added_song(e.value);break;case"deleted":N.deleted_song(e.value);break;case"vote":N.voted_song(e.value,e.time);break;case"song_change":"/"!=window.location.pathname&&N.song_change(e.time)}},insertAtBeginning:function(e,t){var a=0==N.page?"":"none",o=N.generateSong(e,t,!1,!0,!1,a,!1);$("#wrapper").append(o)},insertAtIndex:function(e,t){var a=N.getIndexOfSong(e.id),o="none";if(!e.now_playing){a>=N.page&&a<N.page+19&&(o="block");var n=N.generateSong(e,t,!1,!0,!1,o,!1);0===a?$("#wrapper").prepend(n):$("#wrapper > div:nth-child("+a+")").after(n);var i=$("#wrapper").children()[a];$(i).css("display",o),"block"==o&&$("#wrapper").children().length>=N.page+21?$($("#wrapper").children()[N.page+20]).css("display","none"):a<N.page&&$("#wrapper").children().length-(N.page+1)>=0?$($("#wrapper").children()[N.page-1]).css("display","block"):$("#wrapper").children().length>N.page+20&&$($("#wrapper").children()[N.page+20]).css("display","block"),t&&setTimeout(function(){$(i).css("height",66)},5)}},populate_list:function(e){void 0===O&&(O=$("#list-song-html").html()),Te=e,N.can_fit=$("main").height()/66,N.sortList(),$("#wrapper").empty(),A.log("---------------------------"),A.log("---------FULL PLAYLIST-----"),A.log(Te),A.log("---------------------------"),Te.length>1?($.each(Te,function(e,t){t.now_playing||$("#wrapper").append(N.generateSong(t,!1,ie,!0,!1,"",!0))}),$("#wrapper").children().length>20&&!$("#pageButtons").length?($('<div id="pageButtons"><span class="prev_page_hide btn-flat">< prev</span><a class="prev_page waves-effect waves-light btn-flat">< prev</a> <span id="pageNumber" class="btn-flat">1</span> <a class="next_page waves-effect waves-light btn-flat">next ></a><span class="next_page_hide btn-flat">next ></span></div>').insertAfter("#wrapper"),$(".prev_page").toggleClass("hide"),$(".next_page_hide").css("display","none")):$("#pageButtons").length||($('<div id="pageButtons"><span class="prev_page_hide btn-flat">< prev</span><a class="prev_page waves-effect waves-light btn-flat">< prev</a> <span id="pageNumber" class="btn-flat">1</span> <a class="next_page waves-effect waves-light btn-flat">next ></a><span class="next_page_hide btn-flat">next ></span></div>').insertAfter("#wrapper"),$(".prev_page").toggleClass("hide"),$(".next_page").toggleClass("hide"),$(".next_page_hide").css("display","inline-block"),$(".prev_page_hide").css("display","inline-block"))):(N.empty=!0,
$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>"),$("#pageButtons").length||($('<div id="pageButtons"><span class="prev_page_hide btn-flat">< prev</span><a class="prev_page waves-effect waves-light btn-flat">< prev</a> <span id="pageNumber" class="btn-flat">1</span> <a class="next_page waves-effect waves-light btn-flat">next ></a><span class="next_page_hide btn-flat">next ></span></div>').insertAfter("#wrapper"),$(".prev_page").toggleClass("hide"),$(".next_page").toggleClass("hide"),$(".next_page_hide").css("display","inline-block"),$(".prev_page_hide").css("display","inline-block"))),$("#settings").css("visibility","visible"),$("#settings").css("opacity","1"),$("#wrapper").css("opacity","1")},dynamicContentPage:function(e){1==e?($("#wrapper").children().slice(N.page,N.page+20).hide(),N.page=N.page+20,$("#wrapper").children().slice(N.page,N.page+20).show(),N.page>0&&$(".prev_page").hasClass("hide")&&($(".prev_page").toggleClass("hide"),$(".prev_page_hide").css("display","none")),N.page+20>=$("#wrapper").children().length&&($(".next_page_hide").css("display","inline-block"),$(".next_page").css("display","none"))):($("#wrapper").children().slice(N.page-20,N.page).show(),$("#wrapper").children().slice(N.page,N.page+20).hide(),N.page=N.page-20,0!=N.page||$(".prev_page").hasClass("hide")?$(".prev_page").hasClass("hide")?$(".prev_page_hide").css("display","inline-block"):$(".prev_page_hide").css("display","none"):($(".prev_page").toggleClass("hide"),$(".prev_page_hide").css("display","inline-block")),N.page+20<$("#wrapper").children().length&&($(".next_page_hide").css("display","none"),$(".next_page").css("display","inline-block"))),$("#pageNumber").html(N.page/20+1)},added_song:function(e){var t;0!==Te.length&&(t=Te.pop()),Te.push(e),N.sortList(),t&&Te.push(t),$("#suggested-"+e.id).remove(),N.empty&&(N.empty=!1),$("#empty-channel-message").remove(),N.insertAtIndex(e,!0),$("#wrapper").children().length>N.page+20?($(".next_page_hide").css("display","none"),$(".next_page").removeClass("hide"),$(".next_page").css("display","inline-block")):($(".next_page_hide").css("display","inline-block"),$(".next_page").css("display","none"))},deleted_song:function(e){var t=N.getIndexOfSong(e),a=$("#wrapper").children()[t];try{a.style.height=0,setTimeout(function(){$("#"+e).remove(),Te.splice(N.getIndexOfSong(e),1),t<N.page&&$("#wrapper").children().length-(N.page+1)>=0?$($("#wrapper").children()[N.page-1]).css("display","block"):$("#wrapper").children().length>N.page+19&&$($("#wrapper").children()[N.page+19]).css("display","block"),N.page>=$("#wrapper").children().length?N.dynamicContentPage(-1):N.page+20>=$("#wrapper").children().length&&($(".next_page_hide").css("display","inline-block"),$(".next_page").css("display","none"))},305)}catch(a){Te.splice(N.getIndexOfSong(e),1),N.empty||($("#wrapper").children()[$("#wrapper").children().length-1].remove(),t<N.page&&$("#wrapper").children().length-(N.page+1)>=0?$($("#wrapper").children()[N.page-1]).css("display","block"):$("#wrapper").children().length>N.page+20&&$($("#wrapper").children()[N.page+19]).css("display","block"))}Te.length<=2&&(N.empty=!0,$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>")),$("#suggested-"+e).remove(),N.page+20<$("#wrapper").children().length&&($(".next_page_hide").css("display","none"),$(".next_page").css("display","inline-block")),N.page>=$("#wrapper").children().length&&N.dynamicContentPage(-1),Ze.checkUserEmpty()},voted_song:function(e,t){var a=N.getIndexOfSong(e),o=Te[a];Te[a].votes+=1,Te[a].added=t,N.sortList(),$("#"+e).remove(),N.insertAtIndex(o,!1)},song_change:function(e){var t=Te.length-1;Te[0].now_playing=!0,Te[0].votes=0,Te[0].guids=[],Te[0].added=e,Te[t].now_playing=!1,A.log("---------------------------"),A.log("---SONG ON FIRST INDEX-----"),A.log(Te[0]),A.log("---------------------------");try{Te.push(Te.shift()),N.empty||$("#wrapper").children()[0].remove(),0===$("#wrapper").children().length&&(N.empty=!0,$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>")),N.insertAtIndex(Te[t-1],!1),$("#wrapper").children().length>=N.page+20&&$($("#wrapper").children()[N.page+20]).css("display","block"),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(e){}},vote:function(e,t){return De.emit("vote",{channel:z,id:e,type:t,adminpass:W}),!0},skip:function(){return De.emit("skip",{pass:W,id:Pe,channel:z.toLowerCase()}),!0},exportToYoutube:function(){var e="https://www.googleapis.com/youtube/v3/playlists?part=snippet";$.ajax({type:"POST",url:e,headers:{Authorization:"Bearer "+$e.access_token,"Content-Type":"application/json"},data:JSON.stringify({snippet:{title:z.toLowerCase(),description:"Playlist exported from zoff"}}),success:function(e){var t=0,a=e.id;$.each(Te,function(e,o){var n="https://www.googleapis.com/youtube/v3/playlistItems?part=snippet";$.ajax({type:"POST",url:n,headers:{Authorization:"Bearer "+$e.access_token,"Content-Type":"application/json"},data:JSON.stringify({snippet:{playlistId:a,resourceId:{kind:"youtube#video",videoId:o.id}}}),success:function(e){A.log("Added video: "+o.id+" to playlist id "+a),t==Te.length-1&&(A.log("All videoes added!"),A.log("url: https://www.youtube.com/playlist?list="+a),$(".exported-list").append("<h5>Exported URL:</h5>"),$(".exported-list").append("<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list="+a+"'>"+z+"</a>"),$("#playlist_loader_export").addClass("hide"),$(".exported-list-container").removeClass("hide")),t+=1}})})},error:function(e){A.log(e)}})},importOldList:function(e){var t="",a=0;playlist_url="lists/"+e+".json",Me=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(Me.songs,function(e,o){t+=o.id+",",a>45&&(We.addVideos(t),t="",a=0),a++}),We.addVideos(t),document.getElementById("search").value=""},sortList:function(){Te.sort(A.predicate({name:"votes",reverse:!0},{name:"added",reverse:!1},{name:"title",reverse:!1}))},show:function(){A.mobilecheck()||(j?(j=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+z.toLowerCase())):(j=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(z)))},generateSong:function(e,t,a,o,n,i,s){void 0===O&&(O=$("#list-song-html").html());var l,r,c=e.id,d=e.title,p=e.votes,u="background-image:url('//img.youtube.com/vi/"+c+"/mqdefault.jpg');",g=$("<div>"+O+"</div>"),m="style";return t&&g.find("#list-song").css("height",0),V||g.find(".card-action").removeClass("hide"),1==p&&g.find(".vote-text").text("vote"),a&&(u="//img.youtube.com/vi/"+c+"/mqdefault.jpg",m="data-original"),o?(g.find(".list-votes").text(p),g.find("#list-song").attr("id",c),g.find(".vote-container").attr("title",d),($("#wrapper").children().length>=20&&s||"none"==i)&&g.find(".card").css("display","none"),l=".vote-container",r="del"):o||(g.find(".vote-text").text(e.duration),l=".add-suggested",r=n?"del_user_suggested":"del_suggested",g.find(".vote-container").attr("class","clickable add-suggested"),g.find(".add-suggested").attr("title",d),g.find("#del").attr("id",r),g.find(l).attr("data-video-title",d),g.find(l).attr("data-video-length",e.length),g.find("#list-song").attr("id","suggested-"+c),g.find(".list-image").attr("class",g.find(".list-image").attr("class").replace("list-image","list-suggested-image"))),g.find(".list-title").text(d),g.find(".list-title").attr("title",d),g.find(l).attr("data-video-id",c),g.find(".list-image").attr(m,u),g.find(".list-suggested-image").attr(m,u),g.find("#"+r).attr("data-video-id",c),g.html()},getIndexOfSong:function(e){return indexes=$.map(Te,function(t,a){if(t.id==e)return a}),indexes[0]},scrollTop:function(){$("#wrapper").scrollTop(0)},scrollBottom:function(){$("#wrapper").scrollTop($("#wrapper")[0].scrollHeight)}},z=void 0===window.chan?$("#chan").html():window.chan,V=!0,D=0,j=!0,O=$("#list-song-html").html(),R=!1,Y=!1,U="***REMOVED***",H=!1,q=/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)?)?/,F=[],J=0,G=1,W="",Z="",Q=!1,X=1,K=!1,ee=!1,te=6e3,ae=Date.now(),oe=!1,ne=-1,ie=!1,se=!1,le=!0,re=!1,ce=!1,de=!1,pe=!1,ue={},ge=!1,me="",he=300,fe=600,ye="&autoplay",ve=!1,$e={},we=!1,be=!1;if(void 0===localStorage.debug){var _e=!1;localStorage.debug=_e}var ke,Ce,xe,Se,Ie,Te,F,Ee,Be,Le,Ae,X,Pe,Me,Ne,ze,Ve,De,je={"sync disconnect on unload":!0,secure:!0,"force new connection":!0},Oe=!1,Re=!1;navigator.serviceWorker?navigator.serviceWorker.register("/service-worker.js",{scope:"/"}).then(function(e){A.log(e)}).catch(function(e){console.error(e)}):A.log("Service Worker is not supported in this browser."),$().ready(function(){Oe||"/"==window.location.pathname?Re||"/"!=window.location.pathname||T():e(),De.on("connect",function(){ve&&(ve=!1,$(".connect_error").fadeOut(function(){$(".connect_error").remove(),Materialize.toast("Connected!",2e3,"green lighten")}))}),o();try{Ue=$.ajax({type:"GET",url:"https://api.github.com/repos/zoff-music/zoff/commits",async:!1}).responseText,Ue=$.parseJSON(Ue),$("#latest-commit").html("Latest Commit: <br>"+Ue[0].commit.author.date.substring(0,10)+": "+Ue[0].committer.login+"<br><a href='"+Ue[0].html_url+"'>"+Ue[0].sha.substring(0,10)+"</a>: "+Ue[0].commit.message+"<br")}catch(e){A.log("Error with fetching GitHub commit info")}}),initializeCastApi=function(){cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:"E6856E24",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED});var e=cast.framework.CastContext.getInstance();e.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(e){switch(console.log(e),e.sessionState){case cast.framework.SessionState.SESSION_STARTED:P=cast.framework.CastContext.getInstance().getCurrentSession(),P.addMessageListner("urn:x-cast:zoff.no",a),window.castSession=cast.framework.CastContext.getInstance().getCurrentSession(),be=!0,P.sendMessage("urn:x-cast:zoff.no",{type:"loadVideo",videoId:Pe,seekTo:Je.player.getCurrentTime()}),t(1),$(".castButton").toggleClass("hide"),$(".castButton-active").toggleClass("hide");break;case cast.framework.SessionState.SESSION_RESUMED:$(".castButton").toggleClass("hide"),$(".castButton-active").toggleClass("hide");break;case cast.framework.SessionState.SESSION_ENDED:be=!1,$(".castButton").toggleClass("hide"),$(".castButton-active").toggleClass("hide"),t(0)}})},window.hide_native=t,window.enable_debug=f,window.disable_debug=y,$(document).keyup(function(e){27==event.keyCode&&($("#results").html(""),A.contains($("#search-wrapper").attr("class").split(" "),"hide")||$("#search-wrapper").toggleClass("hide"),A.contains($("#song-title").attr("class").split(" "),"hide")&&$("#song-title").toggleClass("hide"),"mdi-navigation-close"==$("#search-btn i").attr("class")&&($("#search-btn i").toggleClass("mdi-navigation-close"),$("#search-btn i").toggleClass("mdi-action-search")),$("#results").toggleClass("hide"))}),$(document).on("click","#playpause-overlay",function(){$("#play-overlay").hasClass("hide")?(Je.pauseVideo(),$("#play-overlay").toggleClass("hide"),$("#pause-overlay").toggleClass("hide")):$("#pause-overlay").hasClass("hide")&&(Je.playVideo(),$("#play-overlay").toggleClass("hide"),$("#pause-overlay").toggleClass("hide"))}),$(document).on("click",".castButton-active",function(e){e.preventDefault();var t=cast.framework.CastContext.getInstance().getCurrentSession();t.endSession(!0)}),$(document).on("click","#cookieok",function(){$(this).fadeOut(function(){$(this).remove(),localStorage.ok_cookie=!0})}),$(document).on("click",".connect_error",function(e){e.preventDefault(),$(this).fadeOut(function(){$(this).remove(),ve=!1})}),$(document).on("click",".extra-button-search",function(e){e.preventDefault(),$("#search").val($(this).attr("data-text")),We.search($(this).attr("data-text"))}),$(document).on("click",".extra-button-delete",function(e){e.preventDefault(),$(this).parent().remove(),0===$(".not-imported-container").children().length&&$(".not-imported").toggleClass("hide")}),$(document).on("click","#closePlayer",function(e){e.preventDefault(),De.emit("change_channel");try{Je.player.destroy()}catch(e){}De.removeEventListener("np"),De.removeEventListener("id"),De.removeEventListener(Ie),$("#alreadychannel").remove(),Je.player="",document.title="Zöff",$("#closePlayer").remove()}),$(document).on("click",".prev_page",function(e){e.preventDefault(),N.dynamicContentPage(-1)}),$(document).on("click",".modal-close",function(e){e.preventDefault()}),$(document).on("click",".next_page",function(e){e.preventDefault(),N.dynamicContentPage(1)}),$(document).on("click","#toast-container",function(){$(".toast").fadeOut(function(){$(".toast").remove()})}),$(document).on("click","#aprilfools",function(){$(".mega").css("-webkit-transform","rotate(0deg)"),$(".mega").css("-moz-transform","rotate(0deg)")}),$(document).on("keyup mouseup","#width_embed",function(){var e=$(this);fe=e.val(),$("#embed-area").val(v(ye,fe,he))}),$(document).on("keyup mouseup","#height_embed",function(){var e=$(this);he=e.val(),$("#embed-area").val(v(ye,fe,he))}),$(document).on("click",".chan-link",function(e){e.preventDefault(),Fe.to_channel($(this).attr("href"),!1)}),$(document).on("click",".listen-button",function(e){""===$(".room-namer").val()&&(e.preventDefault(),Fe.to_channel($(".room-namer").attr("placeholder")))}),$(document).on("submit",".channel-finder",function(e){return e.preventDefault(),Fe.to_channel($(".room-namer").val()),!1}),$(document).on("submit",".channel-finder-mobile",function(e){return e.preventDefault(),Fe.to_channel($("#search-mobile").val()),!1}),$(document).on("change","input[class=remote_switch_class]",function(){M.change_enabled(document.getElementsByName("remote_switch")[0].checked),L.set_remote(enabled)}),$(document).on("change","input[class=conf]",function(){E.save()}),$("#clickme").click(function(){Je.playVideo()}),$(document).on("click","#listExport",function(e){if(e.preventDefault(),A.log(Te),$("#playlist_loader_export").removeClass("hide"),$(".youtube_export_button").addClass("hide"),we)N.exportToYoutube();else{var t=w(29);window.callback=function(e){$e=e,$e.state==t?(we=!0,setTimeout(function(){we=!1,$e={}},1e3*$e.expires_in),N.exportToYoutube()):($e="",console.error("Nonce doesn't match")),youtube_window.close(),window.callback=""},youtube_window=window.open("/o_callback#youtube=true&nonce="+t,"","width=600, height=600")}}),$(document).on("click","#listExportSpotify",function(e){e.preventDefault(),A.log(Te)}),$(document).on("submit","#listImport",function(e){e.preventDefault();var t=$("#import").val().split("https://www.youtube.com/playlist?list=");""!==$("#import").val()&&2==t.length?(We.importPlaylist(t[1]),document.getElementById("import").value="",document.getElementById("import").disabled=!0,$("#import").addClass("hide"),$("#playlist_loader").removeClass("hide")):Materialize.toast("It seems you've entered a invalid url.",4e3),document.getElementById("import").value=""}),$(document).on("submit","#listImportSpotify",function(e){if(e.preventDefault(),ge&&""!==$("#import_spotify").val()){var t=$("#import_spotify").val().split("https://open.spotify.com/user/");if(2==t.length){t=t[1].split("/");var a=t[0],o=t[2];document.getElementById("import_spotify").disabled=!0,$("#import_spotify").addClass("hide"),$("#playlist_loader_spotify").removeClass("hide"),We.importSpotifyPlaylist("https://api.spotify.com/v1/users/"+a+"/playlists/"+o+"/tracks")}else Materialize.toast("It seems you've entered a invalid url.",4e3)}document.getElementById("import_spotify").value=""}),$(window).focus(function(){$("#favicon").attr("href","static/images/favicon.png"),Y=!1}),$(document).on("change","#autoplay",function(){ye=this.checked?"&autoplay":"",$("#embed-area").val(v(ye,fe,he))}),$(document).on("click","#playbutton_remote",function(e){e.preventDefault(),qe.play_remote()}),$(document).on("click","#pausebutton_remote",function(e){e.preventDefault(),qe.pause_remote()}),$(document).on("click","#skipbutton_remote",function(e){e.preventDefault(),qe.skip_remote()}),$(document).on("submit","#remoteform",function(e){e.preventDefault(),qe.get_input($("#remote_channel").val())}),$(document).on("click","#chat-btn",function(){$("#text-chat-input").focus(),$("#chat-btn i").css("opacity",1),clearInterval(Ee),R=!1,Y=!1,$("#favicon").attr("href","static/images/favicon.png")}),/iPad|iPhone|iPod/.test(navigator.userAgent)?$(document).on("keydown",".search_input",function(e){k(e)}):$(document).on("keyup",".search_input",function(e){k(e)}),$(document).on("click",".chat-tab",function(){$("#text-chat-input").focus()}),$(document).on("click","#skip",function(e){e.preventDefault(),N.skip()}),$(document).on("click","#chan",function(e){e.preventDefault(),N.show()}),$(document).on("submit","#adminForm",function(e){e.preventDefault(),E.pass_save()}),$(document).on("click",".chat-link",function(e){ce=!0,Y=!1,de=!1,$(".chat-link").attr("style","color: white !important;"),pe=!1,$("#favicon").attr("href","static/images/favicon.png"),$("#chatPlaylist").css("display","block"),$("#wrapper").css("display","none"),$("#suggestions").css("display","none"),$("#text-chat-input").focus(),$("#pageButtons").css("display","none")}),$(document).on("click",".playlist-link",function(e){ce=!1,$("#chatPlaylist").css("display","none"),$("#wrapper").css("display","block"),$("#suggestions").css("display","none"),$("#pageButtons").css("display","block")}),$(document).on("click",".suggested-link",function(e){ce=!1,$("#chatPlaylist").css("display","none"),$("#wrapper").css("display","none"),$("#suggestions").css("display","block"),$("#pageButtons").css("display","none")}),$(document).on("click",".import-spotify-auth",function(e){e.preventDefault();var t=w(29);window.callback=function(e){ue=e,ue.state==t?(ge=!0,_(!0),setTimeout(function(){ge=!1,ue={},_(!1),$(".spotify_authenticated").css("display","none"),$(".spotify_unauthenticated").css("display","block")},1e3*ue.expires_in)):(ue={},console.error("States doesn't match")),spotify_window.close(),window.callback=""},spotify_window=window.open("/o_callback#spotify=true&nonce="+t,"","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(),B.chat(document.getElementById("chatForm").input)}),$(document).on("click","#shuffle",function(e){e.preventDefault(),E.shuffle()}),$(document).on("click","#search-btn",function(e){e.preventDefault(),We.showSearch()}),$(document).on("click","#song-title",function(e){e.preventDefault(),We.showSearch()}),$(document).on("click","#admin-lock",function(e){e.preventDefault(),E.log_out()}),$(document).on("click","#closeSettings",function(e){e.preventDefault(),E.hide_settings()}),$(document).on("click",".result-object",function(e){var t=$(e.target),a=t.prop("outerHTML").substring(0,4);if("<i c"!=a){var o=$(this).attr("data-video-id"),n=$(this).attr("data-video-title"),i=$(this).attr("data-video-length");We.submitAndClose(o,n,i)}}),$(document).on("click","#add-many",function(e){var t=$(this).attr("data-video-id"),a=$(this).attr("data-video-title"),o=$(this).attr("data-video-length");We.submit(t,a,o)}),$(document).on("click",".vote-container",function(e){var t=$(this).attr("data-video-id");N.vote(t,"pos")}),$(document).on("click","#del",function(e){var t=$(this).attr("data-video-id");N.vote(t,"del")}),$(document).on("click",".add-suggested",function(e){var t=$(this).attr("data-video-id"),a=$(this).attr("data-video-title"),o=$(this).attr("data-video-length");We.submit(t,a,o),$("#suggested-"+t).remove()}),$(document).on("click","#del_suggested",function(e){var t=$(this).attr("data-video-id");$("#suggested-"+t).remove()}),$(document).on("click","#del_user_suggested",function(e){var t=$(this).attr("data-video-id");$("#suggested-"+t).remove(),N.vote(t,"del")}),$(document).on("click","#toast-container",function(){$(this).fadeOut(function(){$(this).remove()})}),$(document).on("click","#embed-area",function(){this.select()}),$(document).on("click",".brand-logo-navigate",function(e){e.preventDefault(),window.history.pushState("to the frontpage!","Title","/"),S()}),$(document).on("click","#player_bottom_overlay",function(){Fe.to_channel(z.toLowerCase(),!1)}),$(document).on("mousemove","#playlist",function(e){var t=e.pageY-this.offsetTop;t<=80&&t>=48&&$("#wrapper").scrollTop()>0?($("#top-button").removeClass("hide"),A.addClass("#bottom-button","hide")):t>=$("#playlist").height()-59&&t<=$("#playlist").height()-32&&$("#wrapper").scrollTop()<$("#wrapper")[0].scrollHeight-$("#wrapper").height()-1?($("#bottom-button").removeClass("hide"),A.addClass("#top-button","hide")):(A.addClass("#bottom-button","hide"),A.addClass("#top-button","hide"))}),$(document).on("mouseleave","#playlist",function(){A.addClass("#bottom-button","hide"),A.addClass("#top-button","hide")}),$(document).on("click","#top-button",function(){N.scrollTop()}),$(document).on("click","#bottom-button",function(){N.scrollBottom()});var Ye,Ue,De,He,qe={id:"",get_input:function(e){""===qe.id?qe.set_id(e.toLowerCase()):qe.set_channel(e.toLowerCase())},set_id:function(e){qe.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){De.emit("id",{id:qe.id,type:"channel",value:e})},play_remote:function(){De.emit("id",{id:qe.id,type:"play",value:"mock"})},pause_remote:function(){De.emit("id",{id:qe.id,type:"pause",value:"mock"})},skip_remote:function(){De.emit("id",{id:qe.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){De.emit("id",{id:qe.id,type:"volume",value:t.value}),A.log("volume")}})}},G=!0,Fe={blob_list:[],winter:!1,times_rotated:0,frontpage_function:function(e){$("#channels").empty(),G=!0,Fe.populate_channels(e.channels),Fe.set_viewers(e.viewers)},populate_channels:function(e){var t,a="",o=0;1==e[0].pinned&&(t=e.shift()),e.sort(Fe.sortFunction),void 0!==t&&e.unshift(t),pre_card=$(Ye),A.mobilecheck()||Fe.add_backdrop(e,0);for(var n in e){var i=e[n].channel;if(o<12){var s=e[n].id,l=e[n].viewers,r="background-image:url('https://img.youtube.com/vi/"+s+"/hqdefault.jpg');",c=e[n].count,d=pre_card;1==e[n].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(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())}a+="<option value='"+i+"'> ",o++}document.getElementById("preloader").style.display="none",document.getElementById("searches").innerHTML=a,document.getElementById("searches_mobile").innerHTML=a,$("#channels").fadeIn(800),$("#searchFrontpage").focus()},sortFunction:function(e,t){var a=e.viewers,o=t.viewers,n=e.count,i=t.count;return a<o?1:a>o?-1:n<i?1:n>i?-1:0},getCookie:function(e){for(var t=e+"=",a=document.cookie.split(";"),o=0;o<a.length;o++){for(var n=a[o];" "==n.charAt(0);)n=n.substring(1);if(0===n.indexOf(t))return n.substring(t.length,n.length)}return""},add_backdrop:function(e,t){(t>=e.length||t>=8)&&(t=0);var a=e[t].id;if(void 0!==Fe.blob_list[t])setTimeout(function(){G&&($("#mega-background").css("background","url(data:image/png;base64,"+Fe.blob_list[t]+")"),$("#mega-background").css("background-size","200%"),$("#mega-background").css("opacity",1),$("#searchFrontpage").attr("placeholder",e[t].channel))},500);else{var o=new Image;o.src="/static/images/thumbnails/"+a+".jpg",o.onerror=function(){$.ajax({type:"POST",data:{id:a},url:"/php/imageblob.php",success:function(a){Fe.blob_list.push(a),setTimeout(function(){$("#mega-background").css("background","url(data:image/png;base64,"+a+")"),$("#mega-background").css("background-size","200%"),$("#mega-background").css("opacity",1),$("#searchFrontpage").attr("placeholder",e[t].channel)},500)}})},o.onload=function(){$("#mega-background").css("background","url("+o.src+")"),$("#mega-background").css("background-size","200%"),$("#mega-background").css("opacity",1),$("#searchFrontpage").attr("placeholder",e[t].channel)}}He=setTimeout(function(){50==Fe.times_rotated&&G?(Fe.times_rotated=0,t=0,De.emit("frontpage_lists")):G&&(Fe.times_rotated+=1,Fe.add_backdrop(e,t+1))},6e3)},start_snowfall:function(){setTimeout(function(){var e=Math.floor(Math.random()*window.innerWidth+1),t=document.createElement("div"),a=document.getElementsByClassName("mega")[0];t.className="snow",t.style.left=e+"px",t.style.top="0px",a.appendChild(t),Fe.fall_snow(t),Fe.start_snowfall()},800)},fall_snow:function(e){e.style.top=parseInt(e.style.top.replace("px",""))+2+"px",parseInt(e.style.top.replace("px",""))<document.getElementById("mega-background").offsetHeight-2.5?setTimeout(function(){Fe.fall_snow(e)},50):e.remove()},set_viewers:function(e){if(e>0){var t=e>1?"listeners":"listener";$("#frontpage-viewer-counter").html(e+" "+t)}},to_channel:function(t,a){$("#channel-load").css("display","block"),window.scrollTo(0,0),G=!1,clearTimeout(He),A.mobilecheck()&&De.removeAllListeners(),$("body").css("background-color","#2d2d2d"),$.ajax({url:t+"/php/index.php",success:function(o){if(""!==Je.player&&De.emit("change_channel",{channel:z.toLowerCase()}),$("#frontpage_player").empty(),A.mobilecheck()&&De.disconnect(),a||(window.history.pushState("to the channel!","Title","/"+t),window.chan=t),$(".mega").remove(),$(".mobile-search").remove(),$("main").attr("class","container center-align main"),$("body").attr("id","channelpage"),$("header").html($($(o)[59]).html()),0===$("#alreadychannel").length||A.mobilecheck()||void 0===Je.player)$("main").html($($(o)[63]).html());else{var n=$($($($($(o)[65]).html())[0]).html());$("#main-row").append($(n[2]).wrap("<div>").parent().html()),$("#video-container").append($($($(n[0]).html())[4]).wrap("<div>").parent().html()),$("#main-row").append("<div id='playbar'></div>"),$("#player").removeClass("player_bottom"),$("#main-row").removeClass("frontpage_modified_heights"),$("#main_section_frontpage").remove(),$("#closePlayer").remove(),$("#player_bottom_overlay").remove()}$("#search").attr("placeholder","Find song on YouTube..."),$(".page-footer").addClass("padding-bottom-novideo"),1==$("#alreadychannel").length?e():(Oe=!0,e()),0===$("#alreadyfp").length&&$("head").append("<div id='alreadyfp'></div>")}})}};String.prototype.capitalizeFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)};var Je={loaded:!0,before_load:"",after_load:"",player:"",stopInterval:!1,youtube_listener:function(e){Je.loaded=!1,A.log("--------youtube_listener--------"),A.log("Received: "),A.log(e),A.log("paused variable: "+K),A.log("mobile_beginning variable: "+xe);try{A.log("getVideoUrl(): "+Je.player.getVideoUrl().split("v=")[1])}catch(e){}if(A.log("video_id variable: "+Pe),A.log("---------------------------------"),e.np){if(K)Je.getTitle(e.np[0].title,X),Je.notifyUser(e.np[0].id,e.np[0].title),Je.stopVideo();else if(!K){void 0===Ve?Ve=e.np[0].id:Ve!=Pe&&(Ve=Pe),Pe=e.np[0].id,F=e.conf[0],time=e.time,Ne=time-F.startTime,ze=e.np[0].title,duration=e.np[0].duration,xe&&A.mobilecheck()&&0===Ne&&(Ne=1);try{Te[0].id==Pe&&N.song_change(Te[0].added),Ze.fetchYoutubeSuggests(Pe)}catch(e){}if(Je.getTitle(ze,X),Je.setBGimage(Pe),Q&&!window.MSStream)try{Je.player.getVideoUrl().split("v=")[1]!=Pe&&(Je.loadVideoById(Pe),Je.notifyUser(Pe,ze),Je.seekTo(Ne),K&&Je.pauseVideo()),K||(xe||Je.playVideo(),re||Je.durationSetter()),(Je.player.getDuration()>Ne||0===Je.player.getDuration()||be)&&Je.seekTo(Ne),Je.after_load=Pe,Je.loaded||setTimeout(function(){Je.loaded=!0},500)}catch(e){re||Je.durationSetter()}else Je.getTitle(ze,X)}}else{document.getElementById("song-title").innerHTML="Empty channel. Add some songs!",$("#player_overlay").height($("#player").height()),window.MSStream||be||$("#player_overlay").toggleClass("hide");try{Je.stopVideo()}catch(e){}}},onPlayerStateChange:function(e){A.log("-------onPlayerStateChange------"),A.log("New state\nState: "),A.log(e);try{A.log("Duration: "+Je.player.getDuration(),"Current time: "+Je.player.getCurrentTime()),A.log("getVideoUrl(): "+Je.player.getVideoUrl().split("v=")[1])}catch(e){}switch(A.log("video_id variable: "+Pe),A.log("---------------------------------"),e.data){case-1:break;case 0:ee=!1,K=!1,De.emit("end",{id:Pe,channel:z.toLowerCase()});break;case 1:ee=!0,beginning&&A.mobilecheck()&&(Je.pauseVideo(),beginning=!1,xe=!1),!se&&"/"!=window.location.pathname&&be&&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")),K&&(De.emit("pos",{channel:z.toLowerCase()}),K=!1);break;case 2:K=!0,"/"!=window.location.pathname&&Ge.play_pause_show(),xe=!0;break;case 3:}},playVideo:function(){be?P.sendMessage("urn:x-cast:zoff.no",{type:"playVideo"}):Je.player.playVideo()},pauseVideo:function(){be?P.sendMessage("urn:x-cast:zoff.no",{type:"pauseVideo"}):Je.player.pauseVideo()},seekTo:function(e){be?P.sendMessage("urn:x-cast:zoff.no",{type:"seekTo",seekTo:e}):Je.player.seekTo(e)},loadVideoById:function(e){be?P.sendMessage("urn:x-cast:zoff.no",{type:"loadVideoById",videoId:e}):Je.player.loadVideoById(e)},stopVideo:function(){be?P.sendMessage("urn:x-cast:zoff.no",{type:"stopVideo"}):Je.player.stopVideo()},getTitle:function(e,t){var a=t>1?"viewers":"viewer",o=decodeURIComponent(e);if("/"!=window.location.pathname){var n=document.getElementById("song-title"),i=document.getElementById("viewers");n.innerHTML=o,i.innerHTML=t+" "+a,n.title=o}document.title=o+" • Zöff / "+z},errorHandler:function(e){5==e.data||100==e.data||101==e.data||150==e.data?(curr_playing=Je.player.getVideoUrl().replace("https://www.youtube.com/watch?v=",""),De.emit("skip",{error:e.data,id:Pe,pass:W,channel:z.toLowerCase})):void 0!==Pe&&Je.loadVideoById(Pe)},onPlayerReady:function(e){$("#channel-load").css("display","none");try{beginning=!0,Q=!0,window.MSStream||($("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),Je.loadVideoById(Pe),le&&!A.mobilecheck()&&Je.playVideo(),re||Je.durationSetter(),se?setTimeout(function(){Je.seekTo(Ne),le||(Je.pauseVideo(),Ge.play_pause_show())},1e3):Je.seekTo(Ne)),Je.readyLooks(),Ge.initYoutubeControls(Je.player),Ge.initSlider(),Je.player.setVolume(L.get_volume()),$(".video-container").removeClass("no-opacity")}catch(e){}},readyLooks:function(){Je.setBGimage(Pe)},setBGimage:function(e){if(void 0!==e&&!se){var t=new Image;t.onload=function(){var e=new ColorThief,a=e.getColor(t);"/"!=window.location.pathname&&(document.getElementsByTagName("body")[0].style.backgroundColor=A.rgbToHsl(a,!0),$("meta[name=theme-color]").attr("content",A.rgbToHex(a[0],a[1],a[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 a=new Notification("Now Playing",{body:t,icon:"https://i.ytimg.com/vi/"+e+"/mqdefault.jpg",iconUrl:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg"});a.onclick=function(e){window.focus(),this.cancel()},setTimeout(function(){a.close();
},5e3)}},setup_all_listeners:function(){i(),n(),c(),d(),p()},onYouTubeIframeAPIReady:function(){Je.player=new YT.Player("player",{videoId:Pe,playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",color:"white",showinfo:0},events:{onReady:Je.onPlayerReady,onStateChange:Je.onPlayerStateChange,onError:Je.errorHandler}})},durationSetter:function(){if(void 0!==duration)try{Je.stopInterval||(re=!0),dMinutes=Math.floor(duration/60),dSeconds=duration-60*dMinutes,currDurr=void 0!==Je.player.getCurrentTime()?Math.floor(Je.player.getCurrentTime()):Ne,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){}Je.stopInterval||setTimeout(Je.durationSetter,1e3)},loadPlayer:function(){if(1==$("script[src='https://www.youtube.com/iframe_api']").length)try{Je.onYouTubeIframeAPIReady()}catch(e){console.error("Seems YouTube iFrame script isn't correctly loaded. Please reload the page.")}else Be=document.createElement("script"),Be.src="https://www.youtube.com/iframe_api",Le=document.getElementsByTagName("script")[0],Le.parentNode.insertBefore(Be,Le)}},Ge={stopInterval:!1,initYoutubeControls:function(){!A.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||$("#controls").appendTo("#playbar"),Ge.initControls()},initControls:function(){document.getElementById("volume-button").addEventListener("click",Ge.mute_video),document.getElementById("playpause").addEventListener("click",Ge.play_pause),document.getElementById("volume-button-overlay").addEventListener("click",Ge.mute_video),document.getElementById("playpause-overlay").addEventListener("click",Ge.play_pause),document.getElementById("fullscreen").addEventListener("click",Ge.fullscreen)},initSlider:function(){try{vol=L.get_volume()}catch(e){}$("#volume").slider({min:0,max:100,value:vol,range:"min",animate:!0,slide:function(e,t){Ge.setVolume(t.value);try{L.set_volume(t.value)}catch(e){}}}),Ge.choose_button(vol,!1)},fullscreen:function(){var e=document.getElementById("player"),t=e.requestFullScreen||e.mozRequestFullScreen||e.webkitRequestFullScreen;t&&t.bind(e)()},play_pause:function(){1==Je.player.getPlayerState()?(Je.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!=Je.player.getPlayerState()&&0!==Je.player.getPlayerState()||(Je.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"),$("#pause-overlay").toggleClass("hide")),2==document.getElementById("play").className.split(" ").length&&($("#play").toggleClass("hide"),$("#play-overlay").toggleClass("hide"))},settings:function(){$("#qS").toggleClass("hide")},changeQuality:function(e){Je.player.getPlaybackQuality!=e&&(Je.player.setPlaybackQuality(e),Je.player.getPlaybackQuality()),$("#qS").toggleClass("hide")},mute_video:function(){Je.player.isMuted()?(Je.player.unMute(),Ge.choose_button(Je.player.getVolume(),!1)):(Ge.choose_button(0,!0),Je.player.mute())},setVolume:function(e){Je.player.setVolume(e),Ge.choose_button(e,!1),Je.player.isMuted()&&Je.player.unMute()},choose_button:function(e,t){t?(1==document.getElementById("v-full").className.split(" ").length&&($("#v-full").toggleClass("hide"),$("#v-full-overlay").toggleClass("hide")),1==document.getElementById("v-medium").className.split(" ").length&&($("#v-medium").toggleClass("hide"),$("#v-medium-overlay").toggleClass("hide")),1==document.getElementById("v-low").className.split(" ").length&&($("#v-low").toggleClass("hide"),$("#v-low-overlay").toggleClass("hide")),2==document.getElementById("v-mute").className.split(" ").length&&($("#v-mute").toggleClass("hide"),$("#v-mute-overlay").toggleClass("hide"))):e>=0&&e<=33?(1==document.getElementById("v-full").className.split(" ").length&&($("#v-full").toggleClass("hide"),$("#v-full-overlay").toggleClass("hide")),1==document.getElementById("v-medium").className.split(" ").length&&($("#v-medium").toggleClass("hide"),$("#v-medium-overlay").toggleClass("hide")),2==document.getElementById("v-low").className.split(" ").length&&($("#v-low").toggleClass("hide"),$("#v-low-overlay").toggleClass("hide")),1==document.getElementById("v-mute").className.split(" ").length&&($("#v-mute").toggleClass("hide"),$("#v-mute-overlay").toggleClass("hide"))):e>=34&&e<=66?(1==document.getElementById("v-full").className.split(" ").length&&($("#v-full").toggleClass("hide"),$("#v-full-overlay").toggleClass("hide")),2==document.getElementById("v-medium").className.split(" ").length&&($("#v-medium").toggleClass("hide"),$("#v-medium-overlay").toggleClass("hide")),1==document.getElementById("v-low").className.split(" ").length&&($("#v-low").toggleClass("hide"),$("#v-low-overlay").toggleClass("hide")),1==document.getElementById("v-mute").className.split(" ").length&&($("#v-mute").toggleClass("hide"),$("#v-mute-overlay").toggleClass("hide"))):e>=67&&e<=100&&(2==document.getElementById("v-full").className.split(" ").length&&($("#v-full").toggleClass("hide"),$("#v-full-overlay").toggleClass("hide")),1==document.getElementById("v-medium").className.split(" ").length&&($("#v-medium").toggleClass("hide"),$("#v-medium-overlay").toggleClass("hide")),1==document.getElementById("v-low").className.split(" ").length&&($("#v-low").toggleClass("hide"),$("#v-low-overlay").toggleClass("hide")),1==document.getElementById("v-mute").className.split(" ").length&&($("#v-mute").toggleClass("hide"),$("#v-mute-overlay").toggleClass("hide")))},playPause:function(){state=Je.player.getPlayerState(),button=document.getElementById("playpause"),1==state?Je.pauseVideo():2==state&&Je.playVideo()},volumeOptions:function(){be||(Je.player.isMuted()?(Je.player.unMute(),vol=Je.player.getVolume(),$("#volume").slider("value",Je.player.getVolume())):(Je.player.mute(),$("#volume").slider("value",0)))},hoverMute:function(e){vol=Je.player.getVolume()}},We={submitArray:[],submitArrayExpected:null,showSearch:function(){$("#search-wrapper").toggleClass("hide"),A.mobilecheck()&&$(".search_input").focus(),$("#song-title").toggleClass("hide"),$("#results").toggleClass("hide"),$("#results").empty(),$("#search-btn i").toggleClass("mdi-navigation-close"),$("#search-btn i").toggleClass("mdi-action-search"),$("#search").focus()},search:function(e){if(void 0!==ke&&void 0!==Ce||(ke=$("#temp-results-container"),Ce=$("#empty-results-container").html()),$(".search_results").html(""),""!==e){H=!0;var t=encodeURIComponent(e),a="https://www.googleapis.com/youtube/v3/search?key="+U+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";a+="&q="+t,J&&(a+="&videoCategoryId=10");var o="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+U+"&id=";A.contains($("#search_loader").attr("class").split(" "),"hide")&&$("#search_loader").removeClass("hide"),A.contains($("#results").attr("class").split(" "),"hide")&&$("#results").removeClass("hide"),$.ajax({type:"GET",url:a,dataType:"jsonp",success:function(e){0===e.items.length?($("<div style='display:none;' id='mock-div'>"+Ce+"</div>").appendTo($("#results")).show("blind",83.33),A.contains($("#search_loader").attr("class").split(" "),"hide")||$("#search_loader").addClass("hide")):e.items&&($.each(e.items,function(e,t){o+=t.id.videoId+","}),$.ajax({type:"GET",url:o,dataType:"jsonp",success:function(e){var t="",a=$(ke);$.each(e.items,function(e,o){var n=o.contentDetails.duration;if(secs=We.durationToSeconds(n),!longsongs||secs<720){Ae=o.snippet.title,enc_title=Ae,Ie=o.id,n=n.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"),thumb=o.snippet.thumbnails.medium.url;var i=a;i.find(".search-title").text(Ae),i.find(".result_info").text(n),i.find(".thumb").attr("data-original",thumb),i.find("#add-many").attr("data-video-id",Ie),i.find("#add-many").attr("data-video-title",enc_title),i.find("#add-many").attr("data-video-length",secs),i.find("#temp-results").attr("data-video-id",Ie),i.find("#temp-results").attr("data-video-title",enc_title),i.find("#temp-results").attr("data-video-length",secs),t+=i.html()}}),$("<div style='display:none;' id='mock-div'>"+t+"</div>").appendTo($("#results")).show("blind",83.33*(e.items.length-1)),setTimeout(function(){$(".thumb").lazyload({container:$("#results")})},250),A.contains($("#search_loader").attr("class").split(" "),"hide")||$("#search_loader").addClass("hide"),$(".add-many").click(function(e){return e.preventDefault(),e.stopPropagation(),!1})}}))}})}else $(".main").removeClass("blurT"),$("#controls").removeClass("blurT"),$(".main").removeClass("clickthrough")},backgroundSearch:function(e,t,a,o,n){var i=encodeURIComponent(e+" "+t),s="https://www.googleapis.com/youtube/v3/search?key="+U+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10";s+="&q="+i;var l="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+U+"&id=";t=t.split(" ");var r=e.split("-");r=r.join(" ").split(" "),$.ajax({type:"GET",url:s,dataType:"jsonp",success:function(n){if(0===n.items.length){We.readySubmit(!1,{totalLength:o-1}),A.log("------------------------------"),A.log("NO MATCH FOR:"),A.log("Spotify title: "+e+" "+t.join(" ")),A.log("Spotify length: "+a),A.log("------------------------------");var i=$("<div>"+me+"</div>");i.find(".extra-add-text").text(e+" - "+t.join(" ")),i.find(".extra-add-text").attr("title",e+" - "+t.join(" ")),i.find(".extra-button-search").attr("data-text",e+" - "+t.join(" ")),$(".not-imported-container").append(i.html()),$(".not-imported").removeClass("hide")}else n.items.length>0&&($.each(n.items,function(e,t){l+=t.id.videoId+","}),$.ajax({type:"GET",url:l,dataType:"jsonp",success:function(n){if(n.items.length>0){var i=!1;if($.each(n.items,function(a,n){var s=We.durationToSeconds(n.contentDetails.duration),l=!1;if($.each(r,function(a,o){return n.snippet.title.toLowerCase().indexOf(o.toLowerCase())!=-1&&n.snippet.title.toLowerCase().indexOf("cover")==-1&&e.toLowerCase().indexOf("cover")==-1&&(n.snippet.title.toLowerCase().indexOf("remix")==-1&&e.toLowerCase().indexOf("remix")==-1||n.snippet.title.toLowerCase().indexOf("remix")!=-1&&e.toLowerCase().indexOf("remix")!=-1||n.snippet.title.toLowerCase().indexOf(t[0].toLowerCase())!=-1||n.snippet.channelTitle.toLowerCase().indexOf(t[0].toLowerCase())!=-1||n.snippet.channelTitle.toLowerCase().indexOf("vevo")!=-1)||(l=!0),!1}),!l)return i=!0,We.readySubmit(!0,{id:n.id,title:n.snippet.title,duration:s,totalLength:o-1}),!1}),!i){We.readySubmit(!1,{totalLength:o-1}),A.log("------------------------------"),A.log("NO MATCH FOR:"),A.log("Spotify title: "+e+" "+t.join(" ")),A.log("Spotify length: "+a),A.log("------------------------------");var s=$("<div>"+me+"</div>");s.find(".extra-add-text").text(e+" - "+t.join(" ")),s.find(".extra-add-text").attr("title",e+" - "+t.join(" ")),s.find(".extra-button-search").attr("data-text",e+" - "+t.join(" ")),$(".not-imported-container").append(s.html()),$(".not-imported").removeClass("hide")}}}}))}})},readySubmit:function(e,t){null===We.submitArrayExpected&&(We.submitArrayExpected=t.totalLength),e?We.submitArray.push(t):We.submitArrayExpected-=1,We.submitArray.length-1==We.submitArrayExpected&&($.each(We.submitArray,function(e,t){We.submit(t.id,t.title,t.duration,!0,e,We.submitArray.length-1)}),document.getElementById("import_spotify").disabled=!1,$("#import_spotify").removeClass("hide"),$("#playlist_loader_spotify").addClass("hide"),We.submitArray=[],We.submitArrayExpected=null)},submitAndClose:function(e,t,a){We.submit(e,t,a,!1,0,1),$("#results").html(""),We.showSearch(),document.getElementById("search").value="",$("#results").html="",$(".main").removeClass("blurT"),$("#controls").removeClass("blurT"),$(".main").removeClass("clickthrough")},importPlaylist:function(e,t){token="";var a,o;void 0!==t&&(token="&pageToken="+t),playlist_url="https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+U+"&playlistId="+e+token,we?(o="html",a={"Content-Type":"application/json",Authorization:"Bearer "+$e.access_token}):(a={},o="jsonp"),$.ajax({type:"GET",url:playlist_url,dataType:o,headers:a,success:function(a){if(a.error)if("playlistItemsNotAccessible"==a.error.errors[0].reason){var o=w(29);window.callback=function(a){$e=a,$e.state==o?(we=!0,setTimeout(function(){we=!1,$e={}},1e3*$e.expires_in),We.importPlaylist(e,t)):($e="",console.error("Nonce doesn't match")),youtube_window.close(),window.callback=""},youtube_window=window.open("/o_callback#youtube=true&nonce="+o,"","width=600, height=600")}else A.log(a.error),document.getElementById("import").disabled=!1,$("#playlist_loader").addClass("hide"),$("#import").removeClass("hide"),Materialize.toast("It seems you've entered a invalid url.",4e3);else{var n="";"string"==typeof a&&(a=$.parseJSON(a)),$.each(a.items,function(e,t){n+=t.contentDetails.videoId+","}),We.addVideos(n,!0),a.nextPageToken&&We.importPlaylist(e,a.nextPageToken),document.getElementById("import").value=""}}})},importSpotifyPlaylist:function(e){$.ajax({url:e,headers:{Authorization:"Bearer "+ue.access_token},success:function(e){$.each(e.items,function(t,a){We.backgroundSearch(a.track.name,a.track.artists.map(function(e){return e.name}).join(" "),Math.floor(a.track.duration_ms/1e3),e.total,t+e.offset)}),e.next&&We.importSpotifyPlaylist(e.next)},error:function(){document.getElementById("import_spotify").disabled=!1,$("#import_spotify").removeClass("hide"),$("#playlist_loader_spotify").addClass("hide"),Materialize.toast("It seems you've entered a invalid url.",4e3)}})},addVideos:function(e,t){var a="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";a+=e,$.ajax({type:"POST",url:a,dataType:"jsonp",success:function(e){var a=0,o=[];$.each(e.items,function(e,n){var i=We.durationToSeconds(n.contentDetails.duration);(!longsongs||i<720)&&(enc_title=n.snippet.title,a+=1,o.push({id:n.id,enc_title:enc_title,duration:i,playlist:t}))}),$.each(o,function(e,t){We.submit(t.id,t.enc_title,t.duration,t.playlist,e,a)})}})},submit:function(e,t,a,o,n,i){De.emit("add",{id:e,title:decodeURIComponent(t),adminpass:W,list:z.toLowerCase(),duration:a,playlist:o,num:n,total:i})},durationToSeconds:function(e){var t=e.match(q);return hours=parseInt(t[12])||0,minutes=parseInt(t[14])||0,seconds=parseInt(t[16])||0,60*hours*60+60*minutes+seconds}},Ze={catchUserSuggests:function(e,t){if(t)Ze.createSuggested(e);else for(var a in e)Ze.createSuggested(e[a]);Ze.checkUserEmpty()},createSuggested:function(e){var t=e.duration,a=e.id,o=e.title,n=Math.floor(t/60),i=t-60*n;duration=n+"m "+i+"s";var s=N.generateSong({id:a,title:o,length:t,duration:duration},!1,!1,!1,!0);$("#user-suggest-html").append(s)},fetchYoutubeSuggests:function(e){var t="https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+e+"&type=video&key="+U,a="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+U+"&id=";$.ajax({type:"GET",url:t,dataType:"jsonp",success:function(e){$.each(e.items.slice(0,5),function(e,t){a+=t.id.videoId+","}),$.ajax({type:"GET",url:a,dataType:"jsonp",success:function(e){$("#suggest-song-html").empty(),$.each(e.items,function(e,t){var a=t.contentDetails.duration,o=We.durationToSeconds(a),n=t.id,i=t.snippet.title;a=a.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"),$("#suggest-song-html").append(N.generateSong({id:n,title:i,length:o,duration:a},!1,!1,!1))})}})}})},checkUserEmpty:function(){var e=$("#user-suggest-html").children().length;0===e?A.contains($("#user_suggests").attr("class").split(" "),"hide")||$("#user_suggests").addClass("hide"):$("#user_suggests").removeClass("hide")}}}();