mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Trying to improve frontpage fetching
This commit is contained in:
@@ -3,19 +3,23 @@ var frontpage_lists = function(msg, socket) {
|
||||
socket.emit("update_required");
|
||||
}
|
||||
|
||||
db.collection("frontpage_lists").find({frontpage:true, count: {$gt: 0}}, function(err, docs){
|
||||
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot){
|
||||
socket.emit("playlists", {channels: docs, viewers: tot[0].total_users});
|
||||
});
|
||||
console.log("gotten second ", Functions.get_time());
|
||||
db.collection("frontpage_lists").find({frontpage:true, count: {$ne: 0}}, function(err, docs){
|
||||
console.log("gotten third ", Functions.get_time());
|
||||
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot){
|
||||
console.log("sending frontpage ", Functions.get_time());
|
||||
socket.compress(true).emit("playlists", {channels: docs, viewers: tot[0].total_users});
|
||||
console.log("sent frontpage ", Functions.get_time());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function update_frontpage(coll, id, title) {
|
||||
db.collection("frontpage_lists").update({_id: coll}, {$set: {
|
||||
id: id,
|
||||
title: title,
|
||||
accessed: Functions.get_time()}
|
||||
},{upsert: true}, function(err, returnDocs){});
|
||||
db.collection("frontpage_lists").update({_id: coll}, {$set: {
|
||||
id: id,
|
||||
title: title,
|
||||
accessed: Functions.get_time()}
|
||||
},{upsert: true}, function(err, returnDocs){});
|
||||
}
|
||||
|
||||
module.exports.update_frontpage = update_frontpage;
|
||||
|
||||
@@ -65,12 +65,6 @@ module.exports = function() {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("get_userlists", function(id) {
|
||||
db.collection("frontpage_lists_" + id).find(function(err, docs) {
|
||||
socket.emit("userlists", [docs]);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on("get_spread", function(){
|
||||
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot) {
|
||||
db.collection("connected_users").find({"_id": "offline_users"}, function(err, off) {
|
||||
@@ -157,6 +151,7 @@ module.exports = function() {
|
||||
|
||||
socket.on('frontpage_lists', function(msg)
|
||||
{
|
||||
console.log("First gotten", Functions.get_time());
|
||||
Frontpage.frontpage_lists(msg, socket);
|
||||
});
|
||||
|
||||
@@ -371,38 +366,6 @@ module.exports = function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
/*ping_timeout = setTimeout(function() {
|
||||
send_ping(guid, coll, socket);
|
||||
}, 3000);
|
||||
|
||||
var send_ping = function(guid, coll, socket) {
|
||||
console.log(guid, coll);
|
||||
if(coll == undefined) {
|
||||
ping_timeout = setTimeout(function(){
|
||||
send_ping(guid, coll, socket);
|
||||
}, 3000);
|
||||
} else {
|
||||
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, docs) {
|
||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, docs) {
|
||||
db.collection("frontpage_lists").update({"_id": coll, viewers: {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) {
|
||||
db.collection("user_names").find({"guid": guid}, function(err, user_name) {
|
||||
if(user_name.length > 0) {
|
||||
name = user_name[0].name;
|
||||
db.collection("user_names").remove({"guid": guid}, function(err, docs) {
|
||||
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: user_name[0].name}}, function(err, docs) {
|
||||
socket.emit("self_ping");
|
||||
ping_timeout = setTimeout(function(){
|
||||
send_ping(guid, coll, socket);
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}*/
|
||||
});
|
||||
|
||||
send_ping();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"node-cryptojs-aes": "^0.4.0",
|
||||
"nodemailer": "^4.0.1",
|
||||
"request": "^2.72.0",
|
||||
"socket.io": "^2.0.1",
|
||||
"socket.io": "^2.0.3",
|
||||
"uniqid": "^4.1.1"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
2
server/public/assets/dist/embed.min.js
vendored
2
server/public/assets/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
2
server/public/assets/dist/main.min.js
vendored
2
server/public/assets/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -29,7 +29,7 @@ var Crypt = {
|
||||
|
||||
Hostcontroller.change_enabled(conf_arr.remote);
|
||||
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
|
||||
if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
|
||||
//if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ var Frontpage = {
|
||||
num++;
|
||||
//if(num>19)break;
|
||||
}
|
||||
|
||||
var options_list = lists.slice();
|
||||
|
||||
options_list = options_list.sort(Frontpage.sortFunction_active);
|
||||
@@ -153,13 +154,13 @@ var Frontpage = {
|
||||
var to_autocomplete = "input.desktop-search";
|
||||
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
|
||||
|
||||
$(to_autocomplete).autocomplete({
|
||||
/*$(to_autocomplete).autocomplete({
|
||||
data: data,
|
||||
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
|
||||
onAutocomplete: function(val) {
|
||||
Frontpage.to_channel(val, false);
|
||||
},
|
||||
});
|
||||
});*/
|
||||
|
||||
//$(".autocomplete").off('keydown.autocomplete');
|
||||
|
||||
@@ -445,7 +446,7 @@ function initfp(){
|
||||
tooltip: "Total Viewers"
|
||||
});
|
||||
socket.emit('frontpage_lists', {version: parseInt(localStorage.getItem("VERSION"))});
|
||||
socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
||||
//socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
||||
|
||||
$("#channel-load").css("display", "none");
|
||||
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
|
||||
|
||||
@@ -154,11 +154,11 @@ $().ready(function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
if(conf_arr != undefined && conf_arr.name !== undefined && conf_arr.name !== "") {
|
||||
/*if(conf_arr != undefined && conf_arr.name !== undefined && conf_arr.name !== "") {
|
||||
setTimeout(function(){
|
||||
Chat.namechange(conf_arr.name);
|
||||
}, 1000);
|
||||
}
|
||||
}*/
|
||||
});
|
||||
|
||||
socket.on("self_ping", function() {
|
||||
@@ -169,7 +169,7 @@ $().ready(function(){
|
||||
|
||||
setup_no_connection_listener();
|
||||
|
||||
try{
|
||||
/*try{
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "https://api.github.com/users/zoff-music/received_events",
|
||||
@@ -189,7 +189,7 @@ $().ready(function(){
|
||||
});
|
||||
} catch(error){
|
||||
Helper.log("Error with fetching GitHub commit info");
|
||||
}
|
||||
}*/
|
||||
});
|
||||
|
||||
|
||||
@@ -735,6 +735,7 @@ function setup_list_listener(){
|
||||
|
||||
function setup_playlist_listener(){
|
||||
Helper.log("Setting up playlist_listener");
|
||||
console.log("asd");
|
||||
socket.on('playlists', Frontpage.frontpage_function);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<script type="text/javascript" src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.js"></script>
|
||||
<script type="text/javascript" src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.ui.position.min.js"></script>
|
||||
<script type="text/javascript" src="/assets/dist/lib/jquery.ui.touch-punch.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.1/socket.io.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
|
||||
<script type="text/javascript" src="/assets/dist/lib/color-thief.js"></script>
|
||||
<script type="text/javascript" src="/assets/dist/lib/sha256.js"></script>
|
||||
<script type="text/javascript" src="/assets/dist/lib/aes.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user