From 30b6c2b888b72ab8f8b6d703e49516353206c7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 13 Nov 2015 16:30:02 +0100 Subject: [PATCH 01/27] Added function for pinning playlists during festivities --- php/nochan.php | 1 + server/server.js | 9 +++++++-- static/css/style.css | 6 ++++++ static/dist/frontpage.min.js | 2 +- static/dist/main.min.js | 2 +- static/images/pin.png | Bin 0 -> 299 bytes static/js/nochan.js | 19 ++++++++++++++++++- 7 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 static/images/pin.png diff --git a/php/nochan.php b/php/nochan.php index 62c8c5ee..4e75e054 100755 --- a/php/nochan.php +++ b/php/nochan.php @@ -106,6 +106,7 @@ if(isset($_GET['chan'])){
+


diff --git a/server/server.js b/server/server.js index 54e806d4..2640dee5 100755 --- a/server/server.js +++ b/server/server.js @@ -138,11 +138,16 @@ io.on('connection', function(socket){ { var id = list[0]["id"]; var title = list[0]["title"]; + var pinned = 0; + if(conf[0].pinned == 1) pinned = 1; try{ var viewers = lists[name].length; }catch(err){var viewers = 0;} - var to_push = [viewers, id, title, name, count]; - if(conf[0]["frontpage"]) + var to_push = [viewers, id, title, name, count, pinned]; + if(conf[0].pinned == 1) + { + playlists_to_send.unshift(to_push); + }else if(conf[0]["frontpage"]) playlists_to_send.push(to_push); } if(curr == tot) diff --git a/static/css/style.css b/static/css/style.css index 60325a9e..2ba7342c 100755 --- a/static/css/style.css +++ b/static/css/style.css @@ -78,6 +78,12 @@ input[type=text]:focus:not([readonly]) + label, input[type=password]:focus:not([ color: #2D2D2D; } +.pin { + position:absolute; + right:10px; + font-size:25px; +} + .field-settings{ margin-left: 25px !important; color: rgb(68,68,68); diff --git a/static/dist/frontpage.min.js b/static/dist/frontpage.min.js index 0df1ffb5..d2af8345 100755 --- a/static/dist/frontpage.min.js +++ b/static/dist/frontpage.min.js @@ -1 +1 @@ -!function(){var e,t,o={populate_channels:function(t){var n="",a=0;t.sort(o.sortFunction),pre_card=$(e);for(x in t){var i=t[x][3];if(20>a){var s=t[x][1],l=t[x][0],r="background-image:url('https://img.youtube.com/vi/"+s+"/hqdefault.jpg');",c=t[x][4],d=pre_card;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())}n+="
"+t[0].sha.substring(0,10)+": "+t[0].commit.message+"s){var l=t[x][1],r=t[x][0],c="background-image:url('https://img.youtube.com/vi/"+l+"/hqdefault.jpg');",d=t[x][4],u=pre_card;1==t[x][5]?(u.find(".pin").attr("style","display:block;"),u.find(".card").attr("title","Pinned!")):(u.find(".pin").attr("style","display:none;"),u.find(".card").attr("title","")),u.find(".chan-name").text(i),u.find(".chan-name").attr("title",i),u.find(".chan-views").text(r),u.find(".chan-songs").text(d),u.find(".chan-bg").attr("style",c),u.find(".chan-link").attr("href",i),$("#channels").append(u.html())}a+="

  • "+e[0]+"
  • ");var a=document.createTextNode(e[1]);$("#chatall li:last")[0].appendChild(a),document.getElementById("chatall").scrollTop=document.getElementById("chatall").scrollHeight})},setup_chat_listener:function(e){document.getElementsByClassName("chat-tab")[0].innerHTML=e,F.on("chat",function(e){0!=$("#chat-bar").position().left&&e[1].indexOf(":")>=0&&(S||($("#favicon").attr("href","static/images/highlogo.png"),S=!0,s=setInterval(t.chat_blink,2e3)));var n=o.intToARGB(o.hashCode(e[0])).substring(0,6);$("#chatchannel").append("
  • "+e[0]+"
  • ");var a=document.createTextNode(e[1]);$("#chatchannel li:last")[0].appendChild(a),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)}};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 o={rnd:function(e){return e[Math.floor(Math.random()*e.length)]},predicate:function(){for(var e,t,o,n=[],a=arguments.length,i=function(e,t){return e===t?0:t>e?-1:1},s=function(e,t){var o=i,n=i;return e&&(n=function(t,n){return o(e(t),e(n))}),t?function(e,t){return-1*n(e,t)}:n},l=0;a>l;l++)e=arguments[l],"string"==typeof e?(t=e,o=i):(t=e.name,o=s(e.primer,e.reverse)),n.push({name:t,cmp:o});return function(t,o){for(var i,s,l=0;a>l&&(s=0,e=n[l],i=e.name,s=e.cmp(t[i],o[i]),0===s);l++);return s}},hashCode:function(e){for(var t=0,o=0;o>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()-q>=2*D&&(F.removeAllListeners(),F.disconnect(),F.connect(),Z.setup_all_listeners()),q=Date.now(),setTimeout(o.sample,D)},loadjsfile:function(e){if(-1==j.indexOf("["+e+"]")){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(t),j+="["+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),i=(n+a)/2;if(n==a)t=o=0;else{var s=n-a;switch(o=i>.5?s/(2-n-a):s/(n+a),n){case r:t=(g-b)/s+(g.5&&(i=.5),"hsl("+Math.floor(360*t)+", "+Math.floor(100*o)+"%, "+Math.floor(100*i)+"%)"},componentToHex:function(e){var t=e.toString(16);return 1==t.length?"0"+t:t},rgbToHex:function(e,t,n){return"#"+o.componentToHex(e)+o.componentToHex(t)+o.componentToHex(n)}};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])};var n,a,i,s,l,c,d,u,m,p,h,f,v,y={host_listener:function(){var e;F.on("id",function(t){void 0===e?e=t:(F.removeAllListeners(t),Y=!1,e=t);var o="http://"+window.location.hostname+"/remote/"+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),Y||(Y=!0,F.on(t,function(e){"volume"==e[0]?($("#volume").slider("value",e[1]),d.setVolume(e[1]),localStorage.setItem("volume",e[1]),W.choose_button(e[1],!1)):"channel"==e[0]?(F.emit("change_channel"),k=e[1].toLowerCase(),$("#chan").html(k.substring(0,1).toUpperCase()+k.substring(1).toLowerCase()),C=!0,F.emit("list",k.toLowerCase()),localStorage[k.toLowerCase()]&&(64!=localStorage[k.toLowerCase()].length?localStorage.removeItem(k.toLowerCase()):F.emit("password",[localStorage[k.toLowerCase()],k.toLowerCase()])),window.history.pushState("object or string","Title","/"+k.toLowerCase())):"pause"==e[0]?d.pauseVideo():"play"==e[0]?d.playVideo():"skip"==e[0]&&w.skip()}))})}},w={channel_listener:function(){F.on("channel",function(e){w.channel_function(e)})},channel_function:function(e){switch(e[0]){case"list":w.populate_list(e[1]);break;case"added":w.added_song(e[1]);break;case"deleted":w.deleted_song(e[1]);break;case"vote":w.voted_song(e[1],e[2]);break;case"song_change":w.song_change(e[1])}},skipping_listener:function(){F.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){a=e,w.sortList(),$("#wrapper").empty(),$.each(a,function(e,t){t.now_playing||$("#wrapper").append(w.generateSong(t,!1,!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){a.push(e),w.sortList(),w.insertAtIndex(e,!0)},deleted_song:function(e){var t=w.getIndexOfSong(e),o=$("#wrapper").children()[t];o.style.height=0,setTimeout(function(){$("#"+e).remove(),a.splice(w.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1},voted_song:function(e,t){var o=w.getIndexOfSong(e),n=a[o];a[o].votes+=1,a[o].added=t,w.sortList(),$("#"+e).remove(),w.insertAtIndex(n,!1)},song_change:function(e){var t=a.length-1;a[0].now_playing=!0,a[0].votes=0,a[0].guids=[],a[0].added=e,a[t].now_playing=!1,a.push(a.shift()),$("#wrapper").children()[0].remove(),w.insertAtIndex(a[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1},vote:function(e,t){return F.emit("vote",[k,e,t,V]),!0},skip:function(){return F.emit("skip",[k,localStorage[k.toLowerCase()]]),!0},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",h=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(h.songs,function(e,n){t+=n.id+",",o>45&&(J.addVideos(t),t="",o=0),o++}),J.addVideos(t),document.getElementById("search").value=""},sortList:function(){a.sort(o.predicate({name:"votes",reverse:!0},"added"))},show:function(){window.mobilecheck()||(_?(_=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+k.toLowerCase())):(_=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(k)))},insertAtIndex:function(e,t){G=w.getIndexOfSong(e.id),0===G?$("#wrapper").prepend(w.generateSong(e,t)):$("#wrapper > div:nth-child("+G+")").after(w.generateSong(e,t)),t&&setTimeout(function(){var e=$("#wrapper").children()[G];$(e).css("height",66)},5)},generateSong:function(e,t,o){var n=e.id,a=e.title,i=e.votes,s="background-image:url('//img.youtube.com/vi/"+n+"/mqdefault.jpg');",l=$("
    "+T+"
    "),r="style";return t&&l.find("#list-song").css("height",0),C||l.find(".card-action").removeClass("hide"),1==i&&l.find(".vote-text").text("vote"),o&&(s="//img.youtube.com/vi/"+n+"/mqdefault.jpg",r="data-original"),l.find(".list-title").text(a),l.find(".list-title").attr("title",a),l.find(".list-votes").text(i),l.find(".vote-container").attr("onclick","vote('"+n+"','pos')"),l.find(".list-image").attr(r,s),l.find("#list-song").attr("id",n),l.find("#del").attr("onclick","vote('"+n+"', 'del')"),l.html()},getIndexOfSong:function(e){return indexes=$.map(a,function(t,o){return t.id==e?o:void 0}),indexes[0]}},k=$("#chan").html(),C=!0,I=0,_=!0,T=$("#list-song-html").html(),S=!1,E=!1,x=0,B="***REMOVED***",L=$("#temp-results-container"),M=$("#empty-results-container").html(),N=!1,A=/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)?)?/,i=[],R=0,z=1,V="",j="",P=!1,m=1,H=!1,O=!1,D=6e3,q=Date.now(),Y=!1,G=-1,U={"sync disconnect on unload":!0},F=io.connect("http://"+window.location.hostname+":8880",U);F.on("get_list",function(){F.emit("list",k.toLowerCase())}),$(document).ready(function(){window.vote=w.vote,window.submit=J.submit,window.submitAndClose=J.submitAndClose,localStorage.list_update&&"13.06.15"==localStorage.list_update||(localStorage.setItem("list_update","13.06.15"),window.location.reload(!0)),Z.setup_youtube_listener(k),e.admin_listener(),w.channel_listener(),w.skipping_listener(),$("#settings").sideNav({menuWidth:300,edge:"right",closeOnClick:!1}),$(".video-container").resizable({handles:"e",minWidth:350}),localStorage[k.toLowerCase()]&&(64!=localStorage[k.toLowerCase()].length?localStorage.removeItem(k.toLowerCase()):F.emit("password",[localStorage[k.toLowerCase()],k.toLowerCase()])),window.mobilecheck()?(document.getElementById("search").blur(),Z.readyLooks()):(t.setup_chat_listener(k),t.allchat_listener(),y.host_listener(),Z.loadPlayer(),window.onYouTubeIframeAPIReady=Z.onYouTubeIframeAPIReady,$("#chat-btn").sideNav({menuWidth:272,edge:"left",closeOnClick:!1}),$(".drag-target")[1].remove(),o.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[G-1]).removeClass("hoverResults"),$(children[G]).addClass("hoverResults"),G1&&G--,$(children[G]).removeClass("hoverResults"),$(children[G-1]).addClass("hoverResults");else if(13==e.keyCode){G=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(){e.save()}),$("#listImport").on("submit",function(){J.importPlaylist(document.getElementById("import").value)}),$(window).focus(function(){E&&($("#favicon").attr("href","static/images/favicon.png"),E=!1)}),document.getElementById("chat-btn").addEventListener("click",function(){$("#text-chat-input").focus(),$("#chat-btn i").css("opacity",1),clearInterval(s),S=!1,E=!1,$("#favicon").attr("href","static/images/favicon.png")}),$(".chat-tab").click(function(){$("#text-chat-input").focus()}),$("#skip").on("click",function(){w.skip()}),$("#chan").on("click",function(){w.show()}),$("#adminForm").on("submit",function(){e.pass_save()}),$("#chatForm").on("submit",function(){t.chat(document.getElementById("chatForm").input)}),$("#shuffle").on("click",function(){e.shuffle()}),$("#search-btn").on("click",function(){J.showSearch()}),$("#song-title").on("click",function(){J.showSearch()}),$("#admin-lock").on("click",function(){e.log_out()}),$("#closeSettings").on("click",function(){e.hide_settings()});var W={initYoutubeControls:function(e){setInterval(W.durationSetter,1e3),W.initControls()},initControls:function(){document.getElementById("volume-button").addEventListener("click",W.mute_video),document.getElementById("playpause").addEventListener("click",W.play_pause),document.getElementById("fullscreen").addEventListener("click",W.fullscreen)},initSlider:function(){localStorage.volume?vol=localStorage.getItem("volume"):(vol=100,localStorage.setItem("volume",vol)),$("#volume").slider({min:0,max:100,value:vol,range:"min",animate:!0,slide:function(e,t){W.setVolume(t.value),localStorage.setItem("volume",t.value)}}),W.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==d.getPlayerState()?d.pauseVideo():(2==d.getPlayerState()||0==d.getPlayerState())&&d.playVideo()},settings:function(){$("#qS").toggleClass("hide")},changeQuality:function(e){d.getPlaybackQuality!=e&&(d.setPlaybackQuality(e),d.getPlaybackQuality()),$("#qS").toggleClass("hide")},mute_video:function(){d.isMuted()?(d.unMute(),W.choose_button(d.getVolume(),!1)):(W.choose_button(0,!0),d.mute())},setVolume:function(e){d.setVolume(e),W.choose_button(e,!1),d.isMuted()&&d.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=d.getPlayerState(),button=document.getElementById("playpause"),1==state?d.pauseVideo():2==state&&d.playVideo()},durationSetter:function(){duration=d.getDuration(),dMinutes=Math.floor(duration/60),dSeconds=duration-60*dMinutes,currDurr=d.getCurrentTime(),currDurr>duration&&(currDurr=duration),minutes=Math.floor(currDurr/60),seconds=currDurr-60*minutes,document.getElementById("duration").innerHTML=o.pad(minutes)+":"+o.pad(seconds)+" / "+o.pad(dMinutes)+":"+o.pad(dSeconds),per=100/duration*currDurr,per>=100?per=100:0==duration&&(per=0),$("#bar").width(per+"%")},volumeOptions:function(){d.isMuted()?(d.unMute(),vol=d.getVolume(),$("#volume").slider("value",d.getVolume())):(d.mute(),$("#volume").slider("value",0))},hoverMute:function(e){vol=d.getVolume()}},J={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){N=!0;var t=encodeURIComponent(window.search_input),a="https://www.googleapis.com/youtube/v3/search?key="+B+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";a+="&q="+t,R&&(a+="&videoCategoryId=10");var i="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+B+"&id=";o.contains($("#search_loader").attr("class").split(" "),"hide")&&$("#search_loader").removeClass("hide"),o.contains($("#results").attr("class").split(" "),"hide")&&$("#results").removeClass("hide"),$.ajax({type:"GET",url:a,dataType:"jsonp",success:function(e){0==e.items.length?($("").appendTo($("#results")).show("blind",83.33),o.contains($("#search_loader").attr("class").split(" "),"hide")||$("#search_loader").addClass("hide")):e.items&&($.each(e.items,function(e,t){i+=t.id.videoId+","}),$.ajax({type:"GET",url:i,dataType:"jsonp",success:function(e){var t="",a=$(L);$.each(e.items,function(e,o){var i=o.contentDetails.duration;if(secs=J.durationToSeconds(i),!longsongs||secs<720){u=o.snippet.title,enc_title=encodeURIComponent(u).replace(/'/g,"\\'"),n=o.id,i=i.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"),thumb=o.snippet.thumbnails.medium.url;var s=a;s.find(".search-title").text(u),s.find(".result_info").text(i),s.find(".thumb").attr("data-original",thumb),s.find(".add-many").attr("onclick","submit('"+n+"','"+enc_title+"',"+secs+");"),$($(s).find("div")[0]).attr("onclick","submitAndClose('"+n+"','"+enc_title+"',"+secs+");"),t+=s.html()}}),$("").appendTo($("#results")).show("blind",83.33*(e.items.length-1)),setTimeout(function(){$(".thumb").lazyload({container:$("#results")})},250),o.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){J.submit(e,t,o),$("#results").html(""),J.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="+B+"&playlistId="+e+token,$.ajax({type:"GET",url:playlist_url,dataType:"jsonp",success:function(t){var o="";J.addVideos(t.items[0].contentDetails.videoId),$.each(t.items,function(e,t){o+=t.contentDetails.videoId+","}),J.addVideos(o),t.nextPageToken&&J.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=J.durationToSeconds(t.contentDetails.duration);(!longsongs||720>o)&&(enc_title=encodeURIComponent(t.snippet.title),J.submit(t.id,enc_title,o))})}})},submit:function(e,t,o){F.emit("add",[e,decodeURIComponent(t),V,o])},durationToSeconds:function(e){var t=e.match(A);return hours=parseInt(t[12])||0,minutes=parseInt(t[14])||0,seconds=parseInt(t[16])||0,60*hours*60+60*minutes+seconds}},Z={setup_youtube_listener:function(e){F.on("np",function(e){if(0==e[0].length){document.getElementById("song-title").innerHTML="Empty channel. Add some songs!",$("#player_overlay").height($("#player").height()),window.mobilecheck()||$("#player_overlay").toggleClass("hide");try{d.stopVideo()}catch(t){}}else p=e[0][0].id,i=e[1][0],time=e[2],f=time-i.startTime,v=e[0][0].title,$("#player_overlay").addClass("hide"),Z.getTitle(v,m),Z.setBGimage(p),P&&!window.mobilecheck()?(d.getVideoUrl().split("v=")[1]!=p&&(d.loadVideoById(p),Z.notifyUser(p,v),d.seekTo(f),H&&d.pauseVideo()),H||d.playVideo(),(d.getDuration()>f||0==d.getDuration())&&d.seekTo(f)):Z.getTitle(v,m)}),F.on("viewers",function(e){m=e,void 0!==v&&Z.getTitle(v,m)})},onPlayerStateChange:function(e){switch(e.data){case-1:break;case 0:O=!1,H=!1,F.emit("end",p);break;case 1:O=!0,1==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide"),2==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide"),H&&(F.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"),i=document.getElementById("viewers");document.title=n+" • Zöff / "+k,a.innerHTML=n,i.innerHTML=t+" "+o,a.title=n+" • "+t+" "+o},errorHandler:function(e){5==e.data||100==e.data||101==e.data||150==e.data?F.emit("skip",e.data):void 0!==p&&d.loadVideoById(p)},onPlayerReady:function(e){P=!0,window.mobilecheck()||($("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),d.loadVideoById(p),d.playVideo(),d.seekTo(f)),Z.readyLooks(),W.initYoutubeControls(d),W.initSlider(),d.setVolume(localStorage.getItem("volume"))},readyLooks:function(){Z.setBGimage(p)},setBGimage:function(e){if(void 0!==e){var t=new Image;t.onload=function(){var e=new ColorThief,n=e.getColor(t);document.getElementsByTagName("body")[0].style.backgroundColor=o.rgbToHsl(n),$("meta[name=theme-color]").attr("content",o.rgbToHex(n[0],n[1],n[2]))},t.crossOrigin="Anonymous",t.src="//zoff.no:8080/http://img.youtube.com/vi/"+e+"/mqdefault.jpg"}},notifyUser:function(e,t){if(t=t.replace(/\\\'/g,"'").replace(/"/g,"'").replace(/&/g,"&"),"granted"===Notification.permission&&document.hidden&&"30H2Z8Lr-4c"!=e&&!window.mobilecheck()){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(){F.on("get_list",function(){F.emit("list",k.toLowerCase())}),Z.setup_youtube_listener(k),e.admin_listener(),t.setup_chat_listener(k),t.allchat_listener(),w.channel_listener(),w.skipping_listener()},onYouTubeIframeAPIReady:function(){d=new YT.Player("player",{videoId:"asd",playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",color:"white"},events:{onReady:Z.onPlayerReady,onStateChange:Z.onPlayerStateChange,onError:Z.errorHandler}})},loadPlayer:function(){l=document.createElement("script"),l.src="https://www.youtube.com/iframe_api",c=document.getElementsByTagName("script")[0],c.parentNode.insertBefore(l,c)}}}(); \ No newline at end of file +!function(){var e={admin_listener:function(){F.on("toast",function(t){switch(t){case"addedsong":t=o.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":t=o.rnd(["I've saved your settings","I stored all your settings","Your settings have been stored in a safe place"]);break;case"wrongpass":t=o.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."]),localStorage[k.toLowerCase()]&&localStorage.removeItem(k.toLowerCase()),e.display_logged_out(),C=!0;break;case"shuffled":t=o.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":t=o.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":t=o.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":t=o.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":t=o.rnd(["The song was skipped","I have skipped a song","Skipped to the beat","Skipmaster3000","They see me skippin', they hatin'"]);break;case"listhaspass":t=o.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":t=o.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":t=o.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":t="Skipping is disabled the first 10 seconds.";break;case"correctpass":t="Correct password. You now have access to the sacred realm of The Admin.";break;case"changedpass":t="Your password has been changed!"}Materialize.toast(t,4e3)}),F.on("pw",function(e){C=!1,z=e,names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay","skip","shuffle"],localStorage.setItem(k.toLowerCase(),e);for(var t=0;t150||("#all_chat"==$(".tab a.active").attr("href")?F.emit("all,chat",e.value):F.emit("chat",e.value),e.value="")},allchat_listener:function(){F.on("chat.all",function(e){0!=$("#chat-bar").position().left?S||($("#favicon").attr("href","static/images/highlogo.png"),S=!0,E=!0,i=setInterval(t.chat_blink,2e3)):document.hidden&&($("#favicon").attr("href","static/images/highlogo.png"),E=!0);var n=o.intToARGB(o.hashCode(e[0])).substring(0,6);$("#chatall").append("
  • "+e[0]+"
  • ");var a=document.createTextNode(e[1]);$("#chatall li:last")[0].appendChild(a),document.getElementById("chatall").scrollTop=document.getElementById("chatall").scrollHeight})},setup_chat_listener:function(e){document.getElementsByClassName("chat-tab")[0].innerHTML=e,F.on("chat",function(e){0!=$("#chat-bar").position().left&&e[1].indexOf(":")>=0&&(S||($("#favicon").attr("href","static/images/highlogo.png"),S=!0,i=setInterval(t.chat_blink,2e3)));var n=o.intToARGB(o.hashCode(e[0])).substring(0,6);$("#chatchannel").append("
  • "+e[0]+"
  • ");var a=document.createTextNode(e[1]);$("#chatchannel li:last")[0].appendChild(a),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)}};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 o={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},l=0;a>l;l++)e=arguments[l],"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,l=0;a>l&&(i=0,e=n[l],s=e.name,i=e.cmp(t[s],o[s]),0===i);l++);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()-q>=2*H&&(F.removeAllListeners(),F.disconnect(),F.connect(),K.setup_all_listeners()),q=Date.now(),setTimeout(o.sample,H)},loadjsfile:function(e){if(-1==P.indexOf("["+e+"]")){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(t),P+="["+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,n){return"#"+o.componentToHex(e)+o.componentToHex(t)+o.componentToHex(n)}};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])};var n,a,s,i,l,c,d,u,m,h,p,f,v,y={host_listener:function(){var e;F.on("id",function(t){void 0===e?e=t:(F.removeAllListeners(t),Y=!1,e=t);var o="http://"+window.location.hostname+"/remote/"+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),Y||(Y=!0,F.on(t,function(e){"volume"==e[0]?($("#volume").slider("value",e[1]),d.setVolume(e[1]),localStorage.setItem("volume",e[1]),W.choose_button(e[1],!1)):"channel"==e[0]?(F.emit("change_channel"),k=e[1].toLowerCase(),$("#chan").html(k.substring(0,1).toUpperCase()+k.substring(1).toLowerCase()),C=!0,F.emit("list",k.toLowerCase()),localStorage[k.toLowerCase()]&&(64!=localStorage[k.toLowerCase()].length?localStorage.removeItem(k.toLowerCase()):F.emit("password",[localStorage[k.toLowerCase()],k.toLowerCase()])),window.history.pushState("object or string","Title","/"+k.toLowerCase())):"pause"==e[0]?d.pauseVideo():"play"==e[0]?d.playVideo():"skip"==e[0]&&w.skip()}))})}},w={channel_listener:function(){F.on("channel",function(e){w.channel_function(e)})},channel_function:function(e){switch(e[0]){case"list":w.populate_list(e[1]);break;case"added":w.added_song(e[1]);break;case"deleted":w.deleted_song(e[1]);break;case"vote":w.voted_song(e[1],e[2]);break;case"song_change":w.song_change(e[1])}},skipping_listener:function(){F.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){a=e,w.sortList(),$("#wrapper").empty(),$.each(a,function(e,t){t.now_playing||$("#wrapper").append(w.generateSong(t,!1,!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){a.push(e),w.sortList(),w.insertAtIndex(e,!0)},deleted_song:function(e){var t=w.getIndexOfSong(e),o=$("#wrapper").children()[t];o.style.height=0,setTimeout(function(){$("#"+e).remove(),a.splice(w.getIndexOfSong(e),1)},305),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1},voted_song:function(e,t){var o=w.getIndexOfSong(e),n=a[o];a[o].votes+=1,a[o].added=t,w.sortList(),$("#"+e).remove(),w.insertAtIndex(n,!1)},song_change:function(e){var t=a.length-1;a[0].now_playing=!0,a[0].votes=0,a[0].guids=[],a[0].added=e,a[t].now_playing=!1,a.push(a.shift()),$("#wrapper").children()[0].remove(),w.insertAtIndex(a[t-1],!1),document.getElementById("wrapper").scrollTop+=1,document.getElementById("wrapper").scrollTop+=-1},vote:function(e,t){return F.emit("vote",[k,e,t,z]),!0},skip:function(){return F.emit("skip",[k,localStorage[k.toLowerCase()]]),!0},importOldList:function(e){var t="",o=0;playlist_url="lists/"+e+".json",p=$.parseJSON($.ajax({type:"GET",url:playlist_url,async:!1}).responseText),$.each(p.songs,function(e,n){t+=n.id+",",o>45&&(J.addVideos(t),t="",o=0),o++}),J.addVideos(t),document.getElementById("search").value=""},sortList:function(){a.sort(o.predicate({name:"votes",reverse:!0},"added"))},show:function(){window.mobilecheck()||(I?(I=!1,$("#toptitle").empty(),$("#chan").addClass("bigChan"),$("#chan").html("zoff.no/"+k.toLowerCase())):(I=!0,$("#toptitle").html("Zöff"),$("#chan").removeClass("bigChan"),$("#chan").html(k)))},insertAtIndex:function(e,t){G=w.getIndexOfSong(e.id),0===G?$("#wrapper").prepend(w.generateSong(e,t)):$("#wrapper > div:nth-child("+G+")").after(w.generateSong(e,t)),t&&setTimeout(function(){var e=$("#wrapper").children()[G];$(e).css("height",66)},5)},generateSong:function(e,t,o){var n=e.id,a=e.title,s=e.votes,i="background-image:url('//img.youtube.com/vi/"+n+"/mqdefault.jpg');",l=$("
    "+T+"
    "),r="style";return t&&l.find("#list-song").css("height",0),C||l.find(".card-action").removeClass("hide"),1==s&&l.find(".vote-text").text("vote"),o&&(i="//img.youtube.com/vi/"+n+"/mqdefault.jpg",r="data-original"),l.find(".list-title").text(a),l.find(".list-title").attr("title",a),l.find(".list-votes").text(s),l.find(".vote-container").attr("onclick","vote('"+n+"','pos')"),l.find(".list-image").attr(r,i),l.find("#list-song").attr("id",n),l.find("#del").attr("onclick","vote('"+n+"', 'del')"),l.html()},getIndexOfSong:function(e){return indexes=$.map(a,function(t,o){return t.id==e?o:void 0}),indexes[0]}},k=$("#chan").html(),C=!0,_=0,I=!0,T=$("#list-song-html").html(),S=!1,E=!1,x=0,B="***REMOVED***",L=$("#temp-results-container"),M=$("#empty-results-container").html(),N=!1,A=/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)?)?/,s=[],V=0,R=1,z="",P="",j=!1,m=1,O=!1,D=!1,H=6e3,q=Date.now(),Y=!1,G=-1,U={"sync disconnect on unload":!0},F=io.connect("http://"+window.location.hostname+":8880",U);F.on("get_list",function(){F.emit("list",k.toLowerCase())}),$(document).ready(function(){window.vote=w.vote,window.submit=J.submit,window.submitAndClose=J.submitAndClose,localStorage.list_update&&"13.06.15"==localStorage.list_update||(localStorage.setItem("list_update","13.06.15"),window.location.reload(!0)),K.setup_youtube_listener(k),e.admin_listener(),w.channel_listener(),w.skipping_listener(),$("#settings").sideNav({menuWidth:300,edge:"right",closeOnClick:!1}),$(".video-container").resizable({handles:"e",minWidth:350}),localStorage[k.toLowerCase()]&&(64!=localStorage[k.toLowerCase()].length?localStorage.removeItem(k.toLowerCase()):F.emit("password",[localStorage[k.toLowerCase()],k.toLowerCase()])),window.mobilecheck()?(document.getElementById("search").blur(),K.readyLooks()):(t.setup_chat_listener(k),t.allchat_listener(),y.host_listener(),K.loadPlayer(),window.onYouTubeIframeAPIReady=K.onYouTubeIframeAPIReady,$("#chat-btn").sideNav({menuWidth:272,edge:"left",closeOnClick:!1}),$(".drag-target")[1].remove(),o.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[G-1]).removeClass("hoverResults"),$(children[G]).addClass("hoverResults"),G1&&G--,$(children[G]).removeClass("hoverResults"),$(children[G-1]).addClass("hoverResults");else if(13==e.keyCode){G=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(){e.save()}),$("#listImport").on("submit",function(){J.importPlaylist(document.getElementById("import").value)}),$(window).focus(function(){E&&($("#favicon").attr("href","static/images/favicon.png"),E=!1)}),document.getElementById("chat-btn").addEventListener("click",function(){$("#text-chat-input").focus(),$("#chat-btn i").css("opacity",1),clearInterval(i),S=!1,E=!1,$("#favicon").attr("href","static/images/favicon.png")}),$(".chat-tab").click(function(){$("#text-chat-input").focus()}),$("#skip").on("click",function(){w.skip()}),$("#chan").on("click",function(){w.show()}),$("#adminForm").on("submit",function(){e.pass_save()}),$("#chatForm").on("submit",function(){t.chat(document.getElementById("chatForm").input)}),$("#shuffle").on("click",function(){e.shuffle()}),$("#search-btn").on("click",function(){J.showSearch()}),$("#song-title").on("click",function(){J.showSearch()}),$("#admin-lock").on("click",function(){e.log_out()}),$("#closeSettings").on("click",function(){e.hide_settings()});var W={initYoutubeControls:function(e){setInterval(W.durationSetter,1e3),W.initControls()},initControls:function(){document.getElementById("volume-button").addEventListener("click",W.mute_video),document.getElementById("playpause").addEventListener("click",W.play_pause),document.getElementById("fullscreen").addEventListener("click",W.fullscreen)},initSlider:function(){localStorage.volume?vol=localStorage.getItem("volume"):(vol=100,localStorage.setItem("volume",vol)),$("#volume").slider({min:0,max:100,value:vol,range:"min",animate:!0,slide:function(e,t){W.setVolume(t.value),localStorage.setItem("volume",t.value)}}),W.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==d.getPlayerState()?d.pauseVideo():(2==d.getPlayerState()||0==d.getPlayerState())&&d.playVideo()},settings:function(){$("#qS").toggleClass("hide")},changeQuality:function(e){d.getPlaybackQuality!=e&&(d.setPlaybackQuality(e),d.getPlaybackQuality()),$("#qS").toggleClass("hide")},mute_video:function(){d.isMuted()?(d.unMute(),W.choose_button(d.getVolume(),!1)):(W.choose_button(0,!0),d.mute())},setVolume:function(e){d.setVolume(e),W.choose_button(e,!1),d.isMuted()&&d.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=d.getPlayerState(),button=document.getElementById("playpause"),1==state?d.pauseVideo():2==state&&d.playVideo()},durationSetter:function(){duration=d.getDuration(),dMinutes=Math.floor(duration/60),dSeconds=duration-60*dMinutes,currDurr=d.getCurrentTime(),currDurr>duration&&(currDurr=duration),minutes=Math.floor(currDurr/60),seconds=currDurr-60*minutes,document.getElementById("duration").innerHTML=o.pad(minutes)+":"+o.pad(seconds)+" / "+o.pad(dMinutes)+":"+o.pad(dSeconds),per=100/duration*currDurr,per>=100?per=100:0==duration&&(per=0),$("#bar").width(per+"%")},volumeOptions:function(){d.isMuted()?(d.unMute(),vol=d.getVolume(),$("#volume").slider("value",d.getVolume())):(d.mute(),$("#volume").slider("value",0))},hoverMute:function(e){vol=d.getVolume()}},J={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){N=!0;var t=encodeURIComponent(window.search_input),a="https://www.googleapis.com/youtube/v3/search?key="+B+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";a+="&q="+t,V&&(a+="&videoCategoryId=10");var s="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+B+"&id=";o.contains($("#search_loader").attr("class").split(" "),"hide")&&$("#search_loader").removeClass("hide"),o.contains($("#results").attr("class").split(" "),"hide")&&$("#results").removeClass("hide"),$.ajax({type:"GET",url:a,dataType:"jsonp",success:function(e){0==e.items.length?($("").appendTo($("#results")).show("blind",83.33),o.contains($("#search_loader").attr("class").split(" "),"hide")||$("#search_loader").addClass("hide")):e.items&&($.each(e.items,function(e,t){s+=t.id.videoId+","}),$.ajax({type:"GET",url:s,dataType:"jsonp",success:function(e){var t="",a=$(L);$.each(e.items,function(e,o){var s=o.contentDetails.duration;if(secs=J.durationToSeconds(s),!longsongs||secs<720){u=o.snippet.title,enc_title=encodeURIComponent(u).replace(/'/g,"\\'"),n=o.id,s=s.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(u),i.find(".result_info").text(s),i.find(".thumb").attr("data-original",thumb),i.find(".add-many").attr("onclick","submit('"+n+"','"+enc_title+"',"+secs+");"),$($(i).find("div")[0]).attr("onclick","submitAndClose('"+n+"','"+enc_title+"',"+secs+");"),t+=i.html()}}),$("").appendTo($("#results")).show("blind",83.33*(e.items.length-1)),setTimeout(function(){$(".thumb").lazyload({container:$("#results")})},250),o.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){J.submit(e,t,o),$("#results").html(""),J.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="+B+"&playlistId="+e+token,$.ajax({type:"GET",url:playlist_url,dataType:"jsonp",success:function(t){var o="";J.addVideos(t.items[0].contentDetails.videoId),$.each(t.items,function(e,t){o+=t.contentDetails.videoId+","}),J.addVideos(o),t.nextPageToken&&J.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=J.durationToSeconds(t.contentDetails.duration);(!longsongs||720>o)&&(enc_title=encodeURIComponent(t.snippet.title),J.submit(t.id,enc_title,o))})}})},submit:function(e,t,o){F.emit("add",[e,decodeURIComponent(t),z,o])},durationToSeconds:function(e){var t=e.match(A);return hours=parseInt(t[12])||0,minutes=parseInt(t[14])||0,seconds=parseInt(t[16])||0,60*hours*60+60*minutes+seconds}},K={setup_youtube_listener:function(e){F.on("np",function(e){if(0==e[0].length){document.getElementById("song-title").innerHTML="Empty channel. Add some songs!",$("#player_overlay").height($("#player").height()),window.mobilecheck()||$("#player_overlay").toggleClass("hide");try{d.stopVideo()}catch(t){}}else h=e[0][0].id,s=e[1][0],time=e[2],f=time-s.startTime,v=e[0][0].title,$("#player_overlay").addClass("hide"),K.getTitle(v,m),K.setBGimage(h),j&&!window.mobilecheck()?(d.getVideoUrl().split("v=")[1]!=h&&(d.loadVideoById(h),K.notifyUser(h,v),d.seekTo(f),O&&d.pauseVideo()),O||d.playVideo(),(d.getDuration()>f||0==d.getDuration())&&d.seekTo(f)):K.getTitle(v,m)}),F.on("viewers",function(e){m=e,void 0!==v&&K.getTitle(v,m)})},onPlayerStateChange:function(e){switch(e.data){case-1:break;case 0:D=!1,O=!1,F.emit("end",h);break;case 1:D=!0,1==document.getElementById("play").className.split(" ").length&&$("#play").toggleClass("hide"),2==document.getElementById("pause").className.split(" ").length&&$("#pause").toggleClass("hide"),O&&(F.emit("pos"),O=!1);break;case 2:O=!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 / "+k,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?F.emit("skip",e.data):void 0!==h&&d.loadVideoById(h)},onPlayerReady:function(e){j=!0,window.mobilecheck()||($("#player").css("opacity","1"),$("#controls").css("opacity","1"),$(".playlist").css("opacity","1"),d.loadVideoById(h),d.playVideo(),d.seekTo(f)),K.readyLooks(),W.initYoutubeControls(d),W.initSlider(),d.setVolume(localStorage.getItem("volume"))},readyLooks:function(){K.setBGimage(h)},setBGimage:function(e){if(void 0!==e){var t=new Image;t.onload=function(){var e=new ColorThief,n=e.getColor(t);document.getElementsByTagName("body")[0].style.backgroundColor=o.rgbToHsl(n),$("meta[name=theme-color]").attr("content",o.rgbToHex(n[0],n[1],n[2]))},t.crossOrigin="Anonymous",t.src="//zoff.no:8080/http://img.youtube.com/vi/"+e+"/mqdefault.jpg"}},notifyUser:function(e,t){if(t=t.replace(/\\\'/g,"'").replace(/"/g,"'").replace(/&/g,"&"),"granted"===Notification.permission&&document.hidden&&"30H2Z8Lr-4c"!=e&&!window.mobilecheck()){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(){F.on("get_list",function(){F.emit("list",k.toLowerCase())}),K.setup_youtube_listener(k),e.admin_listener(),t.setup_chat_listener(k),t.allchat_listener(),w.channel_listener(),w.skipping_listener()},onYouTubeIframeAPIReady:function(){d=new YT.Player("player",{videoId:"asd",playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",color:"white"},events:{onReady:K.onPlayerReady,onStateChange:K.onPlayerStateChange,onError:K.errorHandler}})},loadPlayer:function(){l=document.createElement("script"),l.src="https://www.youtube.com/iframe_api",c=document.getElementsByTagName("script")[0],c.parentNode.insertBefore(l,c)}}}(); \ No newline at end of file diff --git a/static/images/pin.png b/static/images/pin.png new file mode 100644 index 0000000000000000000000000000000000000000..2fd2ab7dfcbfa7f2a1fb7be426417336ded07e7d GIT binary patch literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1(2s1Lwnj--eWH0gbb!ETL&C91NSG9M!08mJ>#5JPCIX^cyHLrxhxhOTUBsE2$ zJhLQ2!QIn0AiR-J9H?lrr;B5V#p$<`9Jvk|2)M?tnj&{p_=PREURBq+>h)TSH1GGe zZn1dlqLKG2(d^{;nlAr|HAqnXu;JbEuvHA_ zKQ1unS<7r@cBRUy=fJ_8a}^I1@~)Uu+uoAgYm@RpEspy}D#LEy`pT1)ktY-XOmpV{ np|wMG!R`eU?OAvKTWiiV-M8w}?7CE-^B6o`{an^LB{Ts5d4_GZ literal 0 HcmV?d00001 diff --git a/static/js/nochan.js b/static/js/nochan.js index ab71fe49..ca1add01 100755 --- a/static/js/nochan.js +++ b/static/js/nochan.js @@ -20,8 +20,14 @@ var Nochan = { { var output = ""; var num = 0; + var pinned; + if(lists[0][5] == 1){ + pinned = lists.shift(); + } lists.sort(Nochan.sortFunction); - + if(pinned !== undefined){ + lists.unshift(pinned); + } pre_card = $(list_html); for(x in lists) @@ -38,6 +44,17 @@ var Nochan = { //$("#channels").append(list_html); var card = pre_card; + + if(lists[x][5] == 1) + { + card.find(".pin").attr("style", "display:block;"); + card.find(".card").attr("title", "Pinned!"); + } + else + { + card.find(".pin").attr("style", "display:none;"); + card.find(".card").attr("title", ""); + } card.find(".chan-name").text(chan); card.find(".chan-name").attr("title", chan); card.find(".chan-views").text(viewers); From 69a5dba6b133507b484b826111420d189ff5095b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 13 Nov 2015 23:27:41 +0100 Subject: [PATCH 02/27] Reindented some --- server/server.js | 1251 +++++++++++++++++++++++----------------------- 1 file changed, 618 insertions(+), 633 deletions(-) diff --git a/server/server.js b/server/server.js index 2640dee5..1ff1cd22 100755 --- a/server/server.js +++ b/server/server.js @@ -1,36 +1,36 @@ var server; /*try{ - var fs = require('fs'); - var privateKey = fs.readFileSync('/etc/apache2/ssl/private.key', 'utf8'); - var certificate = fs.readFileSync('/etc/apache2/ssl/ssl.crt', 'utf8'); - var credentials = {key: privateKey, cert: certificate}; - var https = require('https'); - server = https.createServer(credentials, handler); + var fs = require('fs'); + var privateKey = fs.readFileSync('/etc/apache2/ssl/private.key', 'utf8'); + var certificate = fs.readFileSync('/etc/apache2/ssl/ssl.crt', 'utf8'); + var credentials = {key: privateKey, cert: certificate}; + var https = require('https'); + server = https.createServer(credentials, handler); - var cors_proxy = require('cors-anywhere'); + var cors_proxy = require('cors-anywhere'); - cors_proxy.createServer({ - requireHeader: ['origin', 'x-requested-with'], - removeHeaders: ['cookie', 'cookie2'], - httpsOptions: credentials - }).listen(8080, function() { - console.log('Running CORS Anywhere on :' + 8080); - }); + cors_proxy.createServer({ + requireHeader: ['origin', 'x-requested-with'], + removeHeaders: ['cookie', 'cookie2'], + httpsOptions: credentials + }).listen(8080, function() { + console.log('Running CORS Anywhere on :' + 8080); + }); }*/ //catch(err){ - console.log("Starting without https (probably on localhost)"); - //if(err["errno"] != 34)console.log(err); - var cors_proxy = require('cors-anywhere'); + console.log("Starting without https (probably on localhost)"); +//if(err["errno"] != 34)console.log(err); +var cors_proxy = require('cors-anywhere'); - cors_proxy.createServer({ - requireHeader: ['origin', 'x-requested-with'], - removeHeaders: ['cookie', 'cookie2'], - }).listen(8080, function() { - console.log('Running CORS Anywhere on :' + 8080); - }); - var http = require('http'); - server = http.createServer(handler); +cors_proxy.createServer({ + requireHeader: ['origin', 'x-requested-with'], + removeHeaders: ['cookie', 'cookie2'], +}).listen(8080, function() { + console.log('Running CORS Anywhere on :' + 8080); +}); +var http = require('http'); +server = http.createServer(handler); //} var io = require('socket.io')(server, {'pingTimeout': 25000}); @@ -49,17 +49,17 @@ var lists = {}; var unique_ids = []; function handler (req, res) { - res.writeHead(302, {'Location': 'http://'+req.headers.host.split(":")[0]}); - return res.end('Wrong port'); + res.writeHead(302, {'Location': 'http://'+req.headers.host.split(":")[0]}); + return res.end('Wrong port'); } server.listen(port, function () { - console.log('Server listening at port %d', port); + console.log('Server listening at port %d', port); }); process.on('uncaughtException', function(e){ - console.log("\n" + new Date().toString() + "\n", e.stack || e); - process.exit(1); + console.log("\n" + new Date().toString() + "\n", e.stack || e); + process.exit(1); }) db.on('error',function(err) { @@ -67,557 +67,545 @@ db.on('error',function(err) { }); io.on('connection', function(socket){ - socket.emit("get_list"); + console.log("connection"); + socket.emit("get_list"); - var guid = hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); + var guid = hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); - socket.on('close', function() { - console.log("closing socket"); - }) + socket.on('close', function() { + console.log("closing socket"); + }) - socket.on('ping', function() { - socket.emit("ok"); - }); - - var coll; - var tot_lists = []; - var in_list = false; - var name = rndName(guid,8); - var short_id = uniqueID(socket.id,4); - unique_ids.push(short_id); - - socket.on('namechange', function(data) - { - if(name.length < 9 && name.indexOf(" ") == -1) - { - io.to(coll).emit('chat', [name, " changed name to " + data]); - io.sockets.emit('chat.all', [name ," changed name to " + data, coll]); - name = data; - } - }); - - socket.on('chat', function (data) { - check_inlist(coll, guid, socket, name); - if(data != "" && data !== undefined && data !== null && data.length < 151 && data.replace(/\s/g, '').length) - io.to(coll).emit('chat', [name, ": " + data]); - }); - - socket.on("all,chat", function(data) - { - check_inlist(coll, guid, socket, name); - if(data != "" && data !== undefined && data !== null && data.length < 151 && data.replace(/\s/g, '').length) - io.sockets.emit('chat.all', [name, ": " + data, coll]); - }); - - socket.on('frontpage_lists', function() - { - var playlists_to_send = []; - var i = 0; - var playlists_to_send = []; - in_list = false; - - db.getCollectionNames(function(err, colNames){ - colNames.forEach(function(name){ - if(name != "system.indexes") - { - db.collection(name).find({views:{$exists:true}}, function(err, conf){ - db.collection(name).count(function(err, num){ - db.collection(name).find({now_playing:true}, function(err, np){ - complete(np, i, colNames.length-2, name, num-1, conf); - i++; - }); - }); - }); - } - }); + socket.on('ping', function() { + socket.emit("ok"); }); - var complete = function(list, curr, tot, name, count, conf) + var coll; + var tot_lists = []; + var in_list = false; + var name = rndName(guid,8); + var short_id = uniqueID(socket.id,4); + unique_ids.push(short_id); + + socket.on('namechange', function(data) { - if(list.length > 0) - { - var id = list[0]["id"]; - var title = list[0]["title"]; - var pinned = 0; - if(conf[0].pinned == 1) pinned = 1; - try{ - var viewers = lists[name].length; - }catch(err){var viewers = 0;} - var to_push = [viewers, id, title, name, count, pinned]; - if(conf[0].pinned == 1) + if(name.length < 9 && name.indexOf(" ") == -1) { - playlists_to_send.unshift(to_push); - }else if(conf[0]["frontpage"]) - playlists_to_send.push(to_push); - } - if(curr == tot) - { - socket.emit("playlists", playlists_to_send); - } - } - }); - - socket.on('now_playing', function(list) - { - db.collection(list).find({now_playing:true}, function(err, docs) - { - var title = docs[0]["title"]; - socket.emit("title", title); + io.to(coll).emit('chat', [name, " changed name to " + data]); + io.sockets.emit('chat.all', [name ," changed name to " + data, coll]); + name = data; + } }); - }); - socket.on('id', function(arr) - { + socket.on('chat', function (data) { + check_inlist(coll, guid, socket, name); + if(data != "" && data !== undefined && data !== null && data.length < 151 && data.replace(/\s/g, '').length) + io.to(coll).emit('chat', [name, ": " + data]); + }); - if(arr.length == 3) - io.to(arr[0]).emit(arr[0], [arr[1], arr[2]]); - }); - - socket.on('list', function(list) - { - if(list !== undefined && list !== null && list != "") + socket.on("all,chat", function(data) { - in_list = true; - coll = emojiStrip(list).toLowerCase(); - coll = decodeURIComponent(coll); - coll = coll.replace(/\W/g, ''); - socket.join(coll); - socket.join(short_id); - socket.emit("id", short_id); + check_inlist(coll, guid, socket, name); + if(data != "" && data !== undefined && data !== null && data.length < 151 && data.replace(/\s/g, '').length) + io.sockets.emit('chat.all', [name, ": " + data, coll]); + }); - check_inlist(coll, guid, socket, name); - - io.to(coll).emit("viewers", lists[coll].length); - - db.getCollectionNames(function(err, docs){ - - if(contains(docs, coll)) - { - send_list(coll, socket, true, false, true); - }else - { - db.createCollection(coll, function(err, docs){ - db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":false, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":get_time(), "views": [], "vote": false, "desc": ""}, function(err, docs) - { - send_list(coll, socket, true, false, true); - - }); - }); - } - }); - } - }); - - socket.on('end', function(id) - { - if(id !== undefined && id !== null && id != "") + socket.on('frontpage_lists', function() { - check_inlist(coll, guid, socket, name); + console.log("connected"); + var playlists_to_send = []; + var i = 0; + var playlists_to_send = []; + in_list = false; - db.collection(coll).find({now_playing:true}, function(err, np){ - if(err !== null) console.log(err); - if(np !== null && np !== undefined && np.length == 1 && np[0]["id"] == id){ - db.collection(coll).find({views:{$exists:true}}, function(err, docs){ - var startTime = docs[0]["startTime"]; - if(docs[0]["removeplay"] == true) - { - db.collection(coll).remove({now_playing:true}, function(err, docs) - { - change_song_post(coll); - }) - }else - { - if(startTime+parseInt(np[0]["duration"])<=get_time()+2) + db.getCollectionNames(function(err, colNames){ + colNames.forEach(function(name){ + if(name != "system.indexes") { - db.collection(coll).update({now_playing:true, id:id}, - {$set:{ - now_playing:false, - votes:0, - guids:[] - }}, function(err, docs) - { - if(docs["n"] == 1) - { - db.collection(coll).aggregate([ - {$match:{now_playing:false}}, - {$sort:{votes:-1, added:1}}, - {$limit:1}], function(err, docs){ - if(docs !== null && docs.length > 0){ - db.collection(coll).update({id:docs[0]["id"]}, - {$set:{ - now_playing:true, - votes:0, - guids:[], - added:get_time()}}, function(err, docs){ - db.collection(coll).update({views:{$exists:true}}, - {$set:{startTime:get_time(), skips:[]}}, function(err, docs){ - io.to(coll).emit("channel", ["song_change", get_time()]); - send_play(coll); - }); + db.collection(name).find({views:{$exists:true}}, function(err, conf){ + db.collection(name).count(function(err, num){ + db.collection(name).find({now_playing:true}, function(err, np){ + complete(np, i, colNames.length-2, name, num-1, conf); + i++; + }); + }); + }); + } + }); + }); + + var complete = function(list, curr, tot, name, count, conf) + { + if(list.length > 0) + { + var id = list[0]["id"]; + var title = list[0]["title"]; + var pinned = 0; + if(conf[0].pinned == 1) pinned = 1; + try{var viewers = lists[name].length;} + catch(err){var viewers = 0;} + var to_push = [viewers, id, title, name, count, pinned]; + if(conf[0].pinned == 1) + { + playlists_to_send.unshift(to_push); + }else if(conf[0]["frontpage"]) + playlists_to_send.push(to_push); + } + if(curr == tot) + { + socket.emit("playlists", playlists_to_send); + } + } + }); + + socket.on('now_playing', function(list) + { + db.collection(list).find({now_playing:true}, function(err, docs){ + var title = docs[0]["title"]; + socket.emit("title", title); + }); + }); + + socket.on('id', function(arr) + { + if(arr.length == 3) + io.to(arr[0]).emit(arr[0], [arr[1], arr[2]]); + }); + + socket.on('list', function(list) + { + if(list !== undefined && list !== null && list != "") + { + in_list = true; + coll = emojiStrip(list).toLowerCase(); + coll = decodeURIComponent(coll); + coll = coll.replace(/\W/g, ''); + socket.join(coll); + socket.join(short_id); + socket.emit("id", short_id); + + check_inlist(coll, guid, socket, name); + + io.to(coll).emit("viewers", lists[coll].length); + + db.getCollectionNames(function(err, docs){ + if(contains(docs, coll)) + { + send_list(coll, socket, true, false, true); + }else{ + db.createCollection(coll, function(err, docs){ + db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":false, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":get_time(), "views": [], "vote": false, "desc": ""}, function(err, docs){ + send_list(coll, socket, true, false, true); + }); + }); + } + }); + } + }); + + socket.on('end', function(id) + { + if(id !== undefined && id !== null && id != "") + { + check_inlist(coll, guid, socket, name); + + db.collection(coll).find({now_playing:true}, function(err, np){ + if(err !== null) console.log(err); + if(np !== null && np !== undefined && np.length == 1 && np[0]["id"] == id){ + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + var startTime = docs[0]["startTime"]; + if(docs[0]["removeplay"] == true) + { + db.collection(coll).remove({now_playing:true}, function(err, docs){ + change_song_post(coll); + }); + }else{ + if(startTime+parseInt(np[0]["duration"])<=get_time()+2) + { + db.collection(coll).update({now_playing:true, id:id}, + {$set:{ + now_playing:false, + votes:0, + guids:[] + }}, function(err, docs){ + if(docs["n"] == 1) + { + db.collection(coll).aggregate([ + {$match:{now_playing:false}}, + {$sort:{votes:-1, added:1}}, + {$limit:1 + }], function(err, docs){ + if(docs !== null && docs.length > 0){ + db.collection(coll).update({id:docs[0]["id"]}, + {$set:{ + now_playing:true, + votes:0, + guids:[], + added:get_time() + }}, function(err, docs){ + db.collection(coll).update({views:{$exists:true}}, + {$set:{startTime:get_time(), skips:[] + }}, function(err, docs){ + io.to(coll).emit("channel", ["song_change", get_time()]); + send_play(coll); + }); + }); + } + }); + } }); } - }); - } - - }); - + } + }); } - } - }); - } - }); - } - }); - - socket.on('add', function(arr) - { - if(arr !== undefined && arr !== null && arr != "") - { - if(arr.length == 5) coll = arr[4]; - else check_inlist(coll, guid, socket, name); - - var id = arr[0]; - var title = arr[1]; - var hash = hash_pass(arr[2]); - var duration = parseInt(arr[3]); - db.collection(coll).find({views:{$exists:true}}, function(err, docs) - { - if(docs !== null && docs.length != 0 && ((docs[0]["addsongs"] == true && (hash == docs[0]["adminpass"] || docs[0]["adminpass"] == "")) - || docs[0]["addsongs"] == false)) - { - db.collection(coll).find({id:id}, function(err, docs){ - if(docs !== null && docs.length == 0) - { - var guids = [guid]; - var votes = 1; - - db.collection(coll).find({now_playing:true}, function(err, docs){ - if(docs !== null && docs.length == 0) - np = true; - else - np = false; - db.collection(coll).insert({"added":get_time(),"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}, function(err, docs){ - io.to(coll).emit("channel", ["added", {"_id": "asd", "added":get_time(),"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}]); - if(np) - { - send_play(coll, undefined); - io.to(coll).emit("channel", ["song_change", get_time()]); - } - }); - }); - }else{ - vote(coll, id, guid, socket); - } - }); - }else - socket.emit("toast", "listhaspass"); - }); - } - }); - - socket.on('vote', function(msg) - { - if(msg !== undefined && msg !== null) - { - check_inlist(coll, guid, socket, name); - - if(msg[2] == "del") - del(msg, socket); - else - { - var id = msg[1]; - var hash = hash_pass(msg[3]); - db.collection(coll).find({views:{$exists:true}}, function(err, docs) - { - if(docs !== null && docs.length != 0 && ((docs[0]["vote"] == true && (hash == docs[0]["adminpass"] || docs[0]["adminpass"] == "")) - || docs[0]["vote"] == false)) - { - vote(coll, id, guid, socket); - }else{ - socket.emit("toast", "listhaspass"); - } - }); - } - } - }); - - socket.on('password', function(inp) - { - if(inp !== undefined && inp !== null && inp != "") - { - pw = inp[0]; - opw = inp[0]; - coll = inp[1]; - - check_inlist(coll, guid, socket, name); - - if(inp.length == 3) - { - opw = inp[2]; - } - - db.collection(coll).find({views:{$exists:true}}, function(err, docs){ - if(docs !== null && docs.length != 0) - { - if(docs[0]["adminpass"] == "" || docs[0]["adminpass"] == hash_pass(opw)) - { - db.collection(coll).update({views:{$exists:true}}, {$set:{adminpass:hash_pass(pw)}}, function(err, docs) - { - if(inp.length == 3) - socket.emit("toast", "changedpass"); - else - socket.emit("toast", "correctpass"); - socket.emit("pw", pw); - }) - }else - socket.emit("toast", "wrongpass"); + }); } - }); - } - }); + }); - socket.on('skip', function(list) - { - if(list !== undefined && list !== null && list != "") + socket.on('add', function(arr) { - check_inlist(coll, guid, socket, name); - - adminpass = ""; - - var error = false; - if(list != "5" && list != "100" && list != "101" && list != "150" && list !== undefined) - { - adminpass = list[1]; - }else if(list == "5" || list == "100" || list == "101" || list == "150"){ - error = true; - } - - if(adminpass !== undefined && adminpass !== null && adminpass != "") - var hash = hash_pass(adminpass); - else - var hash = ""; - - db.collection(coll).find({views: {$exists:true}}, function(err, docs){ - if(docs !== null && docs.length != 0) + if(arr !== undefined && arr !== null && arr != "") { - if(!docs[0]["skip"] || (docs[0]["adminpass"] == hash && docs[0]["adminpass"] != "") || error) - { - if((lists[coll].length/2 <= docs[0]["skips"].length+1 && !contains(docs[0]["skips"], guid) && lists[coll].length != 2) - || (lists[coll].length == 2 && docs[0]["skips"].length+1 == 2 && !contains(docs[0]["skips"], guid)) - || (docs[0]["adminpass"] == hash && docs[0]["adminpass"] != "" && docs[0]["skip"])) - { - change_song(coll); - socket.emit("toast", "skip"); - io.to(coll).emit('chat', [name, " skipped"]); - }else if(!contains(docs[0]["skips"], guid)){ - db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){ - if(lists[coll].length == 2) - to_skip = 1; - else - to_skip = (Math.ceil(lists[coll].length/2) - docs[0]["skips"].length-1); - socket.emit("toast", to_skip + " more are needed to skip!"); - socket.broadcast.to(coll).emit('chat', [name, " voted to skip"]); - }); - }else{ - socket.emit("toast", "alreadyskip"); - } - }else - socket.emit("toast", "noskip"); + if(arr.length == 5) coll = arr[4]; + else check_inlist(coll, guid, socket, name); + + var id = arr[0]; + var title = arr[1]; + var hash = hash_pass(arr[2]); + var duration = parseInt(arr[3]); + db.collection(coll).find({views:{$exists:true}}, function(err, docs) + { + if(docs !== null && docs.length != 0 && ((docs[0]["addsongs"] == true && (hash == docs[0]["adminpass"] || docs[0]["adminpass"] == "")) + || docs[0]["addsongs"] == false)) + { + db.collection(coll).find({id:id}, function(err, docs){ + if(docs !== null && docs.length == 0) + { + var guids = [guid]; + var votes = 1; + + db.collection(coll).find({now_playing:true}, function(err, docs){ + if(docs !== null && docs.length == 0) + np = true; + else + np = false; + db.collection(coll).insert({"added":get_time(),"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}, function(err, docs){ + io.to(coll).emit("channel", ["added", {"_id": "asd", "added":get_time(),"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}]); + if(np) + { + send_play(coll, undefined); + io.to(coll).emit("channel", ["song_change", get_time()]); + } + }); + }); + }else{ + vote(coll, id, guid, socket); + } + }); + }else + socket.emit("toast", "listhaspass"); + }); } - }); - } - }); + }); - socket.on('conf', function(params) - { - if(params !== undefined && params !== null && params != "") + socket.on('vote', function(msg) { - check_inlist(coll, guid, socket,name); - - var voting = params[0]; - var addsongs = params[1]; - var longsongs = params[2]; - var frontpage = params[3]; - var allvideos = params[4]; - var removeplay = params[5]; - var adminpass = params[6]; - var skipping = params[7]; - var shuffling = params[8]; - var description = ""; - if(params.length == 10) description = params[9]; - - if(adminpass != "") - var hash = hash_pass(adminpass); - else - var hash = adminpass; - - db.collection(coll).find({views:{$exists:true}}, function(err, docs){ - if(docs !== null && docs.length != 0 && docs[0]["adminpass"] == "" || docs[0]["adminpass"] == hash) + if(msg !== undefined && msg !== null) { - db.collection(coll).update({views:{$exists:true}}, { - $set:{addsongs:addsongs, - allvideos:allvideos, - frontpage:frontpage, - skip:skipping, - vote:voting, - removeplay:removeplay, - shuffle:shuffling, - longsongs:longsongs, - adminpass:hash, - desc: description}}, function(err, docs){ - db.collection(coll).find({views:{$exists:true}}, function(err, docs) - { - io.to(coll).emit("conf", docs); - socket.emit("toast", "savedsettings"); - }); + check_inlist(coll, guid, socket, name); + + if(msg[2] == "del") + del(msg, socket); + else + { + var id = msg[1]; + var hash = hash_pass(msg[3]); + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + if(docs !== null && docs.length != 0 && ((docs[0]["vote"] == true && (hash == docs[0]["adminpass"] || docs[0]["adminpass"] == "")) + || docs[0]["vote"] == false)) + { + vote(coll, id, guid, socket); + }else{ + socket.emit("toast", "listhaspass"); + } + }); + } + } + }); + + socket.on('password', function(inp) + { + if(inp !== undefined && inp !== null && inp != "") + { + pw = inp[0]; + opw = inp[0]; + coll = inp[1]; + + check_inlist(coll, guid, socket, name); + + if(inp.length == 3) + { + opw = inp[2]; + } + + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + if(docs !== null && docs.length != 0) + { + if(docs[0]["adminpass"] == "" || docs[0]["adminpass"] == hash_pass(opw)) + { + db.collection(coll).update({views:{$exists:true}}, {$set:{adminpass:hash_pass(pw)}}, function(err, docs){ + if(inp.length == 3) + socket.emit("toast", "changedpass"); + else + socket.emit("toast", "correctpass"); + socket.emit("pw", pw); + }); + }else + socket.emit("toast", "wrongpass"); + } + }); + } + }); + + socket.on('skip', function(list) + { + if(list !== undefined && list !== null && list != "") + { + check_inlist(coll, guid, socket, name); + + adminpass = ""; + + var error = false; + if(list != "5" && list != "100" && list != "101" && list != "150" && list !== undefined) + { + adminpass = list[1]; + }else if(list == "5" || list == "100" || list == "101" || list == "150"){ + error = true; + } + + if(adminpass !== undefined && adminpass !== null && adminpass != "") + var hash = hash_pass(adminpass); + else + var hash = ""; + + db.collection(coll).find({views: {$exists:true}}, function(err, docs){ + if(docs !== null && docs.length != 0) + { + if(!docs[0]["skip"] || (docs[0]["adminpass"] == hash && docs[0]["adminpass"] != "") || error) + { + if((lists[coll].length/2 <= docs[0]["skips"].length+1 && !contains(docs[0]["skips"], guid) && lists[coll].length != 2) + || (lists[coll].length == 2 && docs[0]["skips"].length+1 == 2 && !contains(docs[0]["skips"], guid)) + || (docs[0]["adminpass"] == hash && docs[0]["adminpass"] != "" && docs[0]["skip"])) + { + change_song(coll); + socket.emit("toast", "skip"); + io.to(coll).emit('chat', [name, " skipped"]); + }else if(!contains(docs[0]["skips"], guid)){ + db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){ + if(lists[coll].length == 2) + to_skip = 1; + else + to_skip = (Math.ceil(lists[coll].length/2) - docs[0]["skips"].length-1); + socket.emit("toast", to_skip + " more are needed to skip!"); + socket.broadcast.to(coll).emit('chat', [name, " voted to skip"]); + }); + }else{ + socket.emit("toast", "alreadyskip"); + } + }else + socket.emit("toast", "noskip"); + } + }); + } + }); + + socket.on('conf', function(params) + { + if(params !== undefined && params !== null && params != "") + { + check_inlist(coll, guid, socket,name); + + var voting = params[0]; + var addsongs = params[1]; + var longsongs = params[2]; + var frontpage = params[3]; + var allvideos = params[4]; + var removeplay = params[5]; + var adminpass = params[6]; + var skipping = params[7]; + var shuffling = params[8]; + var description = ""; + if(params.length == 10) description = params[9]; + + if(adminpass != "") + var hash = hash_pass(adminpass); + else + var hash = adminpass; + + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + if(docs !== null && docs.length != 0 && docs[0]["adminpass"] == "" || docs[0]["adminpass"] == hash) + { + db.collection(coll).update({views:{$exists:true}}, { + $set:{addsongs:addsongs, + allvideos:allvideos, + frontpage:frontpage, + skip:skipping, + vote:voting, + removeplay:removeplay, + shuffle:shuffling, + longsongs:longsongs, + adminpass:hash, + desc: description + }}, function(err, docs){ + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + io.to(coll).emit("conf", docs); + socket.emit("toast", "savedsettings"); + }); + }); + }else{ + socket.emit("toast", "wrongpass"); + } + }); + } + }); + + socket.on('shuffle', function(pass) + { + if(pass !== undefined && pass !== null) + { + check_inlist(coll, guid, socket, name); + + if(pass == "") var hash = pass; + else var hash = hash_pass(pass); + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + if(docs !== null && docs.length != 0 && ((docs[0]["adminpass"] == hash || docs[0]["adminpass"] == "") || docs[0]["shuffle"] == false)) + { + db.collection(coll).find({now_playing:false}).forEach(function(err, docs){ + if(!docs){ + send_list(coll, undefined, false, true, false); + socket.emit("toast", "shuffled"); + return; + }else{ + num = Math.floor(Math.random()*1000000); + db.collection(coll).update({id:docs["id"]}, {$set:{added:num}}); + } + }); + }else + socket.emit("toast", "wrongpass"); }); - }else - { - socket.emit("toast", "wrongpass"); - } - }); - } - }); - - socket.on('shuffle', function(pass) - { - if(pass !== undefined && pass !== null) - { - check_inlist(coll, guid, socket, name); - - if(pass == "") var hash = pass; - else var hash = hash_pass(pass); - db.collection(coll).find({views:{$exists:true}}, function(err, docs){ - if(docs !== null && docs.length != 0 && ((docs[0]["adminpass"] == hash || docs[0]["adminpass"] == "") || docs[0]["shuffle"] == false)) - { - db.collection(coll).find({now_playing:false}).forEach(function(err, docs){ - if(!docs){ - send_list(coll, undefined, false, true, false); - socket.emit("toast", "shuffled"); - return; - }else{ - num = Math.floor(Math.random()*1000000); - db.collection(coll).update({id:docs["id"]}, {$set:{added:num}}); + var complete = function(tot, curr){ + if(tot == curr) + { + send_list(coll, undefined, false, true, false); + } } - }); }else - socket.emit("toast", "wrongpass"); - }); + socket.emit("toast", "wrongpass"); + }); - var complete = function(tot, curr){ - if(tot == curr) - { - send_list(coll, undefined, false, true, false); - } - }; - }else - socket.emit("toast", "wrongpass"); - }); - - socket.on('change_channel', function() - { - if(in_list) + socket.on('change_channel', function() { - if(contains(lists[coll], guid)) + if(in_list) { - var index = lists[coll].indexOf(guid); - if(index != -1) - { - lists[coll].splice(index, 1); - io.to(coll).emit("viewers", lists[coll].length); - io.to(coll).emit('chat', [name, " left"]); - socket.leave(coll); - } + if(contains(lists[coll], guid)) + { + var index = lists[coll].indexOf(guid); + if(index != -1) + { + lists[coll].splice(index, 1); + io.to(coll).emit("viewers", lists[coll].length); + io.to(coll).emit('chat', [name, " left"]); + socket.leave(coll); + } + } } + }); - } - }); + socket.on('disconnect', function() + { + left_channel(coll, guid, name, short_id); + }); - socket.on('disconnect', function() - { - left_channel(coll, guid, name, short_id); - }); + socket.on('reconnect_failed', function() + { + left_channel(coll, guid, name, short_id); + }); - socket.on('reconnect_failed', function() - { - left_channel(coll, guid, name, short_id); - }); + socket.on('connect_timeout', function() + { + left_channel(coll, guid, name, short_id); + }); - socket.on('connect_timeout', function() - { - left_channel(coll, guid, name, short_id); - }); + socket.on('error', function() + { + left_channel(coll, guid, name, short_id); + }); - socket.on('error', function() - { - left_channel(coll, guid, name, short_id); - }); - - socket.on('pos', function() - { - check_inlist(coll, guid, socket, name); - send_play(coll, socket); - }); + socket.on('pos', function() + { + check_inlist(coll, guid, socket, name); + send_play(coll, socket); + }); }); function left_channel(coll, guid, name, short_id) { - if(lists[coll] !== undefined && contains(lists[coll], guid)) - { - var index = lists[coll].indexOf(guid); - if(index != -1) + if(lists[coll] !== undefined && contains(lists[coll], guid)) { - lists[coll].splice(index, 1); - io.to(coll).emit("viewers", lists[coll].length); - io.to(coll).emit('chat', [name, " left"]); + var index = lists[coll].indexOf(guid); + if(index != -1) + { + lists[coll].splice(index, 1); + io.to(coll).emit("viewers", lists[coll].length); + io.to(coll).emit('chat', [name, " left"]); + } } - } - if(contains(unique_ids, short_id)) - { - var index = unique_ids.indexOf(guid); - if(index != -1) - lists[coll].splice(index, 1); - } + if(contains(unique_ids, short_id)) + { + var index = unique_ids.indexOf(guid); + if(index != -1) + lists[coll].splice(index, 1); + } } function del(params, socket) { - var coll = emojiStrip(params[0]).toLowerCase(); - coll = decodeURIComponent(coll); - coll = coll.replace(/\W/g, ''); - db.collection(coll).find({views:{$exists:true}}, function(err, docs){ - if(docs !== null && docs.length != 0 && docs[0]["adminpass"] == hash_pass(params[3])) - { - db.collection(coll).remove({id:params[1]}, function(err, docs){ - socket.emit("toast", "deletesong"); - io.to(coll).emit("channel", ["deleted", params[1]]); - }); - } - }); + var coll = emojiStrip(params[0]).toLowerCase(); + coll = decodeURIComponent(coll); + coll = coll.replace(/\W/g, ''); + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + if(docs !== null && docs.length != 0 && docs[0]["adminpass"] == hash_pass(params[3])) + { + db.collection(coll).remove({id:params[1]}, function(err, docs){ + socket.emit("toast", "deletesong"); + io.to(coll).emit("channel", ["deleted", params[1]]); + }); + } + }); } function check_inlist(coll, guid, socket, name) { - if(lists[coll] == undefined) - { - lists[coll] = []; - lists[coll].push(guid); - io.to(coll).emit("viewers", lists[coll].length); - socket.broadcast.to(coll).emit('chat', [name, " joined"]); - }else if(!contains(lists[coll], guid)) - { - lists[coll].push(guid); - io.to(coll).emit("viewers", lists[coll].length); - socket.broadcast.to(coll).emit('chat', [name, " joined"]); - } + if(lists[coll] == undefined) + { + lists[coll] = []; + lists[coll].push(guid); + io.to(coll).emit("viewers", lists[coll].length); + socket.broadcast.to(coll).emit('chat', [name, " joined"]); + }else if(!contains(lists[coll], guid)) + { + lists[coll].push(guid); + io.to(coll).emit("viewers", lists[coll].length); + socket.broadcast.to(coll).emit('chat', [name, " joined"]); + } } function hash_pass(adminpass) { - return crypto.createHash('sha256').update(adminpass).digest('base64'); + return crypto.createHash('sha256').update(adminpass).digest('base64'); } function vote(coll, id, guid, socket) @@ -625,156 +613,153 @@ function vote(coll, id, guid, socket) db.collection(coll).find({id:id}, function(err, docs){ if(docs !== null && docs.length > 0 && !contains(docs[0]["guids"], guid)) { - db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:get_time()}, $push :{guids: guid}}, function(err, docs) - { - socket.emit("toast", "voted"); - io.to(coll).emit("channel", ["vote", id, get_time()]); - }); - }else - { - socket.emit("toast", "alreadyvoted"); - } - }); + db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:get_time()}, $push :{guids: guid}}, function(err, docs) + { + socket.emit("toast", "voted"); + io.to(coll).emit("channel", ["vote", id, get_time()]); + }); + }else + { + socket.emit("toast", "alreadyvoted"); + } + }); } function change_song(coll, id, np_id) { - db.collection(coll).find({views:{$exists:true}}, function(err, docs){ - var startTime = docs[0]["startTime"]; - if(docs !== null && docs.length != 0) - { - if(docs[0]["removeplay"] == true) - { - db.collection(coll).remove({now_playing:true}, function(err, docs) + db.collection(coll).find({views:{$exists:true}}, function(err, docs){ + var startTime = docs[0]["startTime"]; + if(docs !== null && docs.length != 0) { - change_song_post(coll); - }) - }else - { - db.collection(coll).update({now_playing:true}, - {$set:{ - now_playing:false, - votes:0, - guids:[] - }},{multi:true}, function(err, docs) + if(docs[0]["removeplay"] == true) { - change_song_post(coll); - }); - } - } - }); + db.collection(coll).remove({now_playing:true}, function(err, docs){ + change_song_post(coll); + }); + }else{ + db.collection(coll).update({now_playing:true}, + {$set:{ + now_playing:false, + votes:0, + guids:[] + }},{multi:true}, function(err, docs){ + change_song_post(coll); + }); + } + } + }); } function change_song_post(coll) { db.collection(coll).aggregate([ - {$match:{now_playing:false}}, - {$sort:{votes:-1, added:1}}, - {$limit:1}], function(err, docs){ - if(docs !== null && docs.length > 0){ - db.collection(coll).update({id:docs[0]["id"]}, - {$set:{ - now_playing:true, - votes:0, - guids:[], - added:get_time()}}, function(err, docs){ - db.collection(coll).update({views:{$exists:true}}, - {$set:{startTime:get_time(), skips:[]}}, function(err, docs){ - io.to(coll).emit("channel", ["song_change", get_time()]); - send_play(coll); - }); - + {$match:{now_playing:false}}, + {$sort:{votes:-1, added:1}}, + {$limit:1 + }], function(err, docs){ + if(docs !== null && docs.length > 0){ + db.collection(coll).update({id:docs[0]["id"]}, + {$set:{ + now_playing:true, + votes:0, + guids:[], + added:get_time() + }}, function(err, docs){ + db.collection(coll).update({views:{$exists:true}}, + {$set:{startTime:get_time(), skips:[] + }}, function(err, docs){ + io.to(coll).emit("channel", ["song_change", get_time()]); + send_play(coll); + }); }); } - }); + }); } function send_list(coll, socket, send, list_send, configs) { - db.collection(coll).find({views:{$exists:false}}, function(err, docs) - { - if(list_send) - io.to(coll).emit("channel", ["list", docs]); - else if(!list_send) - socket.emit("channel",["list", docs]); - if(socket === undefined && send) - send_play(coll); - else if(send) - send_play(coll, socket); - }); - - if(configs) - { - db.collection(coll).find({views:{$exists:true}}, function(err, conf){ - if(conf[0].desc === undefined) - db.collection(coll).update({views:{$exists:true}}, {$set:{"desc":""}}); - //db.collection(coll).update({views:{$exists:true}}, {$set:{"desc":""}}, function(err, d){console.log(d)}); - io.to(coll).emit("conf", conf); + db.collection(coll).find({views:{$exists:false}}, function(err, docs) + { + if(list_send) + io.to(coll).emit("channel", ["list", docs]); + else if(!list_send) + socket.emit("channel",["list", docs]); + if(socket === undefined && send) + send_play(coll); + else if(send) + send_play(coll, socket); }); - } + if(configs) + { + db.collection(coll).find({views:{$exists:true}}, function(err, conf){ + if(conf[0].desc === undefined) + db.collection(coll).update({views:{$exists:true}}, {$set:{"desc":""}}); + //db.collection(coll).update({views:{$exists:true}}, {$set:{"desc":""}}, function(err, d){console.log(d)}); + io.to(coll).emit("conf", conf); + }); + } } function send_play(coll, socket) { - db.collection(coll).find({now_playing:true}, function(err, np){ - db.collection(coll).find({views:{$exists:true}}, function(err, conf){ - if(err !== null) console.log(err); - if(conf !== null && conf !== undefined && conf.length != 0) - { - toSend = [np,conf,get_time()]; - if(socket === undefined) - io.to(coll).emit("np", toSend); - else - socket.emit("np", toSend); - } - }); - }); + db.collection(coll).find({now_playing:true}, function(err, np){ + db.collection(coll).find({views:{$exists:true}}, function(err, conf){ + if(err !== null) console.log(err); + if(conf !== null && conf !== undefined && conf.length != 0) + { + toSend = [np,conf,get_time()]; + if(socket === undefined) + io.to(coll).emit("np", toSend); + else + socket.emit("np", toSend); + } + }); + }); } function get_time() { - var d = new Date(); - var time = Math.floor(d.getTime() / 1000); - return time; + var d = new Date(); + var time = Math.floor(d.getTime() / 1000); + return time; } function contains(a, obj) { var i = a.length; while (i--) { - if (a[i] === obj) { - return true; - } + if (a[i] === obj) { + return true; + } } return false; -} +} function rndName(seed, len) { - var vowels = ['a', 'e', 'i', 'o', 'u', 'aa', 'ae', 'oe']; - consts = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'tt', 'ch', 'sh']; - //len = 8; - len = Math.floor(len); - word = ''; - is_vowel = false; - var arr; - for (var i = 0; i < len; i++) { - if (is_vowel) arr = vowels - else arr = consts - is_vowel = !is_vowel; - word += arr[(seed[i%seed.length].charCodeAt()+i) % (arr.length-1)]; - } - return word + var vowels = ['a', 'e', 'i', 'o', 'u', 'aa', 'ae', 'oe']; + consts = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'tt', 'ch', 'sh']; + //len = 8; + len = Math.floor(len); + word = ''; + is_vowel = false; + var arr; + for (var i = 0; i < len; i++) { + if (is_vowel) arr = vowels; + else arr = consts; + is_vowel = !is_vowel; + word += arr[(seed[i%seed.length].charCodeAt()+i) % (arr.length-1)]; + } + return word } function uniqueID(seed, minlen){ - var len = minlen; - var id = rndName(seed, minlen); + var len = minlen; + var id = rndName(seed, minlen); - while( contains(unique_ids, id) && len<=8){ - id = rndName(String(len)+id, len); - len += 0.1; // try 10 times at each length - } - - return id; + while( contains(unique_ids, id) && len<=8){ + id = rndName(String(len)+id, len); + len += 0.1; // try 10 times at each length + } + return id; } From 6f20b1285e446c263bac84cdd3ef0f915f0f8972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 13 Nov 2015 23:40:14 +0100 Subject: [PATCH 03/27] Trying to fix pinned posts --- server/node_modules/cors-anywhere/.jshintrc | 0 server/node_modules/cors-anywhere/.npmignore | 0 server/node_modules/cors-anywhere/Procfile | 0 server/node_modules/cors-anywhere/README.md | 0 server/node_modules/cors-anywhere/demo.html | 0 .../node_modules/cors-anywhere/lib/cors-anywhere.js | 0 server/node_modules/cors-anywhere/lib/help.txt | 0 .../cors-anywhere/lib/regexp-top-level-domain.js | 0 .../node_modules/http-proxy/.npmignore | 0 .../cors-anywhere/node_modules/http-proxy/LICENSE | 0 .../cors-anywhere/node_modules/http-proxy/README.md | 0 .../cors-anywhere/node_modules/http-proxy/index.js | 0 .../node_modules/http-proxy/lib/http-proxy.js | 0 .../http-proxy/lib/http-proxy/common.js | 0 .../node_modules/http-proxy/lib/http-proxy/index.js | 0 .../lib/http-proxy/passes/web-incoming.js | 0 .../lib/http-proxy/passes/web-outgoing.js | 0 .../http-proxy/lib/http-proxy/passes/ws-incoming.js | 0 .../http-proxy/node_modules/eventemitter3/LICENSE | 0 .../http-proxy/node_modules/eventemitter3/README.md | 0 .../http-proxy/node_modules/eventemitter3/index.js | 0 .../node_modules/eventemitter3/package.json | 0 .../node_modules/requires-port/.npmignore | 0 .../node_modules/requires-port/.travis.yml | 0 .../http-proxy/node_modules/requires-port/LICENSE | 0 .../http-proxy/node_modules/requires-port/README.md | 0 .../http-proxy/node_modules/requires-port/index.js | 0 .../node_modules/requires-port/package.json | 0 .../http-proxy/node_modules/requires-port/test.js | 0 .../node_modules/http-proxy/package.json | 0 server/node_modules/cors-anywhere/package.json | 0 server/node_modules/cors-anywhere/server.js | 0 .../test-old-for-leak-testing/runner.js | 0 .../test-old-for-leak-testing/sub-no-cors-server.js | 0 .../test-old-for-leak-testing/sub-server.js | 0 server/node_modules/cors-anywhere/test/cert.pem | 0 server/node_modules/cors-anywhere/test/child.js | 0 server/node_modules/cors-anywhere/test/dummy.txt | 0 server/node_modules/cors-anywhere/test/key.pem | 0 server/node_modules/cors-anywhere/test/setup.js | 0 .../node_modules/cors-anywhere/test/test-memory.js | 0 server/node_modules/cors-anywhere/test/test.js | 0 server/node_modules/emoji-strip/.npmignore | 0 server/node_modules/emoji-strip/LICENSE | 0 server/node_modules/emoji-strip/README.md | 0 .../emoji-strip/emoji-strip.sublime-project | 0 .../emoji-strip/emoji-strip.sublime-workspace | 0 .../emoji-strip/examples/emoji-strip.js | 0 server/node_modules/emoji-strip/index.js | 0 .../emoji-strip/node_modules/gemoji/.jscs.json | 0 .../emoji-strip/node_modules/gemoji/.npmignore | 0 .../emoji-strip/node_modules/gemoji/History.md | 0 .../emoji-strip/node_modules/gemoji/LICENSE | 0 .../emoji-strip/node_modules/gemoji/Readme.md | 0 .../node_modules/gemoji/Supported-Gemoji.md | 0 .../emoji-strip/node_modules/gemoji/bower.json | 0 .../emoji-strip/node_modules/gemoji/build-data.js | 0 .../node_modules/gemoji/build-supported-gemoji.js | 0 .../emoji-strip/node_modules/gemoji/component.json | 0 .../node_modules/gemoji/data/gemoji.json | 0 .../emoji-strip/node_modules/gemoji/index.js | 0 .../emoji-strip/node_modules/gemoji/package.json | 0 server/node_modules/emoji-strip/package.json | 0 .../node_modules/emoji-strip/tests/emoji-strip.js | 0 server/server.js | 3 +-- static/css/materialize.css | 0 static/css/materialize.min.css | 0 static/dist/frontpage.min.js | 2 +- static/dist/lib/materialize.js | 0 static/dist/lib/materialize.min.js | 0 static/dist/main.min.js | 2 +- static/font/material-design-icons/LICENSE.txt | 0 .../material-design-icons/Material-Design-Icons.eot | Bin .../material-design-icons/Material-Design-Icons.svg | 0 .../material-design-icons/Material-Design-Icons.ttf | Bin .../Material-Design-Icons.woff | Bin .../Material-Design-Icons.woff2 | Bin static/font/roboto/Roboto-Bold.ttf | Bin static/font/roboto/Roboto-Bold.woff | Bin static/font/roboto/Roboto-Bold.woff2 | Bin static/font/roboto/Roboto-Light.ttf | Bin static/font/roboto/Roboto-Light.woff | Bin static/font/roboto/Roboto-Light.woff2 | Bin static/font/roboto/Roboto-Medium.ttf | Bin static/font/roboto/Roboto-Medium.woff | Bin static/font/roboto/Roboto-Medium.woff2 | Bin static/font/roboto/Roboto-Regular.ttf | Bin static/font/roboto/Roboto-Regular.woff | Bin static/font/roboto/Roboto-Regular.woff2 | Bin static/font/roboto/Roboto-Thin.ttf | Bin static/font/roboto/Roboto-Thin.woff | Bin static/font/roboto/Roboto-Thin.woff2 | Bin static/images/loading.png | Bin static/images/pin.png | Bin static/js/nochan.js | 1 + 95 files changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 server/node_modules/cors-anywhere/.jshintrc mode change 100644 => 100755 server/node_modules/cors-anywhere/.npmignore mode change 100644 => 100755 server/node_modules/cors-anywhere/Procfile mode change 100644 => 100755 server/node_modules/cors-anywhere/README.md mode change 100644 => 100755 server/node_modules/cors-anywhere/demo.html mode change 100644 => 100755 server/node_modules/cors-anywhere/lib/cors-anywhere.js mode change 100644 => 100755 server/node_modules/cors-anywhere/lib/help.txt mode change 100644 => 100755 server/node_modules/cors-anywhere/lib/regexp-top-level-domain.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/.npmignore mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/LICENSE mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/README.md mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/index.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/common.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/index.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/LICENSE mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/README.md mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/index.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/package.json mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/.npmignore mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/.travis.yml mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/LICENSE mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/README.md mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/index.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/package.json mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/test.js mode change 100644 => 100755 server/node_modules/cors-anywhere/node_modules/http-proxy/package.json mode change 100644 => 100755 server/node_modules/cors-anywhere/package.json mode change 100644 => 100755 server/node_modules/cors-anywhere/server.js mode change 100644 => 100755 server/node_modules/cors-anywhere/test-old-for-leak-testing/runner.js mode change 100644 => 100755 server/node_modules/cors-anywhere/test-old-for-leak-testing/sub-no-cors-server.js mode change 100644 => 100755 server/node_modules/cors-anywhere/test-old-for-leak-testing/sub-server.js mode change 100644 => 100755 server/node_modules/cors-anywhere/test/cert.pem mode change 100644 => 100755 server/node_modules/cors-anywhere/test/child.js mode change 100644 => 100755 server/node_modules/cors-anywhere/test/dummy.txt mode change 100644 => 100755 server/node_modules/cors-anywhere/test/key.pem mode change 100644 => 100755 server/node_modules/cors-anywhere/test/setup.js mode change 100644 => 100755 server/node_modules/cors-anywhere/test/test-memory.js mode change 100644 => 100755 server/node_modules/cors-anywhere/test/test.js mode change 100644 => 100755 server/node_modules/emoji-strip/.npmignore mode change 100644 => 100755 server/node_modules/emoji-strip/LICENSE mode change 100644 => 100755 server/node_modules/emoji-strip/README.md mode change 100644 => 100755 server/node_modules/emoji-strip/emoji-strip.sublime-project mode change 100644 => 100755 server/node_modules/emoji-strip/emoji-strip.sublime-workspace mode change 100644 => 100755 server/node_modules/emoji-strip/examples/emoji-strip.js mode change 100644 => 100755 server/node_modules/emoji-strip/index.js mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/.jscs.json mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/.npmignore mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/History.md mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/LICENSE mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/Readme.md mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/Supported-Gemoji.md mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/bower.json mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/build-data.js mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/build-supported-gemoji.js mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/component.json mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/data/gemoji.json mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/index.js mode change 100644 => 100755 server/node_modules/emoji-strip/node_modules/gemoji/package.json mode change 100644 => 100755 server/node_modules/emoji-strip/package.json mode change 100644 => 100755 server/node_modules/emoji-strip/tests/emoji-strip.js mode change 100644 => 100755 static/css/materialize.css mode change 100644 => 100755 static/css/materialize.min.css mode change 100644 => 100755 static/dist/lib/materialize.js mode change 100644 => 100755 static/dist/lib/materialize.min.js mode change 100644 => 100755 static/font/material-design-icons/LICENSE.txt mode change 100644 => 100755 static/font/material-design-icons/Material-Design-Icons.eot mode change 100644 => 100755 static/font/material-design-icons/Material-Design-Icons.svg mode change 100644 => 100755 static/font/material-design-icons/Material-Design-Icons.ttf mode change 100644 => 100755 static/font/material-design-icons/Material-Design-Icons.woff mode change 100644 => 100755 static/font/material-design-icons/Material-Design-Icons.woff2 mode change 100644 => 100755 static/font/roboto/Roboto-Bold.ttf mode change 100644 => 100755 static/font/roboto/Roboto-Bold.woff mode change 100644 => 100755 static/font/roboto/Roboto-Bold.woff2 mode change 100644 => 100755 static/font/roboto/Roboto-Light.ttf mode change 100644 => 100755 static/font/roboto/Roboto-Light.woff mode change 100644 => 100755 static/font/roboto/Roboto-Light.woff2 mode change 100644 => 100755 static/font/roboto/Roboto-Medium.ttf mode change 100644 => 100755 static/font/roboto/Roboto-Medium.woff mode change 100644 => 100755 static/font/roboto/Roboto-Medium.woff2 mode change 100644 => 100755 static/font/roboto/Roboto-Regular.ttf mode change 100644 => 100755 static/font/roboto/Roboto-Regular.woff mode change 100644 => 100755 static/font/roboto/Roboto-Regular.woff2 mode change 100644 => 100755 static/font/roboto/Roboto-Thin.ttf mode change 100644 => 100755 static/font/roboto/Roboto-Thin.woff mode change 100644 => 100755 static/font/roboto/Roboto-Thin.woff2 mode change 100644 => 100755 static/images/loading.png mode change 100644 => 100755 static/images/pin.png diff --git a/server/node_modules/cors-anywhere/.jshintrc b/server/node_modules/cors-anywhere/.jshintrc old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/.npmignore b/server/node_modules/cors-anywhere/.npmignore old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/Procfile b/server/node_modules/cors-anywhere/Procfile old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/README.md b/server/node_modules/cors-anywhere/README.md old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/demo.html b/server/node_modules/cors-anywhere/demo.html old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/lib/cors-anywhere.js b/server/node_modules/cors-anywhere/lib/cors-anywhere.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/lib/help.txt b/server/node_modules/cors-anywhere/lib/help.txt old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/lib/regexp-top-level-domain.js b/server/node_modules/cors-anywhere/lib/regexp-top-level-domain.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/.npmignore b/server/node_modules/cors-anywhere/node_modules/http-proxy/.npmignore old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/LICENSE b/server/node_modules/cors-anywhere/node_modules/http-proxy/LICENSE old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/README.md b/server/node_modules/cors-anywhere/node_modules/http-proxy/README.md old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/index.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/index.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/common.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/common.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/index.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/index.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/LICENSE b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/LICENSE old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/README.md b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/README.md old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/index.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/index.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/package.json b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/eventemitter3/package.json old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/.npmignore b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/.npmignore old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/.travis.yml b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/.travis.yml old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/LICENSE b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/LICENSE old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/README.md b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/README.md old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/index.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/index.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/package.json b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/package.json old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/test.js b/server/node_modules/cors-anywhere/node_modules/http-proxy/node_modules/requires-port/test.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/node_modules/http-proxy/package.json b/server/node_modules/cors-anywhere/node_modules/http-proxy/package.json old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/package.json b/server/node_modules/cors-anywhere/package.json old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/server.js b/server/node_modules/cors-anywhere/server.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test-old-for-leak-testing/runner.js b/server/node_modules/cors-anywhere/test-old-for-leak-testing/runner.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test-old-for-leak-testing/sub-no-cors-server.js b/server/node_modules/cors-anywhere/test-old-for-leak-testing/sub-no-cors-server.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test-old-for-leak-testing/sub-server.js b/server/node_modules/cors-anywhere/test-old-for-leak-testing/sub-server.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test/cert.pem b/server/node_modules/cors-anywhere/test/cert.pem old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test/child.js b/server/node_modules/cors-anywhere/test/child.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test/dummy.txt b/server/node_modules/cors-anywhere/test/dummy.txt old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test/key.pem b/server/node_modules/cors-anywhere/test/key.pem old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test/setup.js b/server/node_modules/cors-anywhere/test/setup.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test/test-memory.js b/server/node_modules/cors-anywhere/test/test-memory.js old mode 100644 new mode 100755 diff --git a/server/node_modules/cors-anywhere/test/test.js b/server/node_modules/cors-anywhere/test/test.js old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/.npmignore b/server/node_modules/emoji-strip/.npmignore old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/LICENSE b/server/node_modules/emoji-strip/LICENSE old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/README.md b/server/node_modules/emoji-strip/README.md old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/emoji-strip.sublime-project b/server/node_modules/emoji-strip/emoji-strip.sublime-project old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/emoji-strip.sublime-workspace b/server/node_modules/emoji-strip/emoji-strip.sublime-workspace old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/examples/emoji-strip.js b/server/node_modules/emoji-strip/examples/emoji-strip.js old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/index.js b/server/node_modules/emoji-strip/index.js old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/.jscs.json b/server/node_modules/emoji-strip/node_modules/gemoji/.jscs.json old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/.npmignore b/server/node_modules/emoji-strip/node_modules/gemoji/.npmignore old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/History.md b/server/node_modules/emoji-strip/node_modules/gemoji/History.md old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/LICENSE b/server/node_modules/emoji-strip/node_modules/gemoji/LICENSE old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/Readme.md b/server/node_modules/emoji-strip/node_modules/gemoji/Readme.md old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/Supported-Gemoji.md b/server/node_modules/emoji-strip/node_modules/gemoji/Supported-Gemoji.md old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/bower.json b/server/node_modules/emoji-strip/node_modules/gemoji/bower.json old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/build-data.js b/server/node_modules/emoji-strip/node_modules/gemoji/build-data.js old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/build-supported-gemoji.js b/server/node_modules/emoji-strip/node_modules/gemoji/build-supported-gemoji.js old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/component.json b/server/node_modules/emoji-strip/node_modules/gemoji/component.json old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/data/gemoji.json b/server/node_modules/emoji-strip/node_modules/gemoji/data/gemoji.json old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/index.js b/server/node_modules/emoji-strip/node_modules/gemoji/index.js old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/node_modules/gemoji/package.json b/server/node_modules/emoji-strip/node_modules/gemoji/package.json old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/package.json b/server/node_modules/emoji-strip/package.json old mode 100644 new mode 100755 diff --git a/server/node_modules/emoji-strip/tests/emoji-strip.js b/server/node_modules/emoji-strip/tests/emoji-strip.js old mode 100644 new mode 100755 diff --git a/server/server.js b/server/server.js index 1ff1cd22..a17a3e22 100755 --- a/server/server.js +++ b/server/server.js @@ -67,7 +67,7 @@ db.on('error',function(err) { }); io.on('connection', function(socket){ - console.log("connection"); + socket.emit("get_list"); var guid = hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); @@ -112,7 +112,6 @@ io.on('connection', function(socket){ socket.on('frontpage_lists', function() { - console.log("connected"); var playlists_to_send = []; var i = 0; var playlists_to_send = []; diff --git a/static/css/materialize.css b/static/css/materialize.css old mode 100644 new mode 100755 diff --git a/static/css/materialize.min.css b/static/css/materialize.min.css old mode 100644 new mode 100755 diff --git a/static/dist/frontpage.min.js b/static/dist/frontpage.min.js index d2af8345..3a3169d7 100755 --- a/static/dist/frontpage.min.js +++ b/static/dist/frontpage.min.js @@ -1 +1 @@ -!function(){var e,t,o={populate_channels:function(t){var n,a="",s=0;1==t[0][5]&&(n=t.shift()),t.sort(o.sortFunction),void 0!==n&&t.unshift(n),pre_card=$(e);for(x in t){var i=t[x][3];if(20>s){var l=t[x][1],r=t[x][0],c="background-image:url('https://img.youtube.com/vi/"+l+"/hqdefault.jpg');",d=t[x][4],u=pre_card;1==t[x][5]?(u.find(".pin").attr("style","display:block;"),u.find(".card").attr("title","Pinned!")):(u.find(".pin").attr("style","display:none;"),u.find(".card").attr("title","")),u.find(".chan-name").text(i),u.find(".chan-name").attr("title",i),u.find(".chan-views").text(r),u.find(".chan-songs").text(d),u.find(".chan-bg").attr("style",c),u.find(".chan-link").attr("href",i),$("#channels").append(u.html())}a+="