Improved performance on server on frontpage a bit

This commit is contained in:
Kasper Rynning-Tønnesen
2017-09-11 09:52:58 +02:00
parent 2673892974
commit 052cdc229a
7 changed files with 65 additions and 71 deletions

View File

@@ -1 +1 @@
!function(){function e(e){var t,a=e.substring(1).split("&"),n={};for(var o in a)t=a[o].split("="),2==t.length&&(n[t[0]]=t[1]);return n}window.addEventListener("load",function(){var t,a,n,o=e(window.location.hash),s=window.location.protocol+"//"+window.location.hostname+"/o_callback";if(o.spotify)t="b934ecdd173648f5bcd38738af529d58",a="token",n="playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public",state=o.nonce,window.location.href="https://accounts.spotify.com/authorize?client_id="+t+"&scope="+n+"&show_dialog=false&response_type="+a+"&redirect_uri="+s+"&state="+state;else if(o.youtube)t="944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com",a="token",n="https://www.googleapis.com/auth/youtube",state=o.nonce,window.location.href="https://accounts.google.com/o/oauth2/v2/auth?client_id="+t+"&response_type="+a+"&state="+state+"&redirect_uri="+s+"&scope="+n;else{var i=e(window.location.hash);window.opener.callback(i)}})}();
!function(){function e(e){var t,a=e.substring(1).split("&"),n={};for(var s in a)t=a[s].split("="),2==t.length&&(n[t[0]]=t[1]);return n}window.addEventListener("load",function(){var t,a,n,s=e(window.location.hash),i=window.location.protocol+"//"+window.location.hostname+"/o_callback";if(s.spotify)t="b934ecdd173648f5bcd38738af529d58",a="token",n="playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public",state=s.nonce,window.location.href="https://accounts.spotify.com/authorize?client_id="+t+"&scope="+n+"&show_dialog=false&response_type="+a+"&redirect_uri="+i+"&state="+state;else if(s.youtube)t="944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com",a="token",n="https://www.googleapis.com/auth/youtube",state=s.nonce,window.location.href="https://accounts.google.com/o/oauth2/v2/auth?client_id="+t+"&response_type="+a+"&state="+state+"&redirect_uri="+i+"&scope="+n;else{var o=e(window.location.hash);window.opener.callback(o)}})}();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -34,12 +34,21 @@ var Frontpage = {
var num = 0;
var pinned;
if(lists[0].pinned == 1){
pinned = lists.shift();
for(var i = 0; i < lists.length; i++) {
if(!lists[i].hasOwnProperty("viewers")){
lists[i].viewers = 0;
}
if(!lists[i].hasOwnProperty("pinned")){
lists[i].pinned = 0;
}
}
if(popular) {
lists = lists.sort(Helper.predicate({
name: 'pinned',
reverse: true
}, {
name: 'viewers',
reverse: true
}, {
@@ -51,6 +60,9 @@ var Frontpage = {
}));
} else {
lists = lists.sort(Helper.predicate({
name: 'pinned',
reverse: true
}, {
name: 'viewers',
reverse: true
}, {
@@ -77,7 +89,7 @@ var Frontpage = {
for(var x in lists)
{
var chan = lists[x].channel;
var chan = lists[x]._id;
if(num<12 || !popular)
{
var id = lists[x].id;
@@ -90,8 +102,6 @@ var Frontpage = {
var song_count = lists[x].count;
//$("#channels").append(channel_list);
var card = pre_card.clone();
if(lists[x].pinned == 1)
{
@@ -110,7 +120,7 @@ var Frontpage = {
card.find(".chan-bg").attr("style", img);
card.find(".chan-link").attr("href", chan + "/");
if(description != "" && !Helper.mobilecheck()){
if(description != "" && description != undefined && !Helper.mobilecheck()){
card.find(".card-title").text(chan);
card.find(".description_text").text(description);
description = "";

View File

@@ -102,7 +102,6 @@ var Helper = {
hslToRgb: function(h, s, l) {
var r, g, b;
console.log(h, s, l);
if (s == 0) {
r = g = b = l; // achromatic

View File

@@ -1,4 +1,4 @@
var VERSION = 2;
var VERSION = 3;
var chan = window.chan === undefined ? $("#chan").html() : window.chan;
var w_p = true;
var hasadmin = 0;
@@ -126,7 +126,7 @@ $.ajaxPrefilter(function( options, original_Options, jqXHR ) {
});
$().ready(function(){
if(!localStorage.getItem("VERSION") || parseInt(localStorage.getItem("VERSION")) != 2) {
if(!localStorage.getItem("VERSION") || parseInt(localStorage.getItem("VERSION")) != VERSION) {
localStorage.setItem("VERSION", VERSION);
}
if(!fromFront && window.location.pathname != "/") init();