Files
zoff/static/dist/frontpage.min.js
Kasper Rynning-Tønnesen d96dbe99a9 Cleaning up logs
2015-11-13 23:59:26 +01:00

1 line
2.5 KiB
JavaScript
Executable File

!function(){var e,t,o={populate_channels:function(t){var n,a="",i=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 s=t[x][3];if(20>i){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(s),u.find(".chan-name").attr("title",s),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",s),$("#channels").append(u.html())}a+="<option value='"+s+"'> ",i++}document.getElementById("preloader").style.display="none",document.getElementById("searches").innerHTML=a,$("#channels").fadeIn(800),$("#search").focus()},sortFunction:function(e,t){var o=e[0],n=t[0],a=e[4],i=t[4];return n>o?1:o>n?-1:i>a?1:a>i?-1:0},getCookie:function(e){for(var t=e+"=",o=document.cookie.split(";"),n=0;n<o.length;n++){for(var a=o[n];" "==a.charAt(0);)a=a.substring(1);if(0==a.indexOf(t))return a.substring(t.length,a.length)}return""}};String.prototype.capitalizeFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)},$(document).ready(function(){"#donation"==window.location.hash&&$("#donation").openModal(),e=$("#channel-list-container").html(),window.list_html=e,$("#channels").empty();var n=io.connect("//"+window.location.hostname+":8880");n.emit("frontpage_lists"),n.on("playlists",function(e){o.populate_channels(e)});var a=0;if(document.getElementById("zicon").addEventListener("click",function(){a+=10,document.getElementById("zicon").style.paddingLeft=a+"%",a>=100&&(window.location.href="https://www.youtube.com/v/0IGsNdVoEh0?autoplay=1&showinfo=0&autohide=1")}),navigator.userAgent.toLowerCase().indexOf("android")>-1&&""==o.getCookie("show_prompt")){var i=confirm("Do you want to download the native app for this webpage?");if(i)window.location.href="https://play.google.com/store/apps/details?id=no.lqasse.zoff";else{var s=new Date;s.setTime(s.getTime()+864e6);var l="expires="+s.toUTCString();document.cookie="show_prompt=false;"+l}}t=$.ajax({type:"GET",url:"https://api.github.com/repos/zoff-music/zoff/commits",async:!1}).responseText,t=$.parseJSON(t),$("#latest-commit").html("Latest Commit: <br>"+t[0].commit.author.date.substring(0,10)+": "+t[0].committer.login+"<br><a href='"+t[0].html_url+"'>"+t[0].sha.substring(0,10)+"</a>: "+t[0].commit.message+"<br")})}();