//script for frontpage var list_html; var git_info; /* function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i "; num++; //if(num>19)break; } document.getElementById("preloader").style.display = "none"; document.getElementById("searches").innerHTML = output; //Materialize.fadeInImage('#channels'); $("#channels").fadeIn(800); $("#search").focus(); }, sortFunction: function(a, b) { var o1 = a[0]; var o2 = b[0]; var p1 = a[4]; var p2 = b[4]; if (o1 < o2) return 1; if (o1 > o2) return -1; if (p1 < p2) return 1; if (p1 > p2) return -1; return 0; }, getCookie: function(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i= list.length || i >= 8) i = 0; var id = list[i][1]; if(Nochan.blob_list[i] !== undefined){ //$(".room-namer").css("opacity", 0); setTimeout(function(){ $("#mega-background").css("background", "url(data:image/png;base64,"+Nochan.blob_list[i]+")"); $("#mega-background").css("background-size" , "200%"); $("#mega-background").css("opacity", 1); $("#search").attr("placeholder", list[i][3]); //$(".room-namer").css("opacity", 1); },500); }else{ var img = new Image(); img.src = "/static/images/thumbnails/"+id+".jpg"; img.onerror = function(){ // Failed to load $.ajax({ type: "POST", data: {id:id}, url: "/php/imageblob.php", success: function(data){ Nochan.blob_list.push(data); //data will contain the vote count echoed by the controller i.e. //$(".room-namer").css("opacity", 0); setTimeout(function(){ $("#mega-background").css("background", "url(data:image/png;base64,"+data+")"); $("#mega-background").css("background-size" , "200%"); $("#mega-background").css("opacity", 1); $("#search").attr("placeholder", list[i][3]); //$(".room-namer").css("opacity", 1); },500); //then append the result where ever you want like //$("span#votes_number").html(data); //data will be containing the vote count which you have echoed from the controller } }); }; img.onload = function(){ // Loaded successfully $("#mega-background").css("background", "url("+img.src+")"); $("#mega-background").css("background-size" , "200%"); $("#mega-background").css("opacity", 1); $("#search").attr("placeholder", list[i][3]); }; } setTimeout(function(){ Nochan.add_backdrop(list, i+1); },6000); }, start_snowfall: function(){ setTimeout(function(){ var x = Math.floor((Math.random() * window.innerWidth) + 1); var snow = document.createElement("div"); var parent = document.getElementsByClassName("mega")[0]; snow.className = "snow"; //snow.attr("left", x); snow.style.left = x+"px"; snow.style.top = "0px"; parent.appendChild(snow); Nochan.fall_snow(snow); Nochan.start_snowfall(); }, 800); }, fall_snow: function(corn){ corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px"; if(parseInt(corn.style.top.replace("px", "")) < document.getElementById("mega-background").offsetHeight-2.5){ setTimeout(function(){ Nochan.fall_snow(corn); },50); }else{ corn.remove(); } }, to_channel: function(chan, popstate){ $("#channel-load").css("display", "block"); $.ajax({ url: chan + "/php/channel.php", success: function(e){ delete Nochan socket.disconnect(); if(!popstate) window.history.pushState("to the channel!", "Title", "/" + chan); $.holdReady(true); $(".mega").remove(); $(".mobile-search").remove(); $("main").attr("class", "container center-align main"); $("body").attr("id", "channelpage"); $("header").html($($(e)[0]).html()); $("main").html($($(e)[2]).html()); $("#scripts").html($($(e)[4]).html()); } }); } } window.onpopstate = function(e){ var url_split = window.location.href.split("/"); if(url_split[3] != "" || url_split[3].substring(0,1) != "#"){ Nochan.to_channel(url_split[3], true); } } String.prototype.capitalizeFirstLetter = function() { return this.charAt(0).toUpperCase() + this.slice(1); } $(document).ready(function (){ //Materialize.toast("Try out our new feature, remote!", 8000) if(window.location.hash == "#donation") $('#donation').openModal() list_html = $("#channel-list-container").html(); window.list_html = list_html; $("#channels").empty(); var connection_options = { 'secure': true, 'force new connection': true }; if(window.location.hostname == "zoff.no") add = "https://zoff.no"; else add = "localhost"; var socket = io.connect(''+add+':8880', connection_options); socket.emit('frontpage_lists'); socket.on('playlists', function(msg){ Nochan.populate_channels(msg); }); window.socket = socket; if(!localStorage["ok_cookie"]) Materialize.toast("We're using cookies to enhance your experience! ok", 10000); var pad = 0; document.getElementById("zicon").addEventListener("click", function(){ pad+=10; document.getElementById("zicon").style.paddingLeft = pad+"%"; if(pad >= 100) window.location.href = 'https://www.youtube.com/v/0IGsNdVoEh0?autoplay=1&showinfo=0&autohide=1'; }); if(!window.mobilecheck() && Nochan.winter) Nochan.start_snowfall(); /*if(navigator.userAgent.toLowerCase().indexOf("android") > -1){ //console.log("android"); if(Nochan.getCookie("show_prompt") == ""){ var r = confirm("Do you want to download the native app for this webpage?"); if(r) window.location.href = 'https://play.google.com/store/apps/details?id=no.lqasse.zoff'; else { var d = new Date(); d.setTime(d.getTime() + (10*24*60*60*1000)); var expires = "expires="+d.toUTCString(); document.cookie = "show_prompt=false;"+expires; } } }*/ git_info = $.ajax({ type: "GET", url: "https://api.github.com/repos/zoff-music/zoff/commits", async: false }).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+"