Rewriting stuff

This commit is contained in:
Kasper Rynning-Tønnesen
2018-02-27 11:26:31 +01:00
parent 370e9ae72b
commit d2b3759913
4 changed files with 39 additions and 3 deletions

31
server/apps/rewrite.js Normal file
View File

@@ -0,0 +1,31 @@
path = require('path'),
pathThumbnails = __dirname;
db = require(pathThumbnails + '/../handlers/db.js');
db.getCollectionNames(function(err, docs) {
for(var i = 0; i < docs.length; i++) {
makeNewAndDelete(docs[i]);
}
})
/*function delete(name) {
db.collection(name).remove(function(err, doc) {
})
}*/
function makeNewAndDelete(name) {
db.collection(name).find({views: {$exists: true}}, function(err, doc) {
//console.log(doc);
if(doc.length == 0) {
//console.log(name);
} else if(doc.length == 1) {
db.collection(name + "_settings").insert(doc[0], function(err, result){
console.log("Result insert", result);
/*db.collection(name).remove({views: {$exists: true}}, function(err, result_del) {
console.log("Result delete", result_del);
});*/
});
}
});
}

View File

@@ -58,7 +58,7 @@ function list(msg, guid, coll, offline, socket) {
} else { } else {
db.createCollection(coll, function(err, docs){ db.createCollection(coll, function(err, docs){
var configs = {"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": ""}; var configs = {"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": ""};
db.collection(coll).insert(configs, function(err, docs){ db.collection(coll + "_settings").insert(configs, function(err, docs){
socket.join(coll); socket.join(coll);
List.send_list(coll, socket, true, false, true); List.send_list(coll, socket, true, false, true);
db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time(), "viewers": 1}); db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time(), "viewers": 1});

View File

@@ -23,7 +23,12 @@ var Frontpage = {
msg msg
]); ]);
Frontpage.all_channels = msg.channels; Frontpage.all_channels = msg.channels;
Frontpage.populate_channels(msg.channels, true); if(msg.channels.length == 0) {
$("#preloader").css("display", "none");
$("#channel-list-container").append("<p>No channels yet</p>");
} else {
Frontpage.populate_channels(msg.channels, true);
}
Frontpage.set_viewers(msg.viewers); Frontpage.set_viewers(msg.viewers);
}, },

View File

@@ -9,6 +9,7 @@ var Player = {
np: {}, np: {},
youtube_listener: function(obj) { youtube_listener: function(obj) {
Helper.log(["object", obj]);
var state; var state;
if(embed && obj.np) { if(embed && obj.np) {
if(window.parentWindow && window.parentOrigin) { if(window.parentWindow && window.parentOrigin) {
@@ -42,7 +43,6 @@ var Player = {
} }
Helper.log(["video_id variable: " + video_id]); Helper.log(["video_id variable: " + video_id]);
if(!obj.np){ if(!obj.np){
$('#song-title').html("Empty channel. Add some songs!"); $('#song-title').html("Empty channel. Add some songs!");
document.title = "Zoff - the shared YouTube based radio"; document.title = "Zoff - the shared YouTube based radio";