diff --git a/static/dist/main.min.js b/static/dist/main.min.js index 3a989260..610cb8ba 100644 --- a/static/dist/main.min.js +++ b/static/dist/main.min.js @@ -1,2 +1,2 @@ -!function(){function e(){$("#channel-load").css("display","block"),window.scrollTo(0,0),Z.stopInterval=!0;var e=window.location.href.split("/");(""==e[3]||"#"==e[3].substring(0,1))&&$.ajax({url:"php/nochan_content.php",success:function(e){te.ytplayer.destroy(),Q.disconnect(),document.getElementById("volume-button").removeEventListener("click",Z.mute_video),document.getElementById("playpause").removeEventListener("click",Z.play_pause),document.getElementById("fullscreen").removeEventListener("click",Z.fullscreen),setTimeout(function(){delete t,delete o,delete n,delete _,delete Z,delete C,delete X,delete ee,delete te,delete S,delete I,delete T,delete E,delete B,delete P,delete L,delete M,delete A,delete N,delete V,delete j,delete R,delete l,delete Y,delete D,delete O,delete z,delete J,delete h,delete H,delete q,delete U,delete G,delete F,delete W,delete s,delete i,delete l,delete d,delete c,delete u,delete te.ytplayer,delete m,delete h,delete y,delete f,delete v,delete w,delete k,delete K,delete Q,delete window.onYouTubeIframeAPIReady},1e3),document.title="Zöff",$(".drag-target").remove(),$(".sidenav-overlay").remove(),$("main").attr("class","center-align container"),$("body").attr("id",""),$("body").attr("style",""),$("header").html($($(e)[0]).html()),$($(e)[2]).insertAfter("header"),$($(e)[4]).insertAfter(".mega"),$("main").html($($(e)[6]).html()),$("#scripts").html($($(e)[8]).html())}})}var t={beginning:!0,admin_listener:function(){Q.on("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"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."]),n.remove_pass(S.toLowerCase()),t.display_logged_out(),I=!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"]);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)}),Q.on("pw",function(e){I=!1,O=e,names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],n.set_pass(S.toLowerCase(),n.decrypt_pass(e));for(var t=0;t150||(e.value.startsWith("/name ")?Q.emit("namechange",e.value.substring(6)):"#all_chat"==$(".tab a.active").attr("href")?Q.emit("all,chat",e.value):Q.emit("chat",e.value),e.value="")},allchat_listener:function(){Q.on("chat.all",function(e){0!=$("#chat-bar").position().left?P||($("#favicon").attr("href","static/images/highlogo.png"),P=!0,L=!0,d=setInterval(o.chat_blink,2e3)):document.hidden&&($("#favicon").attr("href","static/images/highlogo.png"),L=!0);var t=a.intToARGB(a.hashCode(e[0])).substring(0,6);$("#chatall").append("
  • "+e[0]+"
  • ");var n=document.createTextNode(e[1]);$("#chatall li:last")[0].appendChild(n),document.getElementById("chatall").scrollTop=document.getElementById("chatall").scrollHeight})},setup_chat_listener:function(e){document.getElementsByClassName("chat-tab")[0].innerHTML=e,Q.on("chat",function(e){0!=$("#chat-bar").position().left&&e[1].indexOf(":")>=0&&(P||($("#favicon").attr("href","static/images/highlogo.png"),P=!0,d=setInterval(o.chat_blink,2e3)));var t=a.intToARGB(a.hashCode(e[0])).substring(0,6);$("#chatchannel").append("
  • "+e[0]+"
  • ");var n=document.createTextNode(e[1]);$("#chatchannel li:last")[0].appendChild(n),document.getElementById("chatchannel").scrollTop=document.getElementById("chatchannel").scrollHeight})},chat_blink:function(){$("#chat-btn i").css("opacity",.5),setTimeout(function(){$("#chat-btn i").css("opacity",1)},1e3)}},n={conf_arr:{},init:function(){try{conf_arr=n.decrypt(n.getCookie("_opt"),"_opt")}catch(e){conf_arr=n.decrypt(n.create_cookie("_opt"),"_opt")}try{conf_pass=n.decrypt(n.getCookie(S.toLowerCase()),S.toLowerCase())}catch(e){conf_pass=n.decrypt(n.create_cookie(S.toLowerCase()),S.toLowerCase())}_.change_enabled(conf_arr.remote),100!=conf_arr.width&&te.set_width(conf_arr.width)},decrypt:function(e,t){void 0===n.getCookie(t)&&(e=n.create_cookie(t));var o=CryptoJS.AES.decrypt(e,navigator.userAgent+navigator.languages,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return $.parseJSON(o.toString(CryptoJS.enc.Utf8))},decrypt_pass:function(e){var t=CryptoJS.AES.decrypt(e,Q.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString(CryptoJS.enc.Utf8)},encrypt:function(e,t){var o=JSON.stringify(e),n=CryptoJS.AES.encrypt(o,navigator.userAgent+navigator.languages,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),a=new Date;a.setFullYear(a.getFullYear()+1),document.cookie=t+"="+n.toString()+";expires="+a.toGMTString()+";path=/;"},encrypt_string:function(e){var t=CryptoJS.AES.encrypt(e,Q.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString()},get_volume:function(){return n.decrypt(n.getCookie("_opt"),"_opt").volume},set_volume:function(e){conf_arr.volume=e,n.encrypt(conf_arr,"_opt")},create_cookie:function(e){"_opt"==e?cookie_object={volume:100,width:100,remote:!0}:cookie_object={passwords:{}};var t=JSON.stringify(cookie_object),o=CryptoJS.AES.encrypt(t,navigator.userAgent+navigator.languages,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),a=new Date;return a.setFullYear(a.getFullYear()+1),document.cookie=e+"="+o.toString()+";expires="+a.toGMTString()+";path=/;",n.getCookie(e)},set_pass:function(e,t){conf_pass.passwords[e]=t,n.encrypt(conf_pass,e)},remove_pass:function(e){delete conf_pass.passwords[e],n.encrypt(conf_pass,e.toLowerCase())},get_pass:function(e){return conf_pass.passwords[e]},set_remote:function(e){conf_arr.remote=e,n.encrypt(conf_arr,"_opt")},get_remote:function(e){return conf_arr.remote},crypt_pass:function(e){var t=CryptoJS.AES.encrypt(e,Q.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,n.encrypt(conf_arr,"_opt")},getCookie:function(e){var t="; "+document.cookie,o=t.split("; "+e+"=");return 2==o.length?o.pop().split(";").shift():void 0}};window.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};var a={rnd:function(e){return e[Math.floor(Math.random()*e.length)]},predicate:function(){for(var e,t,o,n=[],a=arguments.length,s=function(e,t){return e===t?0:t>e?-1:1},i=function(e,t){var o=s,n=s;return e&&(n=function(t,n){return o(e(t),e(n))}),t?function(e,t){return-1*n(e,t)}:n},r=0;a>r;r++)e=arguments[r],"string"==typeof e?(t=e,o=s):(t=e.name,o=i(e.primer,e.reverse)),n.push({name:t,cmp:o});return function(t,o){for(var s,i,r=0;a>r&&(i=0,e=n[r],s=e.name,i=e.cmp(t[s],o[s]),0===i);r++);return i}},hashCode:function(e){for(var t=0,o=0;o>24&255).toString(16)+(e>>16&255).toString(16)+(e>>8&255).toString(16)+(255&e).toString(16)},pad:function(e){return 10>e?"0"+Math.floor(e):Math.floor(e)},contains:function(e,t){for(var o=e.length;o--;)if(e[o]===t)return!0;return!1},sample:function(){Date.now()-G>=2*U&&(Q.removeAllListeners(),Q.disconnect(),Q.connect(),te.setup_all_listeners()),G=Date.now(),setTimeout(a.sample,U)},loadjsfile:function(e){if(-1==z.indexOf("["+e+"]")){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\./)?!0:!1},getRandomInt:function(e,t){return Math.floor(Math.random()*(t-e))+e},rgbToHsl:function(e){r=e[0],g=e[1],b=e[2],r/=255,g/=255,b/=255;var t,o,n=Math.max(r,g,b),a=Math.min(r,g,b),s=(n+a)/2;if(n==a)t=o=0;else{var i=n-a;switch(o=s>.5?i/(2-n-a):i/(n+a),n){case r:t=(g-b)/i+(g.5&&(s=.5),"hsl("+Math.floor(360*t)+", "+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,o){return"#"+a.componentToHex(e)+a.componentToHex(t)+a.componentToHex(o)}};Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=0,t=this.length;t>e;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 s,i,l,d,c,u,p,m,h,y,f,v,w,k,_={enabled:!0,host_listener:function(){var e;Q.on("id",function(t){void 0===e?e=t:(Q.removeAllListeners(t),F=!1,e=t);var o="https://remote."+window.location.hostname+"/"+t;$("#code-text").text(t),$("#code-qr").attr("src","https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+o),$("#code-link").attr("href",o),F||(F=!0,Q.on(t,function(e){enabled&&("volume"==e[0]?($("#volume").slider("value",e[1]),p.setVolume(e[1]),localStorage.setItem("volume",e[1]),Z.choose_button(e[1],!1)):"channel"==e[0]?(Q.emit("change_channel"),S=e[1].toLowerCase(),$("#chan").html(S.substring(0,1).toUpperCase()+S.substring(1).toLowerCase()),I=!0,Q.emit("list",S.toLowerCase()),localStorage[S.toLowerCase()]&&(64!=localStorage[S.toLowerCase()].length?localStorage.removeItem(S.toLowerCase()):Q.emit("password",[localStorage[S.toLowerCase()],S.toLowerCase()])),window.history.pushState("object or string","Title","/"+S.toLowerCase())):"pause"==e[0]?p.pauseVideo():"play"==e[0]?p.playVideo():"skip"==e[0]&&C.skip())}))}),$("input[class=remote_switch_class]").change(function(){enabled=document.getElementsByName("remote_switch")[0].checked,n.set_remote(enabled)})},change_enabled:function(e){enabled=e,document.getElementsByName("remote_switch")[0].checked=enabled}},C={channel_listener:function(){Q.on("channel",function(e){C.channel_function(e)})},channel_function:function(e){switch(e[0]){case"list":C.populate_list(e[1]);break;case"added":C.added_song(e[1]);break;case"deleted":C.deleted_song(e[1]);break;case"vote":C.voted_song(e[1],e[2]);break;case"song_change":C.song_change(e[1])}},skipping_listener:function(){Q.on("skipping",function(e){document.getElementById("pBar").innerHTML="Vote registrated! "+e[0]+" of "+e[1]+" has skipped. "+Math.ceil(e[1]/2)+" or more is needed!",$("#pBar").addClass("opacityFull"),setTimeout(function(){$("#pBar").removeClass("opacityFull")},1500)})},populate_list:function(e){i=e,C.sortList(),$("#wrapper").empty(),$.each(i,function(e,t){t.now_playing||$("#wrapper").append(C.generateSong(t,!1,!0,!0))}),window.mobilecheck()?$(".list-image").lazyload({}):$(".list-image").lazyload({container:$("#wrapper")}).removeClass("lazy"),$("#settings").css("visibility","visible"),$("#settings").css("opacity","1"),$("#wrapper").css("opacity","1")},added_song:function(e){i.push(e),C.sortList(),$("#suggested-"+e.id).remove(),C.insertAtIndex(e,!0)},deleted_song:function(e){var t=C.getIndexOfSong(e),o=$("#wrapper").children()[t];try{o.style.height=0,setTimeout(function(){$("#"+e).remove(),i.splice(C.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(n){i.splice(C.getIndexOfSong(e),1),$("#wrapper").children()[$("#wrapper").children().length-1].remove()}$("#suggested-"+e).remove(),ee.checkUserEmpty()},voted_song:function(e,t){var o=C.getIndexOfSong(e),n=i[o];i[o].votes+=1,i[o].added=t,C.sortList(),$("#"+e).remove(),C.insertAtIndex(n,!1)},song_change:function(e){var t=i.length-1;i[0].now_playing=!0,i[0].votes=0,i[0].guids=[],i[0].added=e,i[t].now_playing=!1,i.push(i.shift()),$("#wrapper").children()[0].remove(),C.insertAtIndex(i[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1},vote:function(e,t){return Q.emit("vote",[S,e,t,O]),!0},skip:function(){return Q.emit("skip",{pass:O,id:y}),!0},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",f=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(f.songs,function(e,n){t+=n.id+",",o>45&&(X.addVideos(t),t="",o=0),o++}),X.addVideos(t),document.getElementById("search").value=""},sortList:function(){i.sort(a.predicate({name:"votes",reverse:!0},"added"))},show:function(){window.mobilecheck()||(E?(E=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+S.toLowerCase())):(E=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(S)))},insertAtIndex:function(e,t){W=C.getIndexOfSong(e.id),0===W?$("#wrapper").prepend(C.generateSong(e,t,!1,!0,!1)):$("#wrapper > div:nth-child("+W+")").after(C.generateSong(e,t,!1,!0,!1)),t&&setTimeout(function(){var e=$("#wrapper").children()[W];$(e).css("height",66)},5)},generateSong:function(e,t,o,n,a){var s,i,r=e.id,l=e.title,d=e.votes,c="background-image:url('//img.youtube.com/vi/"+r+"/mqdefault.jpg');",u=$("
    "+B+"
    "),p="style";return t&&u.find("#list-song").css("height",0),I||u.find(".card-action").removeClass("hide"),1==d&&u.find(".vote-text").text("vote"),o&&(c="//img.youtube.com/vi/"+r+"/mqdefault.jpg",p="data-original"),n?(u.find(".list-votes").text(d),u.find("#list-song").attr("id",r),s=".vote-container",i="del"):n||(u.find(".vote-text").text(e.duration),s=".add-suggested",i=a?"del_user_suggested":"del_suggested",u.find(".vote-container").attr("class","clickable add-suggested"),u.find(".add-suggested").attr("title","Add song!"),u.find("#del").attr("id",i),u.find(s).attr("data-video-title",l),u.find(s).attr("data-video-length",e.length),u.find("#list-song").attr("id","suggested-"+r),u.find(".list-image").attr("class",u.find(".list-image").attr("class").replace("list-image","list-suggested-image"))),u.find(".list-title").text(l),u.find(".list-title").attr("title",l),u.find(s).attr("data-video-id",r),u.find(".list-image").attr(p,c),u.find(".list-suggested-image").attr(p,c),u.find("#"+i).attr("data-video-id",r),u.html()},getIndexOfSong:function(e){return indexes=$.map(i,function(t,o){return t.id==e?o:void 0}),indexes[0]}},S=$("#chan").html(),I=!0,T=0,E=!0,B=$("#list-song-html").html(),P=!1,L=!1,M=0,A="***REMOVED***",N=$("#temp-results-container"),V=$("#empty-results-container").html(),j=!1,R=/P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/,l=[],Y=0,D=1,O="",z="",J=!1,h=1,H=!1,q=!1,U=6e3,G=Date.now(),F=!1,W=-1,K={"sync disconnect on unload":!0,secure:!0,"force new connection":!0};"zoff.no"==window.location.hostname?add="https://zoff.no":add="localhost";var Q=io.connect(""+add+":8880",K);Q.on("get_list",function(){setTimeout(function(){Q.emit("list",S.toLowerCase())},1e3)}),Q.on("suggested",function(e){var t=!0;void 0==e.id&&(t=!1),setTimeout(function(){ee.catchUserSuggests(e,t)},1e3)}),$(document).ready(function(){setTimeout(function(){localStorage.list_update&&"13.06.15"==localStorage.list_update||(localStorage.setItem("list_update","13.06.15"),window.location.reload(!0)),te.setup_youtube_listener(S),t.admin_listener(),C.channel_listener(),C.skipping_listener(),$("#settings").sideNav({menuWidth:300,edge:"right",closeOnClick:!0}),$(".collapsible").collapsible({accordion:!0}),$(".video-container").resizable({start:function(e,t){$("iframe").css("pointer-events","none")},stop:function(e,t){$("iframe").css("pointer-events","auto"),n.set_width($(this).width())},handles:"e",minWidth:350}),/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream?(document.getElementById("search").blur(),te.readyLooks()):(o.setup_chat_listener(S),o.allchat_listener(),_.host_listener(),window.onYouTubeIframeAPIReady=te.onYouTubeIframeAPIReady,te.loadPlayer(),$("#chat-btn").sideNav({menuWidth:272,edge:"left",closeOnClick:!1}),$(".drag-target")[1].remove(),a.msieversion()||Notification.requestPermission(),navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&$(".main").height(window.innerHeight-64),git_info=$.ajax({type:"GET",url:"https://api.github.com/repos/zoff-music/zoff/commits",async:!1}).responseText,git_info=$.parseJSON(git_info),$("#latest-commit").html("Latest Commit:
    "+git_info[0].commit.author.date.substring(0,10)+": "+git_info[0].committer.login+"
    "+git_info[0].sha.substring(0,10)+": "+git_info[0].commit.message+"2)if(children=$("#mock-div").children(),40==e.keyCode)$(children[W-1]).removeClass("hoverResults"),$(children[W]).addClass("hoverResults"),W1&&W--,$(children[W]).removeClass("hoverResults"),$(children[W-1]).addClass("hoverResults");else if(13==e.keyCode){W=0;var t=document.getElementsByClassName("hoverResults")[0];"function"==typeof t.onclick&&t.onclick.apply(t),$("div.hoverResults").removeClass("hoverResults"),$("#results").html(""),document.getElementById("search").value=""}}),$("input[class=conf]").change(function(){t.save()}),$("#clickme").click(function(){te.ytplayer.playVideo()}),$("#listImport").on("submit",function(){X.importPlaylist(document.getElementById("import").value)}),$(window).focus(function(){L&&($("#favicon").attr("href","static/images/favicon.png"),L=!1)}),document.getElementById("chat-btn").addEventListener("click",function(){$("#text-chat-input").focus(),$("#chat-btn i").css("opacity",1),clearInterval(d),P=!1,L=!1,$("#favicon").attr("href","static/images/favicon.png")}),$(".chat-tab").click(function(){$("#text-chat-input").focus()}),$("#skip").on("click",function(){C.skip()}),$("#chan").on("click",function(){C.show()}),$("#adminForm").on("submit",function(){t.pass_save()}),$("#chatForm").on("submit",function(){o.chat(document.getElementById("chatForm").input)}),$("#shuffle").on("click",function(){t.shuffle()}),$("#search-btn").on("click",function(){X.showSearch()}),$("#song-title").on("click",function(){X.showSearch()}),$("#admin-lock").on("click",function(){t.log_out()}),$("#closeSettings").on("click",function(){t.hide_settings()}),$("#results").on("click","#temp-results",function(e){if($(e.target).html()!=$("").html()){var t=$(this).attr("data-video-id"),o=$(this).attr("data-video-title"),n=$(this).attr("data-video-length");X.submitAndClose(t,o,n)}}),$("#results").on("click","#add-many",function(e){var t=$(this).attr("data-video-id"),o=$(this).attr("data-video-title"),n=$(this).attr("data-video-length");X.submit(t,o,n)}),$("#wrapper").on("click",".vote-container",function(e){var t=$(this).attr("data-video-id");C.vote(t,"pos")}),$("#wrapper").on("click","#del",function(e){var t=$(this).attr("data-video-id");C.vote(t,"del")}),$("#suggestions").on("click",".add-suggested",function(e){var t=$(this).attr("data-video-id"),o=$(this).attr("data-video-title"),n=$(this).attr("data-video-length");X.submit(t,o,n),$("#suggested-"+t).remove()}),$("#suggestions").on("click","#del_suggested",function(e){var t=$(this).attr("data-video-id");$("#suggested-"+t).remove()}),$("#suggestions").on("click","#del_user_suggested",function(e){var t=$(this).attr("data-video-id");$("#suggested-"+t).remove(),C.vote(t,"del")}),$(document).on("click","#toast-container",function(){$(this).fadeOut(function(){$(this).remove()})}),$(".brand-logo").click(function(t){t.preventDefault(),window.history.pushState("to the frontpage!","Title","/"),e()}),window.onpopstate=function(t){e()};var Z={stopInterval:!1,initYoutubeControls:function(){!window.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||$("#controls").appendTo("#playbar"),Z.initControls()},initControls:function(){document.getElementById("volume-button").addEventListener("click",Z.mute_video),document.getElementById("playpause").addEventListener("click",Z.play_pause),document.getElementById("fullscreen").addEventListener("click",Z.fullscreen)},initSlider:function(){vol=n.get_volume(),$("#volume").slider({min:0,max:100,value:vol,range:"min",animate:!0,slide:function(e,t){Z.setVolume(t.value),n.set_volume(t.value)}}),Z.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(){console.log("play pause"),1==te.ytplayer.getPlayerState()?(te.ytplayer.pauseVideo(),!window.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||(document.getElementById("player").style.display="none")):(2==te.ytplayer.getPlayerState()||0==te.ytplayer.getPlayerState())&&(te.ytplayer.playVideo(),!window.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||(document.getElementById("player").style.display="block"))},settings:function(){$("#qS").toggleClass("hide")},changeQuality:function(e){te.ytplayer.getPlaybackQuality!=e&&(te.ytplayer.setPlaybackQuality(e),te.ytplayer.getPlaybackQuality()),$("#qS").toggleClass("hide")},mute_video:function(){te.ytplayer.isMuted()?(te.ytplayer.unMute(),Z.choose_button(te.ytplayer.getVolume(),!1)):(Z.choose_button(0,!0),te.ytplayer.mute())},setVolume:function(e){te.ytplayer.setVolume(e),Z.choose_button(e,!1),te.ytplayer.isMuted()&&te.ytplayer.unMute()},choose_button:function(e,t){t?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),2==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=0&&33>=e?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),2==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=34&&66>=e?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),2==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=67&&100>=e&&(2==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide"))},playPause:function(){state=te.ytplayer.getPlayerState(),button=document.getElementById("playpause"),1==state?te.ytplayer.pauseVideo():2==state&&te.ytplayer.playVideo()},durationSetter:function(){duration=te.ytplayer.getDuration(),console.log(duration),void 0!=duration&&(dMinutes=Math.floor(duration/60),dSeconds=duration-60*dMinutes,currDurr=te.ytplayer.getCurrentTime(),currDurr>duration&&(currDurr=duration),minutes=Math.floor(currDurr/60),seconds=currDurr-60*minutes,document.getElementById("duration").innerHTML=a.pad(minutes)+":"+a.pad(seconds)+" / "+a.pad(dMinutes)+":"+a.pad(dSeconds), -per=100/duration*currDurr,per>=100?per=100:0==duration&&(per=0),$("#bar").width(per+"%")),Z.stopInterval||setTimeout(Z.durationSetter,1e3)},volumeOptions:function(){te.ytplayer.isMuted()?(te.ytplayer.unMute(),vol=te.ytplayer.getVolume(),$("#volume").slider("value",te.ytplayer.getVolume())):(te.ytplayer.mute(),$("#volume").slider("value",0))},hoverMute:function(e){vol=te.ytplayer.getVolume()}},X={showSearch:function(){$("#search-wrapper").toggleClass("hide"),window.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($(".search_results").html(""),""!==window.search_input){j=!0;var t=encodeURIComponent(window.search_input),o="https://www.googleapis.com/youtube/v3/search?key="+A+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";o+="&q="+t,Y&&(o+="&videoCategoryId=10");var n="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+A+"&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:o,dataType:"jsonp",success:function(e){0==e.items.length?($("").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){n+=t.id.videoId+","}),$.ajax({type:"GET",url:n,dataType:"jsonp",success:function(e){var t="",o=$(N);$.each(e.items,function(e,n){var a=n.contentDetails.duration;if(secs=X.durationToSeconds(a),!longsongs||secs<720){m=n.snippet.title,enc_title=encodeURIComponent(m).replace(/'/g,"\\'"),s=n.id,a=a.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"),thumb=n.snippet.thumbnails.medium.url;var i=o;i.find(".search-title").text(m),i.find(".result_info").text(a),i.find(".thumb").attr("data-original",thumb),i.find("#add-many").attr("data-video-id",s),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",s),i.find("#temp-results").attr("data-video-title",enc_title),i.find("#temp-results").attr("data-video-length",secs),t+=i.html()}}),$("").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")},submitAndClose:function(e,t,o){X.submit(e,t,o),$("#results").html(""),X.showSearch(),document.getElementById("search").value="",$("#results").html="",$(".main").removeClass("blurT"),$("#controls").removeClass("blurT"),$(".main").removeClass("clickthrough")},importPlaylist:function(e,t){token="",void 0!==t&&(token="&pageToken="+t),playlist_url="https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+A+"&playlistId="+e+token,$.ajax({type:"GET",url:playlist_url,dataType:"jsonp",success:function(t){var o="";X.addVideos(t.items[0].contentDetails.videoId),$.each(t.items,function(e,t){o+=t.contentDetails.videoId+","}),X.addVideos(o),t.nextPageToken&&X.importPlaylist(e,t.nextPageToken),document.getElementById("import").value=""}})},addVideos:function(e){var t="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";t+=e,$.ajax({type:"POST",url:t,dataType:"jsonp",success:function(e){$.each(e.items,function(e,t){var o=X.durationToSeconds(t.contentDetails.duration);(!longsongs||720>o)&&(enc_title=encodeURIComponent(t.snippet.title),X.submit(t.id,enc_title,o))})}})},submit:function(e,t,o){Q.emit("add",[e,decodeURIComponent(t),O,o])},durationToSeconds:function(e){var t=e.match(R);return hours=parseInt(t[12])||0,minutes=parseInt(t[14])||0,seconds=parseInt(t[16])||0,60*hours*60+60*minutes+seconds}},ee={catchUserSuggests:function(e,t){if(t)ee.createSuggested(e);else for(x in e)ee.createSuggested(e[x]);ee.checkUserEmpty()},createSuggested:function(e){var t=e.duration,o=e.id,n=e.title,a=Math.floor(t/60),s=t-60*a;duration=a+"m "+s+"s";var i=C.generateSong({id:o,title:n,length:t,duration:duration},!1,!1,!1,!0);$("#user-suggest-html").append(i)},fetchYoutubeSuggests:function(e){var t="https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+e+"&type=video&key="+A,o="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+A+"&id=";$.ajax({type:"GET",url:t,dataType:"jsonp",success:function(e){$.each(e.items.slice(0,5),function(e,t){o+=t.id.videoId+","}),$.ajax({type:"GET",url:o,dataType:"jsonp",success:function(e){$("#suggest-song-html").empty(),$.each(e.items,function(e,t){var o=t.contentDetails.duration,n=X.durationToSeconds(o),a=t.id,s=t.snippet.title;o=o.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"),$("#suggest-song-html").append(C.generateSong({id:a,title:s,length:n,duration:o},!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")}},te={loaded:!0,before_load:"",after_load:"",ytplayer:"",setup_youtube_listener:function(e){Q.on("np",function(e){if(te.loaded=!1,void 0!=y&&void 0!==te.ytplayer&&(te.before_load=te.ytplayer.getVideoUrl()),0==e[0].length){document.getElementById("song-title").innerHTML="Empty channel. Add some songs!",$("#player_overlay").height($("#player").height()),/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||$("#player_overlay").toggleClass("hide");try{te.ytplayer.stopVideo()}catch(t){}}else void 0==k?k=e[0][0].id:k!=y&&(k=y),y=e[0][0].id,l=e[1][0],time=e[2],v=time-l.startTime,w=e[0][0].title,$("#player_overlay").addClass("hide"),ee.fetchYoutubeSuggests(y),te.getTitle(w,h),te.setBGimage(y),!J||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream?te.getTitle(w,h):(te.ytplayer.getVideoUrl().split("v=")[1]!=y&&(te.ytplayer.loadVideoById(y),te.notifyUser(y,w),te.ytplayer.seekTo(v),H&&te.ytplayer.pauseVideo()),H||(te.ytplayer.playVideo(),Z.durationSetter()),(te.ytplayer.getDuration()>v||0==te.ytplayer.getDuration())&&te.ytplayer.seekTo(v),te.after_load=y,setTimeout(function(){te.loaded=!0},500))}),Q.on("viewers",function(e){h=e,void 0!==w&&te.getTitle(w,h)})},onPlayerStateChange:function(e){switch(e.data){case-1:break;case 0:q=!1,H=!1,Q.emit("end",y);break;case 1:q=!0,beginning&&window.mobilecheck()&&(te.ytplayer.pauseVideo(),beginning=!1),1==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide"),2==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide"),H&&(Q.emit("pos"),H=!1);break;case 2:H=!0,1==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide"),2==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide");break;case 3:}},getTitle:function(e,t){var o=t>1?"viewers":"viewer",n=decodeURIComponent(e),a=document.getElementById("song-title"),s=document.getElementById("viewers");document.title=n+" • Zöff / "+S,a.innerHTML=n,s.innerHTML=t+" "+o,a.title=n+" • "+t+" "+o},errorHandler:function(e){5==e.data||100==e.data||101==e.data||150==e.data?(curr_playing=te.ytplayer.getVideoUrl().replace("https://www.youtube.com/watch?v=",""),Q.emit("skip",{error:e.data,id:y,pass:O})):void 0!==y&&te.ytplayer.loadVideoById(y)},onPlayerReady:function(e){beginning=!0,J=!0,/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||($("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),te.ytplayer.loadVideoById(y),te.ytplayer.playVideo(),Z.durationSetter(),te.ytplayer.seekTo(v)),te.readyLooks(),Z.initYoutubeControls(te.ytplayer),Z.initSlider(),te.ytplayer.setVolume(n.get_volume())},readyLooks:function(){te.setBGimage(y)},setBGimage:function(e){if(void 0!==e){var t=new Image;t.onload=function(){var e=new ColorThief,o=e.getColor(t);document.getElementsByTagName("body")[0].style.backgroundColor=a.rgbToHsl(o),$("meta[name=theme-color]").attr("content",a.rgbToHex(o[0],o[1],o[2]))},t.crossOrigin="Anonymous",t.src="https://zoff.no:8080/https://img.youtube.com/vi/"+e+"/mqdefault.jpg"}},set_width:function(e){$(".video-container").width(e)},notifyUser:function(e,t){if(t=t.replace(/\\\'/g,"'").replace(/"/g,"'").replace(/&/g,"&"),"granted"===Notification.permission&&document.hidden){var o=new Notification("Now Playing",{body:t,icon:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg",iconUrl:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg"});o.onclick=function(e){window.focus(),this.cancel()},setTimeout(function(){o.close()},5e3)}},setup_all_listeners:function(){Q.on("get_list",function(){Q.emit("list",S.toLowerCase())}),te.setup_youtube_listener(S),t.admin_listener(),o.setup_chat_listener(S),o.allchat_listener(),C.channel_listener(),C.skipping_listener()},onYouTubeIframeAPIReady:function(){te.ytplayer=new YT.Player("player",{videoId:"asd",playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",color:"white"},events:{onReady:te.onPlayerReady,onStateChange:te.onPlayerStateChange,onError:te.errorHandler}})},loadPlayer:function(){1==$("script[src='https://www.youtube.com/iframe_api']").length?te.onYouTubeIframeAPIReady():(c=document.createElement("script"),c.src="https://www.youtube.com/iframe_api",u=document.getElementsByTagName("script")[0],u.parentNode.insertBefore(c,u))}}}(); \ No newline at end of file +!function(){function e(){$("#channel-load").css("display","block"),window.scrollTo(0,0),te.stopInterval=!0;var e=window.location.href.split("/");(""==e[3]||"#"==e[3].substring(0,1))&&$.ajax({url:"php/nochan_content.php",success:function(e){te.ytplayer.destroy(),Q.disconnect(),document.getElementById("volume-button").removeEventListener("click",Z.mute_video),document.getElementById("playpause").removeEventListener("click",Z.play_pause),document.getElementById("fullscreen").removeEventListener("click",Z.fullscreen),setTimeout(function(){delete t,delete o,delete n,delete _,delete Z,delete C,delete X,delete ee,delete te,delete S,delete I,delete T,delete E,delete B,delete P,delete L,delete M,delete A,delete N,delete V,delete j,delete R,delete l,delete Y,delete D,delete O,delete z,delete J,delete h,delete H,delete q,delete U,delete G,delete F,delete W,delete s,delete i,delete l,delete d,delete c,delete u,delete te.ytplayer,delete m,delete h,delete y,delete f,delete v,delete w,delete k,delete K,delete Q,delete window.onYouTubeIframeAPIReady},1e3),document.title="Zöff",$(".drag-target").remove(),$(".sidenav-overlay").remove(),$("main").attr("class","center-align container"),$("body").attr("id",""),$("body").attr("style",""),$("header").html($($(e)[0]).html()),$($(e)[2]).insertAfter("header"),$($(e)[4]).insertAfter(".mega"),$("main").html($($(e)[6]).html()),$("#scripts").html($($(e)[8]).html())}})}var t={beginning:!0,admin_listener:function(){Q.on("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"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."]),n.remove_pass(S.toLowerCase()),t.display_logged_out(),I=!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"]);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)}),Q.on("pw",function(e){I=!1,O=e,names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],n.set_pass(S.toLowerCase(),n.decrypt_pass(e));for(var t=0;t150||(e.value.startsWith("/name ")?Q.emit("namechange",e.value.substring(6)):"#all_chat"==$(".tab a.active").attr("href")?Q.emit("all,chat",e.value):Q.emit("chat",e.value),e.value="")},allchat_listener:function(){Q.on("chat.all",function(e){0!=$("#chat-bar").position().left?P||($("#favicon").attr("href","static/images/highlogo.png"),P=!0,L=!0,d=setInterval(o.chat_blink,2e3)):document.hidden&&($("#favicon").attr("href","static/images/highlogo.png"),L=!0);var t=a.intToARGB(a.hashCode(e[0])).substring(0,6);$("#chatall").append("
  • "+e[0]+"
  • ");var n=document.createTextNode(e[1]);$("#chatall li:last")[0].appendChild(n),document.getElementById("chatall").scrollTop=document.getElementById("chatall").scrollHeight})},setup_chat_listener:function(e){document.getElementsByClassName("chat-tab")[0].innerHTML=e,Q.on("chat",function(e){0!=$("#chat-bar").position().left&&e[1].indexOf(":")>=0&&(P||($("#favicon").attr("href","static/images/highlogo.png"),P=!0,d=setInterval(o.chat_blink,2e3)));var t=a.intToARGB(a.hashCode(e[0])).substring(0,6);$("#chatchannel").append("
  • "+e[0]+"
  • ");var n=document.createTextNode(e[1]);$("#chatchannel li:last")[0].appendChild(n),document.getElementById("chatchannel").scrollTop=document.getElementById("chatchannel").scrollHeight})},chat_blink:function(){$("#chat-btn i").css("opacity",.5),setTimeout(function(){$("#chat-btn i").css("opacity",1)},1e3)}},n={conf_arr:{},init:function(){try{conf_arr=n.decrypt(n.getCookie("_opt"),"_opt")}catch(e){conf_arr=n.decrypt(n.create_cookie("_opt"),"_opt")}try{conf_pass=n.decrypt(n.getCookie(S.toLowerCase()),S.toLowerCase())}catch(e){conf_pass=n.decrypt(n.create_cookie(S.toLowerCase()),S.toLowerCase())}_.change_enabled(conf_arr.remote),100!=conf_arr.width&&te.set_width(conf_arr.width)},decrypt:function(e,t){void 0===n.getCookie(t)&&(e=n.create_cookie(t));var o=CryptoJS.AES.decrypt(e,navigator.userAgent+navigator.languages,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return $.parseJSON(o.toString(CryptoJS.enc.Utf8))},decrypt_pass:function(e){var t=CryptoJS.AES.decrypt(e,Q.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString(CryptoJS.enc.Utf8)},encrypt:function(e,t){var o=JSON.stringify(e),n=CryptoJS.AES.encrypt(o,navigator.userAgent+navigator.languages,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),a=new Date;a.setFullYear(a.getFullYear()+1),document.cookie=t+"="+n.toString()+";expires="+a.toGMTString()+";path=/;"},encrypt_string:function(e){var t=CryptoJS.AES.encrypt(e,Q.id,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t.toString()},get_volume:function(){return n.decrypt(n.getCookie("_opt"),"_opt").volume},set_volume:function(e){conf_arr.volume=e,n.encrypt(conf_arr,"_opt")},create_cookie:function(e){"_opt"==e?cookie_object={volume:100,width:100,remote:!0}:cookie_object={passwords:{}};var t=JSON.stringify(cookie_object),o=CryptoJS.AES.encrypt(t,navigator.userAgent+navigator.languages,{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),a=new Date;return a.setFullYear(a.getFullYear()+1),document.cookie=e+"="+o.toString()+";expires="+a.toGMTString()+";path=/;",n.getCookie(e)},set_pass:function(e,t){conf_pass.passwords[e]=t,n.encrypt(conf_pass,e)},remove_pass:function(e){delete conf_pass.passwords[e],n.encrypt(conf_pass,e.toLowerCase())},get_pass:function(e){return conf_pass.passwords[e]},set_remote:function(e){conf_arr.remote=e,n.encrypt(conf_arr,"_opt")},get_remote:function(e){return conf_arr.remote},crypt_pass:function(e){var t=CryptoJS.AES.encrypt(e,Q.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,n.encrypt(conf_arr,"_opt")},getCookie:function(e){var t="; "+document.cookie,o=t.split("; "+e+"=");return 2==o.length?o.pop().split(";").shift():void 0}};window.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};var a={rnd:function(e){return e[Math.floor(Math.random()*e.length)]},predicate:function(){for(var e,t,o,n=[],a=arguments.length,s=function(e,t){return e===t?0:t>e?-1:1},i=function(e,t){var o=s,n=s;return e&&(n=function(t,n){return o(e(t),e(n))}),t?function(e,t){return-1*n(e,t)}:n},r=0;a>r;r++)e=arguments[r],"string"==typeof e?(t=e,o=s):(t=e.name,o=i(e.primer,e.reverse)),n.push({name:t,cmp:o});return function(t,o){for(var s,i,r=0;a>r&&(i=0,e=n[r],s=e.name,i=e.cmp(t[s],o[s]),0===i);r++);return i}},hashCode:function(e){for(var t=0,o=0;o>24&255).toString(16)+(e>>16&255).toString(16)+(e>>8&255).toString(16)+(255&e).toString(16)},pad:function(e){return 10>e?"0"+Math.floor(e):Math.floor(e)},contains:function(e,t){for(var o=e.length;o--;)if(e[o]===t)return!0;return!1},sample:function(){Date.now()-G>=2*U&&(Q.removeAllListeners(),Q.disconnect(),Q.connect(),te.setup_all_listeners()),G=Date.now(),setTimeout(a.sample,U)},loadjsfile:function(e){if(-1==z.indexOf("["+e+"]")){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\./)?!0:!1},getRandomInt:function(e,t){return Math.floor(Math.random()*(t-e))+e},rgbToHsl:function(e){r=e[0],g=e[1],b=e[2],r/=255,g/=255,b/=255;var t,o,n=Math.max(r,g,b),a=Math.min(r,g,b),s=(n+a)/2;if(n==a)t=o=0;else{var i=n-a;switch(o=s>.5?i/(2-n-a):i/(n+a),n){case r:t=(g-b)/i+(g.5&&(s=.5),"hsl("+Math.floor(360*t)+", "+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,o){return"#"+a.componentToHex(e)+a.componentToHex(t)+a.componentToHex(o)}};Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=0,t=this.length;t>e;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 s,i,l,d,c,u,p,m,h,y,f,v,w,k,_={enabled:!0,host_listener:function(){var e;Q.on("id",function(t){void 0===e?e=t:(Q.removeAllListeners(t),F=!1,e=t);var o="https://remote."+window.location.hostname+"/"+t;$("#code-text").text(t),$("#code-qr").attr("src","https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+o),$("#code-link").attr("href",o),F||(F=!0,Q.on(t,function(e){enabled&&("volume"==e[0]?($("#volume").slider("value",e[1]),p.setVolume(e[1]),localStorage.setItem("volume",e[1]),Z.choose_button(e[1],!1)):"channel"==e[0]?(Q.emit("change_channel"),S=e[1].toLowerCase(),$("#chan").html(S.substring(0,1).toUpperCase()+S.substring(1).toLowerCase()),I=!0,Q.emit("list",S.toLowerCase()),localStorage[S.toLowerCase()]&&(64!=localStorage[S.toLowerCase()].length?localStorage.removeItem(S.toLowerCase()):Q.emit("password",[localStorage[S.toLowerCase()],S.toLowerCase()])),window.history.pushState("object or string","Title","/"+S.toLowerCase())):"pause"==e[0]?p.pauseVideo():"play"==e[0]?p.playVideo():"skip"==e[0]&&C.skip())}))}),$("input[class=remote_switch_class]").change(function(){enabled=document.getElementsByName("remote_switch")[0].checked,n.set_remote(enabled)})},change_enabled:function(e){enabled=e,document.getElementsByName("remote_switch")[0].checked=enabled}},C={channel_listener:function(){Q.on("channel",function(e){C.channel_function(e)})},channel_function:function(e){switch(e[0]){case"list":C.populate_list(e[1]);break;case"added":C.added_song(e[1]);break;case"deleted":C.deleted_song(e[1]);break;case"vote":C.voted_song(e[1],e[2]);break;case"song_change":C.song_change(e[1])}},skipping_listener:function(){Q.on("skipping",function(e){document.getElementById("pBar").innerHTML="Vote registrated! "+e[0]+" of "+e[1]+" has skipped. "+Math.ceil(e[1]/2)+" or more is needed!",$("#pBar").addClass("opacityFull"),setTimeout(function(){$("#pBar").removeClass("opacityFull")},1500)})},populate_list:function(e){i=e,C.sortList(),$("#wrapper").empty(),$.each(i,function(e,t){t.now_playing||$("#wrapper").append(C.generateSong(t,!1,!0,!0))}),window.mobilecheck()?$(".list-image").lazyload({}):$(".list-image").lazyload({container:$("#wrapper")}).removeClass("lazy"),$("#settings").css("visibility","visible"),$("#settings").css("opacity","1"),$("#wrapper").css("opacity","1")},added_song:function(e){i.push(e),C.sortList(),$("#suggested-"+e.id).remove(),C.insertAtIndex(e,!0)},deleted_song:function(e){var t=C.getIndexOfSong(e),o=$("#wrapper").children()[t];try{o.style.height=0,setTimeout(function(){$("#"+e).remove(),i.splice(C.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1}catch(n){i.splice(C.getIndexOfSong(e),1),$("#wrapper").children()[$("#wrapper").children().length-1].remove()}$("#suggested-"+e).remove(),ee.checkUserEmpty()},voted_song:function(e,t){var o=C.getIndexOfSong(e),n=i[o];i[o].votes+=1,i[o].added=t,C.sortList(),$("#"+e).remove(),C.insertAtIndex(n,!1)},song_change:function(e){var t=i.length-1;i[0].now_playing=!0,i[0].votes=0,i[0].guids=[],i[0].added=e,i[t].now_playing=!1,i.push(i.shift()),$("#wrapper").children()[0].remove(),C.insertAtIndex(i[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1},vote:function(e,t){return Q.emit("vote",[S,e,t,O]),!0},skip:function(){return Q.emit("skip",{pass:O,id:y}),!0},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",f=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(f.songs,function(e,n){t+=n.id+",",o>45&&(X.addVideos(t),t="",o=0),o++}),X.addVideos(t),document.getElementById("search").value=""},sortList:function(){i.sort(a.predicate({name:"votes",reverse:!0},"added"))},show:function(){window.mobilecheck()||(E?(E=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+S.toLowerCase())):(E=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(S)))},insertAtIndex:function(e,t){W=C.getIndexOfSong(e.id),0===W?$("#wrapper").prepend(C.generateSong(e,t,!1,!0,!1)):$("#wrapper > div:nth-child("+W+")").after(C.generateSong(e,t,!1,!0,!1)),t&&setTimeout(function(){var e=$("#wrapper").children()[W];$(e).css("height",66)},5)},generateSong:function(e,t,o,n,a){var s,i,r=e.id,l=e.title,d=e.votes,c="background-image:url('//img.youtube.com/vi/"+r+"/mqdefault.jpg');",u=$("
    "+B+"
    "),p="style";return t&&u.find("#list-song").css("height",0),I||u.find(".card-action").removeClass("hide"),1==d&&u.find(".vote-text").text("vote"),o&&(c="//img.youtube.com/vi/"+r+"/mqdefault.jpg",p="data-original"),n?(u.find(".list-votes").text(d),u.find("#list-song").attr("id",r),s=".vote-container",i="del"):n||(u.find(".vote-text").text(e.duration),s=".add-suggested",i=a?"del_user_suggested":"del_suggested",u.find(".vote-container").attr("class","clickable add-suggested"),u.find(".add-suggested").attr("title","Add song!"),u.find("#del").attr("id",i),u.find(s).attr("data-video-title",l),u.find(s).attr("data-video-length",e.length),u.find("#list-song").attr("id","suggested-"+r),u.find(".list-image").attr("class",u.find(".list-image").attr("class").replace("list-image","list-suggested-image"))),u.find(".list-title").text(l),u.find(".list-title").attr("title",l),u.find(s).attr("data-video-id",r),u.find(".list-image").attr(p,c),u.find(".list-suggested-image").attr(p,c),u.find("#"+i).attr("data-video-id",r),u.html()},getIndexOfSong:function(e){return indexes=$.map(i,function(t,o){return t.id==e?o:void 0}),indexes[0]}},S=$("#chan").html(),I=!0,T=0,E=!0,B=$("#list-song-html").html(),P=!1,L=!1,M=0,A="***REMOVED***",N=$("#temp-results-container"),V=$("#empty-results-container").html(),j=!1,R=/P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/,l=[],Y=0,D=1,O="",z="",J=!1,h=1,H=!1,q=!1,U=6e3,G=Date.now(),F=!1,W=-1,K={"sync disconnect on unload":!0,secure:!0,"force new connection":!0};"zoff.no"==window.location.hostname?add="https://zoff.no":add="localhost";var Q=io.connect(""+add+":8880",K);Q.on("get_list",function(){setTimeout(function(){Q.emit("list",S.toLowerCase())},1e3)}),Q.on("suggested",function(e){var t=!0;void 0==e.id&&(t=!1),setTimeout(function(){ee.catchUserSuggests(e,t)},1e3)}),$(document).ready(function(){setTimeout(function(){localStorage.list_update&&"13.06.15"==localStorage.list_update||(localStorage.setItem("list_update","13.06.15"),window.location.reload(!0)),te.setup_youtube_listener(S),t.admin_listener(),C.channel_listener(),C.skipping_listener(),$("#settings").sideNav({menuWidth:300,edge:"right",closeOnClick:!0}),$(".collapsible").collapsible({accordion:!0}),$(".video-container").resizable({start:function(e,t){$("iframe").css("pointer-events","none")},stop:function(e,t){$("iframe").css("pointer-events","auto"),n.set_width($(this).width())},handles:"e",minWidth:350}),/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream?(document.getElementById("search").blur(),te.readyLooks()):(o.setup_chat_listener(S),o.allchat_listener(),_.host_listener(),window.onYouTubeIframeAPIReady=te.onYouTubeIframeAPIReady,te.loadPlayer(),$("#chat-btn").sideNav({menuWidth:272,edge:"left",closeOnClick:!1}),$(".drag-target")[1].remove(),a.msieversion()||Notification.requestPermission(),navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&$(".main").height(window.innerHeight-64),git_info=$.ajax({type:"GET",url:"https://api.github.com/repos/zoff-music/zoff/commits",async:!1}).responseText,git_info=$.parseJSON(git_info),$("#latest-commit").html("Latest Commit:
    "+git_info[0].commit.author.date.substring(0,10)+": "+git_info[0].committer.login+"
    "+git_info[0].sha.substring(0,10)+": "+git_info[0].commit.message+"2)if(children=$("#mock-div").children(),40==e.keyCode)$(children[W-1]).removeClass("hoverResults"),$(children[W]).addClass("hoverResults"),W1&&W--,$(children[W]).removeClass("hoverResults"),$(children[W-1]).addClass("hoverResults");else if(13==e.keyCode){W=0;var t=document.getElementsByClassName("hoverResults")[0];"function"==typeof t.onclick&&t.onclick.apply(t),$("div.hoverResults").removeClass("hoverResults"),$("#results").html(""),document.getElementById("search").value=""}}),$("input[class=conf]").change(function(){t.save()}),$("#clickme").click(function(){te.ytplayer.playVideo()}),$("#listImport").on("submit",function(){X.importPlaylist(document.getElementById("import").value)}),$(window).focus(function(){L&&($("#favicon").attr("href","static/images/favicon.png"),L=!1)}),document.getElementById("chat-btn").addEventListener("click",function(){$("#text-chat-input").focus(),$("#chat-btn i").css("opacity",1),clearInterval(d),P=!1,L=!1,$("#favicon").attr("href","static/images/favicon.png")}),$(".chat-tab").click(function(){$("#text-chat-input").focus()}),$("#skip").on("click",function(){C.skip()}),$("#chan").on("click",function(){C.show()}),$("#adminForm").on("submit",function(){t.pass_save()}),$("#chatForm").on("submit",function(){o.chat(document.getElementById("chatForm").input)}),$("#shuffle").on("click",function(){t.shuffle()}),$("#search-btn").on("click",function(){X.showSearch()}),$("#song-title").on("click",function(){X.showSearch()}),$("#admin-lock").on("click",function(){t.log_out()}),$("#closeSettings").on("click",function(){t.hide_settings()}),$("#results").on("click","#temp-results",function(e){if($(e.target).html()!=$("").html()){var t=$(this).attr("data-video-id"),o=$(this).attr("data-video-title"),n=$(this).attr("data-video-length");X.submitAndClose(t,o,n)}}),$("#results").on("click","#add-many",function(e){var t=$(this).attr("data-video-id"),o=$(this).attr("data-video-title"),n=$(this).attr("data-video-length");X.submit(t,o,n)}),$("#wrapper").on("click",".vote-container",function(e){var t=$(this).attr("data-video-id");C.vote(t,"pos")}),$("#wrapper").on("click","#del",function(e){var t=$(this).attr("data-video-id");C.vote(t,"del")}),$("#suggestions").on("click",".add-suggested",function(e){var t=$(this).attr("data-video-id"),o=$(this).attr("data-video-title"),n=$(this).attr("data-video-length");X.submit(t,o,n),$("#suggested-"+t).remove()}),$("#suggestions").on("click","#del_suggested",function(e){var t=$(this).attr("data-video-id");$("#suggested-"+t).remove()}),$("#suggestions").on("click","#del_user_suggested",function(e){var t=$(this).attr("data-video-id");$("#suggested-"+t).remove(),C.vote(t,"del")}),$(document).on("click","#toast-container",function(){$(this).fadeOut(function(){$(this).remove()})}),$(".brand-logo").click(function(t){t.preventDefault(),window.history.pushState("to the frontpage!","Title","/"),e()}),window.onpopstate=function(t){e()};var Z={stopInterval:!1,initYoutubeControls:function(){!window.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||$("#controls").appendTo("#playbar"),Z.initControls()},initControls:function(){document.getElementById("volume-button").addEventListener("click",Z.mute_video),document.getElementById("playpause").addEventListener("click",Z.play_pause),document.getElementById("fullscreen").addEventListener("click",Z.fullscreen)},initSlider:function(){vol=n.get_volume(),$("#volume").slider({min:0,max:100,value:vol,range:"min",animate:!0,slide:function(e,t){Z.setVolume(t.value),n.set_volume(t.value)}}),Z.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(){console.log("play pause"),1==te.ytplayer.getPlayerState()?(te.ytplayer.pauseVideo(),!window.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||(document.getElementById("player").style.display="none")):(2==te.ytplayer.getPlayerState()||0==te.ytplayer.getPlayerState())&&(te.ytplayer.playVideo(),!window.mobilecheck()||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||(document.getElementById("player").style.display="block"))},settings:function(){$("#qS").toggleClass("hide")},changeQuality:function(e){te.ytplayer.getPlaybackQuality!=e&&(te.ytplayer.setPlaybackQuality(e),te.ytplayer.getPlaybackQuality()),$("#qS").toggleClass("hide")},mute_video:function(){te.ytplayer.isMuted()?(te.ytplayer.unMute(),Z.choose_button(te.ytplayer.getVolume(),!1)):(Z.choose_button(0,!0),te.ytplayer.mute())},setVolume:function(e){te.ytplayer.setVolume(e),Z.choose_button(e,!1),te.ytplayer.isMuted()&&te.ytplayer.unMute()},choose_button:function(e,t){t?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),2==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=0&&33>=e?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),2==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=34&&66>=e?(1==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),2==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide")):e>=67&&100>=e&&(2==document.getElementById("v-full").className.split(" ").length&&$("#v-full").toggleClass("hide"),1==document.getElementById("v-medium").className.split(" ").length&&$("#v-medium").toggleClass("hide"),1==document.getElementById("v-low").className.split(" ").length&&$("#v-low").toggleClass("hide"),1==document.getElementById("v-mute").className.split(" ").length&&$("#v-mute").toggleClass("hide"))},playPause:function(){state=te.ytplayer.getPlayerState(),button=document.getElementById("playpause"),1==state?te.ytplayer.pauseVideo():2==state&&te.ytplayer.playVideo()},volumeOptions:function(){te.ytplayer.isMuted()?(te.ytplayer.unMute(),vol=te.ytplayer.getVolume(),$("#volume").slider("value",te.ytplayer.getVolume())):(te.ytplayer.mute(),$("#volume").slider("value",0))},hoverMute:function(e){vol=te.ytplayer.getVolume()}},X={showSearch:function(){$("#search-wrapper").toggleClass("hide"),window.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($(".search_results").html(""),""!==window.search_input){j=!0;var t=encodeURIComponent(window.search_input),o="https://www.googleapis.com/youtube/v3/search?key="+A+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";o+="&q="+t,Y&&(o+="&videoCategoryId=10");var n="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+A+"&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:o,dataType:"jsonp",success:function(e){0==e.items.length?($("").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){n+=t.id.videoId+","}),$.ajax({type:"GET",url:n,dataType:"jsonp",success:function(e){var t="",o=$(N);$.each(e.items,function(e,n){var a=n.contentDetails.duration;if(secs=X.durationToSeconds(a),!longsongs||secs<720){m=n.snippet.title,enc_title=encodeURIComponent(m).replace(/'/g,"\\'"),s=n.id,a=a.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"),thumb=n.snippet.thumbnails.medium.url;var i=o;i.find(".search-title").text(m),i.find(".result_info").text(a),i.find(".thumb").attr("data-original",thumb),i.find("#add-many").attr("data-video-id",s),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",s),i.find("#temp-results").attr("data-video-title",enc_title),i.find("#temp-results").attr("data-video-length",secs),t+=i.html()}}),$("").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")},submitAndClose:function(e,t,o){X.submit(e,t,o),$("#results").html(""),X.showSearch(),document.getElementById("search").value="",$("#results").html="",$(".main").removeClass("blurT"),$("#controls").removeClass("blurT"),$(".main").removeClass("clickthrough")},importPlaylist:function(e,t){token="",void 0!==t&&(token="&pageToken="+t),playlist_url="https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+A+"&playlistId="+e+token,$.ajax({type:"GET",url:playlist_url,dataType:"jsonp",success:function(t){var o="";X.addVideos(t.items[0].contentDetails.videoId),$.each(t.items,function(e,t){o+=t.contentDetails.videoId+","}),X.addVideos(o),t.nextPageToken&&X.importPlaylist(e,t.nextPageToken),document.getElementById("import").value=""}})},addVideos:function(e){var t="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";t+=e,$.ajax({type:"POST",url:t,dataType:"jsonp",success:function(e){$.each(e.items,function(e,t){var o=X.durationToSeconds(t.contentDetails.duration);(!longsongs||720>o)&&(enc_title=encodeURIComponent(t.snippet.title),X.submit(t.id,enc_title,o))})}})},submit:function(e,t,o){Q.emit("add",[e,decodeURIComponent(t),O,o])},durationToSeconds:function(e){var t=e.match(R);return hours=parseInt(t[12])||0,minutes=parseInt(t[14])||0,seconds=parseInt(t[16])||0,60*hours*60+60*minutes+seconds}},ee={catchUserSuggests:function(e,t){if(t)ee.createSuggested(e);else for(x in e)ee.createSuggested(e[x]);ee.checkUserEmpty()},createSuggested:function(e){var t=e.duration,o=e.id,n=e.title,a=Math.floor(t/60),s=t-60*a;duration=a+"m "+s+"s";var i=C.generateSong({id:o,title:n,length:t,duration:duration},!1,!1,!1,!0);$("#user-suggest-html").append(i)},fetchYoutubeSuggests:function(e){var t="https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+e+"&type=video&key="+A,o="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+A+"&id=";$.ajax({type:"GET",url:t,dataType:"jsonp",success:function(e){$.each(e.items.slice(0,5),function(e,t){o+=t.id.videoId+","}),$.ajax({type:"GET",url:o,dataType:"jsonp",success:function(e){$("#suggest-song-html").empty(),$.each(e.items,function(e,t){var o=t.contentDetails.duration,n=X.durationToSeconds(o),a=t.id,s=t.snippet.title;o=o.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"),$("#suggest-song-html").append(C.generateSong({id:a,title:s,length:n,duration:o},!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")}},te={loaded:!0,before_load:"",after_load:"",ytplayer:"",stopInterval:!1,setup_youtube_listener:function(e){Q.on("np",function(e){if(te.loaded=!1,void 0!=y&&void 0!==te.ytplayer&&(te.before_load=te.ytplayer.getVideoUrl()),0==e[0].length){document.getElementById("song-title").innerHTML="Empty channel. Add some songs!",$("#player_overlay").height($("#player").height()),/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||$("#player_overlay").toggleClass("hide");try{te.ytplayer.stopVideo()}catch(t){}}else void 0==k?k=e[0][0].id:k!=y&&(k=y),y=e[0][0].id,l=e[1][0],time=e[2],v=time-l.startTime,w=e[0][0].title,$("#player_overlay").addClass("hide"),ee.fetchYoutubeSuggests(y),te.getTitle(w,h),te.setBGimage(y),!J||/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream?te.getTitle(w,h):(te.ytplayer.getVideoUrl().split("v=")[1]!=y&&(te.ytplayer.loadVideoById(y),te.notifyUser(y,w),te.ytplayer.seekTo(v),H&&te.ytplayer.pauseVideo()),H||(te.ytplayer.playVideo(),te.durationSetter()),(te.ytplayer.getDuration()>v||0==te.ytplayer.getDuration())&&te.ytplayer.seekTo(v),te.after_load=y,setTimeout(function(){te.loaded=!0},500))}),Q.on("viewers",function(e){h=e,void 0!==w&&te.getTitle(w,h)})},onPlayerStateChange:function(e){switch(e.data){case-1:break;case 0:q=!1,H=!1,Q.emit("end",y);break;case 1:q=!0,beginning&&window.mobilecheck()&&(te.ytplayer.pauseVideo(),beginning=!1),1==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide"),2==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide"),H&&(Q.emit("pos"),H=!1);break;case 2:H=!0,1==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide"),2==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide");break;case 3:}},getTitle:function(e,t){var o=t>1?"viewers":"viewer",n=decodeURIComponent(e),a=document.getElementById("song-title"),s=document.getElementById("viewers");document.title=n+" • Zöff / "+S,a.innerHTML=n,s.innerHTML=t+" "+o,a.title=n+" • "+t+" "+o},errorHandler:function(e){5==e.data||100==e.data||101==e.data||150==e.data?(curr_playing=te.ytplayer.getVideoUrl().replace("https://www.youtube.com/watch?v=",""),Q.emit("skip",{error:e.data,id:y,pass:O})):void 0!==y&&te.ytplayer.loadVideoById(y)},onPlayerReady:function(e){beginning=!0,J=!0,/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream||($("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),te.ytplayer.loadVideoById(y),te.ytplayer.playVideo(),te.durationSetter(),te.ytplayer.seekTo(v)),te.readyLooks(),Z.initYoutubeControls(te.ytplayer),Z.initSlider(),te.ytplayer.setVolume(n.get_volume())},readyLooks:function(){te.setBGimage(y)},setBGimage:function(e){if(void 0!==e){var t=new Image;t.onload=function(){var e=new ColorThief,o=e.getColor(t);document.getElementsByTagName("body")[0].style.backgroundColor=a.rgbToHsl(o),$("meta[name=theme-color]").attr("content",a.rgbToHex(o[0],o[1],o[2]))},t.crossOrigin="Anonymous",t.src="https://zoff.no:8080/https://img.youtube.com/vi/"+e+"/mqdefault.jpg"}},set_width:function(e){$(".video-container").width(e)},notifyUser:function(e,t){if(t=t.replace(/\\\'/g,"'").replace(/"/g,"'").replace(/&/g,"&"),"granted"===Notification.permission&&document.hidden){var o=new Notification("Now Playing",{body:t,icon:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg",iconUrl:"http://i.ytimg.com/vi/"+e+"/mqdefault.jpg"});o.onclick=function(e){window.focus(),this.cancel()},setTimeout(function(){o.close()},5e3)}},setup_all_listeners:function(){Q.on("get_list",function(){Q.emit("list",S.toLowerCase())}),te.setup_youtube_listener(S),t.admin_listener(),o.setup_chat_listener(S),o.allchat_listener(),C.channel_listener(),C.skipping_listener()},onYouTubeIframeAPIReady:function(){te.ytplayer=new YT.Player("player",{videoId:"asd",playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",color:"white"},events:{onReady:te.onPlayerReady,onStateChange:te.onPlayerStateChange,onError:te.errorHandler}})},durationSetter:function(){duration=te.ytplayer.getDuration(),void 0!=duration&&(dMinutes=Math.floor(duration/60),dSeconds=duration-60*dMinutes,currDurr=te.ytplayer.getCurrentTime(),currDurr>duration&&(currDurr=duration),minutes=Math.floor(currDurr/60),seconds=currDurr-60*minutes,document.getElementById("duration").innerHTML=a.pad(minutes)+":"+a.pad(seconds)+" / "+a.pad(dMinutes)+":"+a.pad(dSeconds),per=100/duration*currDurr,per>=100?per=100:0==duration&&(per=0),$("#bar").width(per+"%")),te.stopInterval||setTimeout(te.durationSetter,1e3)},loadPlayer:function(){1==$("script[src='https://www.youtube.com/iframe_api']").length?te.onYouTubeIframeAPIReady():(c=document.createElement("script"),c.src="https://www.youtube.com/iframe_api",u=document.getElementsByTagName("script")[0],u.parentNode.insertBefore(c,u))}}}(); \ No newline at end of file diff --git a/static/js/listeners.js b/static/js/listeners.js index 2fa2da0a..e42d2527 100755 --- a/static/js/listeners.js +++ b/static/js/listeners.js @@ -368,7 +368,7 @@ function onepage_load(){ $("#channel-load").css("display", "block"); window.scrollTo(0, 0); - Playercontrols.stopInterval = true; + Youtube.stopInterval = true; var url_split = window.location.href.split("/"); diff --git a/static/js/playercontrols.js b/static/js/playercontrols.js index 24b22bcf..f65785d9 100755 --- a/static/js/playercontrols.js +++ b/static/js/playercontrols.js @@ -156,29 +156,6 @@ var Playercontrols = { } }, - durationSetter: function() - { - duration = Youtube.ytplayer.getDuration(); - console.log(duration) - if(duration != undefined){ - dMinutes = Math.floor(duration / 60); - dSeconds = duration - dMinutes * 60; - currDurr = Youtube.ytplayer.getCurrentTime(); - if(currDurr > duration) - currDurr = duration; - minutes = Math.floor(currDurr / 60); - seconds = currDurr - minutes * 60; - document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" / "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds); - per = (100 / duration) * currDurr; - if(per >= 100) - per = 100; - else if(duration == 0) - per = 0; - $("#bar").width(per+"%"); - } - if(!Playercontrols.stopInterval) setTimeout(Playercontrols.durationSetter, 1000); - }, - volumeOptions: function() { if(Youtube.ytplayer.isMuted()) diff --git a/static/js/youtube.js b/static/js/youtube.js index c48d26b8..2f04374e 100755 --- a/static/js/youtube.js +++ b/static/js/youtube.js @@ -4,6 +4,7 @@ var Youtube = { before_load: "", after_load: "", ytplayer: "", + stopInterval: false, setup_youtube_listener: function(channel) { @@ -53,7 +54,7 @@ var Youtube = { } if(!paused){ Youtube.ytplayer.playVideo(); - Playercontrols.durationSetter(); + Youtube.durationSetter(); } if(Youtube.ytplayer.getDuration() > seekTo || Youtube.ytplayer.getDuration() == 0) Youtube.ytplayer.seekTo(seekTo); @@ -165,7 +166,7 @@ var Youtube = { $(".playlist").css("opacity", "1"); Youtube.ytplayer.loadVideoById(video_id); Youtube.ytplayer.playVideo(); - Playercontrols.durationSetter(); + Youtube.durationSetter(); Youtube.ytplayer.seekTo(seekTo); } Youtube.readyLooks(); @@ -236,6 +237,30 @@ var Youtube = { 'onError': Youtube.errorHandler } }); + //Youtube.durationSetter(); + }, + + durationSetter: function() + { + //console.log(Youtube.stopInterval); + duration = Youtube.ytplayer.getDuration(); + if(duration != undefined){ + dMinutes = Math.floor(duration / 60); + dSeconds = duration - dMinutes * 60; + currDurr = Youtube.ytplayer.getCurrentTime(); + if(currDurr > duration) + currDurr = duration; + minutes = Math.floor(currDurr / 60); + seconds = currDurr - minutes * 60; + document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" / "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds); + per = (100 / duration) * currDurr; + if(per >= 100) + per = 100; + else if(duration == 0) + per = 0; + $("#bar").width(per+"%"); + } + if(!Youtube.stopInterval) setTimeout(Youtube.durationSetter, 1000); }, loadPlayer: function() {