Fixed some audit-issues, and started using prettify

This commit is contained in:
Kasper Rynning-Tønnesen
2019-07-25 16:47:01 +02:00
parent 9d6a07dbec
commit 1594bafb60
11 changed files with 12153 additions and 8559 deletions

View File

@@ -1,120 +1,198 @@
var gulp = require('gulp'), var gulp = require("gulp"),
gutil = require('gulp-util'), gutil = require("gulp-util"),
uglify = require('gulp-uglify'), uglify = require("gulp-uglify"),
//sourcemaps = require('gulp-sourcemaps'), //sourcemaps = require('gulp-sourcemaps'),
gutil = require('gulp-util'), gutil = require("gulp-util"),
concat = require('gulp-concat'), concat = require("gulp-concat"),
cssnano = require('gulp-cssnano'); cleanCSS = require("gulp-clean-css");
gulp.task('css', function() { gulp.task("css", function() {
return gulp.src('server/public/assets/css/style.css') return gulp
.pipe(cssnano({ .src("server/public/assets/css/style.css")
preset: ['default', { .pipe(cleanCSS({ compatibility: "ie8" }))
discardComments: { .pipe(gulp.dest("server/public/assets/dist"));
removeAll: true,
},
}]
}))
.pipe(gulp.dest('server/public/assets/dist'));
}); });
gulp.task('css-embed', function() { gulp.task("css-embed", function() {
return gulp.src('server/public/assets/css/embed.css') return gulp
.pipe(cssnano({ .src("server/public/assets/css/embed.css")
preset: ['default', { .pipe(cleanCSS({ compatibility: "ie8" }))
discardComments: { .pipe(gulp.dest("server/public/assets/dist"));
removeAll: true,
},
}]
}))
.pipe(gulp.dest('server/public/assets/dist'));
}); });
gulp.task('js', function () { gulp.task("js", function() {
return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/*.js', '!server/public/assets/js/embed*', '!server/public/assets/js/token*', '!server/public/assets/js/remotecontroller.js', '!server/public/assets/js/callback.js']) return (
gulp
.src([
"server/VERSION.js",
"server/config/api_key.js",
"server/public/assets/js/*.js",
"!server/public/assets/js/embed*",
"!server/public/assets/js/token*",
"!server/public/assets/js/remotecontroller.js",
"!server/public/assets/js/callback.js"
])
//.pipe(sourcemaps.init()) //.pipe(sourcemaps.init())
.pipe(concat('main.min.js')) .pipe(concat("main.min.js"))
.pipe(uglify({ .pipe(
mangle: true, uglify({
compress: true,
enclose: true,
}))
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
//.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('server/public/assets/dist'));
});
gulp.task('embed', function () {
return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/player.js', 'server/public/assets/js/functions.js', 'server/public/assets/js/helpers.js', 'server/public/assets/js/playercontrols.js', 'server/public/assets/js/list.js', 'server/public/assets/js/embed.js', '!server/public/assets/js/frontpage*', '!server/public/assets/js/remotecontroller.js', 'server/public/assets/js/hostcontroller.js'])
//.pipe(sourcemaps.init())
.pipe(concat('embed.min.js'))
.pipe(uglify({
mangle: true, mangle: true,
compress: true, compress: true,
enclose: true enclose: true
})) })
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); }) )
.on("error", function(err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
})
//.pipe(sourcemaps.write('maps')) //.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('server/public/assets/dist')); .pipe(gulp.dest("server/public/assets/dist"))
);
}); });
gulp.task('token', function() { gulp.task("embed", function() {
return gulp.src(['server/public/assets/js/token*', 'server/public/assets/js/helpers.js']) return (
gulp
.src([
"server/VERSION.js",
"server/config/api_key.js",
"server/public/assets/js/player.js",
"server/public/assets/js/functions.js",
"server/public/assets/js/helpers.js",
"server/public/assets/js/playercontrols.js",
"server/public/assets/js/list.js",
"server/public/assets/js/embed.js",
"!server/public/assets/js/frontpage*",
"!server/public/assets/js/remotecontroller.js",
"server/public/assets/js/hostcontroller.js"
])
//.pipe(sourcemaps.init()) //.pipe(sourcemaps.init())
.pipe(concat('token.min.js')) .pipe(concat("embed.min.js"))
.pipe(uglify({ .pipe(
uglify({
mangle: true, mangle: true,
compress: true, compress: true,
enclose: true enclose: true
})) })
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); }) )
.on("error", function(err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
})
//.pipe(sourcemaps.write('maps')) //.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('server/public/assets/dist')); .pipe(gulp.dest("server/public/assets/dist"))
);
});
gulp.task("token", function() {
return (
gulp
.src([
"server/public/assets/js/token*",
"server/public/assets/js/helpers.js"
])
//.pipe(sourcemaps.init())
.pipe(concat("token.min.js"))
.pipe(
uglify({
mangle: true,
compress: true,
enclose: true
})
)
.on("error", function(err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
}) })
gulp.task('callback', function () { //.pipe(sourcemaps.write('maps'))
return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/callback.js']) .pipe(gulp.dest("server/public/assets/dist"))
);
});
gulp.task("callback", function() {
return (
gulp
.src([
"server/VERSION.js",
"server/config/api_key.js",
"server/public/assets/js/callback.js"
])
//.pipe(sourcemaps.init()) //.pipe(sourcemaps.init())
.pipe(concat('callback.min.js')) .pipe(concat("callback.min.js"))
.pipe(uglify({ .pipe(
uglify({
mangle: true, mangle: true,
compress: true, compress: true,
enclose: true enclose: true
})) })
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); }) )
.on("error", function(err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
})
//.pipe(sourcemaps.write('maps')) //.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('server/public/assets/dist')); .pipe(gulp.dest("server/public/assets/dist"))
);
}); });
gulp.task('build', done => { gulp.task("build", done => {
gulp.series('css', 'css-embed', 'js', 'embed', 'remotecontroller', 'callback', 'token')(); gulp.series(
"css",
"css-embed",
"js",
"embed",
"remotecontroller",
"callback",
"token"
)();
done(); done();
}); });
gulp.task('remotecontroller', function () { gulp.task("remotecontroller", function() {
return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/remotecontroller.js', 'server/public/assets/js/helpers.js']) return (
gulp
.src([
"server/VERSION.js",
"server/config/api_key.js",
"server/public/assets/js/remotecontroller.js",
"server/public/assets/js/helpers.js"
])
////.pipe(sourcemaps.init()) ////.pipe(sourcemaps.init())
.pipe(concat('remote.min.js')) .pipe(concat("remote.min.js"))
.pipe(uglify({ .pipe(
uglify({
mangle: true, mangle: true,
compress: true, compress: true,
enclose: true enclose: true
})) })
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); }) )
.on("error", function(err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
})
//.pipe(sourcemaps.write('maps')) //.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('server/public/assets/dist')); .pipe(gulp.dest("server/public/assets/dist"))
);
}); });
gulp.task('default', function(){ gulp.task("default", function() {
gulp.watch(['server/VERSION.js', 'server/public/assets/js/*.js'], ['js']); gulp.watch(["server/VERSION.js", "server/public/assets/js/*.js"], ["js"]);
gulp.watch(['server/public/assets/css/*.css'], ['css']); gulp.watch(["server/public/assets/css/*.css"], ["css"]);
gulp.watch(['server/public/assets/css/*.css'], ['css-embed']); gulp.watch(["server/public/assets/css/*.css"], ["css-embed"]);
gulp.watch(['server/public/assets/js/token*.js', 'server/public/assets/js/helpers.js'], ['token']); gulp.watch(
gulp.watch(['server/VERSION.js', 'server/public/assets/js/*.js'], ['embed']); ["server/public/assets/js/token*.js", "server/public/assets/js/helpers.js"],
gulp.watch(['server/VERSION.js', 'server/public/assets/js/callback.js', 'server/public/assets/js/helpers.js'], ['callback']); ["token"]
);
gulp.watch(["server/VERSION.js", "server/public/assets/js/*.js"], ["embed"]);
gulp.watch(
[
"server/VERSION.js",
"server/public/assets/js/callback.js",
"server/public/assets/js/helpers.js"
],
["callback"]
);
//gulp.watch('server/public/assets/js/*.js', ['nochan']); //gulp.watch('server/public/assets/js/*.js', ['nochan']);
gulp.watch(['server/VERSION.js', 'server/public/assets/js/remotecontroller.js'], ['remotecontroller']); gulp.watch(
["server/VERSION.js", "server/public/assets/js/remotecontroller.js"],
["remotecontroller"]
);
}); });

100
package-lock.json generated
View File

@@ -750,6 +750,14 @@
} }
} }
}, },
"clean-css": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
"integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==",
"requires": {
"source-map": "~0.6.0"
}
},
"cliui": { "cliui": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
@@ -2899,6 +2907,45 @@
} }
} }
}, },
"gulp-clean-css": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/gulp-clean-css/-/gulp-clean-css-4.2.0.tgz",
"integrity": "sha512-r4zQsSOAK2UYUL/ipkAVCTRg/2CLZ2A+oPVORopBximRksJ6qy3EX1KGrIWT4ZrHxz3Hlobb1yyJtqiut7DNjA==",
"requires": {
"clean-css": "4.2.1",
"plugin-error": "1.0.1",
"through2": "3.0.1",
"vinyl-sourcemaps-apply": "0.2.1"
},
"dependencies": {
"readable-stream": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz",
"integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
},
"string_decoder": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz",
"integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==",
"requires": {
"safe-buffer": "~5.1.0"
}
},
"through2": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz",
"integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==",
"requires": {
"readable-stream": "2 || 3"
}
}
}
},
"gulp-concat": { "gulp-concat": {
"version": "2.6.1", "version": "2.6.1",
"resolved": "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.6.1.tgz", "resolved": "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.6.1.tgz",
@@ -3850,6 +3897,11 @@
"strip-bom": "^2.0.0" "strip-bom": "^2.0.0"
} }
}, },
"lodash": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"lodash._basecopy": { "lodash._basecopy": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz",
@@ -4150,9 +4202,9 @@
"integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=" "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8="
}, },
"mixin-deep": { "mixin-deep": {
"version": "1.3.1", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
"integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
"dev": true, "dev": true,
"requires": { "requires": {
"for-in": "^1.0.2", "for-in": "^1.0.2",
@@ -4324,11 +4376,6 @@
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz",
"integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg=="
}, },
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"mongodb": { "mongodb": {
"version": "3.1.13", "version": "3.1.13",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.13.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.13.tgz",
@@ -5835,9 +5882,9 @@
"dev": true "dev": true
}, },
"set-value": { "set-value": {
"version": "2.0.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
"integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
"dev": true, "dev": true,
"requires": { "requires": {
"extend-shallow": "^2.0.1", "extend-shallow": "^2.0.1",
@@ -6647,38 +6694,15 @@
"dev": true "dev": true
}, },
"union-value": { "union-value": {
"version": "1.0.0", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
"integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
"dev": true, "dev": true,
"requires": { "requires": {
"arr-union": "^3.1.0", "arr-union": "^3.1.0",
"get-value": "^2.0.6", "get-value": "^2.0.6",
"is-extendable": "^0.1.1", "is-extendable": "^0.1.1",
"set-value": "^0.4.3" "set-value": "^2.0.1"
},
"dependencies": {
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true,
"requires": {
"is-extendable": "^0.1.0"
}
},
"set-value": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
"integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
"dev": true,
"requires": {
"extend-shallow": "^2.0.1",
"is-extendable": "^0.1.1",
"is-plain-object": "^2.0.1",
"to-object-path": "^0.3.0"
}
}
} }
}, },
"uniq": { "uniq": {

View File

@@ -41,6 +41,7 @@
"express-recaptcha": "^3.0.1", "express-recaptcha": "^3.0.1",
"express-session": "^1.15.6", "express-session": "^1.15.6",
"feature-policy": "^0.2.0", "feature-policy": "^0.2.0",
"gulp-clean-css": "^4.2.0",
"gulp-sourcemaps": "^2.6.5", "gulp-sourcemaps": "^2.6.5",
"gulp-uglify-es": "^1.0.4", "gulp-uglify-es": "^1.0.4",
"helmet": "^3.16.0", "helmet": "^3.16.0",

View File

@@ -1,26 +1,26 @@
var cookieParser = require("cookie-parser"); var cookieParser = require("cookie-parser");
var cookie = require("cookie"); var cookie = require("cookie");
var Functions = require(pathThumbnails + '/handlers/functions.js'); var Functions = require(pathThumbnails + "/handlers/functions.js");
var ListChange = require(pathThumbnails + '/handlers/list_change.js'); var ListChange = require(pathThumbnails + "/handlers/list_change.js");
var Chat = require(pathThumbnails + '/handlers/chat.js'); var Chat = require(pathThumbnails + "/handlers/chat.js");
var List = require(pathThumbnails + '/handlers/list.js'); var List = require(pathThumbnails + "/handlers/list.js");
var Suggestions = require(pathThumbnails + '/handlers/suggestions.js'); var Suggestions = require(pathThumbnails + "/handlers/suggestions.js");
var ListSettings = require(pathThumbnails + '/handlers/list_settings.js'); var ListSettings = require(pathThumbnails + "/handlers/list_settings.js");
var Frontpage = require(pathThumbnails + '/handlers/frontpage.js'); var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");
var Search = require(pathThumbnails + '/handlers/search.js'); var Search = require(pathThumbnails + "/handlers/search.js");
var crypto = require('crypto'); var crypto = require("crypto");
var Filter = require('bad-words'); var Filter = require("bad-words");
var filter = new Filter({ placeHolder: 'x'}); var filter = new Filter({ placeHolder: "x" });
/*var filter = { /*var filter = {
clean: function(str) { clean: function(str) {
return str; return str;
} }
}*/ }*/
var db = require(pathThumbnails + '/handlers/db.js'); var db = require(pathThumbnails + "/handlers/db.js");
module.exports = function() { module.exports = function() {
io.on('connection', function(socket){ io.on("connection", function(socket) {
try { try {
var parsedCookies = cookie.parse(socket.handshake.headers.cookie); var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
socket.cookie_id = parsedCookies["_uI"]; socket.cookie_id = parsedCookies["_uI"];
@@ -30,15 +30,18 @@ module.exports = function() {
} }
socket.zoff_id = socket.id; socket.zoff_id = socket.id;
socket.emit("get_list"); socket.emit("get_list");
var guid = socket.cookie_id; var guid = socket.cookie_id;
if(guid == "empty" || guid == null || guid == undefined) guid = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); if (guid == "empty" || guid == null || guid == undefined)
guid = Functions.hash_pass(
socket.handshake.headers["user-agent"] +
socket.handshake.address +
socket.handshake.headers["accept-language"]
);
socket.guid = guid; socket.guid = guid;
socket.on('close', function() { socket.on("close", function() {});
});
socket.on('pinging', function() { socket.on("pinging", function() {
socket.emit("ok"); socket.emit("ok");
}); });
@@ -54,8 +57,7 @@ module.exports = function() {
socket.emit("guid", guid); socket.emit("guid", guid);
socket.on('self_ping', function(msg) { socket.on("self_ping", function(msg) {
var channel = msg.channel; var channel = msg.channel;
if (channel.indexOf("?") > -1) { if (channel.indexOf("?") > -1) {
channel = channel.substring(0, channel.indexOf("?")); channel = channel.substring(0, channel.indexOf("?"));
@@ -65,53 +67,102 @@ module.exports = function() {
} }
//channel = channel.replace(/ /g,''); //channel = channel.replace(/ /g,'');
if (offline) { if (offline) {
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){}); db.collection("connected_users").update(
{ _id: "offline_users" },
{ $addToSet: { users: guid } },
{ upsert: true },
function(err, docs) {}
);
} else { } else {
db.collection("connected_users").update({"_id": channel}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){ db.collection("connected_users").update(
db.collection("frontpage_lists").update({"_id": channel}, {$inc: {viewers: 1}}, {upsert: true}, function(){}); { _id: channel },
}); { $addToSet: { users: guid } },
{ upsert: true },
function(err, docs) {
db.collection("frontpage_lists").update(
{ _id: channel },
{ $inc: { viewers: 1 } },
{ upsert: true },
function() {}
);
}
);
} }
if (channel != "" && channel != undefined) { if (channel != "" && channel != undefined) {
db.collection("connected_users").update({"_id": "total_users"}, {$addToSet: {total_users: guid + channel}}, {upsert: true}, function(err, docs){}); db.collection("connected_users").update(
{ _id: "total_users" },
{ $addToSet: { total_users: guid + channel } },
{ upsert: true },
function(err, docs) {}
);
} }
}); });
socket.on("logout", function() { socket.on("logout", function() {
Functions.removeSessionAdminPass(Functions.getSession(socket), coll, function() {}) Functions.removeSessionAdminPass(
Functions.getSession(socket),
coll,
function() {}
);
}); });
socket.on('next_song', function(obj) { socket.on("next_song", function(obj) {
if(obj == undefined || !obj.hasOwnProperty("channel")) return; if (obj == undefined || !obj.hasOwnProperty("channel")) return;
db.collection(obj.channel + "_settings").find(function(e, docs) { db.collection(obj.channel + "_settings").find(function(e, docs) {
if (docs.length == 0) return; if (docs.length == 0) return;
var pass = ""; var pass = "";
if (obj.hasOwnProperty("pass")) { if (obj.hasOwnProperty("pass")) {
pass = crypto.createHash('sha256').update(Functions.decrypt_string(obj.pass)).digest("base64"); pass = crypto
.createHash("sha256")
.update(Functions.decrypt_string(obj.pass))
.digest("base64");
} }
if((docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || docs[0].userpass == pass))) { if (
docs.length > 0 &&
(docs[0].userpass == undefined ||
docs[0].userpass == "" ||
docs[0].userpass == pass)
) {
List.getNextSong(obj.channel, socket); List.getNextSong(obj.channel, socket);
} }
}); });
}); });
socket.on('chromecast', function(msg) { socket.on("chromecast", function(msg) {
try { try {
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && if (
msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && typeof msg == "object" &&
typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { msg.hasOwnProperty("guid") &&
msg.hasOwnProperty("socket_id") &&
msg.hasOwnProperty("channel") &&
typeof msg.guid == "string" &&
typeof msg.channel == "string" &&
typeof msg.socket_id == "string" &&
msg.channel != ""
) {
if (msg.hasOwnProperty("channel")) { if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { db.collection("connected_users").find({ _id: msg.channel }, function(
if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { err,
connected_users_channel
) {
if (
connected_users_channel.length > 0 &&
connected_users_channel[0].users.indexOf(msg.guid) > -1
) {
coll = msg.channel.toLowerCase(); //.replace(/ /g,''); coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll); //coll = filter.clean(coll);
if (coll.indexOf("?") > -1) { if (coll.indexOf("?") > -1) {
coll = coll.substring(0, coll.indexOf("?")); coll = coll.substring(0, coll.indexOf("?"));
} }
Functions.setChromecastHost(socket.cookie_id, msg.socket_id, msg.channel, function(results) { Functions.setChromecastHost(
}); socket.cookie_id,
msg.socket_id,
msg.channel,
function(results) {}
);
//socket.cookie_id = msg.guid; //socket.cookie_id = msg.guid;
guid = msg.guid; guid = msg.guid;
socketid = msg.socket_id; socketid = msg.socket_id;
@@ -129,7 +180,10 @@ module.exports = function() {
}); });
socket.on("get_id", function() { socket.on("get_id", function() {
socket.emit("id_chromecast", {cookie_id: Functions.getSession(socket), guid: guid}); socket.emit("id_chromecast", {
cookie_id: Functions.getSession(socket),
guid: guid
});
}); });
socket.on("error_video", function(msg) { socket.on("error_video", function(msg) {
@@ -155,20 +209,37 @@ module.exports = function() {
}); });
socket.on("get_spread", function() { socket.on("get_spread", function() {
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot) { db.collection("connected_users").find({ _id: "total_users" }, function(
db.collection("connected_users").find({"_id": "offline_users"}, function(err, off) { err,
db.collection("connected_users").find({"_id": {$ne: "total_users"}, "_id": {$ne: "offline_users"}}, function(err, users_list) { tot
) {
db.collection("connected_users").find(
{ _id: "offline_users" },
function(err, off) {
db.collection("connected_users").find(
{ _id: { $ne: "total_users" }, _id: { $ne: "offline_users" } },
function(err, users_list) {
if (tot.length > 0 && off.length == 0) { if (tot.length > 0 && off.length == 0) {
socket.emit("spread_listeners", {offline: 0, total: tot[0].total_users.length, online_users: users_list}); socket.emit("spread_listeners", {
offline: 0,
total: tot[0].total_users.length,
online_users: users_list
});
} else if (tot.length > 0 && off.length > 0) { } else if (tot.length > 0 && off.length > 0) {
socket.emit("spread_listeners", {offline: off[0].users.length, total: tot[0].total_users.length, online_users: users_list}); socket.emit("spread_listeners", {
offline: off[0].users.length,
total: tot[0].total_users.length,
online_users: users_list
});
} }
}); }
}); );
}
);
}); });
}); });
socket.on('suggest_thumbnail', function(msg){ socket.on("suggest_thumbnail", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -179,7 +250,7 @@ module.exports = function() {
Suggestions.thumbnail(msg, coll, guid, offline, socket); Suggestions.thumbnail(msg, coll, guid, offline, socket);
}); });
socket.on('suggest_description', function(msg){ socket.on("suggest_description", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -190,7 +261,7 @@ module.exports = function() {
Suggestions.description(msg, coll, guid, offline, socket); Suggestions.description(msg, coll, guid, offline, socket);
}); });
socket.on('suggest_rules', function(msg){ socket.on("suggest_rules", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -220,14 +291,14 @@ module.exports = function() {
if (msg.hasOwnProperty("channel")) { if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) { if (typeof msg != "object" || !msg.hasOwnProperty("channel")) {
var result = { var result = {
channel: { channel: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined, got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined
} }
}; };
socket.emit('update_required', result); socket.emit("update_required", result);
return; return;
} }
Chat.removename(guid, msg.channel, socket); Chat.removename(guid, msg.channel, socket);
@@ -241,19 +312,23 @@ module.exports = function() {
if (msg.hasOwnProperty("channel")) { if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') || if (
typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") { !msg.hasOwnProperty("status") ||
!msg.hasOwnProperty("channel") ||
typeof msg.status != "boolean" ||
typeof msg.channel != "string"
) {
var result = { var result = {
status: { status: {
expected: "boolean", expected: "boolean",
got: msg.hasOwnProperty("status") ? typeof(msg.status) : undefined, got: msg.hasOwnProperty("status") ? typeof msg.status : undefined
}, },
channel: { channel: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined
} }
}; };
socket.emit('update_required', result); socket.emit("update_required", result);
return; return;
} }
var status = msg.status; var status = msg.status;
@@ -265,40 +340,74 @@ module.exports = function() {
if (coll !== undefined) { if (coll !== undefined) {
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll); //coll = filter.clean(coll);
db.collection("connected_users").findAndModify({ db.collection("connected_users").findAndModify(
query: {"_id": coll}, {
query: { _id: coll },
update: { $pull: { users: guid } }, update: { $pull: { users: guid } },
upsert: true, upsert: true
}, function(err, updated, d) { },
function(err, updated, d) {
if (d.n == 1) { if (d.n == 1) {
var num = 0; var num = 0;
if (updated && updated.users) { if (updated && updated.users) {
num = updated.users.length; num = updated.users.length;
} }
io.to(coll).emit("viewers", num); io.to(coll).emit("viewers", num);
db.collection("frontpage_lists").update({"_id": coll, "viewers": {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) { }); db.collection("frontpage_lists").update(
db.collection("connected_users").update({"_id": "total_users"}, {$pull: {total_users: guid + coll}}, function(err, docs){ { _id: coll, viewers: { $gt: 0 } },
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs) { { $inc: { viewers: -1 } },
if(docs.nModified == 1 && (coll != undefined && coll != "")) { function(err, docs) {}
db.collection("connected_users").update({"_id": "total_users"}, {$addToSet: {total_users: guid + coll}}, function(err, docs) {}); );
db.collection("connected_users").update(
{ _id: "total_users" },
{ $pull: { total_users: guid + coll } },
function(err, docs) {
db.collection("connected_users").update(
{ _id: "offline_users" },
{ $addToSet: { users: guid } },
{ upsert: true },
function(err, docs) {
if (
docs.nModified == 1 &&
(coll != undefined && coll != "")
) {
db.collection("connected_users").update(
{ _id: "total_users" },
{ $addToSet: { total_users: guid + coll } },
function(err, docs) {}
);
} }
}); }
}); );
}
);
} }
Functions.remove_name_from_db(guid, coll); Functions.remove_name_from_db(guid, coll);
}); }
);
} }
Functions.remove_unique_id(short_id); Functions.remove_unique_id(short_id);
} else { } else {
offline = false; offline = false;
db.collection("connected_users").update({"_id": "offline_users"}, {$pull: {users: guid}}, function(err, docs) { db.collection("connected_users").update(
Functions.check_inlist(coll, guid, socket, offline, undefined, "place 3"); { _id: "offline_users" },
}); { $pull: { users: guid } },
function(err, docs) {
Functions.check_inlist(
coll,
guid,
socket,
offline,
undefined,
"place 3"
);
}
);
} }
}); });
socket.on('get_history', function(msg) { socket.on("get_history", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -306,29 +415,33 @@ module.exports = function() {
if (msg.hasOwnProperty("channel")) { if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") || if (
typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") { !msg.hasOwnProperty("channel") ||
!msg.hasOwnProperty("all") ||
typeof msg.channel != "string" ||
typeof msg.all != "boolean"
) {
var result = { var result = {
all: { all: {
expected: "boolean", expected: "boolean",
got: msg.hasOwnProperty("all") ? typeof(msg.all) : undefined, got: msg.hasOwnProperty("all") ? typeof msg.all : undefined
}, },
channel: { channel: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined, got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined
}, },
pass: { pass: {
expected: "string", expected: "string",
got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined, got: msg.hasOwnProperty("pass") ? typeof msg.pass : undefined
} }
}; };
socket.emit('update_required', result); socket.emit("update_required", result);
return; return;
} }
Chat.get_history(msg.channel, msg.all, socket); Chat.get_history(msg.channel, msg.all, socket);
}); });
socket.on('chat', function (msg) { socket.on("chat", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -339,8 +452,7 @@ module.exports = function() {
Chat.chat(msg, guid, offline, socket); Chat.chat(msg, guid, offline, socket);
}); });
socket.on("all,chat", function(data) socket.on("all,chat", function(data) {
{
if (data.hasOwnProperty("channel") && data.channel.indexOf("?") > -1) { if (data.hasOwnProperty("channel") && data.channel.indexOf("?") > -1) {
var _list = data.channel.substring(0, data.channel.indexOf("?")); var _list = data.channel.substring(0, data.channel.indexOf("?"));
data.channel = _list; data.channel = _list;
@@ -351,8 +463,7 @@ module.exports = function() {
Chat.all_chat(data, guid, offline, socket); Chat.all_chat(data, guid, offline, socket);
}); });
socket.on('frontpage_lists', function(msg) socket.on("frontpage_lists", function(msg) {
{
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -363,7 +474,7 @@ module.exports = function() {
Frontpage.frontpage_lists(msg, socket); Frontpage.frontpage_lists(msg, socket);
}); });
socket.on('import_zoff', function(msg) { socket.on("import_zoff", function(msg) {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -372,15 +483,13 @@ module.exports = function() {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
ListChange.addFromOtherList(msg, guid, offline, socket); ListChange.addFromOtherList(msg, guid, offline, socket);
}) });
socket.on('now_playing', function(list, fn) socket.on("now_playing", function(list, fn) {
{
List.now_playing(list, fn, socket); List.now_playing(list, fn, socket);
}); });
socket.on('id', function(arr) socket.on("id", function(arr) {
{
if (arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1) { if (arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1) {
var _list = arr.channel.substring(0, arr.channel.indexOf("?")); var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
arr.channel = _list; arr.channel = _list;
@@ -388,12 +497,14 @@ module.exports = function() {
if (arr.hasOwnProperty("channel")) { if (arr.hasOwnProperty("channel")) {
arr.channel = Functions.encodeChannelName(arr.channel); arr.channel = Functions.encodeChannelName(arr.channel);
} }
if(typeof(arr) == 'object') if (typeof arr == "object")
io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value}); io.to(arr.id).emit(arr.id.toLowerCase(), {
type: arr.type,
value: arr.value
});
}); });
socket.on('list', function(msg) socket.on("list", function(msg) {
{
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -424,8 +535,7 @@ module.exports = function() {
Functions.get_short_id(socket); Functions.get_short_id(socket);
}); });
socket.on('end', function(obj) socket.on("end", function(obj) {
{
if (obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1) { if (obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1) {
var _list = obj.channel.substring(0, obj.channel.indexOf("?")); var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
obj.channel = _list; obj.channel = _list;
@@ -447,7 +557,7 @@ module.exports = function() {
List.end(obj, coll, guid, offline, socket); List.end(obj, coll, guid, offline, socket);
}); });
socket.on('addPlaylist', function(arr) { socket.on("addPlaylist", function(arr) {
if (arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1) { if (arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1) {
var _list = arr.channel.substring(0, arr.channel.indexOf("?")); var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
arr.channel = _list; arr.channel = _list;
@@ -456,10 +566,9 @@ module.exports = function() {
arr.channel = Functions.encodeChannelName(arr.channel); arr.channel = Functions.encodeChannelName(arr.channel);
} }
ListChange.addPlaylist(arr, guid, offline, socket); ListChange.addPlaylist(arr, guid, offline, socket);
}) });
socket.on('add', function(arr) socket.on("add", function(arr) {
{
if (arr.hasOwnProperty("list") && arr.list.indexOf("?") > -1) { if (arr.hasOwnProperty("list") && arr.list.indexOf("?") > -1) {
var _list = arr.list.substring(0, arr.list.indexOf("?")); var _list = arr.list.substring(0, arr.list.indexOf("?"));
arr.list = _list; arr.list = _list;
@@ -467,7 +576,11 @@ module.exports = function() {
if (arr.hasOwnProperty("list")) { if (arr.hasOwnProperty("list")) {
arr.list = Functions.encodeChannelName(arr.list); arr.list = Functions.encodeChannelName(arr.list);
} }
if(coll !== undefined && ((arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) || !arr.hasOwnProperty("offsiteAdd"))) { if (
coll !== undefined &&
((arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) ||
!arr.hasOwnProperty("offsiteAdd"))
) {
try { try {
coll = arr.list; //.replace(/ /g,''); coll = arr.list; //.replace(/ /g,'');
if (coll.length == 0) return; if (coll.length == 0) return;
@@ -484,7 +597,7 @@ module.exports = function() {
ListChange.add_function(arr, coll, guid, offline, socket); ListChange.add_function(arr, coll, guid, offline, socket);
}); });
socket.on('delete_all', function(msg) { socket.on("delete_all", function(msg) {
try { try {
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
@@ -506,8 +619,7 @@ module.exports = function() {
ListChange.delete_all(msg, coll, guid, offline, socket); ListChange.delete_all(msg, coll, guid, offline, socket);
}); });
socket.on('vote', function(msg) socket.on("vote", function(msg) {
{
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -530,8 +642,7 @@ module.exports = function() {
ListChange.voteUndecided(msg, coll, guid, offline, socket); ListChange.voteUndecided(msg, coll, guid, offline, socket);
}); });
socket.on('password', function(inp) socket.on("password", function(inp) {
{
if (inp.hasOwnProperty("channel") && inp.channel.indexOf("?") > -1) { if (inp.hasOwnProperty("channel") && inp.channel.indexOf("?") > -1) {
var _list = inp.channel.substring(0, inp.channel.indexOf("?")); var _list = inp.channel.substring(0, inp.channel.indexOf("?"));
inp.channel = _list; inp.channel = _list;
@@ -543,8 +654,7 @@ module.exports = function() {
ListSettings.password(inp, coll, guid, offline, socket); ListSettings.password(inp, coll, guid, offline, socket);
}); });
socket.on('skip', function(list) socket.on("skip", function(list) {
{
if (list.hasOwnProperty("channel") && list.channel.indexOf("?") > -1) { if (list.hasOwnProperty("channel") && list.channel.indexOf("?") > -1) {
var _list = list.channel.substring(0, list.channel.indexOf("?")); var _list = list.channel.substring(0, list.channel.indexOf("?"));
list.channel = _list; list.channel = _list;
@@ -557,8 +667,7 @@ module.exports = function() {
List.skip(list, guid, coll, offline, socket); List.skip(list, guid, coll, offline, socket);
}); });
socket.on('conf', function(conf) socket.on("conf", function(conf) {
{
if (conf.hasOwnProperty("channel") && conf.channel.indexOf("?") > -1) { if (conf.hasOwnProperty("channel") && conf.channel.indexOf("?") > -1) {
var _list = conf.channel.substring(0, conf.channel.indexOf("?")); var _list = conf.channel.substring(0, conf.channel.indexOf("?"));
conf.channel = _list; conf.channel = _list;
@@ -572,8 +681,7 @@ module.exports = function() {
ListSettings.conf_function(conf, coll, guid, offline, socket); ListSettings.conf_function(conf, coll, guid, offline, socket);
}); });
socket.on('shuffle', function(msg) socket.on("shuffle", function(msg) {
{
if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
var _list = msg.channel.substring(0, msg.channel.indexOf("?")); var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
msg.channel = _list; msg.channel = _list;
@@ -595,12 +703,15 @@ module.exports = function() {
ListChange.shuffle(msg, coll, guid, offline, socket); ListChange.shuffle(msg, coll, guid, offline, socket);
}); });
socket.on('change_channel', function(obj) socket.on("change_channel", function(obj) {
{
if (obj == undefined && coll != undefined) { if (obj == undefined && coll != undefined) {
obj = {}; obj = {};
obj.channel = coll; obj.channel = coll;
} else if(obj != undefined && obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){ } else if (
obj != undefined &&
obj.hasOwnProperty("channel") &&
obj.channel.indexOf("?") > -1
) {
var _list = obj.channel.substring(0, obj.channel.indexOf("?")); var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
obj.channel = _list; obj.channel = _list;
} }
@@ -610,7 +721,11 @@ module.exports = function() {
if (obj.hasOwnProperty("channel")) { if (obj.hasOwnProperty("channel")) {
obj.channel = Functions.encodeChannelName(obj.channel); obj.channel = Functions.encodeChannelName(obj.channel);
} }
if(coll === undefined && obj !== undefined && obj.channel !== undefined){ if (
coll === undefined &&
obj !== undefined &&
obj.channel !== undefined
) {
try { try {
coll = obj.channel.toLowerCase(); //.replace(/ /g,''); coll = obj.channel.toLowerCase(); //.replace(/ /g,'');
if (coll.length == 0) return; if (coll.length == 0) return;
@@ -622,18 +737,40 @@ module.exports = function() {
return; return;
} }
} }
Functions.left_channel(coll, guid, short_id, in_list, socket, true, "left 1"); Functions.left_channel(
coll,
guid,
short_id,
in_list,
socket,
true,
"left 1"
);
in_list = false; in_list = false;
}); });
socket.on('disconnect', function() socket.on("disconnect", function() {
{ Functions.left_channel(
Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 2"); coll,
guid,
short_id,
in_list,
socket,
false,
"left 2"
);
}); });
socket.on('disconnected', function() socket.on("disconnected", function() {
{ Functions.left_channel(
Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 3"); coll,
guid,
short_id,
in_list,
socket,
false,
"left 3"
);
}); });
socket.on("left_channel", function(msg) { socket.on("left_channel", function(msg) {
@@ -644,32 +781,68 @@ module.exports = function() {
if (msg.hasOwnProperty("channel")) { if (msg.hasOwnProperty("channel")) {
msg.channel = Functions.encodeChannelName(msg.channel); msg.channel = Functions.encodeChannelName(msg.channel);
} }
if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") { if (
msg.hasOwnProperty("channel") &&
msg.channel != "" &&
typeof msg.channel == "string"
) {
coll = msg.channel; //.replace(/ /g,''); coll = msg.channel; //.replace(/ /g,'');
coll = Functions.removeEmojis(coll).toLowerCase(); coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll); //coll = filter.clean(coll);
Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 4"); Functions.left_channel(
coll,
guid,
short_id,
in_list,
socket,
false,
"left 4"
);
} }
})
socket.on('reconnect_failed', function()
{
Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 5");
}); });
socket.on('connect_timeout', function() socket.on("reconnect_failed", function() {
{ Functions.left_channel(
Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 6"); coll,
guid,
short_id,
in_list,
socket,
false,
"left 5"
);
}); });
socket.on('error', function() socket.on("connect_timeout", function() {
{ Functions.left_channel(
Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 7"); coll,
guid,
short_id,
in_list,
socket,
false,
"left 6"
);
}); });
socket.on('pos', function(obj) socket.on("error", function() {
{ Functions.left_channel(
if(obj != undefined && obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){ coll,
guid,
short_id,
in_list,
socket,
false,
"left 7"
);
});
socket.on("pos", function(obj) {
if (
obj != undefined &&
obj.hasOwnProperty("channel") &&
obj.channel.indexOf("?") > -1
) {
var _list = obj.channel.substring(0, obj.channel.indexOf("?")); var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
obj.channel = _list; obj.channel = _list;
} }
@@ -692,43 +865,60 @@ module.exports = function() {
} }
} }
if(!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string") { if (!obj.hasOwnProperty("channel") || typeof obj.channel != "string") {
var result = { var result = {
channel: { channel: {
expected: "string", expected: "string",
got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined got: obj.hasOwnProperty("channel") ? typeof obj.channel : undefined
}, },
pass: { pass: {
expected: "string", expected: "string",
got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined got: obj.hasOwnProperty("pass") ? typeof obj.pass : undefined
} }
}; };
socket.emit('update_required', result); socket.emit("update_required", result);
return; return;
} }
if (coll == undefined) return; if (coll == undefined) return;
db.collection(coll + "_settings").find(function(err, docs) { db.collection(coll + "_settings").find(function(err, docs) {
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) { Functions.getSessionAdminUser(
if(userpass != "" || obj.pass == undefined) { Functions.getSession(socket),
coll,
function(userpass, adminpass) {
if (userpass != "" || obj.pass == undefined) {
obj.pass = userpass; obj.pass = userpass;
} else { } else {
obj.pass = crypto.createHash('sha256').update(Functions.decrypt_string(obj.pass)).digest("base64") obj.pass = crypto
.createHash("sha256")
.update(Functions.decrypt_string(obj.pass))
.digest("base64");
} }
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == obj.pass))) { if (
Functions.check_inlist(coll, guid, socket, offline, undefined, "place 4"); docs.length > 0 &&
(docs[0].userpass == undefined ||
docs[0].userpass == "" ||
(obj.hasOwnProperty("pass") && docs[0].userpass == obj.pass))
) {
Functions.check_inlist(
coll,
guid,
socket,
offline,
undefined,
"place 4"
);
List.send_play(coll, socket); List.send_play(coll, socket);
} else { } else {
socket.emit("auth_required"); socket.emit("auth_required");
} }
}
);
}); });
}); });
}); });
});
//send_ping(); //send_ping();
} };
/* /*
function send_ping() { function send_ping() {

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
var Channel = { var Channel = {
init: function() { init: function() {
if(window.location.hash == "#small" || inIframe()) { if (window.location.hash == "#small" || inIframe()) {
small_player = true; small_player = true;
document.querySelector("footer").style.display = "none"; document.querySelector("footer").style.display = "none";
//addJoinBox(); //addJoinBox();
@@ -31,12 +31,20 @@ var Channel = {
}, function() { }, function() {
});*/ });*/
} }
if(cast_ready_connect || chromecastAvailable || chromecastReady) { if (cast_ready_connect || chromecastAvailable || chromecastReady) {
Helper.addClass(".volume-container", "volume-container-cast"); Helper.addClass(".volume-container", "volume-container-cast");
} }
if (!embed) { if (!embed) {
document.querySelector("#main-container").insertAdjacentHTML("beforeend", "<a id='hide-playlist' class='hide-on-small-only hide-playlist-button' href='#!'><i class='material-icons'>keyboard_arrow_right</i></div>"); document
document.querySelector("#hide-playlist").style.left = (document.querySelector("#video-container").offsetWidth - document.querySelector("#hide-playlist").offsetWidth) + "px"; .querySelector("#main-container")
.insertAdjacentHTML(
"beforeend",
"<a id='hide-playlist' class='hide-on-small-only hide-playlist-button' href='#!'><i class='material-icons'>keyboard_arrow_right</i></div>"
);
document.querySelector("#hide-playlist").style.left =
document.querySelector("#video-container").offsetWidth -
document.querySelector("#hide-playlist").offsetWidth +
"px";
} }
//Player.soundcloud_player = document.querySelector("#soundcloud_player"); //Player.soundcloud_player = document.querySelector("#soundcloud_player");
} }
@@ -58,7 +66,7 @@ var Channel = {
if (window.location.hostname != "localhost") { if (window.location.hostname != "localhost") {
var page = window.location.pathname; var page = window.location.pathname;
if (page.substring(page.length - 1) != "/") page += "/"; if (page.substring(page.length - 1) != "/") page += "/";
ga('send', 'pageview', page); ga("send", "pageview", page);
} }
window.onpopstate = function(e) { window.onpopstate = function(e) {
@@ -70,7 +78,11 @@ var Channel = {
} }
if (window.location.hostname != "fb.zoff.me") Channel.share_link_modifier(); if (window.location.hostname != "fb.zoff.me") Channel.share_link_modifier();
if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.zoff.me") add = "https://zoff.me"; if (
window.location.hostname == "zoff.me" ||
window.location.hostname == "fb.zoff.me"
)
add = "https://zoff.me";
else add = window.location.hostname; else add = window.location.hostname;
if (Player !== undefined && !client) { if (Player !== undefined && !client) {
@@ -79,19 +91,26 @@ var Channel = {
if (!client) { if (!client) {
//Helper.tabs('.playlist-tabs'); //Helper.tabs('.playlist-tabs');
Helper.tabs('.playlist-tabs-loggedIn', { Helper.tabs(".playlist-tabs-loggedIn", {
onShow: function(e) { onShow: function(e) {
if (this.index == 2) { if (this.index == 2) {
document.getElementById("text-chat-input").focus(); document.getElementById("text-chat-input").focus();
Chat.channel_received = 0; Chat.channel_received = 0;
Chat.all_received = 0; Chat.all_received = 0;
Helper.addClass(document.querySelector(".chat-link span.badge.new.white"), "hide"); Helper.addClass(
document.getElementById("favicon").setAttribute("href", "/assets/images/favicon.png"); document.querySelector(".chat-link span.badge.new.white"),
"hide"
);
document
.getElementById("favicon")
.setAttribute("href", "/assets/images/favicon.png");
chat_active = true; chat_active = true;
unseen = false; unseen = false;
chat_unseen = false; chat_unseen = false;
document.getElementsByClassName("chat-link")[0].setAttribute("style", "color: white !important;"); document
.getElementsByClassName("chat-link")[0]
.setAttribute("style", "color: white !important;");
blinking = false; blinking = false;
//Helper.css("#chat-container", "display", "block"); //Helper.css("#chat-container", "display", "block");
//Helper.css("#wrapper", "display", "none"); //Helper.css("#wrapper", "display", "none");
@@ -105,16 +124,22 @@ var Channel = {
}); });
if (window.location.hash == "#chat-container") { if (window.location.hash == "#chat-container") {
M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("chat-container"); M.Tabs.getInstance(
document.querySelector(".playlist-tabs-loggedIn")
).select("chat-container");
} else if (window.location.hash == "#suggestions") { } else if (window.location.hash == "#suggestions") {
M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("suggestions"); M.Tabs.getInstance(
document.querySelector(".playlist-tabs-loggedIn")
).select("suggestions");
} else if (window.location.hash == "#wrapper") { } else if (window.location.hash == "#wrapper") {
M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("wrapper"); M.Tabs.getInstance(
document.querySelector(".playlist-tabs-loggedIn")
).select("wrapper");
} }
Helper.tabs('.chatTabs'); Helper.tabs(".chatTabs");
} }
Helper.tabs('.results-tabs'); Helper.tabs(".results-tabs");
var sidenavElem = document.getElementsByClassName("sidenav")[0]; var sidenavElem = document.getElementsByClassName("sidenav")[0];
M.Sidenav.init(sidenavElem, { M.Sidenav.init(sidenavElem, {
menuWidth: 310, menuWidth: 310,
@@ -126,11 +151,14 @@ var Channel = {
}, },
onCloseStart: function(el) { onCloseStart: function(el) {
Helper.removeClass(".hamburger-sidenav", "open"); Helper.removeClass(".hamburger-sidenav", "open");
}, }
}); });
M.Collapsible.init(document.getElementsByClassName("settings-collapsible")[0], { M.Collapsible.init(
document.getElementsByClassName("settings-collapsible")[0],
{
accordion: true accordion: true
}); }
);
if (!client) { if (!client) {
M.Modal.init(document.getElementById("embed"), { M.Modal.init(document.getElementById("embed"), {
@@ -154,7 +182,7 @@ var Channel = {
} }
}); });
M.FormSelect.init(document.querySelector('.category-advanced-select')); M.FormSelect.init(document.querySelector(".category-advanced-select"));
M.Modal.init(document.getElementById("help")); M.Modal.init(document.getElementById("help"));
M.Modal.init(document.getElementById("contact")); M.Modal.init(document.getElementById("contact"));
M.Modal.init(document.getElementById("channel-share-modal")); M.Modal.init(document.getElementById("channel-share-modal"));
@@ -162,13 +190,17 @@ var Channel = {
dismissible: false dismissible: false
}); });
M.Modal.init(document.getElementById("user_password"), { M.Modal.init(document.getElementById("user_password"), {
dismissible: false, dismissible: false
}); });
Channel.spotify_is_authenticated(spotify_authenticated); Channel.spotify_is_authenticated(spotify_authenticated);
result_html = document.getElementById("temp-results-container"); result_html = document.getElementById("temp-results-container");
pagination_buttons_html = "<div class='pagination-results'>" + document.getElementsByClassName("pagination-results")[0].cloneNode(true).innerHTML + "</div>"; pagination_buttons_html =
"<div class='pagination-results'>" +
document.getElementsByClassName("pagination-results")[0].cloneNode(true)
.innerHTML +
"</div>";
empty_results_html = Helper.html("#empty-results-container"); empty_results_html = Helper.html("#empty-results-container");
not_import_html = Helper.html(".not-imported-container"); not_import_html = Helper.html(".not-imported-container");
not_export_html = Helper.html(".not-exported-container"); not_export_html = Helper.html(".not-exported-container");
@@ -177,8 +209,14 @@ var Channel = {
if (socket === undefined) { if (socket === undefined) {
no_socket = false; no_socket = false;
socket = io.connect(''+add, connection_options); if (window.location.port != "") {
socket.on('update_required', function(msg) { add = add + ":" + window.location.port + "/";
}
socket = io.connect(
"" + add,
connection_options
);
socket.on("update_required", function(msg) {
if (window.location.hostname == "localhost") { if (window.location.hostname == "localhost") {
console.error(msg); console.error(msg);
return; return;
@@ -195,12 +233,22 @@ var Channel = {
document.getElementsByClassName("offline_switch_class")[0].checked = true; document.getElementsByClassName("offline_switch_class")[0].checked = true;
change_offline(true, offline); change_offline(true, offline);
} }
if(!Helper.mobilecheck() && (document.querySelectorAll("#alreadychannel").length === 0 || !Hostcontroller.old_id || document.getElementById("code-text").innerText.toUpperCase() == "ABBADUR")) setup_host_initialization(); if (
!Helper.mobilecheck() &&
(document.querySelectorAll("#alreadychannel").length === 0 ||
!Hostcontroller.old_id ||
document.getElementById("code-text").innerText.toUpperCase() ==
"ABBADUR")
)
setup_host_initialization();
setup_suggested_listener(); setup_suggested_listener();
if (!Helper.mobilecheck()) { if (!Helper.mobilecheck()) {
showOnSmallNotMobile(); showOnSmallNotMobile();
} }
if(document.querySelectorAll("#alreadychannel").length === 0 || Helper.mobilecheck()){ if (
document.querySelectorAll("#alreadychannel").length === 0 ||
Helper.mobilecheck()
) {
setup_now_playing_listener(); setup_now_playing_listener();
get_list_listener(); get_list_listener();
@@ -221,24 +269,52 @@ var Channel = {
Player.player.setVolume(Crypt.get_volume()); Player.player.setVolume(Crypt.get_volume());
} catch (e) {} } catch (e) {}
try { try {
if(scUsingWidget) Player.soundcloud_player.setVolume(embed ? 1 : Crypt.get_volume()); if (scUsingWidget)
else Player.soundcloud_player.setVolume(embed ? 1 : Crypt.get_volume() / 100); Player.soundcloud_player.setVolume(
embed ? 1 : Crypt.get_volume()
);
else
Player.soundcloud_player.setVolume(
embed ? 1 : Crypt.get_volume() / 100
);
} catch (e) {} } catch (e) {}
} }
Helper.removeClass(".video-container", "no-opacity"); Helper.removeClass(".video-container", "no-opacity");
var codeURL = "https://remote." + window.location.hostname + "/" + id; var codeURL = "https://remote." + window.location.hostname + "/" + id;
Helper.setHtml("#code-text", id); Helper.setHtml("#code-text", id);
document.getElementById("code-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL); document
.getElementById("code-qr")
.setAttribute(
"src",
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
codeURL
);
document.getElementById("code-link").setAttribute("href", codeURL); document.getElementById("code-link").setAttribute("href", codeURL);
} }
} }
if (!client) { if (!client) {
if (!Helper.mobilecheck()) { if (!Helper.mobilecheck()) {
var shareCodeUrl = window.location.protocol + "//client."+window.location.hostname+"/r/"+btoa(encodeURIComponent(chan.toLowerCase())); var shareCodeUrl =
document.getElementById("share-join-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+shareCodeUrl); window.location.protocol +
Helper.setHtml("#channel-name-join", "client." + window.location.hostname + "/" + encodeURIComponent(chan.toLowerCase())); "//client." +
window.location.hostname +
"/r/" +
btoa(encodeURIComponent(chan.toLowerCase()));
document
.getElementById("share-join-qr")
.setAttribute(
"src",
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
shareCodeUrl
);
Helper.setHtml(
"#channel-name-join",
"client." +
window.location.hostname +
"/" +
encodeURIComponent(chan.toLowerCase())
);
} /*else if(small_player) { } /*else if(small_player) {
document.querySelector("#channel-share-modal .modal-content").innerHTML = "<p>To listen to this channel with more features, go to</p><p>https://zoff.me/" + encodeURIComponent(chan.toLowerCase()) + "</p><img src='/assets/images/favicon.png' height='100' width='100' alt='circle-logo-zoff'>"; document.querySelector("#channel-share-modal .modal-content").innerHTML = "<p>To listen to this channel with more features, go to</p><p>https://zoff.me/" + encodeURIComponent(chan.toLowerCase()) + "</p><img src='/assets/images/favicon.png' height='100' width='100' alt='circle-logo-zoff'>";
//M.Modal.getInstance(document.getElementById("channel-share-modal")).open(); //M.Modal.getInstance(document.getElementById("channel-share-modal")).open();
@@ -265,7 +341,7 @@ var Channel = {
Helper.tooltip("#chan", { Helper.tooltip("#chan", {
delay: 5, delay: 5,
position: "bottom", position: "bottom",
html: "Show join URL", html: "Show join URL"
}); });
} }
@@ -293,23 +369,27 @@ var Channel = {
html: "Search" html: "Search"
}); });
Helper.tooltip(".shuffle-btn-container", { Helper.tooltip(".shuffle-btn-container", {
delay: 5, delay: 5,
position: "bottom", position: "bottom",
html: "Shuffle", html: "Shuffle"
}); });
Helper.tooltip("#settings", { Helper.tooltip("#settings", {
delay: 5, delay: 5,
position: "bottom", position: "bottom",
html: "Settings", html: "Settings"
}); });
} }
if (!client) { if (!client) {
window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady; window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
if(Player.player === "" || Player.player === undefined || Helper.mobilecheck()) Player.loadPlayer(); if (
Player.player === "" ||
Player.player === undefined ||
Helper.mobilecheck()
)
Player.loadPlayer();
} else { } else {
Player.loadSoundCloudPlayer(); Player.loadSoundCloudPlayer();
} }
@@ -332,20 +412,25 @@ var Channel = {
setup_chat_listener(); setup_chat_listener();
get_history(); get_history();
} }
if(client || Helper.mobilecheck()){ if (client || Helper.mobilecheck()) {
get_list_ajax(); get_list_ajax();
get_np_ajax(); get_np_ajax();
} }
try { try {
if(!Helper.msieversion() && !Helper.mobilecheck() && !client && Notification != undefined) Notification.requestPermission(); if (
!Helper.msieversion() &&
!Helper.mobilecheck() &&
!client &&
Notification != undefined
)
Notification.requestPermission();
} catch (e) {} } catch (e) {}
document.getElementsByClassName("search_input")[0].focus(); document.getElementsByClassName("search_input")[0].focus();
Helper.sample(); Helper.sample();
if (!Helper.mobilecheck() && !client) { if (!Helper.mobilecheck() && !client) {
Helper.tooltip('.castButton', { Helper.tooltip(".castButton", {
delay: 5, delay: 5,
position: "top", position: "top",
html: "Cast Zoff to TV" html: "Cast Zoff to TV"
@@ -382,21 +467,35 @@ var Channel = {
if (!client) { if (!client) {
Helper.addClass("footer", "padding-bottom-novideo"); Helper.addClass("footer", "padding-bottom-novideo");
document.getElementById("embed-area").value = embed_code(embed_autoplay, embed_width, embed_height, color, embed_videoonly, embed_localmode); document.getElementById("embed-area").value = embed_code(
embed_autoplay,
embed_width,
embed_height,
color,
embed_videoonly,
embed_localmode
);
} }
if(!/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && !Helper.mobilecheck() && !client){ if (
!/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) &&
!Helper.mobilecheck() &&
!client
) {
Helper.css(".castButton", "display", "none"); Helper.css(".castButton", "display", "none");
} }
Helper.log(["chromecastAvailable " + chromecastAvailable, "chromecastReady " + chromecastReady]); Helper.log([
"chromecastAvailable " + chromecastAvailable,
"chromecastReady " + chromecastReady
]);
if (chromecastAvailable && !client) { if (chromecastAvailable && !client) {
hide_native(1); hide_native(1);
} else if (chromecastReady && !client) { } else if (chromecastReady && !client) {
initializeCastApi(); initializeCastApi();
} else if (!client) { } else if (!client) {
window['__onGCastApiAvailable'] = function(loaded, errorInfo) { window["__onGCastApiAvailable"] = function(loaded, errorInfo) {
if (loaded) { if (loaded) {
setTimeout(function() { setTimeout(function() {
chromecastReady = true; chromecastReady = true;
@@ -405,27 +504,36 @@ var Channel = {
} else { } else {
chromecastReady = true; chromecastReady = true;
} }
} };
} }
Channel.listeners(true); Channel.listeners(true);
Channel.add_context_menu(); Channel.add_context_menu();
if (!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null) { if (!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null) {
setTimeout(function(){Channel.set_title_width();}, 100); setTimeout(function() {
Channel.set_title_width();
}, 100);
} }
}, },
set_title_width: function(start) { set_title_width: function(start) {
if (window.innerWidth > 600) { if (window.innerWidth > 600) {
var add_width = document.getElementsByClassName("brand-logo")[0].offsetWidth var add_width = document.getElementsByClassName("brand-logo")[0]
.offsetWidth;
if (start) { if (start) {
add_width = window.innerWidth * 0.15; add_width = window.innerWidth * 0.15;
} }
var test_against_width = window.innerWidth - document.getElementsByClassName("control-list")[0].offsetWidth - add_width - 11; var test_against_width =
window.innerWidth -
document.getElementsByClassName("control-list")[0].offsetWidth -
add_width -
11;
title_width = test_against_width; title_width = test_against_width;
document.getElementsByClassName("title-container")[0].style.width = title_width + "px"; document.getElementsByClassName("title-container")[0].style.width =
title_width + "px";
} else { } else {
document.getElementsByClassName("title-container")[0].style.width = "100%"; document.getElementsByClassName("title-container")[0].style.width =
"100%";
} }
}, },
@@ -472,10 +580,41 @@ var Channel = {
}, },
share_link_modifier: function() { share_link_modifier: function() {
document.getElementById("facebook-code-link").setAttribute("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" + chan.toLowerCase()); document
document.getElementById("facebook-code-link").setAttribute("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" + chan.toLowerCase() + "', 'Share Playlist','width=600,height=300'); return false;"); .getElementById("facebook-code-link")
document.getElementById("twitter-code-link").setAttribute("href", "https://twitter.com/intent/tweet?url=https://zoff.me/" + chan.toLowerCase() + "&amp;text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zoff!&amp;via=zoffmusic"); .setAttribute(
document.getElementById("twitter-code-link").setAttribute("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" + chan.toLowerCase() + "/&amp;text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;"); "href",
"https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
chan.toLowerCase()
);
document
.getElementById("facebook-code-link")
.setAttribute(
"onclick",
"window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
chan.toLowerCase() +
"', 'Share Playlist','width=600,height=300'); return false;"
);
document
.getElementById("twitter-code-link")
.setAttribute(
"href",
"https://twitter.com/intent/tweet?url=https://zoff.me/" +
chan.toLowerCase() +
"&amp;text=Check%20out%20this%20playlist%20" +
chan.toLowerCase() +
"%20on%20Zoff!&amp;via=zoffmusic"
);
document
.getElementById("twitter-code-link")
.setAttribute(
"onclick",
"window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" +
chan.toLowerCase() +
"/&amp;text=Check%20out%20this%20playlist%20" +
chan.toLowerCase() +
"%20on%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
);
}, },
window_width_volume_slider: function() { window_width_volume_slider: function() {
@@ -493,26 +632,42 @@ var Channel = {
var scrollListener = function(e) { var scrollListener = function(e) {
if (!programscroll) { if (!programscroll) {
userscroll = true; userscroll = true;
if(document.getElementById("chatchannel").scrollTop + document.getElementById("chatchannel").offsetHeight >= document.getElementById("chatchannel").scrollHeight) { if (
document.getElementById("chatchannel").scrollTop +
document.getElementById("chatchannel").offsetHeight >=
document.getElementById("chatchannel").scrollHeight
) {
userscroll = false; userscroll = false;
} }
} }
} };
var scrollAllListener = function(e) { var scrollAllListener = function(e) {
if (!programscroll) { if (!programscroll) {
userscroll = true; userscroll = true;
if(document.getElementById("chatall").scrollTop+ document.getElementById("chatall").offsetHeight >= document.getElementById("chatall").scrollHeight) { if (
document.getElementById("chatall").scrollTop +
document.getElementById("chatall").offsetHeight >=
document.getElementById("chatall").scrollHeight
) {
userscroll = false; userscroll = false;
} }
} }
} };
if (!client) { if (!client) {
if (on) { if (on) {
document.getElementById("chatchannel").addEventListener("scroll", scrollListener); document
document.getElementById("chatall").addEventListener("scroll", scrollListener); .getElementById("chatchannel")
.addEventListener("scroll", scrollListener);
document
.getElementById("chatall")
.addEventListener("scroll", scrollListener);
} else { } else {
document.getElementById("chatchannel").removeEventListener("scroll", scrollListener); document
document.getElementById("chatall").removeEventListener("scroll", scrollAllListener); .getElementById("chatchannel")
.removeEventListener("scroll", scrollListener);
document
.getElementById("chatall")
.removeEventListener("scroll", scrollAllListener);
} }
} }
}, },
@@ -524,16 +679,20 @@ var Channel = {
Player.stopInterval = true; Player.stopInterval = true;
user_auth_avoid = true; user_auth_avoid = true;
if (!Helper.mobilecheck()) { if (!Helper.mobilecheck()) {
Helper.tooltip('.castButton', "destroy"); Helper.tooltip(".castButton", "destroy");
Helper.tooltip("#viewers", "destroy"); Helper.tooltip("#viewers", "destroy");
Helper.tooltip('#addToOtherList', 'destroy'); Helper.tooltip("#addToOtherList", "destroy");
//$('.castButton-unactive').tooltip("destroy"); //$('.castButton-unactive').tooltip("destroy");
Helper.tooltip("#offline-mode", "destroy"); Helper.tooltip("#offline-mode", "destroy");
Helper.tooltip('#admin-lock', "destroy"); Helper.tooltip("#admin-lock", "destroy");
} }
} }
var url_split = window.location.href.split("/"); var url_split = window.location.href.split("/");
if(url_split[3].substr(0,1) != "#!" && url_split[3] !== "" && !(url_split.length == 5 && url_split[4].substr(0,1) == "#")){ if (
url_split[3].substr(0, 1) != "#!" &&
url_split[3] !== "" &&
!(url_split.length == 5 && url_split[4].substr(0, 1) == "#")
) {
socket.emit("change_channel", { socket.emit("change_channel", {
channel: channel_before_move channel: channel_before_move
}); });
@@ -544,8 +703,10 @@ var Channel = {
var add = ""; var add = "";
w_p = true; w_p = true;
//if(private_channel) add = Crypt.getCookie("_uI") + "_"; //if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", {
socket.emit("list", {version: parseInt(_VERSION), channel: add + chan.toLowerCase()}); version: parseInt(_VERSION),
channel: add + chan.toLowerCase()
});
} else if (url_split[3] === "") { } else if (url_split[3] === "") {
/*if(client) { /*if(client) {
var host = window.location.hostname.split("."); var host = window.location.hostname.split(".");
@@ -554,7 +715,7 @@ var Channel = {
Admin.display_logged_out(); Admin.display_logged_out();
if (hostMode) { if (hostMode) {
Helper.removeClass("#main-row", "fullscreened"); Helper.removeClass("#main-row", "fullscreened");
document.querySelector(".host_switch_class").checked = false document.querySelector(".host_switch_class").checked = false;
enable_host_mode(false); enable_host_mode(false);
} }
var channel_before_move = chan.toLowerCase(); var channel_before_move = chan.toLowerCase();
@@ -578,13 +739,16 @@ var Channel = {
Helper.css("#embed-button", "display", "none"); Helper.css("#embed-button", "display", "none");
if (!Helper.mobilecheck()) { if (!Helper.mobilecheck()) {
Helper.tooltip(".castButton", "destroy"); Helper.tooltip(".castButton", "destroy");
Helper.tooltip('#addToOtherList', 'destroy'); Helper.tooltip("#addToOtherList", "destroy");
Helper.tooltip("#viewers", "destroy"); Helper.tooltip("#viewers", "destroy");
Helper.tooltip("#offline-mode", "destroy"); Helper.tooltip("#offline-mode", "destroy");
Helper.tooltip("search-btn", "destroy"); Helper.tooltip("search-btn", "destroy");
Helper.tooltip('#fullscreen', "destroy"); Helper.tooltip("#fullscreen", "destroy");
if(M.Tooltip.getInstance(document.getElementById("admin-lock")) != undefined) { if (
Helper.tooltip('#admin-lock', "destroy"); M.Tooltip.getInstance(document.getElementById("admin-lock")) !=
undefined
) {
Helper.tooltip("#admin-lock", "destroy");
} }
Helper.tooltip(".search-btn-container", "destroy"); Helper.tooltip(".search-btn-container", "destroy");
Helper.tooltip(".shuffle-btn-container", "destroy"); Helper.tooltip(".shuffle-btn-container", "destroy");
@@ -592,12 +756,14 @@ var Channel = {
} }
Helper.removeElement("#seekToDuration"); Helper.removeElement("#seekToDuration");
M.Sidenav.getInstance(document.getElementsByClassName("sidenav")[0]).destroy(); M.Sidenav.getInstance(
document.getElementsByClassName("sidenav")[0]
).destroy();
if (!client) { if (!client) {
if (!Helper.mobilecheck()) { if (!Helper.mobilecheck()) {
Helper.tooltip("#chan", "destroy"); Helper.tooltip("#chan", "destroy");
} }
var tap_1 = document.querySelectorAll(".tap-target") var tap_1 = document.querySelectorAll(".tap-target");
if (tap_1.length > 0 && M.TapTarget.getInstance(tap_1[0])) { if (tap_1.length > 0 && M.TapTarget.getInstance(tap_1[0])) {
M.TapTarget.getInstance(tap_1[0]).close(); M.TapTarget.getInstance(tap_1[0]).close();
} }
@@ -637,22 +803,30 @@ var Channel = {
url: "/", url: "/",
method: "GET", method: "GET",
success: function(e) { success: function(e) {
if (!client) { if (!client) {
document.querySelector("#hide-playlist").remove(); document.querySelector("#hide-playlist").remove();
if(hiddenPlaylist) document.querySelector("main").style.maxWidth = ""; if (hiddenPlaylist)
document.querySelector("main").style.maxWidth = "";
hiddenPlaylist = false; hiddenPlaylist = false;
document.getElementById("volume-button").removeEventListener("click", Playercontrols.mute_video); document
document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause); .getElementById("volume-button")
document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen); .removeEventListener("click", Playercontrols.mute_video);
document
.getElementById("playpause")
.removeEventListener("click", Playercontrols.play_pause);
document
.getElementById("fullscreen")
.removeEventListener("click", Playercontrols.fullscreen);
} }
Channel.listeners(false); Channel.listeners(false);
if(Helper.mobilecheck() || user_auth_avoid) { if (Helper.mobilecheck() || user_auth_avoid) {
video_id = ""; video_id = "";
song_title = ""; song_title = "";
} }
document.querySelectorAll("meta[name=theme-color]")[0].setAttribute("content", "#2D2D2D"); document
.querySelectorAll("meta[name=theme-color]")[0]
.setAttribute("content", "#2D2D2D");
if (!Helper.mobilecheck() && !user_auth_avoid) { if (!Helper.mobilecheck() && !user_auth_avoid) {
Helper.removeElement("#playbar"); Helper.removeElement("#playbar");
@@ -663,9 +837,21 @@ var Channel = {
Helper.addClass("#main-row", "frontpage_modified_heights"); Helper.addClass("#main-row", "frontpage_modified_heights");
Helper.css("#player", "opacity", "1"); Helper.css("#player", "opacity", "1");
Helper.removeClass("#video-container", "no-opacity"); Helper.removeClass("#video-container", "no-opacity");
document.getElementById("main-row").insertAdjacentHTML("afterbegin", "<div id='player_bottom_overlay' class='player player_bottom'></div>"); document
document.getElementById("player_bottom_overlay").insertAdjacentHTML("afterbegin", "<a id='closePlayer' title='Close Player'><i class='material-icons'>close</i></a>"); .getElementById("main-row")
document.getElementById("player_bottom_overlay").setAttribute("data-channel", channel_before_move.toLowerCase()); .insertAdjacentHTML(
"afterbegin",
"<div id='player_bottom_overlay' class='player player_bottom'></div>"
);
document
.getElementById("player_bottom_overlay")
.insertAdjacentHTML(
"afterbegin",
"<a id='closePlayer' title='Close Player'><i class='material-icons'>close</i></a>"
);
document
.getElementById("player_bottom_overlay")
.setAttribute("data-channel", channel_before_move.toLowerCase());
Helper.removeElement("#playlist"); Helper.removeElement("#playlist");
} else { } else {
try { try {
@@ -683,27 +869,48 @@ var Channel = {
response.innerHTML = e; response.innerHTML = e;
var newList = response.querySelector("#lists-script").innerHTML; var newList = response.querySelector("#lists-script").innerHTML;
newList = newList.trim().replace("window.lists = ", "").replace("window.lists=", ""); newList = newList
.trim()
.replace("window.lists = ", "")
.replace("window.lists=", "");
newList = newList.substring(0, newList.length); newList = newList.substring(0, newList.length);
window.lists = JSON.parse(newList); window.lists = JSON.parse(newList);
response.querySelector("#lists-script").remove(); response.querySelector("#lists-script").remove();
Helper.removeElement("#sidenav-overlay"); Helper.removeElement("#sidenav-overlay");
document.getElementsByTagName("main")[0].className = "center-align container"; document.getElementsByTagName("main")[0].className =
"center-align container";
Helper.removeClass("#main-container", "channelpage"); Helper.removeClass("#main-container", "channelpage");
document.getElementById("main-container").setAttribute("style", ""); document.getElementById("main-container").setAttribute("style", "");
document.getElementsByTagName("header")[0].innerHTML = response.querySelectorAll("header")[0].outerHTML; document.getElementsByTagName(
"header"
)[0].innerHTML = response.querySelectorAll("header")[0].outerHTML;
document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mega")[0].outerHTML); document
.getElementsByTagName("header")[0]
.insertAdjacentHTML(
"afterend",
response.querySelectorAll(".section.mega")[0].outerHTML
);
//document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mobile-search")[0].innerHTML); //document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mobile-search")[0].innerHTML);
if(Helper.mobilecheck() || user_auth_avoid) { if (Helper.mobilecheck() || user_auth_avoid) {
document.getElementsByTagName("main")[0].innerHTML = response.querySelectorAll("main")[0].innerHTML; document.getElementsByTagName(
"main"
)[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
} else { } else {
document.getElementsByTagName("main")[0].insertAdjacentHTML("beforeend", response.querySelectorAll("#main_section_frontpage")[0].outerHTML); document
.getElementsByTagName("main")[0]
.insertAdjacentHTML(
"beforeend",
response.querySelectorAll("#main_section_frontpage")[0]
.outerHTML
);
} }
Helper.removeClass(".page-footer", "padding-bottom-extra"); Helper.removeClass(".page-footer", "padding-bottom-extra");
Helper.removeClass(".page-footer", "padding-bottom-novideo"); Helper.removeClass(".page-footer", "padding-bottom-novideo");
document.getElementById("favicon").setAttribute("href", "/assets/images/favicon-32x32.png"); document
.getElementById("favicon")
.setAttribute("href", "/assets/images/favicon-32x32.png");
Helper.log(["Socket", socket]); Helper.log(["Socket", socket]);
if (document.querySelectorAll("#alreadyfp").length == 1) { if (document.querySelectorAll("#alreadyfp").length == 1) {
@@ -716,8 +923,16 @@ var Channel = {
changing_to_frontpage = false; changing_to_frontpage = false;
if(document.querySelectorAll("#alreadychannel").length === 0 && !user_auth_avoid){ if (
document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", "<div id='alreadychannel'></div"); document.querySelectorAll("#alreadychannel").length === 0 &&
!user_auth_avoid
) {
document
.getElementsByTagName("head")[0]
.insertAdjacentHTML(
"beforeend",
"<div id='alreadychannel'></div"
);
} else if (user_auth_avoid) { } else if (user_auth_avoid) {
Helper.removeElement("#alreadychannel"); Helper.removeElement("#alreadychannel");
} }
@@ -727,7 +942,7 @@ var Channel = {
}); });
} }
} }
} };
function get_history() { function get_history() {
if (socket && socket.id) { if (socket && socket.id) {

View File

@@ -4,12 +4,11 @@ var socket;
var rotation_timeout; var rotation_timeout;
var Frontpage = { var Frontpage = {
blob_list: [], blob_list: [],
winter: (new Date()).getMonth() >= 10 ? true : false, winter: new Date().getMonth() >= 10 ? true : false,
pride: function() { pride: function() {
return (new Date()).getMonth() == 5; return new Date().getMonth() == 5;
}, },
times_rotated: 0, times_rotated: 0,
@@ -19,10 +18,7 @@ var Frontpage = {
frontpage_function: function() { frontpage_function: function() {
frontpage = true; frontpage = true;
Helper.log([ Helper.log(["Frontpage fetch", msg]);
"Frontpage fetch",
msg
]);
Frontpage.all_channels = window.lists; Frontpage.all_channels = window.lists;
var msg = window.lists; var msg = window.lists;
@@ -31,7 +27,9 @@ var Frontpage = {
//document.querySelector("#lists-script").remove(); //document.querySelector("#lists-script").remove();
if (msg.length == 0) { if (msg.length == 0) {
//Helper.css("#preloader", "display", "none"); //Helper.css("#preloader", "display", "none");
document.getElementById("channel-list-container").insertAdjacentHTML("beforeend", "<p>No channels yet</p>"); document
.getElementById("channel-list-container")
.insertAdjacentHTML("beforeend", "<p>No channels yet</p>");
} else { } else {
Frontpage.populate_channels(msg, true, false); Frontpage.populate_channels(msg, true, false);
} }
@@ -46,27 +44,39 @@ var Frontpage = {
else if (set) { else if (set) {
document.getElementById("channels").innerHTML = ""; document.getElementById("channels").innerHTML = "";
if (popular) { if (popular) {
lists = lists.sort(Helper.predicate({ lists = lists.sort(
name: 'pinned', Helper.predicate(
{
name: "pinned",
reverse: true reverse: true
}, { },
name: 'viewers', {
name: "viewers",
reverse: true reverse: true
}, { },
name: 'accessed', {
name: "accessed",
reverse: true reverse: true
}, { },
name: 'count', {
name: "count",
reverse: true reverse: true
})); }
)
);
} else { } else {
lists = lists.sort(Helper.predicate({ lists = lists.sort(
name: 'viewers', Helper.predicate(
{
name: "viewers",
reverse: true reverse: true
}, { },
name: 'count', {
name: "count",
reverse: true reverse: true
})); }
)
);
} }
if (!Helper.mobilecheck()) { if (!Helper.mobilecheck()) {
@@ -76,10 +86,7 @@ var Frontpage = {
pre_card = channel_list; pre_card = channel_list;
Helper.log([ Helper.log(["Pre_card: ", pre_card]);
"Pre_card: ",
pre_card
]);
for (var x in lists) { for (var x in lists) {
var chan = Helper.decodeChannelName(lists[x]._id); var chan = Helper.decodeChannelName(lists[x]._id);
@@ -88,7 +95,10 @@ var Frontpage = {
var viewers = lists[x].viewers; var viewers = lists[x].viewers;
var description = lists[x].description; var description = lists[x].description;
var img; var img;
img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');"; img =
"background-image:url('https://img.youtube.com/vi/" +
id +
"/hqdefault.jpg');";
if (lists[x].thumbnail && lists[x].thumbnail != "") { if (lists[x].thumbnail && lists[x].thumbnail != "") {
img = "background-image:url('" + lists[x].thumbnail + "');"; img = "background-image:url('" + lists[x].thumbnail + "');";
} }
@@ -99,7 +109,9 @@ var Frontpage = {
//card.innerHTML = card.children[0]; //card.innerHTML = card.children[0];
if (song_count > 3) { if (song_count > 3) {
if (lists[x].pinned == 1) { if (lists[x].pinned == 1) {
card.querySelector(".pin").setAttribute("style", "display:block;"); card
.querySelector(".pin")
.setAttribute("style", "display:block;");
//card.find(".card").attr("title", "Featured list"); //card.find(".card").attr("title", "Featured list");
} else { } else {
/*card.find(".pin").attr("style", "display:none;"); /*card.find(".pin").attr("style", "display:none;");
@@ -113,20 +125,26 @@ var Frontpage = {
card.querySelector(".chan-bg").setAttribute("style", img); card.querySelector(".chan-bg").setAttribute("style", img);
card.querySelector(".chan-link").setAttribute("href", chan + "/"); card.querySelector(".chan-link").setAttribute("href", chan + "/");
if(description != "" && description != undefined && !Helper.mobilecheck() && description != "This list has no description") { if (
description != "" &&
description != undefined &&
!Helper.mobilecheck() &&
description != "This list has no description"
) {
card.querySelector(".card-title").innerText = chan; card.querySelector(".card-title").innerText = chan;
card.querySelector(".description_text").innerText = description; card.querySelector(".description_text").innerText = description;
description = ""; description = "";
} else { } else {
card.querySelector(".card-reveal").remove(); card.querySelector(".card-reveal").remove();
Helper.removeClass(card.querySelector(".card"), "sticky-action") Helper.removeClass(card.querySelector(".card"), "sticky-action");
} }
document.getElementById("channels").insertAdjacentHTML("beforeend", card.children[0].innerHTML); document
.getElementById("channels")
.insertAdjacentHTML("beforeend", card.children[0].innerHTML);
} else { } else {
num--; num--;
} }
} }
num++; num++;
} }
@@ -139,12 +157,19 @@ var Frontpage = {
for (var x in options_list) { for (var x in options_list) {
data[Helper.decodeChannelName(options_list[x]._id)] = null; data[Helper.decodeChannelName(options_list[x]._id)] = null;
} }
if(document.querySelectorAll(".pin").length == 1 && !Helper.mobilecheck()) { if (
Helper.tooltip(document.querySelectorAll(".pin")[0].parentElement.parentElement.parentElement, { document.querySelectorAll(".pin").length == 1 &&
!Helper.mobilecheck()
) {
Helper.tooltip(
document.querySelectorAll(".pin")[0].parentElement.parentElement
.parentElement,
{
delay: 5, delay: 5,
position: "top", position: "top",
html: "Featured playlist" html: "Featured playlist"
}); }
);
} }
var to_autocomplete = document.querySelectorAll("input.autocomplete")[0]; var to_autocomplete = document.querySelectorAll("input.autocomplete")[0];
@@ -155,7 +180,7 @@ var Frontpage = {
limit: 5, // The max amount of results that can be shown at once. Default: Infinity. limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
onAutocomplete: function(val) { onAutocomplete: function(val) {
Frontpage.to_channel(Helper.encodeChannelName(val), false); Frontpage.to_channel(Helper.encodeChannelName(val), false);
}, }
}); });
//document.getElementById("preloader").style.display = "none"; //document.getElementById("preloader").style.display = "none";
@@ -196,10 +221,10 @@ var Frontpage = {
getCookie: function(cname) { getCookie: function(cname) {
var name = cname + "="; var name = cname + "=";
var ca = document.cookie.split(';'); var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) { for (var i = 0; i < ca.length; i++) {
var c = ca[i]; var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1); while (c.charAt(0) == " ") c = c.substring(1);
if (c.indexOf(name) === 0) return c.substring(name.length, c.length); if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
} }
return ""; return "";
@@ -213,11 +238,17 @@ var Frontpage = {
//$(".room-namer").css("opacity", 0); //$(".room-namer").css("opacity", 0);
setTimeout(function() { setTimeout(function() {
if (frontpage) { if (frontpage) {
Helper.css("#mega-background","background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")"); Helper.css(
"#mega-background",
"background",
"url(data:image/png;base64," + Frontpage.blob_list[i] + ")"
);
Helper.css("#mega-background", "background-size", "cover"); Helper.css("#mega-background", "background-size", "cover");
Helper.css("#mega-background", "background-repeat", "no-repeat"); Helper.css("#mega-background", "background-repeat", "no-repeat");
Helper.css("#mega-background", "opacity", 1); Helper.css("#mega-background", "opacity", 1);
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id)); document
.querySelector(".autocomplete")
.setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
//$(".room-namer").css("opacity", 1); //$(".room-namer").css("opacity", 1);
} }
}, 500); }, 500);
@@ -225,7 +256,8 @@ var Frontpage = {
var img = new Image(); var img = new Image();
img.src = "/assets/images/thumbnails/" + id + ".jpg"; img.src = "/assets/images/thumbnails/" + id + ".jpg";
img.onerror = function(e){ // Failed to load img.onerror = function(e) {
// Failed to load
var add = ""; var add = "";
if (window.location.hostname == "fb.zoff.me") { if (window.location.hostname == "fb.zoff.me") {
add = "https://zoff.me"; add = "https://zoff.me";
@@ -238,33 +270,53 @@ var Frontpage = {
success: function(data) { success: function(data) {
setTimeout(function() { setTimeout(function() {
try { try {
Helper.css("#mega-background", "background", "url(/assets/images/thumbnails/"+data+")"); Helper.css(
"#mega-background",
"background",
"url(/assets/images/thumbnails/" + data + ")"
);
Helper.css("#mega-background", "background-size", "cover"); Helper.css("#mega-background", "background-size", "cover");
Helper.css("#mega-background", "background-repeat" , "no-repeat"); Helper.css(
"#mega-background",
"background-repeat",
"no-repeat"
);
Helper.css("#mega-background", "opacity", 1); Helper.css("#mega-background", "opacity", 1);
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id)); document
} catch(e) {} .querySelector(".autocomplete")
.setAttribute(
"placeholder",
Helper.decodeChannelName(list[i]._id)
);
} catch (e) {}
}, 500); }, 500);
}, },
error: function() { error: function() {
try { try {
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id)); document
.querySelector(".autocomplete")
.setAttribute(
"placeholder",
Helper.decodeChannelName(list[i]._id)
);
} catch (e) { } catch (e) {
console.log("This is a weird error...", e); console.log("This is a weird error...", e);
} }
} }
}); });
}; };
img.onload = function(){ // Loaded successfully img.onload = function() {
// Loaded successfully
try { try {
Helper.css("#mega-background", "background", "url(" + img.src + ")"); Helper.css("#mega-background", "background", "url(" + img.src + ")");
Helper.css("#mega-background", "background-size", "cover"); Helper.css("#mega-background", "background-size", "cover");
Helper.css("#mega-background", "background-repeat", "no-repeat"); Helper.css("#mega-background", "background-repeat", "no-repeat");
Helper.css("#mega-background", "opacity", 1); Helper.css("#mega-background", "opacity", 1);
document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id)); document
.querySelector(".autocomplete")
.setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
} catch (e) {} } catch (e) {}
}; };
} }
rotation_timeout = setTimeout(function() { rotation_timeout = setTimeout(function() {
if (Frontpage.times_rotated == 50 && frontpage) { if (Frontpage.times_rotated == 50 && frontpage) {
@@ -305,7 +357,7 @@ var Frontpage = {
start_snowfall: function() { start_snowfall: function() {
setTimeout(function() { setTimeout(function() {
var x = Math.floor((Math.random() * window.innerWidth) + 1); var x = Math.floor(Math.random() * window.innerWidth + 1);
var snow = document.createElement("div"); var snow = document.createElement("div");
var parent = document.getElementsByClassName("mega")[0]; var parent = document.getElementsByClassName("mega")[0];
@@ -320,8 +372,11 @@ var Frontpage = {
}, },
fall_snow: function(corn) { fall_snow: function(corn) {
corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px"; 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){ if (
parseInt(corn.style.top.replace("px", "")) <
document.getElementById("mega-background").offsetHeight - 2.5
) {
setTimeout(function() { setTimeout(function() {
Frontpage.fall_snow(corn); Frontpage.fall_snow(corn);
}, 50); }, 50);
@@ -331,7 +386,8 @@ var Frontpage = {
}, },
set_viewers: function(viewers) { set_viewers: function(viewers) {
document.querySelector("#frontpage-viewer-counter").innerHTML = "<i class='material-icons frontpage-viewers'>visibility</i>" + viewers; document.querySelector("#frontpage-viewer-counter").innerHTML =
"<i class='material-icons frontpage-viewers'>visibility</i>" + viewers;
}, },
to_channel: function(new_channel, popstate) { to_channel: function(new_channel, popstate) {
@@ -351,7 +407,11 @@ var Frontpage = {
Helper.tooltip("#offline-mode", "destroy"); Helper.tooltip("#offline-mode", "destroy");
Helper.tooltip("#client-mode-button", "destroy"); Helper.tooltip("#client-mode-button", "destroy");
if (document.querySelectorAll(".pin").length == 1) { if (document.querySelectorAll(".pin").length == 1) {
Helper.tooltip(document.querySelectorAll(".pin")[0].parentElement.parentElement.parentElement, "destroy"); Helper.tooltip(
document.querySelectorAll(".pin")[0].parentElement.parentElement
.parentElement,
"destroy"
);
} }
} }
@@ -362,7 +422,6 @@ var Frontpage = {
method: "get", method: "get",
data: { channel: new_channel }, data: { channel: new_channel },
success: function(e) { success: function(e) {
if (Player.player !== "") { if (Player.player !== "") {
//Player.player.destroy(); //Player.player.destroy();
socket.emit("change_channel", { channel: chan.toLowerCase() }); socket.emit("change_channel", { channel: chan.toLowerCase() });
@@ -376,7 +435,11 @@ var Frontpage = {
} }
var old_chan = chan; var old_chan = chan;
if (!popstate) { if (!popstate) {
window.history.pushState("to the channel!", "Title", "/" + new_channel); window.history.pushState(
"to the channel!",
"Title",
"/" + new_channel
);
if (prev_chan_list == "") prev_chan_list = new_channel; if (prev_chan_list == "") prev_chan_list = new_channel;
if (prev_chan_player == "") prev_chan_player = new_channel; if (prev_chan_player == "") prev_chan_player = new_channel;
chan = new_channel; chan = new_channel;
@@ -385,21 +448,45 @@ var Frontpage = {
var response = document.createElement("div"); var response = document.createElement("div");
response.innerHTML = e; response.innerHTML = e;
M.FormSelect.getInstance(document.querySelector("#view_channels_select")).destroy(); M.FormSelect.getInstance(
document.querySelector("#view_channels_select")
).destroy();
//$('select').formSelect('destroy'); //$('select').formSelect('destroy');
Helper.removeElement(".mega"); Helper.removeElement(".mega");
Helper.removeElement(".mobile-search"); Helper.removeElement(".mobile-search");
document.getElementsByTagName("main")[0].className = "container center-align main"; document.getElementsByTagName("main")[0].className =
"container center-align main";
Helper.addClass("#main-container", "channelpage"); Helper.addClass("#main-container", "channelpage");
document.getElementsByTagName("header")[0].innerHTML = response.querySelectorAll("header")[0].innerHTML; document.getElementsByTagName(
"header"
)[0].innerHTML = response.querySelectorAll("header")[0].innerHTML;
if(document.querySelectorAll("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){ if (
document.getElementsByTagName("main")[0].innerHTML = response.querySelectorAll("main")[0].innerHTML; document.querySelectorAll("#alreadychannel").length === 0 ||
Helper.mobilecheck() ||
Player.player === undefined
) {
document.getElementsByTagName(
"main"
)[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
} else { } else {
document.getElementById("main-row").insertAdjacentHTML("beforeend", response.querySelectorAll("#playlist")[0].outerHTML); document
if(!client) document.getElementById("video-container").insertAdjacentHTML("beforeend", response.querySelectorAll("#main_components")[0].outerHTML); .getElementById("main-row")
document.getElementById("main-row").insertAdjacentHTML("beforeend", "<div id='playbar'></div>"); .insertAdjacentHTML(
"beforeend",
response.querySelectorAll("#playlist")[0].outerHTML
);
if (!client)
document
.getElementById("video-container")
.insertAdjacentHTML(
"beforeend",
response.querySelectorAll("#main_components")[0].outerHTML
);
document
.getElementById("main-row")
.insertAdjacentHTML("beforeend", "<div id='playbar'></div>");
Helper.removeClass("#player", "player_bottom"); Helper.removeClass("#player", "player_bottom");
Helper.removeClass("#player_overlay", "player_bottom"); Helper.removeClass("#player_overlay", "player_bottom");
Helper.removeClass(".video-container", "frontpage-player"); Helper.removeClass(".video-container", "frontpage-player");
@@ -408,7 +495,9 @@ var Frontpage = {
Helper.removeElement("#closePlayer"); Helper.removeElement("#closePlayer");
Helper.removeElement("#player_bottom_overlay"); Helper.removeElement("#player_bottom_overlay");
} }
document.getElementById("search").setAttribute("placeholder", "Search..."); document
.getElementById("search")
.setAttribute("placeholder", "Search...");
Helper.addClass(".page-footer", "padding-bottom-novideo"); Helper.addClass(".page-footer", "padding-bottom-novideo");
from_frontpage = true; from_frontpage = true;
//Player.stopInterval =true; //Player.stopInterval =true;
@@ -420,14 +509,15 @@ var Frontpage = {
fromFront = true; fromFront = true;
Channel.init(); Channel.init();
} }
if(document.querySelectorAll("#alreadyfp").length === 0) document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", "<div id='alreadyfp'></div>"); if (document.querySelectorAll("#alreadyfp").length === 0)
document
.getElementsByTagName("head")[0]
.insertAdjacentHTML("beforeend", "<div id='alreadyfp'></div>");
} }
}); });
}, },
init: function() { init: function() {
var date = new Date(); var date = new Date();
Frontpage.blob_list = []; Frontpage.blob_list = [];
if (date.getMonth() == 3 && date.getDate() == 1) { if (date.getMonth() == 3 && date.getDate() == 1) {
@@ -439,12 +529,12 @@ var Frontpage = {
if (window.location.hostname != "localhost") { if (window.location.hostname != "localhost") {
var page = window.location.pathname; var page = window.location.pathname;
if (page.substring(page.length - 1) != "/") page += "/"; if (page.substring(page.length - 1) != "/") page += "/";
ga('send', 'pageview', page); ga("send", "pageview", page);
} }
window.onpopstate = function(e) { window.onpopstate = function(e) {
var url_split = window.location.href.split("/"); var url_split = window.location.href.split("/");
console.log(url_split);
if (url_split[3] !== "" && url_split[3].substring(0, 1) != "#") { if (url_split[3] !== "" && url_split[3].substring(0, 1) != "#") {
Frontpage.to_channel(url_split[3], true); Frontpage.to_channel(url_split[3], true);
} }
@@ -454,19 +544,31 @@ var Frontpage = {
Helper.addClass("footer", "hide"); Helper.addClass("footer", "hide");
} }
channel_list = document.querySelector(".hidden-channel-list").cloneNode(true).innerHTML; channel_list = document
.querySelector(".hidden-channel-list")
.cloneNode(true).innerHTML;
try { try {
document.querySelector(".hidden-channel-list").remove(); document.querySelector(".hidden-channel-list").remove();
} catch (e) {} } catch (e) {}
Frontpage.share_link_modifier(); Frontpage.share_link_modifier();
if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.zoff.me") add = "https://zoff.me"; if (
window.location.hostname == "zoff.me" ||
window.location.hostname == "fb.zoff.me"
)
add = "https://zoff.me";
else add = window.location.hostname; else add = window.location.hostname;
if (socket === undefined) { if (socket === undefined) {
no_socket = false; no_socket = false;
socket = io.connect(''+add, connection_options); if (window.location.port != "") {
socket.on('update_required', function(msg) { add = add + ":" + window.location.port + "/";
}
socket = io.connect(
"" + add,
connection_options
);
socket.on("update_required", function(msg) {
if (window.location.hostname == "localhost") { if (window.location.hostname == "localhost") {
console.log(msg); console.log(msg);
return; return;
@@ -474,21 +576,23 @@ var Frontpage = {
window.location.reload(true); window.location.reload(true);
}); });
} }
if(document.querySelectorAll("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){ if (
document.querySelectorAll("#alreadyfp").length === 0 ||
Helper.mobilecheck() ||
!socket._callbacks.$playlists ||
user_auth_avoid
) {
setup_playlist_listener(); setup_playlist_listener();
} }
/*M.Modal.init(document.getElementById("about")); /*M.Modal.init(document.getElementById("about"));
M.Modal.init(document.getElementById("help")); M.Modal.init(document.getElementById("help"));
M.Modal.init(document.getElementById("contact"));*/ M.Modal.init(document.getElementById("contact"));*/
var elem = document.querySelector('select'); var elem = document.querySelector("select");
document.querySelector(".no-jump-select").remove(); document.querySelector(".no-jump-select").remove();
M.FormSelect.init(elem); M.FormSelect.init(elem);
Helper.log([ Helper.log(["Sending frontpage_lists", "Socket"]);
"Sending frontpage_lists",
"Socket"
]);
Crypt.init(); Crypt.init();
if (Crypt.get_offline()) { if (Crypt.get_offline()) {
@@ -525,7 +629,7 @@ var Frontpage = {
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000) //Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
if (window.location.hash == "#donation") { if (window.location.hash == "#donation") {
window.location.hash = "#"; window.location.hash = "#";
M.Modal.init(document.getElementById("donation"));; M.Modal.init(document.getElementById("donation"));
M.Modal.getInstance(document.getElementById("donation")).open(); M.Modal.getInstance(document.getElementById("donation")).open();
} }
@@ -541,7 +645,9 @@ var Frontpage = {
});*/ });*/
if (!Helper.mobilecheck() && Frontpage.winter) { if (!Helper.mobilecheck() && Frontpage.winter) {
document.getElementsByClassName("mega")[0].insertAdjacentHTML("afterbegin", '<div id="snow"></div>'); document
.getElementsByClassName("mega")[0]
.insertAdjacentHTML("afterbegin", '<div id="snow"></div>');
} }
if (Frontpage.pride()) { if (Frontpage.pride()) {
Helper.addClass("#fp-nav", "pride-background"); Helper.addClass("#fp-nav", "pride-background");
@@ -551,19 +657,39 @@ var Frontpage = {
//$('input#autocomplete-input').characterCounter(); //$('input#autocomplete-input').characterCounter();
} }
window['__onGCastApiAvailable'] = function(loaded, errorInfo) { window["__onGCastApiAvailable"] = function(loaded, errorInfo) {
if (loaded) { if (loaded) {
chromecastReady = true; chromecastReady = true;
} else { } else {
} }
} };
}, },
share_link_modifier: function() { share_link_modifier: function() {
document.getElementById("facebook-code-link").setAttribute("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/"); document
document.getElementById("facebook-code-link").setAttribute("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;"); .getElementById("facebook-code-link")
document.getElementById("twitter-code-link").setAttribute("href", "https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic"); .setAttribute(
document.getElementById("twitter-code-link").setAttribute("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;"); "href",
"https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/"
);
document
.getElementById("facebook-code-link")
.setAttribute(
"onclick",
"window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;"
);
document
.getElementById("twitter-code-link")
.setAttribute(
"href",
"https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic"
);
document
.getElementById("twitter-code-link")
.setAttribute(
"onclick",
"window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
);
//$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1"); //$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
//$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1"); //$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff