Files
zoff/static/dist/frontpage.min.js
Kasper Rynning-Tønnesen 6f20b1285e Trying to fix pinned posts
2015-11-13 23:40:14 +01:00

1 line
2.5 KiB
JavaScript
Executable File

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