mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
add comment cleanup and add globals
This commit is contained in:
3970
package-lock.json
generated
3970
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
47
package.json
47
package.json
@@ -4,7 +4,7 @@
|
||||
"description": "Zoff, the shared YouTube based radio services",
|
||||
"main": "server/app.js",
|
||||
"scripts": {
|
||||
"start": "npm install --only=dev && npm install && $(npm bin)/gulp build && node server/app.js",
|
||||
"start": "npm install --only=dev && npm install && $(npm bin)/gulp build && node server/start.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
@@ -20,45 +20,50 @@
|
||||
"url": "https://github.com/zoff-music/zoff/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^4.0.0",
|
||||
"@babel/core": "^7.7.2",
|
||||
"@babel/preset-env": "^7.7.1",
|
||||
"@babel/register": "^7.7.0",
|
||||
"@types/node": "^12.12.8",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-uglify": "^3.0.2"
|
||||
},
|
||||
"homepage": "https://github.com/zoff-music/zoff#readme",
|
||||
"dependencies": {
|
||||
"bad-words": "^1.6.5",
|
||||
"@types/mongodb": "^3.3.10",
|
||||
"bad-words": "^3.0.3",
|
||||
"bcrypt-nodejs": "0.0.3",
|
||||
"body-parser": "^1.18.3",
|
||||
"body-parser": "^1.19.0",
|
||||
"color-thief-jimp": "^2.0.2",
|
||||
"compression": "^1.7.3",
|
||||
"connect-mongo": "^2.0.3",
|
||||
"compression": "^1.7.4",
|
||||
"connect-mongo": "^3.1.2",
|
||||
"cookie-parser": "^1.4.4",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.16.4",
|
||||
"express-handlebars": "^3.0.2",
|
||||
"express-recaptcha": "^3.0.1",
|
||||
"express-session": "^1.15.6",
|
||||
"express": "^4.17.1",
|
||||
"express-handlebars": "^3.1.0",
|
||||
"express-recaptcha": "^5.0.1",
|
||||
"express-session": "^1.17.0",
|
||||
"farmhash": "^3.0.0",
|
||||
"feature-policy": "^0.2.0",
|
||||
"feature-policy": "^0.4.0",
|
||||
"gulp-clean-css": "^4.2.0",
|
||||
"gulp-sourcemaps": "^2.6.5",
|
||||
"gulp-uglify-es": "^1.0.4",
|
||||
"helmet": "^3.21.1",
|
||||
"jimp": "^0.2.28",
|
||||
"mongodb": "^2.2.36",
|
||||
"mongojs": "^2.6.0",
|
||||
"gulp-uglify-es": "^2.0.0",
|
||||
"helmet": "^3.21.2",
|
||||
"jimp": "^0.8.5",
|
||||
"mongodb": "^3.3.4",
|
||||
"mongojs": "^3.1.0",
|
||||
"mongojs-paginate": "^1.2.0",
|
||||
"mongoose": "^5.4.18",
|
||||
"mongoose": "^5.7.11",
|
||||
"mpromise": "^0.5.5",
|
||||
"nodemailer": "^4.7.0",
|
||||
"nodemailer": "^6.3.1",
|
||||
"passport": "^0.4.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"redis": "^2.8.0",
|
||||
"referrer-policy": "^1.1.0",
|
||||
"referrer-policy": "^1.2.0",
|
||||
"request": "^2.88.0",
|
||||
"socket.io": "^2.2.0",
|
||||
"socket.io": "^2.3.0",
|
||||
"socket.io-redis": "^5.2.0",
|
||||
"sticky-session": "^1.1.2",
|
||||
"uniqid": "5.0.3"
|
||||
"uniqid": "5.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
var cluster = require("cluster"),
|
||||
net = require("net"),
|
||||
path = require("path"),
|
||||
//publicPath = path.join(__dirname, 'public'),
|
||||
http = require("http"),
|
||||
port = 8080,
|
||||
farmhash = require("farmhash"),
|
||||
uniqid = require("uniqid"),
|
||||
num_processes = require("os").cpus().length;
|
||||
|
||||
publicPath = path.join(__dirname, "public");
|
||||
pathThumbnails = __dirname;
|
||||
|
||||
try {
|
||||
var redis = require("redis");
|
||||
var client = redis.createClient({ host: "localhost", port: 6379 });
|
||||
client.on("error", function(err) {
|
||||
var client = redis.createClient({
|
||||
host: "localhost",
|
||||
port: 6379
|
||||
});
|
||||
client.on("error", function (err) {
|
||||
console.log("Couldn't connect to redis-server, assuming non-clustered run");
|
||||
num_processes = 1;
|
||||
startSingle(false, false);
|
||||
client.quit();
|
||||
});
|
||||
client.on("connect", function() {
|
||||
client.on("connect", function () {
|
||||
startClustered(true);
|
||||
client.quit();
|
||||
});
|
||||
@@ -34,9 +33,9 @@ function startClustered(redis_enabled) {
|
||||
//Found https://stackoverflow.com/questions/40885592/use-node-js-cluster-with-socket-io-chat-application
|
||||
if (cluster.isMaster) {
|
||||
var workers = [];
|
||||
var spawn = function(i) {
|
||||
var spawn = function (i) {
|
||||
workers[i] = cluster.fork();
|
||||
workers[i].on("exit", function(code, signal) {
|
||||
workers[i].on("exit", function (code, signal) {
|
||||
if (code == 1) {
|
||||
process.exit(1);
|
||||
return;
|
||||
@@ -50,8 +49,7 @@ function startClustered(redis_enabled) {
|
||||
spawn(i);
|
||||
}
|
||||
|
||||
var worker_index = function(ip, len) {
|
||||
//console.log(ip);
|
||||
var worker_index = function (ip, len) {
|
||||
var s = "";
|
||||
if (ip !== undefined) {
|
||||
return farmhash.fingerprint32(ip) % len;
|
||||
@@ -66,11 +64,15 @@ function startClustered(redis_enabled) {
|
||||
};
|
||||
|
||||
var server = net
|
||||
.createServer({ pauseOnConnect: true }, function(connection, a) {
|
||||
var worker =
|
||||
workers[worker_index(connection.address().address, num_processes)];
|
||||
worker.send("sticky-session:connection", connection);
|
||||
})
|
||||
.createServer({
|
||||
pauseOnConnect: true
|
||||
},
|
||||
function (connection, a) {
|
||||
var worker =
|
||||
workers[worker_index(connection.address().address, num_processes)];
|
||||
worker.send("sticky-session:connection", connection);
|
||||
}
|
||||
)
|
||||
.listen(port);
|
||||
} else {
|
||||
startSingle(true, redis_enabled);
|
||||
@@ -112,14 +114,19 @@ function startSingle(clustered, redis_enabled) {
|
||||
if (redis_enabled) {
|
||||
var redis = require("socket.io-redis");
|
||||
try {
|
||||
socketIO.adapter(redis({ host: "localhost", port: 6379 }));
|
||||
socketIO.adapter(
|
||||
redis({
|
||||
host: "localhost",
|
||||
port: 6379
|
||||
})
|
||||
);
|
||||
} catch (e) {
|
||||
console.log("No redis-server to connect to..");
|
||||
}
|
||||
}
|
||||
socketIO.listen(server);
|
||||
|
||||
process.on("message", function(message, connection) {
|
||||
process.on("message", function (message, connection) {
|
||||
if (message !== "sticky-session:connection") {
|
||||
return;
|
||||
}
|
||||
@@ -136,12 +143,12 @@ function routingFunction(req, res, next) {
|
||||
var client = require("./apps/client.js");
|
||||
var admin = require("./apps/admin.js");
|
||||
try {
|
||||
var url = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"]
|
||||
: req.headers.host.split(":")[0];
|
||||
var subdomain = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"].split(".")
|
||||
: req.headers.host.split(":")[0].split(".");
|
||||
var url = req.headers["x-forwarded-host"] ?
|
||||
req.headers["x-forwarded-host"] :
|
||||
req.headers.host.split(":")[0];
|
||||
var subdomain = req.headers["x-forwarded-host"] ?
|
||||
req.headers["x-forwarded-host"].split(".") :
|
||||
req.headers.host.split(":")[0].split(".");
|
||||
|
||||
if (subdomain.length > 1 && subdomain[0] == "admin") {
|
||||
admin(req, res, next);
|
||||
@@ -154,4 +161,4 @@ function routingFunction(req, res, next) {
|
||||
res.write("Bad request"); //write a response to the client
|
||||
res.end(); //end the response
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
var express = require("express");
|
||||
var app = express();
|
||||
|
||||
const path = require("path");
|
||||
const publicPath = path.join(__dirname + "", "../public");
|
||||
import {
|
||||
publicPath,
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var exphbs = require("express-handlebars");
|
||||
var hbs = exphbs.create({
|
||||
defaultLayout: publicPath + "/layouts/admin/main",
|
||||
@@ -11,12 +14,10 @@ var hbs = exphbs.create({
|
||||
});
|
||||
|
||||
var passport = require("passport");
|
||||
var mpromise = require("mpromise");
|
||||
var LocalStrategy = require("passport-local").Strategy;
|
||||
var mongoose = require("mongoose");
|
||||
var mongo_db_cred = require(pathThumbnails + "/config/mongo_config.js");
|
||||
var mongojs = require("mongojs");
|
||||
var db = mongojs(mongo_db_cred.config);
|
||||
var token_db = mongojs("tokens");
|
||||
var bodyParser = require("body-parser");
|
||||
var session = require("express-session");
|
||||
@@ -30,7 +31,9 @@ mongoose.connect(url);
|
||||
|
||||
app.engine("handlebars", hbs.engine);
|
||||
app.set("view engine", "handlebars");
|
||||
app.use(compression({ filter: shouldCompress }));
|
||||
app.use(compression({
|
||||
filter: shouldCompress
|
||||
}));
|
||||
|
||||
function shouldCompress(req, res) {
|
||||
if (req.headers["x-no-compression"]) {
|
||||
@@ -44,7 +47,6 @@ function shouldCompress(req, res) {
|
||||
app.set("trust proxy", "127.0.0.1");
|
||||
|
||||
var bodyParser = require("body-parser");
|
||||
var cookieParser = require("cookie-parser");
|
||||
var referrerPolicy = require("referrer-policy");
|
||||
var helmet = require("helmet");
|
||||
var featurePolicy = require("feature-policy");
|
||||
@@ -52,13 +54,11 @@ app.use(
|
||||
featurePolicy({
|
||||
features: {
|
||||
fullscreen: ["*"],
|
||||
//vibrate: ["'none'"],
|
||||
payment: ["'none'"],
|
||||
microphone: ["'none'"],
|
||||
camera: ["'none'"],
|
||||
speaker: ["*"],
|
||||
syncXhr: ["'self'"]
|
||||
//notifications: ["'self'"]
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -67,7 +67,9 @@ app.use(
|
||||
frameguard: false
|
||||
})
|
||||
);
|
||||
app.use(referrerPolicy({ policy: "origin-when-cross-origin" }));
|
||||
app.use(referrerPolicy({
|
||||
policy: "origin-when-cross-origin"
|
||||
}));
|
||||
app.enable("view cache");
|
||||
app.set("views", publicPath);
|
||||
app.use(bodyParser.json()); // to support JSON-encoded bodies
|
||||
@@ -92,43 +94,47 @@ app.use(
|
||||
app.use(passport.initialize());
|
||||
app.use(passport.session()); // persistent login sessions
|
||||
|
||||
//app.use('/assets', express.static(publicPath + '/assets'));
|
||||
|
||||
passport.serializeUser(function(user, done) {
|
||||
passport.serializeUser(function (user, done) {
|
||||
done(null, user.id);
|
||||
});
|
||||
|
||||
// used to deserialize the user
|
||||
passport.deserializeUser(function(id, done) {
|
||||
User.findById(id, function(err, user) {
|
||||
passport.deserializeUser(function (id, done) {
|
||||
User.findById(id, function (err, user) {
|
||||
done(err, user);
|
||||
});
|
||||
});
|
||||
|
||||
passport.use(
|
||||
"local-signup",
|
||||
new LocalStrategy(
|
||||
{
|
||||
new LocalStrategy({
|
||||
// by default, local strategy uses username and password, we will override with username
|
||||
usernameField: "username",
|
||||
passwordField: "password",
|
||||
passReqToCallback: true // allows us to pass back the entire request to the callback
|
||||
},
|
||||
function(req, username, password, done) {
|
||||
function (req, username, password, done) {
|
||||
// asynchronous
|
||||
// User.findOne wont fire unless data is sent back
|
||||
process.nextTick(function() {
|
||||
process.nextTick(function () {
|
||||
// find a user whose username is the same as the forms username
|
||||
// we are checking to see if the user trying to login already exists
|
||||
var token = req.body.token;
|
||||
token_db
|
||||
.collection("tokens")
|
||||
.find({ token: token }, function(err, docs) {
|
||||
.find({
|
||||
token: token
|
||||
}, function (err, docs) {
|
||||
if (docs.length == 1) {
|
||||
token_db
|
||||
.collection("tokens")
|
||||
.remove({ token: token }, function(err, docs) {
|
||||
User.findOne({ username: username }, function(err, user) {
|
||||
.remove({
|
||||
token: token
|
||||
}, function (err, docs) {
|
||||
User.findOne({
|
||||
username: username
|
||||
}, function (err, user) {
|
||||
// if there are any errors, return the error
|
||||
if (err) return done(err);
|
||||
|
||||
@@ -145,7 +151,7 @@ passport.use(
|
||||
newUser.password = newUser.generateHash(password);
|
||||
|
||||
// save the user
|
||||
newUser.save(function(err) {
|
||||
newUser.save(function (err) {
|
||||
if (err) throw err;
|
||||
return done(null, newUser);
|
||||
});
|
||||
@@ -163,19 +169,20 @@ passport.use(
|
||||
|
||||
passport.use(
|
||||
"local-login",
|
||||
new LocalStrategy(
|
||||
{
|
||||
new LocalStrategy({
|
||||
// by default, local strategy uses username and password, we will override with email
|
||||
usernameField: "username",
|
||||
passwordField: "password",
|
||||
passReqToCallback: true // allows us to pass back the entire request to the callback
|
||||
},
|
||||
function(req, username, password, done) {
|
||||
function (req, username, password, done) {
|
||||
// callback with email and password from our form
|
||||
|
||||
// find a user whose email is the same as the forms email
|
||||
// we are checking to see if the user trying to login already exists
|
||||
User.findOne({ username: username }, function(err, user) {
|
||||
User.findOne({
|
||||
username: username
|
||||
}, function (err, user) {
|
||||
// if there are any errors, return the error before anything else
|
||||
if (err) return done(err);
|
||||
|
||||
@@ -211,7 +218,7 @@ app.post(
|
||||
})
|
||||
);
|
||||
|
||||
app.use("/login", isLoggedInTryingToLogIn, function(req, res) {
|
||||
app.use("/login", isLoggedInTryingToLogIn, function (req, res) {
|
||||
var data = {
|
||||
where_get: "not_authenticated"
|
||||
};
|
||||
@@ -219,7 +226,7 @@ app.use("/login", isLoggedInTryingToLogIn, function(req, res) {
|
||||
res.render("layouts/admin/not_authenticated", data);
|
||||
});
|
||||
|
||||
app.use("/signup", isLoggedInTryingToLogIn, function(req, res) {
|
||||
app.use("/signup", isLoggedInTryingToLogIn, function (req, res) {
|
||||
var data = {
|
||||
where_get: "not_authenticated"
|
||||
};
|
||||
@@ -229,12 +236,12 @@ app.use("/signup", isLoggedInTryingToLogIn, function(req, res) {
|
||||
|
||||
app.use("/", api);
|
||||
|
||||
app.use("/logout", function(req, res) {
|
||||
app.use("/logout", function (req, res) {
|
||||
req.logout();
|
||||
res.redirect("/login");
|
||||
});
|
||||
|
||||
app.use("/assets/admin/authenticated", function(req, res, next) {
|
||||
app.use("/assets/admin/authenticated", function (req, res, next) {
|
||||
if (!req.isAuthenticated()) {
|
||||
res.sendStatus(403);
|
||||
return;
|
||||
@@ -244,7 +251,7 @@ app.use("/assets/admin/authenticated", function(req, res, next) {
|
||||
|
||||
app.use("/assets", express.static(publicPath + "/assets"));
|
||||
|
||||
app.use("/", isLoggedIn, function(req, res) {
|
||||
app.use("/", isLoggedIn, function (req, res) {
|
||||
var data = {
|
||||
where_get: "authenticated",
|
||||
year: new Date().getYear() + 1900
|
||||
@@ -265,6 +272,4 @@ function isLoggedIn(req, res, next) {
|
||||
res.redirect("/login");
|
||||
}
|
||||
|
||||
//app.listen(default_port);
|
||||
|
||||
module.exports = app;
|
||||
module.exports = app;
|
||||
@@ -1,4 +1,8 @@
|
||||
VERSION = require(pathThumbnails + "/VERSION.js");
|
||||
import {
|
||||
publicPath,
|
||||
pathThumbnails,
|
||||
} from "../settings/globals";
|
||||
|
||||
var secure = false;
|
||||
var path = require("path");
|
||||
try {
|
||||
@@ -7,18 +11,9 @@ try {
|
||||
"cert_config.js"
|
||||
));
|
||||
var fs = require("fs");
|
||||
var privateKey = fs.readFileSync(cert_config.privateKey).toString();
|
||||
var certificate = fs.readFileSync(cert_config.certificate).toString();
|
||||
var ca = fs.readFileSync(cert_config.ca).toString();
|
||||
var credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
ca: ca
|
||||
};
|
||||
secure = true;
|
||||
} catch (err) {}
|
||||
|
||||
var add = "";
|
||||
var express = require("express");
|
||||
var app = express();
|
||||
var compression = require("compression");
|
||||
@@ -31,21 +26,23 @@ var hbs = exphbs.create({
|
||||
layoutsDir: publicPath + "/layouts/client",
|
||||
partialsDir: publicPath + "/partials",
|
||||
helpers: {
|
||||
if_equal: function(a, b, opts) {
|
||||
if_equal: function (a, b, opts) {
|
||||
if (a == b) {
|
||||
return opts.fn(this);
|
||||
} else {
|
||||
return opts.inverse(this);
|
||||
}
|
||||
},
|
||||
decodeString: function(s) {
|
||||
decodeString: function (s) {
|
||||
if (s == undefined) return s;
|
||||
return Functions.decodeChannelName(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
var uniqid = require("uniqid");
|
||||
app.use(compression({ filter: shouldCompress }));
|
||||
app.use(compression({
|
||||
filter: shouldCompress
|
||||
}));
|
||||
|
||||
function shouldCompress(req, res) {
|
||||
if (req.headers["x-no-compression"]) {
|
||||
@@ -68,17 +65,16 @@ var cookieParser = require("cookie-parser");
|
||||
var referrerPolicy = require("referrer-policy");
|
||||
var helmet = require("helmet");
|
||||
var featurePolicy = require("feature-policy");
|
||||
|
||||
app.use(
|
||||
featurePolicy({
|
||||
features: {
|
||||
fullscreen: ["*"],
|
||||
//vibrate: ["'none'"],
|
||||
payment: ["'none'"],
|
||||
microphone: ["'none'"],
|
||||
camera: ["'none'"],
|
||||
speaker: ["*"],
|
||||
syncXhr: ["'self'"]
|
||||
//notifications: ["'self'"]
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -87,7 +83,9 @@ app.use(
|
||||
frameguard: false
|
||||
})
|
||||
);
|
||||
app.use(referrerPolicy({ policy: "origin-when-cross-origin" }));
|
||||
app.use(referrerPolicy({
|
||||
policy: "origin-when-cross-origin"
|
||||
}));
|
||||
app.use(bodyParser.json()); // to support JSON-encoded bodies
|
||||
app.use(
|
||||
bodyParser.urlencoded({
|
||||
@@ -96,12 +94,9 @@ app.use(
|
||||
})
|
||||
);
|
||||
app.use(cookieParser());
|
||||
//app.set('json spaces', 2);
|
||||
|
||||
io = require("socket.io")({
|
||||
pingTimeout: 25000
|
||||
//path: '/zoff',
|
||||
//"origins": ("https://zoff.me:443*,https://zoff.me:8080*,zoff.me:8080*,https://remote.zoff.me:443*,https://remote.zoff.me:8080*,https://fb.zoff.me:443*,https://fb.zoff.me:8080*,https://admin.zoff.me:443*,https://admin.zoff.me:8080*, http://localhost:8080*")});
|
||||
});
|
||||
|
||||
var socketIO = require(pathThumbnails + "/handlers/io.js");
|
||||
@@ -116,12 +111,12 @@ var api = api_file.router;
|
||||
api_file.sIO = app.socketIO;
|
||||
var ico_router = require(pathThumbnails + "/routing/client/icons_routing.js");
|
||||
|
||||
app.get("/robots.txt", function(req, res) {
|
||||
app.get("/robots.txt", function (req, res) {
|
||||
res.type("text/plain");
|
||||
res.send("User-agent: *\nAllow: /$\nDisallow: /");
|
||||
});
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
app.use(function (req, res, next) {
|
||||
var cookie = req.cookies._uI;
|
||||
var skipElements = [
|
||||
"/_embed",
|
||||
@@ -145,12 +140,6 @@ app.use(function(req, res, next) {
|
||||
next();
|
||||
} else {
|
||||
if (cookie === undefined) {
|
||||
try {
|
||||
//console.error((new Date), "originalUrl", req.originalUrl);
|
||||
//console.error((new Date), "couldn't fetch cookie for some reason, maybe no cookie exists?", req.get('origin'), "couldn't fetch cookie for some reason, maybe no cookie exists?");
|
||||
} catch (e) {
|
||||
//console.error((new Date), "couldn't fetch origin");
|
||||
}
|
||||
var user_name = Functions.hash_pass(
|
||||
Functions.rndName(uniqid.time(), 15)
|
||||
);
|
||||
@@ -158,15 +147,12 @@ app.use(function(req, res, next) {
|
||||
maxAge: 365 * 10000 * 3600000,
|
||||
httpOnly: true,
|
||||
secure: secure
|
||||
//sameSite: true,
|
||||
});
|
||||
} else {
|
||||
//process.stderr.write((new Date), "couldn't fetch cookie for some reason, maybe no cookie exists?", req, "couldn't fetch cookie for some reason, maybe no cookie exists?");
|
||||
res.cookie("_uI", cookie, {
|
||||
maxAge: 365 * 10000 * 3600000,
|
||||
httpOnly: true,
|
||||
secure: secure
|
||||
//sameSite: true,
|
||||
});
|
||||
}
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
@@ -179,7 +165,7 @@ app.use(function(req, res, next) {
|
||||
}
|
||||
});
|
||||
|
||||
app.use("/service-worker.js", function(req, res) {
|
||||
app.use("/service-worker.js", function (req, res) {
|
||||
res.sendFile(publicPath + "/service-worker.js");
|
||||
});
|
||||
|
||||
@@ -187,21 +173,21 @@ app.use("/", ico_router);
|
||||
app.use("/", api);
|
||||
app.use("/", cors(), router);
|
||||
|
||||
app.use("/assets/js", function(req, res, next) {
|
||||
app.use("/assets/js", function (req, res, next) {
|
||||
res.sendStatus(403);
|
||||
return;
|
||||
});
|
||||
|
||||
app.use("/assets/admin", function(req, res, next) {
|
||||
app.use("/assets/admin", function (req, res, next) {
|
||||
res.sendStatus(403);
|
||||
return;
|
||||
});
|
||||
|
||||
app.use("/assets", express.static(publicPath + "/assets"));
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
app.use(function (req, res, next) {
|
||||
res.status(404);
|
||||
res.redirect("/404");
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
module.exports = app;
|
||||
@@ -1,74 +1,52 @@
|
||||
var path = require('path');
|
||||
var publicPath = path.join(__dirname, 'public');
|
||||
var pathThumbnail = __dirname;
|
||||
import {
|
||||
pathThumbnail
|
||||
} from "../settings/globals";
|
||||
pathThumbnails = __dirname + "/../";
|
||||
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/;
|
||||
try {
|
||||
var keys = require(path.join(__dirname, '../config/api_key.js'));
|
||||
var key = keys.youtube;
|
||||
var soundcloudKey = keys.soundcloud;
|
||||
} catch(e) {
|
||||
console.log("Error - missing file");
|
||||
console.log("Seems you forgot to create the file api_key.js in /server/config/. Have a look at api_key.example.js.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var Search = require(pathThumbnail + '/../handlers/search.js');
|
||||
var request = require('request');
|
||||
var db = require(pathThumbnail + '/../handlers/db.js');
|
||||
var currentList = 0;
|
||||
var listNames = [];
|
||||
db.getCollectionNames(function(e, d) {
|
||||
for(var i = 0; i < d.length; i++) {
|
||||
if(d[i].indexOf("_") < 0) {
|
||||
if(d[i].length > 0) {
|
||||
if(d[i].substring(0, 1) == "." || d[i].substring(d[i].length - 1) == ".") continue;
|
||||
db.getCollectionNames(function (e, d) {
|
||||
for (var i = 0; i < d.length; i++) {
|
||||
if (d[i].indexOf("_") < 0) {
|
||||
if (d[i].length > 0) {
|
||||
if (d[i].substring(0, 1) == "." || d[i].substring(d[i].length - 1) == ".") continue;
|
||||
}
|
||||
listNames.push(d[i]);
|
||||
}
|
||||
}
|
||||
console.log("Number of lists is " + listNames.length);
|
||||
/*for(var i = 0; i < listNames.length; i++) {
|
||||
getListItems(d[i]);
|
||||
if(i > 1000) return;
|
||||
}*/
|
||||
recursivifyListLooping(listNames, 0);
|
||||
});
|
||||
|
||||
function filterFunction(el) {
|
||||
return el != null &&
|
||||
el != "" &&
|
||||
el != undefined &&
|
||||
el.trim() != ''
|
||||
}
|
||||
|
||||
function recursivifyListLooping(listNames, i) {
|
||||
if(i > listNames.length) {
|
||||
if (i > listNames.length) {
|
||||
console.log("Done");
|
||||
return;
|
||||
}
|
||||
console.log("List " + i + " of " + listNames.length);
|
||||
getListItems(listNames, 0, function() {
|
||||
getListItems(listNames, 0, function () {
|
||||
console.log("done");
|
||||
});
|
||||
}
|
||||
|
||||
function getListItems(arr, i, callback) {
|
||||
console.log("List " + i + " of " + listNames.length + " - " + arr[i]);
|
||||
if(i >= arr.length) {
|
||||
if(typeof(callback) == "function") callback();
|
||||
if (i >= arr.length) {
|
||||
if (typeof (callback) == "function") callback();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
db.collection(arr[i]).find(function(e, d) {
|
||||
if(d.length > 0) {
|
||||
Search.get_genres_list_recursive(d, arr[i], function(){
|
||||
db.collection(arr[i]).find(function (e, d) {
|
||||
if (d.length > 0) {
|
||||
Search.get_genres_list_recursive(d, arr[i], function () {
|
||||
getListItems(arr, i + 1, callback);
|
||||
});
|
||||
} else {
|
||||
getListItems(arr, i + 1, callback);
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
getListItems(arr, i + 1, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,4 @@ var mongo_config = {
|
||||
expire: 86400,
|
||||
};
|
||||
|
||||
module.exports = mongo_config;
|
||||
module.exports = mongo_config;
|
||||
@@ -73,7 +73,6 @@ var toShowChannel = {
|
||||
_id: 0,
|
||||
tags: 1,
|
||||
now_playing: 1,
|
||||
type: 1,
|
||||
source: 1,
|
||||
thumbnail: 1
|
||||
};
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
var crypto = require("crypto");
|
||||
var db = require(pathThumbnails + "/handlers/db.js");
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
var path = require("path");
|
||||
import { join } from "path";
|
||||
import {
|
||||
mongojs
|
||||
} from 'mongojs';
|
||||
|
||||
try {
|
||||
var mongo_config = require(path.join(
|
||||
path.join(__dirname, "../config/"),
|
||||
var mongo_config = require(
|
||||
join(__dirname, "../config/mongo_config.js"),
|
||||
"mongo_config.js"
|
||||
));
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"(!) Missing file - /config/mongo_config.js. Have a look at /config/mongo_config.example.js. The server won't run without this existing."
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
var mongojs = require("mongojs");
|
||||
var db = mongojs("mongodb://" + mongo_config.host + "/" + mongo_config.config);
|
||||
const db = mongojs("mongodb://" + mongo_config.host + "/" + mongo_config.config);
|
||||
|
||||
db.collection("chat_logs").createIndex({
|
||||
createdAt: 1
|
||||
@@ -20,6 +23,7 @@ db.collection("chat_logs").createIndex({
|
||||
},
|
||||
function () {}
|
||||
);
|
||||
|
||||
db.collection("timeout_api").createIndex({
|
||||
createdAt: 1
|
||||
}, {
|
||||
@@ -27,6 +31,7 @@ db.collection("timeout_api").createIndex({
|
||||
},
|
||||
function () {}
|
||||
);
|
||||
|
||||
db.collection("api_links").createIndex({
|
||||
createdAt: 1
|
||||
}, {
|
||||
@@ -34,6 +39,7 @@ db.collection("api_links").createIndex({
|
||||
},
|
||||
function () {}
|
||||
);
|
||||
|
||||
db.on("connected", function (err) {
|
||||
console.log("connected");
|
||||
});
|
||||
@@ -59,6 +65,7 @@ db.collection("unique_ids").update({
|
||||
},
|
||||
function (err, docs) {}
|
||||
);
|
||||
|
||||
db.collection("user_names").remove({
|
||||
guid: {
|
||||
$exists: true
|
||||
@@ -69,6 +76,7 @@ db.collection("user_names").remove({
|
||||
},
|
||||
function (err, docs) {}
|
||||
);
|
||||
|
||||
db.collection("user_names").update({
|
||||
_id: "all_names"
|
||||
}, {
|
||||
@@ -81,6 +89,7 @@ db.collection("user_names").update({
|
||||
},
|
||||
function (err, docs) {}
|
||||
);
|
||||
|
||||
db.collection("connected_users").update({
|
||||
users: {
|
||||
$exists: true
|
||||
@@ -95,6 +104,7 @@ db.collection("connected_users").update({
|
||||
},
|
||||
function (err, docs) {}
|
||||
);
|
||||
|
||||
db.collection("connected_users").update({
|
||||
_id: "total_users"
|
||||
}, {
|
||||
@@ -107,6 +117,7 @@ db.collection("connected_users").update({
|
||||
},
|
||||
function (err, docs) {}
|
||||
);
|
||||
|
||||
db.collection("frontpage_lists").update({
|
||||
viewers: {
|
||||
$ne: 0
|
||||
@@ -122,4 +133,4 @@ db.collection("frontpage_lists").update({
|
||||
function (err, docs) {}
|
||||
);
|
||||
|
||||
module.exports = db;
|
||||
export default db;
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
pathThumbnails,
|
||||
VERSION
|
||||
} from "../settings/globals";
|
||||
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
var db = require(pathThumbnails + "/handlers/db.js");
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var path = require("path");
|
||||
try {
|
||||
var mongo_config = require(path.join(
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var cookie = require("cookie");
|
||||
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
pathThumbnails,
|
||||
VERSION
|
||||
} from "../settings/globals";
|
||||
|
||||
var ColorThief = require("color-thief-jimp");
|
||||
var Jimp = require("jimp");
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
@@ -99,9 +104,8 @@ function list(msg, guid, coll, offline, socket) {
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
|
||||
coll = msg.channel.toLowerCase();
|
||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||
//coll = filter.clean(coll);
|
||||
var pass = msg.pass;
|
||||
db.collection("frontpage_lists").find({
|
||||
_id: coll
|
||||
@@ -1280,7 +1284,6 @@ function sendColor(coll, socket, url, ajax, res) {
|
||||
}
|
||||
|
||||
function getNextSong(coll, socket, callback) {
|
||||
//coll = coll.replace(/ /g,'');
|
||||
db.collection(coll).aggregate(
|
||||
[{
|
||||
$match: {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
var List = require(pathThumbnails + "/handlers/list.js");
|
||||
var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
var crypto = require("crypto");
|
||||
var projects = require(pathThumbnails + "/handlers/aggregates.js");
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var path = require("path");
|
||||
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/;
|
||||
try {
|
||||
@@ -377,7 +381,6 @@ function get_genres_youtube(ids, channel) {
|
||||
}
|
||||
|
||||
function get_correct_info(song_generated, channel, broadcast, callback) {
|
||||
//channel = channel.replace(/ /g,'');
|
||||
request({
|
||||
type: "GET",
|
||||
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id,topicDetails&key=" +
|
||||
@@ -404,7 +407,6 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
||||
.toLowerCase()
|
||||
.split(",");
|
||||
genre = genre.filter(filterFunction);
|
||||
//console.log(genre + " - ", song_generated.id);
|
||||
if (
|
||||
title != song_generated.title ||
|
||||
duration < parseInt(song_generated.duration)
|
||||
@@ -431,7 +433,6 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
||||
function (err, docs) {
|
||||
if (broadcast && docs.nModified == 1) {
|
||||
song_generated.new_id = song_generated.id;
|
||||
//if(song_generated.type == "video")
|
||||
if (typeof callback == "function") {
|
||||
callback(song_generated, true);
|
||||
} else {
|
||||
@@ -494,7 +495,6 @@ function check_error_video(msg, channel) {
|
||||
return;
|
||||
}
|
||||
if (msg.source == "soundcloud") return;
|
||||
//channel = channel.replace(/ /g,'');
|
||||
request({
|
||||
type: "GET",
|
||||
url: "https://www.googleapis.com/youtube/v3/videos?part=id&key=" +
|
||||
@@ -516,7 +516,6 @@ function check_error_video(msg, channel) {
|
||||
}
|
||||
|
||||
function findSimilar(msg, channel, broadcast, callback) {
|
||||
//channel = channel.replace(/ /g,'');
|
||||
var yt_url =
|
||||
"https://www.googleapis.com/youtube/v3/search?key=" +
|
||||
key +
|
||||
@@ -626,7 +625,7 @@ function editDistance(s1, s2) {
|
||||
s1 = s1.toLowerCase();
|
||||
s2 = s2.toLowerCase();
|
||||
|
||||
var costs = new Array();
|
||||
var costs = new [];
|
||||
for (var i = 0; i <= s1.length; i++) {
|
||||
var lastValue = i;
|
||||
for (var j = 0; j <= s2.length; j++) {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
var Notifications = require(pathThumbnails + "/handlers/notifications.js");
|
||||
var crypto = require("crypto");
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
var cluster = require("cluster"),
|
||||
net = require("net"),
|
||||
path = require("path"),
|
||||
//publicPath = path.join(__dirname, 'public'),
|
||||
http = require("http"),
|
||||
port = 8080,
|
||||
//farmhash = require('farmhash'),
|
||||
uniqid = require("uniqid"),
|
||||
num_processes = require("os").cpus().length;
|
||||
|
||||
publicPath = path.join(__dirname, "public");
|
||||
pathThumbnails = __dirname;
|
||||
|
||||
var redis = require("redis");
|
||||
var client = redis.createClient({ host: "localhost", port: 6379 });
|
||||
|
||||
startSingle(true, true);
|
||||
|
||||
function startSingle(clustered, redis_enabled) {
|
||||
var server;
|
||||
var client = require("./apps/client.js");
|
||||
try {
|
||||
var cert_config = require(path.join(
|
||||
path.join(__dirname, "config"),
|
||||
"cert_config.js"
|
||||
));
|
||||
var fs = require("fs");
|
||||
var privateKey = fs.readFileSync(cert_config.privateKey).toString();
|
||||
var certificate = fs.readFileSync(cert_config.certificate).toString();
|
||||
var ca = fs.readFileSync(cert_config.ca).toString();
|
||||
var credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
ca: ca
|
||||
};
|
||||
var https = require("https");
|
||||
server = https.Server(credentials, routingFunction);
|
||||
} catch (err) {
|
||||
console.log("Starting without https (probably on localhost)");
|
||||
server = http.createServer(routingFunction);
|
||||
}
|
||||
|
||||
server.listen(port, onListen);
|
||||
|
||||
var socketIO = client.socketIO;
|
||||
|
||||
var redis = require("socket.io-redis");
|
||||
try {
|
||||
socketIO.adapter(redis({ host: "localhost", port: 6379 }));
|
||||
} catch (e) {
|
||||
console.log("No redis-server to connect to..");
|
||||
}
|
||||
socketIO.listen(server);
|
||||
}
|
||||
|
||||
function onListen() {
|
||||
console.log("Started with pid [" + process.pid + "]");
|
||||
}
|
||||
|
||||
function routingFunction(req, res, next) {
|
||||
var client = require("./apps/client.js");
|
||||
var admin = require("./apps/admin.js");
|
||||
try {
|
||||
var url = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"]
|
||||
: req.headers.host.split(":")[0];
|
||||
var subdomain = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"].split(".")
|
||||
: req.headers.host.split(":")[0].split(".");
|
||||
|
||||
if (subdomain.length > 1 && subdomain[0] == "admin") {
|
||||
admin(req, res, next);
|
||||
} else {
|
||||
client(req, res, next);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Bad request for " + req.headers.host + req.url, e);
|
||||
res.statusCode = 500;
|
||||
res.write("Bad request"); //write a response to the client
|
||||
res.end(); //end the response
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
import {
|
||||
VERSION
|
||||
} from "../../../VERSION";
|
||||
|
||||
var Channel = {
|
||||
init: function() {
|
||||
init: function () {
|
||||
if (window.location.hash == "#small" || inIframe()) {
|
||||
small_player = true;
|
||||
document.querySelector("footer").style.display = "none";
|
||||
@@ -37,7 +41,6 @@ var Channel = {
|
||||
document.querySelector("#hide-playlist").offsetWidth +
|
||||
"px";
|
||||
}
|
||||
//Player.soundcloud_player = document.querySelector("#soundcloud_player");
|
||||
}
|
||||
List.calculate_song_heights();
|
||||
Admin.logged_in = false;
|
||||
@@ -45,7 +48,6 @@ var Channel = {
|
||||
number_suggested = 0;
|
||||
var no_socket = true;
|
||||
|
||||
//chan = Helper.decodeChannelName(Helper.html("#chan"));
|
||||
var _p = window.location.pathname;
|
||||
if (_p.substring(0, 1) == "/") _p = _p.substring(1);
|
||||
if (_p.substring(_p.length - 1) == "/") _p = _p.substring(0, _p.length - 1);
|
||||
@@ -60,7 +62,7 @@ var Channel = {
|
||||
ga("send", "pageview", page);
|
||||
}
|
||||
|
||||
window.onpopstate = function(e) {
|
||||
window.onpopstate = function (e) {
|
||||
Channel.onepage_load();
|
||||
};
|
||||
|
||||
@@ -81,9 +83,8 @@ var Channel = {
|
||||
}
|
||||
|
||||
if (!client) {
|
||||
//Helper.tabs('.playlist-tabs');
|
||||
Helper.tabs(".playlist-tabs-loggedIn", {
|
||||
onShow: function(e) {
|
||||
onShow: function (e) {
|
||||
if (this.index == 2) {
|
||||
document.getElementById("text-chat-input").focus();
|
||||
Chat.channel_received = 0;
|
||||
@@ -103,9 +104,6 @@ var Channel = {
|
||||
.getElementsByClassName("chat-link")[0]
|
||||
.setAttribute("style", "color: white !important;");
|
||||
blinking = false;
|
||||
//Helper.css("#chat-container", "display", "block");
|
||||
//Helper.css("#wrapper", "display", "none");
|
||||
//Helper.css("#suggestions", "display", "none");
|
||||
document.getElementById("text-chat-input").focus();
|
||||
Helper.css("#pageButtons", "display", "none");
|
||||
scrollChat();
|
||||
@@ -137,23 +135,22 @@ var Channel = {
|
||||
edge: side,
|
||||
closeOnClick: false,
|
||||
draggable: Helper.mobilecheck(),
|
||||
onOpenStart: function(el) {
|
||||
onOpenStart: function (el) {
|
||||
Helper.addClass(".hamburger-sidenav", "open");
|
||||
},
|
||||
onCloseStart: function(el) {
|
||||
onCloseStart: function (el) {
|
||||
Helper.removeClass(".hamburger-sidenav", "open");
|
||||
}
|
||||
});
|
||||
M.Collapsible.init(
|
||||
document.getElementsByClassName("settings-collapsible")[0],
|
||||
{
|
||||
document.getElementsByClassName("settings-collapsible")[0], {
|
||||
accordion: true
|
||||
}
|
||||
);
|
||||
|
||||
if (!client) {
|
||||
M.Modal.init(document.getElementById("embed"), {
|
||||
onCloseStart: function() {
|
||||
onCloseStart: function () {
|
||||
document.querySelector(".embed-preview").innerHTML = "";
|
||||
}
|
||||
});
|
||||
@@ -163,12 +160,12 @@ var Channel = {
|
||||
Helper.removeElement(".tabs");
|
||||
}
|
||||
M.Modal.init(document.getElementById("advanced_filter"), {
|
||||
onCloseEnd: function() {
|
||||
onCloseEnd: function () {
|
||||
document.querySelector(".filter-results").innerHTML = "";
|
||||
document.getElementById("filtersearch_input").value = "";
|
||||
document.getElementById("filtersearch_input").blur();
|
||||
},
|
||||
onOpenEnd: function() {
|
||||
onOpenEnd: function () {
|
||||
document.getElementById("filtersearch_input").focus();
|
||||
}
|
||||
});
|
||||
@@ -190,7 +187,7 @@ var Channel = {
|
||||
pagination_buttons_html =
|
||||
"<div class='pagination-results'>" +
|
||||
document.getElementsByClassName("pagination-results")[0].cloneNode(true)
|
||||
.innerHTML +
|
||||
.innerHTML +
|
||||
"</div>";
|
||||
empty_results_html = Helper.html("#empty-results-container");
|
||||
not_import_html = Helper.html(".not-imported-container");
|
||||
@@ -207,7 +204,7 @@ var Channel = {
|
||||
"" + add,
|
||||
connection_options
|
||||
);
|
||||
socket.on("update_required", function(msg) {
|
||||
socket.on("update_required", function (msg) {
|
||||
if (window.location.hostname == "localhost") {
|
||||
console.error(msg);
|
||||
return;
|
||||
@@ -229,7 +226,7 @@ var Channel = {
|
||||
(document.querySelectorAll("#alreadychannel").length === 0 ||
|
||||
!Hostcontroller.old_id ||
|
||||
document.getElementById("code-text").innerText.toUpperCase() ==
|
||||
"ABBADUR")
|
||||
"ABBADUR")
|
||||
)
|
||||
setup_host_initialization();
|
||||
setup_suggested_listener();
|
||||
@@ -278,7 +275,7 @@ var Channel = {
|
||||
.setAttribute(
|
||||
"src",
|
||||
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
|
||||
codeURL
|
||||
codeURL
|
||||
);
|
||||
document.getElementById("code-link").setAttribute("href", codeURL);
|
||||
}
|
||||
@@ -300,15 +297,15 @@ var Channel = {
|
||||
.setAttribute(
|
||||
"src",
|
||||
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
|
||||
shareCodeUrl
|
||||
shareCodeUrl
|
||||
);
|
||||
Helper.setHtml(
|
||||
"#channel-name-join",
|
||||
"client." +
|
||||
window.location.hostname +
|
||||
port +
|
||||
"/" +
|
||||
encodeURIComponent(chan.toLowerCase())
|
||||
window.location.hostname +
|
||||
port +
|
||||
"/" +
|
||||
encodeURIComponent(chan.toLowerCase())
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -380,7 +377,7 @@ var Channel = {
|
||||
} else {
|
||||
Player.loadSoundCloudPlayer();
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
if (Helper.mobilecheck()) {
|
||||
if (!client) {
|
||||
@@ -424,12 +421,11 @@ var Channel = {
|
||||
});
|
||||
}
|
||||
|
||||
addListener("click", ".sp-choose-link", function(e) {
|
||||
addListener("click", ".sp-choose-link", function (e) {
|
||||
event.preventDefault();
|
||||
document.getElementsByClassName("sp-choose")[0].click();
|
||||
});
|
||||
|
||||
//$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
|
||||
document.getElementById("search").focus();
|
||||
Helper.css("#embed-button", "display", "inline-block");
|
||||
document.getElementById("search").setAttribute("placeholder", "Search...");
|
||||
@@ -464,9 +460,9 @@ var Channel = {
|
||||
} else if (chromecastReady && !client) {
|
||||
initializeCastApi();
|
||||
} else if (!client) {
|
||||
window["__onGCastApiAvailable"] = function(loaded, errorInfo) {
|
||||
window["__onGCastApiAvailable"] = function (loaded, errorInfo) {
|
||||
if (loaded) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
chromecastReady = true;
|
||||
initializeCastApi();
|
||||
}, 1000);
|
||||
@@ -479,13 +475,13 @@ var Channel = {
|
||||
Channel.add_context_menu();
|
||||
|
||||
if (!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
Channel.set_title_width();
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
|
||||
set_title_width: function(start) {
|
||||
set_title_width: function (start) {
|
||||
if (window.innerWidth > 600) {
|
||||
var add_width = document.getElementsByClassName("brand-logo")[0]
|
||||
.offsetWidth;
|
||||
@@ -506,7 +502,7 @@ var Channel = {
|
||||
}
|
||||
},
|
||||
|
||||
spotify_is_authenticated: function(bool) {
|
||||
spotify_is_authenticated: function (bool) {
|
||||
if (bool) {
|
||||
Helper.log([
|
||||
"Spotify is authenticated",
|
||||
@@ -524,8 +520,8 @@ var Channel = {
|
||||
}
|
||||
},
|
||||
|
||||
add_context_menu: function() {
|
||||
addListener("contextmenu", ".vote-container", function(e) {
|
||||
add_context_menu: function () {
|
||||
addListener("contextmenu", ".vote-container", function (e) {
|
||||
if (hostMode) {
|
||||
return;
|
||||
}
|
||||
@@ -535,58 +531,58 @@ var Channel = {
|
||||
contextListener(e, that);
|
||||
});
|
||||
|
||||
addListener("contextmenu", ".add-suggested", function(e) {
|
||||
addListener("contextmenu", ".add-suggested", function (e) {
|
||||
this.preventDefault();
|
||||
var that = this;
|
||||
contextListener(e, that);
|
||||
});
|
||||
|
||||
addListener("click", ".list-remove", function(e) {
|
||||
addListener("click", ".list-remove", function (e) {
|
||||
this.preventDefault();
|
||||
var that = this;
|
||||
contextListener(e, that);
|
||||
});
|
||||
},
|
||||
|
||||
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()
|
||||
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;"
|
||||
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() +
|
||||
"&text=Check%20out%20this%20playlist%20" +
|
||||
chan.toLowerCase() +
|
||||
"%20on%20Zoff!&via=zoffmusic"
|
||||
chan.toLowerCase() +
|
||||
"&text=Check%20out%20this%20playlist%20" +
|
||||
chan.toLowerCase() +
|
||||
"%20on%20Zoff!&via=zoffmusic"
|
||||
);
|
||||
document
|
||||
.getElementById("twitter-code-link")
|
||||
.setAttribute(
|
||||
"onclick",
|
||||
"window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" +
|
||||
chan.toLowerCase() +
|
||||
"/&text=Check%20out%20this%20playlist%20" +
|
||||
chan.toLowerCase() +
|
||||
"%20on%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
|
||||
chan.toLowerCase() +
|
||||
"/&text=Check%20out%20this%20playlist%20" +
|
||||
chan.toLowerCase() +
|
||||
"%20on%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
|
||||
);
|
||||
},
|
||||
|
||||
window_width_volume_slider: function() {
|
||||
window_width_volume_slider: function () {
|
||||
if (window.innerWidth <= 600 && slider_type == "horizontal") {
|
||||
slider_type = "vertical";
|
||||
Playercontrols.initSlider();
|
||||
@@ -597,25 +593,25 @@ var Channel = {
|
||||
}
|
||||
},
|
||||
|
||||
listeners: function(on) {
|
||||
var scrollListener = function(e) {
|
||||
listeners: function (on) {
|
||||
var scrollListener = function (e) {
|
||||
if (!programscroll) {
|
||||
userscroll = true;
|
||||
if (
|
||||
document.getElementById("chatchannel").scrollTop +
|
||||
document.getElementById("chatchannel").offsetHeight >=
|
||||
document.getElementById("chatchannel").offsetHeight >=
|
||||
document.getElementById("chatchannel").scrollHeight
|
||||
) {
|
||||
userscroll = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
var scrollAllListener = function(e) {
|
||||
var scrollAllListener = function (e) {
|
||||
if (!programscroll) {
|
||||
userscroll = true;
|
||||
if (
|
||||
document.getElementById("chatall").scrollTop +
|
||||
document.getElementById("chatall").offsetHeight >=
|
||||
document.getElementById("chatall").offsetHeight >=
|
||||
document.getElementById("chatall").scrollHeight
|
||||
) {
|
||||
userscroll = false;
|
||||
@@ -641,7 +637,7 @@ var Channel = {
|
||||
}
|
||||
},
|
||||
|
||||
onepage_load: function() {
|
||||
onepage_load: function () {
|
||||
if (changing_to_frontpage) return;
|
||||
if (user_auth_started) {
|
||||
clearTimeout(durationTimeout);
|
||||
@@ -651,7 +647,6 @@ var Channel = {
|
||||
Helper.tooltip(".castButton", "destroy");
|
||||
Helper.tooltip("#viewers", "destroy");
|
||||
Helper.tooltip("#addToOtherList", "destroy");
|
||||
//$('.castButton-unactive').tooltip("destroy");
|
||||
Helper.tooltip("#offline-mode", "destroy");
|
||||
Helper.tooltip("#admin-lock", "destroy");
|
||||
}
|
||||
@@ -671,9 +666,8 @@ var Channel = {
|
||||
document.getElementById("chan").innerHTML = Helper.upperFirst(chan);
|
||||
var add = "";
|
||||
w_p = true;
|
||||
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {
|
||||
version: parseInt(_VERSION),
|
||||
version: VERSION,
|
||||
channel: add + chan.toLowerCase()
|
||||
});
|
||||
} else if (url_split[3] === "") {
|
||||
@@ -696,7 +690,6 @@ var Channel = {
|
||||
Helper.css("#channel-load", "display", "block");
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
//Player.stopInterval = true;
|
||||
Admin.beginning = true;
|
||||
began = false;
|
||||
durationBegun = false;
|
||||
@@ -734,12 +727,8 @@ var Channel = {
|
||||
}
|
||||
}
|
||||
clearTimeout(tap_target_timeout);
|
||||
//before_toast();
|
||||
if (Helper.mobilecheck() || user_auth_avoid || client) {
|
||||
Helper.log(["Removing all listeners"]);
|
||||
//socket.emit("change_channel");
|
||||
//removeAllListeners();
|
||||
//socket.removeEventListener(id);
|
||||
socket.emit("left_channel", {
|
||||
channel: channel_before_move
|
||||
});
|
||||
@@ -750,14 +739,12 @@ var Channel = {
|
||||
socket.removeEventListener("np");
|
||||
socket.removeEventListener("id");
|
||||
socket.removeEventListener(id);
|
||||
//socket.disconnect();
|
||||
}
|
||||
socket.removeEventListener("chat.all");
|
||||
socket.removeEventListener("chat");
|
||||
socket.removeEventListener("conf");
|
||||
socket.removeEventListener("pw");
|
||||
socket.removeEventListener("toast");
|
||||
//socket.removeEventListener("id");
|
||||
socket.removeEventListener("channel");
|
||||
socket.removeEventListener("auth_required");
|
||||
socket.removeEventListener("auth_accepted");
|
||||
@@ -767,7 +754,7 @@ var Channel = {
|
||||
Helper.ajax({
|
||||
url: "/",
|
||||
method: "GET",
|
||||
success: function(e) {
|
||||
success: function (e) {
|
||||
if (!client) {
|
||||
document.querySelector("#hide-playlist").remove();
|
||||
if (hiddenPlaylist)
|
||||
@@ -857,7 +844,6 @@ var Channel = {
|
||||
"afterend",
|
||||
response.querySelectorAll(".section.mega")[0].outerHTML
|
||||
);
|
||||
//document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mobile-search")[0].innerHTML);
|
||||
if (Helper.mobilecheck() || user_auth_avoid) {
|
||||
document.getElementsByTagName(
|
||||
"main"
|
||||
@@ -868,7 +854,7 @@ var Channel = {
|
||||
.insertAdjacentHTML(
|
||||
"beforeend",
|
||||
response.querySelectorAll("#main_section_frontpage")[0]
|
||||
.outerHTML
|
||||
.outerHTML
|
||||
);
|
||||
}
|
||||
Helper.removeClass(".page-footer", "padding-bottom-extra");
|
||||
@@ -915,11 +901,17 @@ function get_history() {
|
||||
if(p == undefined) p = "";
|
||||
var c = Crypt.crypt_pass(p, true);
|
||||
if(c == undefined) c = "";*/
|
||||
socket.emit("get_history", { channel: chan.toLowerCase(), all: false });
|
||||
socket.emit("get_history", { channel: chan.toLowerCase(), all: true });
|
||||
socket.emit("get_history", {
|
||||
channel: chan.toLowerCase(),
|
||||
all: false
|
||||
});
|
||||
socket.emit("get_history", {
|
||||
channel: chan.toLowerCase(),
|
||||
all: true
|
||||
});
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
get_history();
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,6 @@ var song_title = "";
|
||||
var paused = false;
|
||||
var intelligentList = false;
|
||||
var client = false;
|
||||
var _VERSION;
|
||||
try {
|
||||
_VERSION = localStorage.getItem("VERSION");
|
||||
if (_VERSION == null || _VERSION == undefined) throw "Some error";
|
||||
} catch (e) {
|
||||
_VERSION = 6;
|
||||
}
|
||||
var SC_widget;
|
||||
var scUsingWidget = false;
|
||||
var zoff_api_token = "DwpnKVkaMH2HdcpJT2YPy783SY33byF5/32rbs0+xdU=";
|
||||
@@ -79,10 +72,10 @@ var connection_options = {
|
||||
};
|
||||
|
||||
var Crypt = {
|
||||
crypt_pass: function(pass) {
|
||||
crypt_pass: function (pass) {
|
||||
return pass;
|
||||
},
|
||||
get_background_color: function() {
|
||||
get_background_color: function () {
|
||||
return "dynamic";
|
||||
}
|
||||
};
|
||||
@@ -97,12 +90,16 @@ function receiveMessage(event) {
|
||||
} else if (event.data == "reset") {
|
||||
window.setVolume(100);
|
||||
} else if (event.data == "get_info") {
|
||||
window.parentWindow.postMessage(
|
||||
{ type: "np", title: song_title },
|
||||
window.parentWindow.postMessage({
|
||||
type: "np",
|
||||
title: song_title
|
||||
},
|
||||
window.parentOrigin
|
||||
);
|
||||
window.parentWindow.postMessage(
|
||||
{ type: "controller", id: Hostcontroller.old_id },
|
||||
window.parentWindow.postMessage({
|
||||
type: "controller",
|
||||
id: Hostcontroller.old_id
|
||||
},
|
||||
window.parentOrigin
|
||||
);
|
||||
try {
|
||||
@@ -117,11 +114,11 @@ function receiveMessage(event) {
|
||||
}
|
||||
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
window.addEventListener("DOMContentLoaded", function() {});
|
||||
window.addEventListener("DOMContentLoaded", function () {});
|
||||
|
||||
var Channel = {
|
||||
set_title_width: function() {},
|
||||
window_width_volume_slider: function() {}
|
||||
set_title_width: function () {},
|
||||
window_width_volume_slider: function () {}
|
||||
};
|
||||
|
||||
function getSearch(elem) {
|
||||
@@ -138,7 +135,7 @@ function getSearch(elem) {
|
||||
return result;
|
||||
}
|
||||
|
||||
window.addEventListener("load", function() {
|
||||
window.addEventListener("load", function () {
|
||||
if (autoplay) {
|
||||
Helper.css("#player", "visibility", "hidden");
|
||||
}
|
||||
@@ -156,8 +153,6 @@ window.addEventListener("load", function() {
|
||||
});
|
||||
|
||||
add = "https://zoff.me";
|
||||
//if(window.location.hostname == "localhost") add = "localhost";
|
||||
//add = "localhost";
|
||||
socket = io.connect(
|
||||
"" + add,
|
||||
connection_options
|
||||
@@ -167,7 +162,7 @@ window.addEventListener("load", function() {
|
||||
change_offline(true, false);
|
||||
}
|
||||
|
||||
socket.on("auth_required", function() {
|
||||
socket.on("auth_required", function () {
|
||||
M.Modal.getInstance(document.getElementById("locked_channel")).open();
|
||||
});
|
||||
|
||||
@@ -175,9 +170,9 @@ window.addEventListener("load", function() {
|
||||
"https://zoff.me/" + chan.toLowerCase();
|
||||
document.querySelector(".channel-title").innerText = "/" + chan.toLowerCase();
|
||||
|
||||
socket.on("get_list", function() {
|
||||
socket.on("get_list", function () {
|
||||
socket_connected = true;
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
socket.emit("list", {
|
||||
version: VERSION,
|
||||
channel: chan.toLowerCase(),
|
||||
@@ -186,13 +181,15 @@ window.addEventListener("load", function() {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
socket.on("self_ping", function() {
|
||||
socket.on("self_ping", function () {
|
||||
if (chan != undefined && chan.toLowerCase() != "") {
|
||||
socket.emit("self_ping", { channel: chan.toLowerCase() });
|
||||
socket.emit("self_ping", {
|
||||
channel: chan.toLowerCase()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("viewers", function(view) {
|
||||
socket.on("viewers", function (view) {
|
||||
viewers = view;
|
||||
|
||||
if (song_title !== undefined) Player.getTitle(song_title, viewers);
|
||||
@@ -217,7 +214,6 @@ window.addEventListener("load", function() {
|
||||
.getElementById("playpause")
|
||||
.addEventListener("click", Playercontrols.play_pause);
|
||||
window.setVolume = setVolume;
|
||||
//Helper.css("#controls", "background-color", color);
|
||||
|
||||
document.querySelector("body").style.backgroundColor = color;
|
||||
if (embedOptions.hasOwnProperty("control") && embedOptions.control) {
|
||||
@@ -227,14 +223,14 @@ window.addEventListener("load", function() {
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("resize", function() {
|
||||
window.addEventListener("resize", function () {
|
||||
resizeFunction();
|
||||
});
|
||||
|
||||
function resizePlaylistPlaying() {}
|
||||
|
||||
function startWaitTimerPlay() {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
if (videoSource == "youtube") {
|
||||
Player.player.playVideo();
|
||||
} else if (videoSource == "soundcloud") {
|
||||
@@ -256,7 +252,7 @@ function setup_now_playing_listener() {
|
||||
}
|
||||
|
||||
function setup_list_listener() {
|
||||
socket.on("channel", function(msg) {
|
||||
socket.on("channel", function (msg) {
|
||||
Helper.addClass(".site_loader", "hide");
|
||||
List.channel_function(msg);
|
||||
});
|
||||
@@ -268,6 +264,7 @@ function setVolume(val) {
|
||||
}
|
||||
|
||||
function updateChromecastMetadata() {}
|
||||
|
||||
function loadChromecastVideo() {}
|
||||
|
||||
function toast(msg) {
|
||||
@@ -364,7 +361,10 @@ function toast(msg) {
|
||||
break;
|
||||
}
|
||||
before_toast();
|
||||
M.toast({ html: msg, displayLength: 4000 });
|
||||
M.toast({
|
||||
html: msg,
|
||||
displayLength: 4000
|
||||
});
|
||||
}
|
||||
|
||||
function emit() {
|
||||
@@ -396,23 +396,23 @@ function change_offline(enabled, already_offline) {
|
||||
}
|
||||
}
|
||||
|
||||
var mouseEnter = function(e) {
|
||||
var mouseEnter = function (e) {
|
||||
Helper.removeClass("#seekToDuration", "hide");
|
||||
};
|
||||
|
||||
var mouseLeave = function(e) {
|
||||
var mouseLeave = function (e) {
|
||||
dragging = false;
|
||||
Helper.addClass("#seekToDuration", "hide");
|
||||
};
|
||||
|
||||
var mouseDown = function(e) {
|
||||
var mouseDown = function (e) {
|
||||
var acceptable = ["bar", "controls", "duration"];
|
||||
if (acceptable.indexOf(e.target.id) >= 0) {
|
||||
dragging = true;
|
||||
}
|
||||
};
|
||||
|
||||
var mouseUp = function(e) {
|
||||
var mouseUp = function (e) {
|
||||
dragging = false;
|
||||
};
|
||||
if (enabled) {
|
||||
@@ -467,68 +467,61 @@ function change_offline(enabled, already_offline) {
|
||||
}
|
||||
|
||||
function before_toast() {
|
||||
/*if($('.toast').length > 0) {
|
||||
var toastElement = $('.toast').first()[0];
|
||||
var toastInstance = toastElement.M_Toast;
|
||||
toastInstance.remove();
|
||||
}*/
|
||||
M.Toast.dismissAll();
|
||||
//Materialize.Toast.removeAll();
|
||||
}
|
||||
|
||||
document.addEventListener(
|
||||
"click",
|
||||
function(e) {
|
||||
function (e) {
|
||||
handleEvent(e, e.target, false, "click");
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
addListener("click", ".channel-info-container", function(e) {
|
||||
addListener("click", ".channel-info-container", function (e) {
|
||||
this.preventDefault();
|
||||
Player.pauseVideo();
|
||||
window.open("https://zoff.me/" + chan.toLowerCase() + "/", "_blank");
|
||||
});
|
||||
|
||||
addListener("click", ".vote-container", function(e) {
|
||||
addListener("click", ".vote-container", function (e) {
|
||||
var that = e;
|
||||
var id = that.getAttribute("data-video-id");
|
||||
|
||||
List.vote(id, "pos");
|
||||
});
|
||||
|
||||
addListener("click", ".prev_page", function(e) {
|
||||
addListener("click", ".prev_page", function (e) {
|
||||
event.preventDefault();
|
||||
List.dynamicContentPage(-1);
|
||||
});
|
||||
|
||||
addListener("click", "#player_overlay", function(event) {
|
||||
addListener("click", "#player_overlay", function (event) {
|
||||
if (videoSource == "soundcloud") Playercontrols.play_pause();
|
||||
});
|
||||
|
||||
addListener("click", ".next_page", function(e) {
|
||||
addListener("click", ".next_page", function (e) {
|
||||
event.preventDefault();
|
||||
List.dynamicContentPage(1);
|
||||
});
|
||||
|
||||
addListener("click", ".prev", function(event) {
|
||||
addListener("click", ".prev", function (event) {
|
||||
this.preventDefault();
|
||||
if (!offline) return;
|
||||
List.skip(false);
|
||||
});
|
||||
|
||||
addListener("click", ".skip", function(event) {
|
||||
addListener("click", ".skip", function (event) {
|
||||
this.preventDefault();
|
||||
//if(!offline) return;
|
||||
List.skip(true);
|
||||
});
|
||||
|
||||
addListener("click", ".last_page", function(e) {
|
||||
addListener("click", ".last_page", function (e) {
|
||||
event.preventDefault();
|
||||
List.dynamicContentPage(10);
|
||||
});
|
||||
|
||||
addListener("click", ".first_page", function(e) {
|
||||
addListener("click", ".first_page", function (e) {
|
||||
event.preventDefault();
|
||||
List.dynamicContentPage(-10);
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
VERSION
|
||||
} from "../../../VERSION";
|
||||
|
||||
function removeAllListeners() {
|
||||
Helper.log(["Removing all listeners"]);
|
||||
socket.removeEventListener("chat.all");
|
||||
@@ -9,14 +13,12 @@ function removeAllListeners() {
|
||||
socket.removeEventListener("channel");
|
||||
socket.removeEventListener("np");
|
||||
socket.removeEventListener("get_list");
|
||||
//socket.removeEventListener("self_ping");
|
||||
socket.removeEventListener("viewers");
|
||||
socket.removeEventListener("auth_required");
|
||||
socket.removeEventListener("auth_accepted");
|
||||
socket.removeEventListener("suggested");
|
||||
socket.removeEventListener("color");
|
||||
socket.removeEventListener("chat_history");
|
||||
//socket.removeEventListener("name");
|
||||
socket.removeEventListener(id);
|
||||
}
|
||||
|
||||
@@ -44,7 +46,7 @@ function filterPlaylistElements(page) {
|
||||
page: page,
|
||||
type: search_type
|
||||
},
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
var json = JSON.parse(data);
|
||||
document.querySelector(".filter-results").innerHTML = "";
|
||||
if (json.results.search_results.length > 0) {
|
||||
@@ -70,7 +72,7 @@ function filterPlaylistElements(page) {
|
||||
"Couldn't find any items with those tags..";
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
error: function (e) {
|
||||
if (e.status != 429) {
|
||||
toast("Couldn't find any items with those tags..", "red");
|
||||
|
||||
@@ -111,11 +113,10 @@ function addFilterButtons(position, json) {
|
||||
}
|
||||
|
||||
function say_updated() {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
before_toast();
|
||||
M.toast({
|
||||
html:
|
||||
"The list was updated, want to refresh? <a class='waves-effect waves-light btn light-green' href='#' id='refresh_mobile' style='cursor:pointer;pointer-events:all;margin-left:10px;'> yes</a><a class='waves-effect waves-light btn red lighten' id='dont_refresh_list' style='cursor:pointer;pointer-events:all;margin-left:10px;'>no</a>",
|
||||
html: "The list was updated, want to refresh? <a class='waves-effect waves-light btn light-green' href='#' id='refresh_mobile' style='cursor:pointer;pointer-events:all;margin-left:10px;'> yes</a><a class='waves-effect waves-light btn red lighten' id='dont_refresh_list' style='cursor:pointer;pointer-events:all;margin-left:10px;'>no</a>",
|
||||
displayLength: 10000000
|
||||
});
|
||||
}, 500);
|
||||
@@ -150,9 +151,9 @@ function resizeFunction() {
|
||||
if (document.querySelector("#wrapper") == null) return;
|
||||
if (!client && !embed)
|
||||
document.querySelector("#hide-playlist").style.left =
|
||||
document.querySelector("#video-container").offsetWidth -
|
||||
document.querySelector("#hide-playlist").offsetWidth +
|
||||
"px";
|
||||
document.querySelector("#video-container").offsetWidth -
|
||||
document.querySelector("#hide-playlist").offsetWidth +
|
||||
"px";
|
||||
if (
|
||||
((window.innerWidth > 600 && !embed) ||
|
||||
(window.innerWidth > 500 && embed)) &&
|
||||
@@ -171,7 +172,7 @@ function resizeFunction() {
|
||||
var scPlaying = false;
|
||||
var ytPlaying = false;
|
||||
if (scUsingWidget) {
|
||||
Player.soundcloud_player.isPaused(function(paused) {
|
||||
Player.soundcloud_player.isPaused(function (paused) {
|
||||
try {
|
||||
ytPlaying =
|
||||
Player.player.getPlayerState() == YT.PlayerState.PLAYING ||
|
||||
@@ -213,7 +214,7 @@ function resizeFunction() {
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
71
|
||||
71
|
||||
) + 1;
|
||||
List.element_height =
|
||||
(window.innerHeight -
|
||||
@@ -221,7 +222,7 @@ function resizeFunction() {
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
temp_fit -
|
||||
temp_fit -
|
||||
5;
|
||||
} else {
|
||||
temp_fit =
|
||||
@@ -238,7 +239,7 @@ function resizeFunction() {
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
71
|
||||
71
|
||||
);
|
||||
List.element_height =
|
||||
(window.innerHeight -
|
||||
@@ -246,17 +247,16 @@ function resizeFunction() {
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
temp_fit -
|
||||
temp_fit -
|
||||
5;
|
||||
} else if (List.element_height < 55.2 && embed) {
|
||||
//List.can_fit = List.can_fit - 1;
|
||||
temp_fit = Math.round(
|
||||
(window.innerHeight -
|
||||
Helper.computedStyle(".tabs", "height") -
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
71
|
||||
71
|
||||
);
|
||||
List.element_height =
|
||||
(window.innerHeight -
|
||||
@@ -264,7 +264,7 @@ function resizeFunction() {
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
temp_fit -
|
||||
temp_fit -
|
||||
5;
|
||||
temp_fit = temp_fit - 2;
|
||||
}
|
||||
@@ -295,7 +295,6 @@ function resizeFunction() {
|
||||
}
|
||||
}
|
||||
List.can_fit = temp_fit;
|
||||
//List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-5.3;
|
||||
Helper.css(".list-song", "height", List.element_height + "px");
|
||||
Channel.set_title_width();
|
||||
if (!client) {
|
||||
@@ -354,14 +353,19 @@ function getColor(id) {
|
||||
Helper.ajax({
|
||||
method: "POST",
|
||||
url: "/api/color",
|
||||
headers: { "Content-Type": "application/json;charset=UTF-8" },
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=UTF-8"
|
||||
},
|
||||
data: JSON.stringify({
|
||||
id: id
|
||||
}),
|
||||
success: function(c) {
|
||||
success: function (c) {
|
||||
c = JSON.parse(c);
|
||||
if (typeof c == "object") {
|
||||
Player.setBGimage({ color: c, only: true });
|
||||
Player.setBGimage({
|
||||
color: c,
|
||||
only: true
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -384,14 +388,11 @@ function hide_native(way) {
|
||||
}
|
||||
Helper.toggleClass("#duration", "hide");
|
||||
Helper.toggleClass("#fullscreen", "hide");
|
||||
try {
|
||||
if (videoSource == "youtube") {
|
||||
Player.player.stopVideo();
|
||||
} else if (videoSource == "soundcloud") {
|
||||
Player.soundcloud_player.pause();
|
||||
}
|
||||
} catch (e) {}
|
||||
//clearTimeout(durationTimeout);
|
||||
if (videoSource == "youtube") {
|
||||
Player.player.stopVideo();
|
||||
} else if (videoSource == "soundcloud") {
|
||||
Player.soundcloud_player.pause();
|
||||
}
|
||||
Player.stopInterval = true;
|
||||
if (Helper.mobilecheck()) {
|
||||
if (document.querySelector("#pause").classList.contains("hide")) {
|
||||
@@ -412,7 +413,7 @@ function hide_native(way) {
|
||||
var thisThumbnail;
|
||||
if (Player.np.thumbnail == undefined)
|
||||
thisThumbnail =
|
||||
"https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg";
|
||||
"https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg";
|
||||
else thisThumbnail = Player.np.thumbnail;
|
||||
Helper.removeClass("#player_overlay", "hide");
|
||||
Helper.css("#player_overlay", "display", "block");
|
||||
@@ -472,7 +473,9 @@ function hide_native(way) {
|
||||
Helper.setHtml("#chromecast_text", "");
|
||||
Helper.css("#playing_on", "display", "none");
|
||||
if (!offline) {
|
||||
socket.emit("pos", { channel: chan.toLowerCase() });
|
||||
socket.emit("pos", {
|
||||
channel: chan.toLowerCase()
|
||||
});
|
||||
} else {
|
||||
Player.loadVideoById(video_id);
|
||||
}
|
||||
@@ -521,7 +524,6 @@ function start_auth() {
|
||||
Helper.css("#player_overlay", "display", "block");
|
||||
M.Modal.getInstance(document.getElementById("user_password")).open();
|
||||
document.querySelector("#user-pass-input").focus();
|
||||
//Crypt.remove_userpass(chan.toLowerCase());
|
||||
before_toast();
|
||||
M.toast({
|
||||
html: "That is not the correct password, try again..",
|
||||
@@ -532,32 +534,30 @@ function start_auth() {
|
||||
|
||||
function emit_list() {
|
||||
var add = "";
|
||||
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
/*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(p == undefined) p = "";*/
|
||||
if (socket.id) {
|
||||
socket.emit("list", {
|
||||
version: parseInt(_VERSION),
|
||||
version: parseInt(VERSION),
|
||||
channel: add + chan.toLowerCase()
|
||||
});
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
emit_list();
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
|
||||
function get_list_ajax() {
|
||||
//var c = Crypt.get_userpass(chan.toLowerCase());
|
||||
Helper.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
userpass: "",
|
||||
token: zoff_api_token
|
||||
},
|
||||
headers: { "Content-Type": "application/json;charset=UTF-8" },
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=UTF-8"
|
||||
},
|
||||
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()),
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
response = JSON.parse(response);
|
||||
if (response.results.length > 0) {
|
||||
if (response.status == 403) {
|
||||
@@ -569,19 +569,17 @@ function get_list_ajax() {
|
||||
List.populate_list(response.results);
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
//response = JSON.parse(response);
|
||||
error: function (response) {
|
||||
if (response.status == 403) {
|
||||
start_auth();
|
||||
} else if (response.status == 429) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
get_list_ajax();
|
||||
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||
} else if (response.status == 404) return;
|
||||
if (client) {
|
||||
Helper.removeElement("#channel-load");
|
||||
}
|
||||
//List.populate_list(response.responseJSON.results);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -638,14 +636,14 @@ function inIframe() {
|
||||
}
|
||||
|
||||
function mouseContext(left, top) {
|
||||
var moveFunction = function(event) {
|
||||
var moveFunction = function (event) {
|
||||
if (
|
||||
event.pageX < left - 60 ||
|
||||
event.pageX >
|
||||
left + document.querySelector(".context-menu-root").offsetWidth + 60 ||
|
||||
left + document.querySelector(".context-menu-root").offsetWidth + 60 ||
|
||||
event.pageY < top - 60 ||
|
||||
event.pageY >
|
||||
top + document.querySelector(".context-menu-root").offsetHeight + 60
|
||||
top + document.querySelector(".context-menu-root").offsetHeight + 60
|
||||
) {
|
||||
Helper.addClass(".context-menu-root", "hide");
|
||||
Helper.addClass("#context-menu-overlay", "hide");
|
||||
@@ -659,8 +657,6 @@ function mouseContext(left, top) {
|
||||
}
|
||||
|
||||
function get_np_ajax() {
|
||||
/*var c = Crypt.get_userpass(chan.toLowerCase());
|
||||
if(c == undefined) c = "";*/
|
||||
Helper.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
@@ -668,19 +664,19 @@ function get_np_ajax() {
|
||||
fetch_song: true,
|
||||
token: zoff_api_token
|
||||
},
|
||||
headers: { "Content-Type": "application/json;charset=UTF-8" },
|
||||
url:
|
||||
"/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/__np__",
|
||||
success: function(response) {
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=UTF-8"
|
||||
},
|
||||
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/__np__",
|
||||
success: function (response) {
|
||||
response = JSON.parse(response);
|
||||
Player.getTitle(response.results[0].title, 1);
|
||||
},
|
||||
error: function(response, xmlhttp) {
|
||||
//response = JSON.parse(response);
|
||||
error: function (response, xmlhttp) {
|
||||
if (response.status == 403) {
|
||||
start_auth();
|
||||
} else if (response.status == 429) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
get_np_ajax();
|
||||
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||
}
|
||||
@@ -689,10 +685,6 @@ function get_np_ajax() {
|
||||
}
|
||||
|
||||
function del_ajax(id) {
|
||||
/*var a = Crypt.get_pass(chan.toLowerCase());
|
||||
var u = Crypt.get_userpass(chan.toLowerCase());
|
||||
if(a == undefined) a = "";
|
||||
if(u == undefined) u = "";*/
|
||||
Helper.ajax({
|
||||
type: "DELETE",
|
||||
data: {
|
||||
@@ -700,18 +692,19 @@ function del_ajax(id) {
|
||||
userpass: "",
|
||||
token: zoff_api_token
|
||||
},
|
||||
headers: { "Content-Type": "application/json;charset=UTF-8" },
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=UTF-8"
|
||||
},
|
||||
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
toast("deletesong");
|
||||
get_list_ajax();
|
||||
},
|
||||
error: function(response, xmlhttp) {
|
||||
//response = JSON.parse(response);
|
||||
error: function (response, xmlhttp) {
|
||||
if (response.status == 403) {
|
||||
toast("listhaspass");
|
||||
} else if (response.status == 429) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
del_ajax(id);
|
||||
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||
}
|
||||
@@ -731,10 +724,6 @@ function add_ajax(
|
||||
source,
|
||||
thumbnail
|
||||
) {
|
||||
/*var a = Crypt.get_pass(chan.toLowerCase());
|
||||
var u = Crypt.get_userpass(chan.toLowerCase());
|
||||
if(a == undefined) a = "";
|
||||
if(u == undefined) u = "";*/
|
||||
Helper.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
@@ -748,20 +737,21 @@ function add_ajax(
|
||||
source: source,
|
||||
token: zoff_api_token
|
||||
},
|
||||
headers: { "Content-Type": "application/json;charset=UTF-8" },
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=UTF-8"
|
||||
},
|
||||
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
toast("addedsong");
|
||||
get_list_ajax();
|
||||
},
|
||||
error: function(response, xmlhttp) {
|
||||
//response = JSON.parse(response);
|
||||
error: function (response, xmlhttp) {
|
||||
if (response.status == 403) {
|
||||
toast("listhaspass");
|
||||
} else if (response.status == 409) {
|
||||
vote_ajax(id);
|
||||
} else if (response.status == 429) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
add_ajax(id, title, duration, playlist, num, full_num, start, end);
|
||||
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||
}
|
||||
@@ -770,10 +760,6 @@ function add_ajax(
|
||||
}
|
||||
|
||||
function vote_ajax(id) {
|
||||
/*var a = Crypt.get_pass(chan.toLowerCase());
|
||||
var u = Crypt.get_userpass(chan.toLowerCase());
|
||||
if(a == undefined) a = "";
|
||||
if(u == undefined) u = "";*/
|
||||
Helper.ajax({
|
||||
type: "PUT",
|
||||
data: {
|
||||
@@ -781,18 +767,19 @@ function vote_ajax(id) {
|
||||
userpass: "",
|
||||
token: zoff_api_token
|
||||
},
|
||||
headers: { "Content-Type": "application/json;charset=UTF-8" },
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=UTF-8"
|
||||
},
|
||||
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
toast("voted");
|
||||
get_list_ajax();
|
||||
},
|
||||
error: function(response, xmlhttp) {
|
||||
//response = JSON.parse(response);
|
||||
error: function (response, xmlhttp) {
|
||||
if (response.status == 403) {
|
||||
toast("listhaspass");
|
||||
} else if (response.status == 429) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
vote_ajax(id);
|
||||
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||
}
|
||||
@@ -801,22 +788,21 @@ function vote_ajax(id) {
|
||||
}
|
||||
|
||||
function setup_auth_listener() {
|
||||
socket.on("auth_required", function() {
|
||||
socket.on("auth_required", function () {
|
||||
start_auth();
|
||||
});
|
||||
|
||||
socket.on("auth_accepted", function(msg) {
|
||||
socket.on("auth_accepted", function (msg) {
|
||||
if (msg.hasOwnProperty("value") && msg.value) {
|
||||
if (temp_user_pass != "") {
|
||||
userpass = temp_user_pass;
|
||||
//Crypt.set_userpass(chan.toLowerCase(), userpass);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setup_no_connection_listener() {
|
||||
socket.on("connect_failed", function() {
|
||||
socket.on("connect_failed", function () {
|
||||
Helper.log(["Connection Failed"]);
|
||||
if (!connect_error) {
|
||||
connect_error = true;
|
||||
@@ -828,7 +814,7 @@ function setup_no_connection_listener() {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("connect_error", function() {
|
||||
socket.on("connect_error", function () {
|
||||
Helper.log(["Connection Failed."]);
|
||||
if (!connect_error) {
|
||||
connect_error = true;
|
||||
@@ -871,16 +857,14 @@ function loadChromecastVideo() {
|
||||
seekTo: _seekTo,
|
||||
channel: chan.toLowerCase(),
|
||||
source: videoSource,
|
||||
thumbnail:
|
||||
Player.np.thumbnail != undefined
|
||||
? Player.np.thumbnail
|
||||
: "https://img.youtube.com/vi/" + video_id + "/mqdefault.jpg"
|
||||
thumbnail: Player.np.thumbnail != undefined ?
|
||||
Player.np.thumbnail : "https://img.youtube.com/vi/" + video_id + "/mqdefault.jpg"
|
||||
};
|
||||
castSession.loadMedia(request).then(
|
||||
function() {
|
||||
function () {
|
||||
console.log("Loaded chromecast-video. Don't look here, look at your TV!");
|
||||
},
|
||||
function(errorCode) {
|
||||
function (errorCode) {
|
||||
console.log("Error code: " + errorCode);
|
||||
}
|
||||
);
|
||||
@@ -1027,10 +1011,10 @@ function enable_host_mode(enabled) {
|
||||
.insertAdjacentHTML(
|
||||
"beforeend",
|
||||
"<div id='join-sidebar' style='color:white;'>" +
|
||||
document
|
||||
.querySelector("#channel-share-modal")
|
||||
.querySelector(".modal-content").innerHTML +
|
||||
"</div>"
|
||||
document
|
||||
.querySelector("#channel-share-modal")
|
||||
.querySelector(".modal-content").innerHTML +
|
||||
"</div>"
|
||||
);
|
||||
document.addEventListener("webkitfullscreenchange", exitHandler, false);
|
||||
document.addEventListener("mozfullscreenchange", exitHandler, false);
|
||||
@@ -1069,19 +1053,16 @@ function enable_host_mode(enabled) {
|
||||
}
|
||||
|
||||
function get_list_listener() {
|
||||
socket.on("get_list", function() {
|
||||
socket.on("get_list", function () {
|
||||
var add = "";
|
||||
socket_connected = true;
|
||||
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
/*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(p == undefined) p = "";*/
|
||||
socket.emit("list", {
|
||||
offline: offline,
|
||||
version: parseInt(_VERSION),
|
||||
version: VERSION,
|
||||
channel: add + chan.toLowerCase()
|
||||
});
|
||||
});
|
||||
socket.on("id_chromecast", function(msg) {
|
||||
socket.on("id_chromecast", function (msg) {
|
||||
chromecast_specs_sent = true;
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {
|
||||
type: "mobilespecs",
|
||||
@@ -1094,7 +1075,7 @@ function get_list_listener() {
|
||||
|
||||
function setup_suggested_listener() {
|
||||
if (client) return;
|
||||
socket.on("suggested", function(params) {
|
||||
socket.on("suggested", function (params) {
|
||||
var single = true;
|
||||
if (params.id === undefined) single = false;
|
||||
Suggestions.catchUserSuggests(params, single);
|
||||
@@ -1102,9 +1083,9 @@ function setup_suggested_listener() {
|
||||
}
|
||||
|
||||
function setup_viewers_listener() {
|
||||
socket.on("viewers", function(view) {
|
||||
socket.on("viewers", function (view) {
|
||||
viewers = view;
|
||||
var outPutWord = "<i class='material-icons'>visibility</i>"; //v > 1 ? "viewers" : "viewer";
|
||||
var outPutWord = "<i class='material-icons'>visibility</i>";
|
||||
|
||||
Helper.setHtml("#viewers", outPutWord + " " + view);
|
||||
|
||||
@@ -1119,7 +1100,7 @@ function setup_admin_listener() {
|
||||
}
|
||||
|
||||
function setup_chat_listener() {
|
||||
socket.on("chat_history", function(msg) {
|
||||
socket.on("chat_history", function (msg) {
|
||||
var data = msg.data;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (msg.all) {
|
||||
@@ -1225,23 +1206,23 @@ function change_offline(enabled, already_offline) {
|
||||
}
|
||||
}
|
||||
|
||||
var mouseEnter = function(e) {
|
||||
var mouseEnter = function (e) {
|
||||
Helper.removeClass("#seekToDuration", "hide");
|
||||
};
|
||||
|
||||
var mouseLeave = function(e) {
|
||||
var mouseLeave = function (e) {
|
||||
dragging = false;
|
||||
Helper.addClass("#seekToDuration", "hide");
|
||||
};
|
||||
|
||||
var mouseDown = function(e) {
|
||||
var mouseDown = function (e) {
|
||||
var acceptable = ["bar", "controls", "duration"];
|
||||
if (acceptable.indexOf(e.target.id) >= 0) {
|
||||
dragging = true;
|
||||
}
|
||||
};
|
||||
|
||||
var mouseUp = function(e) {
|
||||
var mouseUp = function (e) {
|
||||
dragging = false;
|
||||
};
|
||||
|
||||
@@ -1348,7 +1329,9 @@ function change_offline(enabled, already_offline) {
|
||||
.removeEventListener("click", seekToClick);
|
||||
Helper.removeElement("#seekToDuration");
|
||||
socket.on("color", Player.setBGimage);
|
||||
socket.emit("pos", { channel: chan.toLowerCase() });
|
||||
socket.emit("pos", {
|
||||
channel: chan.toLowerCase()
|
||||
});
|
||||
var add = "";
|
||||
socket.emit("list", {
|
||||
version: parseInt(_VERSION),
|
||||
@@ -1481,7 +1464,7 @@ function resizePlaylistPlaying(playing, resizing) {
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
71
|
||||
71
|
||||
);
|
||||
List.element_height =
|
||||
(window.innerHeight -
|
||||
@@ -1489,7 +1472,7 @@ function resizePlaylistPlaying(playing, resizing) {
|
||||
Helper.computedStyle("header", "height") -
|
||||
64 -
|
||||
40) /
|
||||
temp_fit -
|
||||
temp_fit -
|
||||
5;
|
||||
}
|
||||
|
||||
@@ -1510,7 +1493,6 @@ function resizePlaylistPlaying(playing, resizing) {
|
||||
);
|
||||
}
|
||||
} else if (List.can_fit > temp_fit) {
|
||||
//Helper.css(document.querySelector("#wrapper").children, "display", "none");
|
||||
Helper.css(
|
||||
document.querySelector("#wrapper").children[List.page + temp_fit],
|
||||
"display",
|
||||
@@ -1676,8 +1658,7 @@ function toast(msg, _class) {
|
||||
if (embed) return;
|
||||
if (Search.submitYouTubeError) {
|
||||
M.toast({
|
||||
html:
|
||||
"Added most of your playlist, but something was wrong. Check the playlist..",
|
||||
html: "Added most of your playlist, but something was wrong. Check the playlist..",
|
||||
displayLength: 4000,
|
||||
classes: "red lighten connect_error"
|
||||
});
|
||||
@@ -1714,7 +1695,6 @@ function toast(msg, _class) {
|
||||
"Nope, wrong password!",
|
||||
"Wrong password. The authorities have been notified."
|
||||
]);
|
||||
//Crypt.remove_pass(chan.toLowerCase());
|
||||
Admin.display_logged_out();
|
||||
Helper.css("#thumbnail_form", "display", "none");
|
||||
Helper.css("#description_form", "display", "none");
|
||||
@@ -1804,7 +1784,6 @@ function toast(msg, _class) {
|
||||
"I can't let you do that",
|
||||
"Please log in to do that"
|
||||
]);
|
||||
//Crypt.remove_pass(chan.toLowerCase());
|
||||
Admin.display_logged_out();
|
||||
Helper.css("#thumbnail_form", "display", "none");
|
||||
Helper.css("#description_form", "display", "none");
|
||||
@@ -1851,9 +1830,9 @@ function toast(msg, _class) {
|
||||
if (embed) return;
|
||||
tried_again = false;
|
||||
adminpass =
|
||||
Crypt.get_pass(chan.toLowerCase()) == undefined
|
||||
? Crypt.tmp_pass
|
||||
: Crypt.get_pass(chan.toLowerCase());
|
||||
Crypt.get_pass(chan.toLowerCase()) == undefined ?
|
||||
Crypt.tmp_pass :
|
||||
Crypt.get_pass(chan.toLowerCase());
|
||||
msg =
|
||||
"Correct password. You now have access to the sacred realm of The Admin.";
|
||||
Helper.css("#thumbnail_form", "display", "inline-block");
|
||||
@@ -1875,7 +1854,11 @@ function toast(msg, _class) {
|
||||
}
|
||||
before_toast();
|
||||
var classes = _class == undefined ? "" : _class;
|
||||
M.toast({ html: msg, displayLength: 4000, classes: classes });
|
||||
M.toast({
|
||||
html: msg,
|
||||
displayLength: 4000,
|
||||
classes: classes
|
||||
});
|
||||
}
|
||||
|
||||
function emit() {
|
||||
@@ -1955,23 +1938,14 @@ function searchTimeout(event) {
|
||||
code != 27
|
||||
) {
|
||||
clearTimeout(timeout_search);
|
||||
/*if(search_input.length < 3){
|
||||
Helper.css(".results-tabs", "display", "none");
|
||||
document.querySelector("#results").innerHTML = "";
|
||||
document.querySelector("#results_soundcloud").innerHTML = "";
|
||||
Helper.css("")
|
||||
if(search_input.length == 0) {
|
||||
document.querySelector("body").setAttribute("style", "overflow-y: auto");
|
||||
}
|
||||
}*/
|
||||
if (code == 13) {
|
||||
Search.search(search_input);
|
||||
Search.soundcloudSearch(search_input);
|
||||
} else {
|
||||
timeout_search = setTimeout(function() {
|
||||
timeout_search = setTimeout(function () {
|
||||
Search.search(search_input);
|
||||
Search.soundcloudSearch(search_input);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
import {
|
||||
VERSION
|
||||
} from "../../../VERSION";
|
||||
|
||||
var Hostcontroller = {
|
||||
enabled: true,
|
||||
|
||||
old_id: null,
|
||||
|
||||
host_listener: function(id) {
|
||||
host_listener: function (id) {
|
||||
if (client) return;
|
||||
Helper.log(["Host-listener triggered", "Host-listener id:" + id]);
|
||||
if (Hostcontroller.old_id === null) Hostcontroller.old_id = id;
|
||||
@@ -16,8 +20,10 @@ var Hostcontroller = {
|
||||
window.location.protocol + "//remote." + window.location.host + "/" + id;
|
||||
if (embed) {
|
||||
if (window.parentWindow && window.parentOrigin) {
|
||||
window.parentWindow.postMessage(
|
||||
{ type: "controller", id: id },
|
||||
window.parentWindow.postMessage({
|
||||
type: "controller",
|
||||
id: id
|
||||
},
|
||||
window.parentOrigin
|
||||
);
|
||||
}
|
||||
@@ -29,7 +35,7 @@ var Hostcontroller = {
|
||||
.setAttribute(
|
||||
"src",
|
||||
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
|
||||
codeURL
|
||||
codeURL
|
||||
);
|
||||
document.querySelector("#code-link").setAttribute("href", codeURL);
|
||||
}
|
||||
@@ -39,7 +45,7 @@ var Hostcontroller = {
|
||||
}
|
||||
},
|
||||
|
||||
host_on_action: function(arr) {
|
||||
host_on_action: function (arr) {
|
||||
if (client) return;
|
||||
if (Hostcontroller.enabled) {
|
||||
if (arr.type == "volume") {
|
||||
@@ -71,20 +77,19 @@ var Hostcontroller = {
|
||||
.setAttribute(
|
||||
"src",
|
||||
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
|
||||
shareCodeUrl
|
||||
shareCodeUrl
|
||||
);
|
||||
Helper.setHtml(
|
||||
"#channel-name-join",
|
||||
"client." +
|
||||
window.location.hostname +
|
||||
"/" +
|
||||
encodeURIComponent(chan.toLowerCase())
|
||||
window.location.hostname +
|
||||
"/" +
|
||||
encodeURIComponent(chan.toLowerCase())
|
||||
);
|
||||
w_p = true;
|
||||
var add = "";
|
||||
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {
|
||||
version: parseInt(_VERSION),
|
||||
version: parseInt(VERSION),
|
||||
channel: add + chan.toLowerCase()
|
||||
});
|
||||
|
||||
@@ -103,7 +108,7 @@ var Hostcontroller = {
|
||||
}
|
||||
},
|
||||
|
||||
change_enabled: function(val) {
|
||||
change_enabled: function (val) {
|
||||
if (client) return;
|
||||
Hostcontroller.enabled = val;
|
||||
try {
|
||||
@@ -111,4 +116,4 @@ var Hostcontroller = {
|
||||
Hostcontroller.enabled;
|
||||
} catch (e) {}
|
||||
}
|
||||
};
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var express = require("express");
|
||||
var router = express.Router();
|
||||
var path = require("path");
|
||||
@@ -21,15 +25,17 @@ var ObjectId = mongojs.ObjectId;
|
||||
var sIO = require(path.join(__dirname, "../../apps/client.js")).socketIO;
|
||||
var projects = require(pathThumbnails + "/handlers/aggregates.js");
|
||||
|
||||
router.use(function(req, res, next) {
|
||||
router.use(function (req, res, next) {
|
||||
next(); // make sure we go to the next routes and don't stop here
|
||||
});
|
||||
|
||||
router.route("/api/lists").get(function(req, res) {
|
||||
router.route("/api/lists").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
db.collection("frontpage_lists")
|
||||
.find()
|
||||
.sort({ count: -1 }, function(err, docs) {
|
||||
.sort({
|
||||
count: -1
|
||||
}, function (err, docs) {
|
||||
res.json(docs);
|
||||
});
|
||||
} else {
|
||||
@@ -37,9 +43,9 @@ router.route("/api/lists").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/thumbnails").get(function(req, res) {
|
||||
router.route("/api/thumbnails").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
db.collection("suggested_thumbnails").find(function(err, docs) {
|
||||
db.collection("suggested_thumbnails").find(function (err, docs) {
|
||||
res.json(docs);
|
||||
});
|
||||
} else {
|
||||
@@ -47,9 +53,9 @@ router.route("/api/thumbnails").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/descriptions").get(function(req, res) {
|
||||
router.route("/api/descriptions").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
db.collection("suggested_descriptions").find(function(err, docs) {
|
||||
db.collection("suggested_descriptions").find(function (err, docs) {
|
||||
res.json(docs);
|
||||
});
|
||||
} else {
|
||||
@@ -57,9 +63,9 @@ router.route("/api/descriptions").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/rules").get(function(req, res) {
|
||||
router.route("/api/rules").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
db.collection("suggested_rules").find(function(err, docs) {
|
||||
db.collection("suggested_rules").find(function (err, docs) {
|
||||
res.json(docs);
|
||||
});
|
||||
} else {
|
||||
@@ -67,30 +73,44 @@ router.route("/api/rules").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/approve_thumbnail").post(function(req, res) {
|
||||
router.route("/api/approve_thumbnail").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("suggested_thumbnails").find({ channel: channel }, function(
|
||||
db.collection("suggested_thumbnails").find({
|
||||
channel: channel
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
var thumbnail = docs[0].thumbnail;
|
||||
db.collection("frontpage_lists").update(
|
||||
{ _id: channel },
|
||||
{ $set: { thumbnail: thumbnail } },
|
||||
{ upsert: true },
|
||||
function(err, docs) {
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { thumbnail: thumbnail } },
|
||||
{ upsert: true },
|
||||
function(err, docs) {
|
||||
db.collection("suggested_thumbnails").remove(
|
||||
{ channel: channel },
|
||||
function(err, docs) {
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: channel
|
||||
}, {
|
||||
$set: {
|
||||
thumbnail: thumbnail
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
thumbnail: thumbnail
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection("suggested_thumbnails").remove({
|
||||
channel: channel
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -99,7 +119,7 @@ router.route("/api/approve_thumbnail").post(function(req, res) {
|
||||
$project: projects.toShowConfig
|
||||
}
|
||||
],
|
||||
function(err, docs) {
|
||||
function (err, docs) {
|
||||
if (docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||
if (
|
||||
docs[0].hasOwnProperty("userpass") &&
|
||||
@@ -123,10 +143,12 @@ router.route("/api/approve_thumbnail").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/deny_thumbnail").post(function(req, res) {
|
||||
router.route("/api/deny_thumbnail").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("suggested_thumbnails").remove({ channel: channel }, function(
|
||||
db.collection("suggested_thumbnails").remove({
|
||||
channel: channel
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
@@ -137,25 +159,34 @@ router.route("/api/deny_thumbnail").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/approve_rules").post(function(req, res) {
|
||||
router.route("/api/approve_rules").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("suggested_rules").find({ channel: channel }, function(
|
||||
db.collection("suggested_rules").find({
|
||||
channel: channel
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
var rules = docs[0].rules;
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { rules: rules } },
|
||||
{ upsert: true },
|
||||
function(err, docs) {
|
||||
db.collection("suggested_rules").remove(
|
||||
{ channel: channel },
|
||||
function(err, docs) {
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
rules: rules
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection("suggested_rules").remove({
|
||||
channel: channel
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -164,7 +195,7 @@ router.route("/api/approve_rules").post(function(req, res) {
|
||||
$project: projects.toShowConfig
|
||||
}
|
||||
],
|
||||
function(err, docs) {
|
||||
function (err, docs) {
|
||||
if (docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||
if (
|
||||
docs[0].hasOwnProperty("userpass") &&
|
||||
@@ -186,10 +217,12 @@ router.route("/api/approve_rules").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/deny_rules").post(function(req, res) {
|
||||
router.route("/api/deny_rules").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("suggested_rules").remove({ channel: channel }, function(
|
||||
db.collection("suggested_rules").remove({
|
||||
channel: channel
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
@@ -200,16 +233,21 @@ router.route("/api/deny_rules").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/remove_rules").post(function(req, res) {
|
||||
router.route("/api/remove_rules").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { rules: "" } },
|
||||
function(err, docs) {
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
rules: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -218,7 +256,7 @@ router.route("/api/remove_rules").post(function(req, res) {
|
||||
$project: projects.toShowConfig
|
||||
}
|
||||
],
|
||||
function(err, docs) {
|
||||
function (err, docs) {
|
||||
if (docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||
if (docs[0].hasOwnProperty("userpass") && docs[0].userpass != "")
|
||||
docs[0].userpass = true;
|
||||
@@ -234,29 +272,42 @@ router.route("/api/remove_rules").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/approve_description").post(function(req, res) {
|
||||
router.route("/api/approve_description").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("suggested_descriptions").find({ channel: channel }, function(
|
||||
db.collection("suggested_descriptions").find({
|
||||
channel: channel
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
var description = docs[0].description;
|
||||
db.collection("frontpage_lists").update(
|
||||
{ _id: channel },
|
||||
{ $set: { description: description } },
|
||||
{ upsert: true },
|
||||
function(err, docs) {
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { description: description } },
|
||||
function(err, docs) {
|
||||
db.collection("suggested_descriptions").remove(
|
||||
{ channel: channel },
|
||||
function(err, docs) {
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: channel
|
||||
}, {
|
||||
$set: {
|
||||
description: description
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
description: description
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection("suggested_descriptions").remove({
|
||||
channel: channel
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -265,7 +316,7 @@ router.route("/api/approve_description").post(function(req, res) {
|
||||
$project: projects.toShowConfig
|
||||
}
|
||||
],
|
||||
function(err, docs) {
|
||||
function (err, docs) {
|
||||
if (docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||
if (
|
||||
docs[0].hasOwnProperty("userpass") &&
|
||||
@@ -289,13 +340,14 @@ router.route("/api/approve_description").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/deny_description").post(function(req, res) {
|
||||
router.route("/api/deny_description").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("suggested_descriptions").remove(
|
||||
{ channel: channel },
|
||||
db.collection("suggested_descriptions").remove({
|
||||
channel: channel
|
||||
},
|
||||
1,
|
||||
function(err, docs) {
|
||||
function (err, docs) {
|
||||
res.send(true);
|
||||
}
|
||||
);
|
||||
@@ -304,20 +356,29 @@ router.route("/api/deny_description").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/remove_thumbnail").post(function(req, res) {
|
||||
router.route("/api/remove_thumbnail").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("frontpage_lists").update(
|
||||
{ _id: channel },
|
||||
{ $set: { thumbnail: "" } },
|
||||
function(err, docs) {
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { thumbnail: "" } },
|
||||
function(err, docs) {
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: channel
|
||||
}, {
|
||||
$set: {
|
||||
thumbnail: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
thumbnail: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -326,7 +387,7 @@ router.route("/api/remove_thumbnail").post(function(req, res) {
|
||||
$project: projects.toShowConfig
|
||||
}
|
||||
],
|
||||
function(err, docs) {
|
||||
function (err, docs) {
|
||||
if (docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||
if (
|
||||
docs[0].hasOwnProperty("userpass") &&
|
||||
@@ -347,20 +408,29 @@ router.route("/api/remove_thumbnail").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/remove_description").post(function(req, res) {
|
||||
router.route("/api/remove_description").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var channel = req.body.channel;
|
||||
db.collection("frontpage_lists").update(
|
||||
{ _id: channel },
|
||||
{ $set: { description: "" } },
|
||||
function(err, docs) {
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { description: "" } },
|
||||
function(err, docs) {
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: channel
|
||||
}, {
|
||||
$set: {
|
||||
description: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
description: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -369,7 +439,7 @@ router.route("/api/remove_description").post(function(req, res) {
|
||||
$project: projects.toShowConfig
|
||||
}
|
||||
],
|
||||
function(err, docs) {
|
||||
function (err, docs) {
|
||||
if (docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||
if (
|
||||
docs[0].hasOwnProperty("userpass") &&
|
||||
@@ -390,12 +460,17 @@ router.route("/api/remove_description").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/names").get(function(req, res) {
|
||||
router.route("/api/names").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
db.collection("registered_users").find(
|
||||
{ _id: { $exists: true } },
|
||||
{ _id: 1, icon: 1 },
|
||||
function(err, docs) {
|
||||
db.collection("registered_users").find({
|
||||
_id: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
_id: 1,
|
||||
icon: 1
|
||||
},
|
||||
function (err, docs) {
|
||||
res.json(docs);
|
||||
}
|
||||
);
|
||||
@@ -404,14 +479,18 @@ router.route("/api/names").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/names").post(function(req, res) {
|
||||
router.route("/api/names").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var icon = req.body.icon;
|
||||
var name = req.body.name;
|
||||
db.collection("registered_users").update(
|
||||
{ _id: name },
|
||||
{ $set: { icon: icon } },
|
||||
function(err, docs) {
|
||||
db.collection("registered_users").update({
|
||||
_id: name
|
||||
}, {
|
||||
$set: {
|
||||
icon: icon
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
if (err) res.send(false);
|
||||
else res.send(true);
|
||||
}
|
||||
@@ -421,10 +500,12 @@ router.route("/api/names").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/names").delete(function(req, res) {
|
||||
router.route("/api/names").delete(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var name = req.body.name;
|
||||
db.collection("registered_users").remove({ _id: name }, function(
|
||||
db.collection("registered_users").remove({
|
||||
_id: name
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
@@ -436,17 +517,23 @@ router.route("/api/names").delete(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/token").get(function(req, res) {
|
||||
router.route("/api/token").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
token_db.collection("tokens").find(function(err, docs) {
|
||||
token_db.collection("tokens").find(function (err, docs) {
|
||||
if (docs.length == 1) {
|
||||
res.json({ token: docs[0].token });
|
||||
res.json({
|
||||
token: docs[0].token
|
||||
});
|
||||
} else {
|
||||
var id = new Buffer(makeid()).toString("base64");
|
||||
token_db
|
||||
.collection("tokens")
|
||||
.insert({ token: id }, function(err, docs) {
|
||||
res.json({ token: id });
|
||||
.insert({
|
||||
token: id
|
||||
}, function (err, docs) {
|
||||
res.json({
|
||||
token: id
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -455,11 +542,15 @@ router.route("/api/token").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/api_token").get(function(req, res) {
|
||||
router.route("/api/api_token").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
token_db
|
||||
.collection("api_token")
|
||||
.find({ token: { $exists: true } }, function(err, all) {
|
||||
.find({
|
||||
token: {
|
||||
$exists: true
|
||||
}
|
||||
}, function (err, all) {
|
||||
res.json(all);
|
||||
});
|
||||
} else {
|
||||
@@ -467,12 +558,14 @@ router.route("/api/api_token").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/api_token").delete(function(req, res) {
|
||||
router.route("/api/api_token").delete(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var id = req.body.id;
|
||||
token_db
|
||||
.collection("api_token")
|
||||
.remove({ _id: ObjectId(id) }, function(err, success) {
|
||||
.remove({
|
||||
_id: ObjectId(id)
|
||||
}, function (err, success) {
|
||||
if (err) {
|
||||
res.send("failed");
|
||||
return;
|
||||
@@ -482,7 +575,7 @@ router.route("/api/api_token").delete(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/api_token").put(function(req, res) {
|
||||
router.route("/api/api_token").put(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var id = req.body.id;
|
||||
var limit = req.body.limit;
|
||||
@@ -492,7 +585,13 @@ router.route("/api/api_token").put(function(req, res) {
|
||||
}
|
||||
token_db
|
||||
.collection("api_token")
|
||||
.update({ _id: ObjectId(id) }, { $set: { limit: limit } }, function(
|
||||
.update({
|
||||
_id: ObjectId(id)
|
||||
}, {
|
||||
$set: {
|
||||
limit: limit
|
||||
}
|
||||
}, function (
|
||||
err,
|
||||
success
|
||||
) {
|
||||
@@ -505,7 +604,7 @@ router.route("/api/api_token").put(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/api_token").post(function(req, res) {
|
||||
router.route("/api/api_token").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var name = req.body.name;
|
||||
var id = crypto
|
||||
@@ -514,9 +613,18 @@ router.route("/api/api_token").post(function(req, res) {
|
||||
.digest("base64");
|
||||
token_db
|
||||
.collection("api_token")
|
||||
.insert({ name: name, token: id, usage: 0 }, function(err, docs) {
|
||||
token_db.collection("api_token").find({ token: id }, function(err, d) {
|
||||
res.json({ token: id, _id: d[0]._id });
|
||||
.insert({
|
||||
name: name,
|
||||
token: id,
|
||||
usage: 0
|
||||
}, function (err, docs) {
|
||||
token_db.collection("api_token").find({
|
||||
token: id
|
||||
}, function (err, d) {
|
||||
res.json({
|
||||
token: id,
|
||||
_id: d[0]._id
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -524,12 +632,14 @@ router.route("/api/api_token").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/delete").post(function(req, res) {
|
||||
router.route("/api/delete").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var list = req.body._id;
|
||||
db.collection(list).drop(function(err, docs) {
|
||||
db.collection(list + "_settings").drop(function(err, docs) {
|
||||
db.collection("frontpage_lists").remove({ _id: list }, function(
|
||||
db.collection(list).drop(function (err, docs) {
|
||||
db.collection(list + "_settings").drop(function (err, docs) {
|
||||
db.collection("frontpage_lists").remove({
|
||||
_id: list
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
@@ -542,13 +652,15 @@ router.route("/api/delete").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/remove_token").get(function(req, res) {
|
||||
router.route("/api/remove_token").get(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
token_db.collection("tokens").find(function(err, docs) {
|
||||
token_db.collection("tokens").find(function (err, docs) {
|
||||
if (docs.length == 1) {
|
||||
token_db
|
||||
.collection("tokens")
|
||||
.remove({ token: docs[0].token }, function(err, docs) {
|
||||
.remove({
|
||||
token: docs[0].token
|
||||
}, function (err, docs) {
|
||||
res.send(true);
|
||||
});
|
||||
} else {
|
||||
@@ -560,17 +672,25 @@ router.route("/api/remove_token").get(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/pinned").post(function(req, res) {
|
||||
router.route("/api/pinned").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var to_pin = req.body._id;
|
||||
db.collection("frontpage_lists").update(
|
||||
{ pinned: 1 },
|
||||
{ $set: { pinned: 0 } },
|
||||
function(err, resp) {
|
||||
db.collection("frontpage_lists").update(
|
||||
{ _id: to_pin },
|
||||
{ $set: { pinned: 1 } },
|
||||
function(err, resp) {
|
||||
db.collection("frontpage_lists").update({
|
||||
pinned: 1
|
||||
}, {
|
||||
$set: {
|
||||
pinned: 0
|
||||
}
|
||||
},
|
||||
function (err, resp) {
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: to_pin
|
||||
}, {
|
||||
$set: {
|
||||
pinned: 1
|
||||
}
|
||||
},
|
||||
function (err, resp) {
|
||||
res.send(true);
|
||||
}
|
||||
);
|
||||
@@ -581,13 +701,19 @@ router.route("/api/pinned").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/admin").post(function(req, res) {
|
||||
router.route("/api/admin").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var to_remove = req.body._id;
|
||||
db.collection(to_remove + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { adminpass: "" } },
|
||||
function(err, docs) {
|
||||
db.collection(to_remove + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
adminpass: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
res.send(true);
|
||||
}
|
||||
);
|
||||
@@ -596,13 +722,19 @@ router.route("/api/admin").post(function(req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
router.route("/api/userpass").post(function(req, res) {
|
||||
router.route("/api/userpass").post(function (req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
var to_remove = req.body._id;
|
||||
db.collection(to_remove + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { userpass: "" } },
|
||||
function(err, docs) {
|
||||
db.collection(to_remove + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
userpass: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
res.send(true);
|
||||
}
|
||||
);
|
||||
@@ -622,4 +754,4 @@ function makeid() {
|
||||
return text;
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
module.exports = router;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,32 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
|
||||
var express = require("express");
|
||||
const path = require("path");
|
||||
var router = express.Router();
|
||||
router.use(function(req, res, next) {
|
||||
router.use(function (req, res, next) {
|
||||
next(); // make sure we go to the next routes and don't stop here
|
||||
});
|
||||
|
||||
router.route("/favicon.ico").get(function(req, res, next) {
|
||||
router.route("/favicon.ico").get(function (req, res, next) {
|
||||
res.sendFile(path.join(pathThumbnails, "/public/assets/images/favicon.ico"));
|
||||
});
|
||||
|
||||
router.route("/browserconfig.xml").get(function(req, res, next) {
|
||||
router.route("/browserconfig.xml").get(function (req, res, next) {
|
||||
res.sendFile(
|
||||
path.join(pathThumbnails, "/public/assets/images/browserconfig.xml")
|
||||
);
|
||||
});
|
||||
|
||||
router.route("/apple-touch-icon.png").get(function(req, res, next) {
|
||||
router.route("/apple-touch-icon.png").get(function (req, res, next) {
|
||||
res.sendFile(
|
||||
path.join(pathThumbnails, "/public/assets/images/apple-touch-icon.png")
|
||||
);
|
||||
});
|
||||
|
||||
router.route("/apple-touch-icon-precomposed.png").get(function(req, res, next) {
|
||||
router.route("/apple-touch-icon-precomposed.png").get(function (req, res, next) {
|
||||
res.sendFile(
|
||||
path.join(
|
||||
pathThumbnails,
|
||||
@@ -30,4 +35,4 @@ router.route("/apple-touch-icon-precomposed.png").get(function(req, res, next) {
|
||||
);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
module.exports = router;
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var express = require("express");
|
||||
var router = express.Router();
|
||||
var path = require("path");
|
||||
@@ -9,7 +13,6 @@ var adsense = "xx";
|
||||
var adds = false;
|
||||
var mongojs = require("mongojs");
|
||||
var token_db = mongojs("tokens");
|
||||
var Functions = require(pathThumbnails + "/handlers/functions.js");
|
||||
var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");
|
||||
|
||||
var db = require(pathThumbnails + "/handlers/db.js");
|
||||
@@ -50,28 +53,28 @@ try {
|
||||
};
|
||||
}
|
||||
|
||||
router.use(recaptcha.middleware.render, function(req, res, next) {
|
||||
router.use(recaptcha.middleware.render, function (req, res, next) {
|
||||
next(); // make sure we go to the next routes and don't stop here
|
||||
});
|
||||
|
||||
router.route("/:channel_name").get(function(req, res, next) {
|
||||
router.route("/:channel_name").get(function (req, res, next) {
|
||||
channel(req, res, next);
|
||||
});
|
||||
|
||||
router.route("/r/:base64data").get(function(req, res, next) {
|
||||
router.route("/r/:base64data").get(function (req, res, next) {
|
||||
var channelToRedirect = Buffer.from(req.params.base64data, "base64");
|
||||
res.redirect("/" + channelToRedirect);
|
||||
});
|
||||
|
||||
router.route("/").get(function(req, res, next) {
|
||||
router.route("/").get(function (req, res, next) {
|
||||
root(req, res, next);
|
||||
});
|
||||
|
||||
router.route("/").post(function(req, res, next) {
|
||||
router.route("/").post(function (req, res, next) {
|
||||
root(req, res, next);
|
||||
});
|
||||
|
||||
router.route("/api/embed").get(function(req, res, next) {
|
||||
router.route("/api/embed").get(function (req, res, next) {
|
||||
var data = {
|
||||
year: year,
|
||||
type: "video",
|
||||
@@ -85,11 +88,11 @@ router.route("/api/embed").get(function(req, res, next) {
|
||||
res.render("layouts/client/embed", data);
|
||||
});
|
||||
|
||||
router.route("/api/oauth").get(function(req, res, next) {
|
||||
router.route("/api/oauth").get(function (req, res, next) {
|
||||
res.sendFile(path.join(pathThumbnails, "/public/assets/html/callback.html"));
|
||||
});
|
||||
|
||||
router.route("/api/apply").get(function(req, res, next) {
|
||||
router.route("/api/apply").get(function (req, res, next) {
|
||||
var data = {
|
||||
year: year,
|
||||
javascript_file: "token.min.js",
|
||||
@@ -108,17 +111,25 @@ router.route("/api/apply").get(function(req, res, next) {
|
||||
res.render("layouts/client/token", data);
|
||||
});
|
||||
|
||||
router.route("/api/apply/:id").get(function(req, res) {
|
||||
router.route("/api/apply/:id").get(function (req, res) {
|
||||
var id = req.params.id;
|
||||
token_db.collection("api_links").find({ id: id }, function(err, result) {
|
||||
token_db.collection("api_links").find({
|
||||
id: id
|
||||
}, function (err, result) {
|
||||
if (result.length == 1) {
|
||||
token_db.collection("api_links").remove({ id: id }, function(e, d) {
|
||||
token_db.collection("api_links").remove({
|
||||
id: id
|
||||
}, function (e, d) {
|
||||
token_db
|
||||
.collection("api_token")
|
||||
.update(
|
||||
{ token: result[0].token },
|
||||
{ $set: { active: true } },
|
||||
function(e, d) {
|
||||
.update({
|
||||
token: result[0].token
|
||||
}, {
|
||||
$set: {
|
||||
active: true
|
||||
}
|
||||
},
|
||||
function (e, d) {
|
||||
var data = {
|
||||
year: year,
|
||||
javascript_file: "token.min.js",
|
||||
@@ -161,12 +172,12 @@ router.route("/api/apply/:id").get(function(req, res) {
|
||||
|
||||
function root(req, res, next) {
|
||||
try {
|
||||
var url = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"]
|
||||
: req.headers.host.split(":")[0];
|
||||
var subdomain = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"].split(".")
|
||||
: req.headers.host.split(":")[0].split(".");
|
||||
var url = req.headers["x-forwarded-host"] ?
|
||||
req.headers["x-forwarded-host"] :
|
||||
req.headers.host.split(":")[0];
|
||||
var subdomain = req.headers["x-forwarded-host"] ?
|
||||
req.headers["x-forwarded-host"].split(".") :
|
||||
req.headers.host.split(":")[0].split(".");
|
||||
if (subdomain[0] == "remote") {
|
||||
var data = {
|
||||
year: year,
|
||||
@@ -202,8 +213,10 @@ function root(req, res, next) {
|
||||
if (subdomain[0] == "client") {
|
||||
data.client = true;
|
||||
}
|
||||
Frontpage.get_frontpage_lists(function(err, docs) {
|
||||
db.collection("connected_users").find({ _id: "total_users" }, function(
|
||||
Frontpage.get_frontpage_lists(function (err, docs) {
|
||||
db.collection("connected_users").find({
|
||||
_id: "total_users"
|
||||
}, function (
|
||||
err,
|
||||
tot
|
||||
) {
|
||||
@@ -228,12 +241,12 @@ function root(req, res, next) {
|
||||
|
||||
function channel(req, res, next) {
|
||||
try {
|
||||
var url = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"]
|
||||
: req.headers.host.split(":")[0];
|
||||
var subdomain = req.headers["x-forwarded-host"]
|
||||
? req.headers["x-forwarded-host"].split(".")
|
||||
: req.headers.host.split(":")[0].split(".");
|
||||
var url = req.headers["x-forwarded-host"] ?
|
||||
req.headers["x-forwarded-host"] :
|
||||
req.headers.host.split(":")[0];
|
||||
var subdomain = req.headers["x-forwarded-host"] ?
|
||||
req.headers["x-forwarded-host"].split(".") :
|
||||
req.headers.host.split(":")[0].split(".");
|
||||
if (subdomain[0] == "remote") {
|
||||
var data = {
|
||||
year: year,
|
||||
@@ -285,4 +298,4 @@ function capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
module.exports = router;
|
||||
6
server/settings/globals.js
Normal file
6
server/settings/globals.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as path from "path";
|
||||
import version from "../VERSION";
|
||||
|
||||
export const publicPath = path.join(__dirname, "public");
|
||||
export const pathThumbnails = __dirname;
|
||||
export const VERSION = version;
|
||||
7
server/start.js
Normal file
7
server/start.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// Transpile all code following this line with babel and use '@babel/preset-env' (aka ES6) preset.
|
||||
require("@babel/register")({
|
||||
presets: ["@babel/preset-env"]
|
||||
});
|
||||
|
||||
// Import the rest of our application.
|
||||
module.exports = require('./app.js')
|
||||
Reference in New Issue
Block a user