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:
3930
package-lock.json
generated
3930
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,19 +1,18 @@
|
||||
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 });
|
||||
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;
|
||||
@@ -51,7 +50,6 @@ function startClustered(redis_enabled) {
|
||||
}
|
||||
|
||||
var worker_index = function (ip, len) {
|
||||
//console.log(ip);
|
||||
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) {
|
||||
.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,7 +114,12 @@ 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..");
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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,7 +94,6 @@ 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) {
|
||||
done(null, user.id);
|
||||
@@ -107,8 +108,7 @@ passport.deserializeUser(function(id, done) {
|
||||
|
||||
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",
|
||||
@@ -123,12 +123,18 @@ passport.use(
|
||||
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);
|
||||
|
||||
@@ -163,8 +169,7 @@ 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",
|
||||
@@ -175,7 +180,9 @@ passport.use(
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -265,6 +272,4 @@ function isLoggedIn(req, res, next) {
|
||||
res.redirect("/login");
|
||||
}
|
||||
|
||||
//app.listen(default_port);
|
||||
|
||||
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");
|
||||
@@ -45,7 +40,9 @@ var hbs = exphbs.create({
|
||||
}
|
||||
});
|
||||
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");
|
||||
@@ -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", "*");
|
||||
|
||||
@@ -1,21 +1,10 @@
|
||||
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++) {
|
||||
@@ -27,20 +16,9 @@ db.getCollectionNames(function(e, d) {
|
||||
}
|
||||
}
|
||||
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) {
|
||||
console.log("Done");
|
||||
|
||||
@@ -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,3 +1,7 @@
|
||||
import {
|
||||
VERSION
|
||||
} from "../../../VERSION";
|
||||
|
||||
var Channel = {
|
||||
init: function () {
|
||||
if (window.location.hash == "#small" || inIframe()) {
|
||||
@@ -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);
|
||||
@@ -81,7 +83,6 @@ var Channel = {
|
||||
}
|
||||
|
||||
if (!client) {
|
||||
//Helper.tabs('.playlist-tabs');
|
||||
Helper.tabs(".playlist-tabs-loggedIn", {
|
||||
onShow: function (e) {
|
||||
if (this.index == 2) {
|
||||
@@ -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();
|
||||
@@ -145,8 +143,7 @@ var Channel = {
|
||||
}
|
||||
});
|
||||
M.Collapsible.init(
|
||||
document.getElementsByClassName("settings-collapsible")[0],
|
||||
{
|
||||
document.getElementsByClassName("settings-collapsible")[0], {
|
||||
accordion: true
|
||||
}
|
||||
);
|
||||
@@ -380,7 +377,7 @@ var Channel = {
|
||||
} else {
|
||||
Player.loadSoundCloudPlayer();
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
if (Helper.mobilecheck()) {
|
||||
if (!client) {
|
||||
@@ -429,7 +426,6 @@ var Channel = {
|
||||
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...");
|
||||
@@ -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");
|
||||
@@ -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"
|
||||
@@ -915,8 +901,14 @@ 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 () {
|
||||
get_history();
|
||||
|
||||
@@ -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=";
|
||||
@@ -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 {
|
||||
@@ -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
|
||||
@@ -188,7 +183,9 @@ window.addEventListener("load", 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()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
@@ -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() {
|
||||
@@ -467,13 +467,7 @@ 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(
|
||||
@@ -519,7 +513,6 @@ addListener("click", ".prev", function(event) {
|
||||
|
||||
addListener("click", ".skip", function (event) {
|
||||
this.preventDefault();
|
||||
//if(!offline) return;
|
||||
List.skip(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -114,8 +116,7 @@ function say_updated() {
|
||||
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);
|
||||
@@ -249,7 +250,6 @@ function resizeFunction() {
|
||||
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") -
|
||||
@@ -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) {
|
||||
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);
|
||||
Player.stopInterval = true;
|
||||
if (Helper.mobilecheck()) {
|
||||
if (document.querySelector("#pause").classList.contains("hide")) {
|
||||
@@ -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,12 +534,9 @@ 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 {
|
||||
@@ -548,14 +547,15 @@ function emit_list() {
|
||||
}
|
||||
|
||||
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) {
|
||||
response = JSON.parse(response);
|
||||
@@ -570,7 +570,6 @@ function get_list_ajax() {
|
||||
}
|
||||
},
|
||||
error: function (response) {
|
||||
//response = JSON.parse(response);
|
||||
if (response.status == 403) {
|
||||
start_auth();
|
||||
} else if (response.status == 429) {
|
||||
@@ -581,7 +580,6 @@ function get_list_ajax() {
|
||||
if (client) {
|
||||
Helper.removeElement("#channel-load");
|
||||
}
|
||||
//List.populate_list(response.responseJSON.results);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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,15 +664,15 @@ 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__",
|
||||
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);
|
||||
if (response.status == 403) {
|
||||
start_auth();
|
||||
} else if (response.status == 429) {
|
||||
@@ -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,14 +692,15 @@ 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) {
|
||||
toast("deletesong");
|
||||
get_list_ajax();
|
||||
},
|
||||
error: function (response, xmlhttp) {
|
||||
//response = JSON.parse(response);
|
||||
if (response.status == 403) {
|
||||
toast("listhaspass");
|
||||
} else if (response.status == 429) {
|
||||
@@ -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,14 +737,15 @@ 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) {
|
||||
toast("addedsong");
|
||||
get_list_ajax();
|
||||
},
|
||||
error: function (response, xmlhttp) {
|
||||
//response = JSON.parse(response);
|
||||
if (response.status == 403) {
|
||||
toast("listhaspass");
|
||||
} else if (response.status == 409) {
|
||||
@@ -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,14 +767,15 @@ 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) {
|
||||
toast("voted");
|
||||
get_list_ajax();
|
||||
},
|
||||
error: function (response, xmlhttp) {
|
||||
//response = JSON.parse(response);
|
||||
if (response.status == 403) {
|
||||
toast("listhaspass");
|
||||
} else if (response.status == 429) {
|
||||
@@ -809,7 +796,6 @@ function setup_auth_listener() {
|
||||
if (msg.hasOwnProperty("value") && msg.value) {
|
||||
if (temp_user_pass != "") {
|
||||
userpass = temp_user_pass;
|
||||
//Crypt.set_userpass(chan.toLowerCase(), userpass);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -871,10 +857,8 @@ 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 () {
|
||||
@@ -1072,12 +1056,9 @@ function get_list_listener() {
|
||||
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()
|
||||
});
|
||||
});
|
||||
@@ -1104,7 +1085,7 @@ function setup_suggested_listener() {
|
||||
function setup_viewers_listener() {
|
||||
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);
|
||||
|
||||
@@ -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),
|
||||
@@ -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,15 +1938,6 @@ 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);
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
VERSION
|
||||
} from "../../../VERSION";
|
||||
|
||||
var Hostcontroller = {
|
||||
enabled: true,
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
@@ -82,9 +88,8 @@ var Hostcontroller = {
|
||||
);
|
||||
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()
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import {
|
||||
VERSION
|
||||
} from "../../../VERSION";
|
||||
|
||||
var chan =
|
||||
window.chan === undefined && document.querySelectorAll("#chan").length > 0
|
||||
? document.querySelector("#chan").innerText
|
||||
: window.chan;
|
||||
window.chan === undefined && document.querySelectorAll("#chan").length > 0 ?
|
||||
document.querySelector("#chan").innerText :
|
||||
window.chan;
|
||||
var w_p = true;
|
||||
var domain = window.location.host.split(".");
|
||||
var client = false;
|
||||
@@ -13,7 +17,7 @@ try {
|
||||
_VERSION = localStorage.getItem("VERSION");
|
||||
if (_VERSION == null || _VERSION == undefined) throw "Some error";
|
||||
} catch (e) {
|
||||
_VERSION = 6;
|
||||
_VERSION = VERSION;
|
||||
}
|
||||
var SC_widget;
|
||||
var scUsingWidget = false;
|
||||
@@ -37,9 +41,9 @@ var hostMode = false;
|
||||
var soundcloud_loading = false;
|
||||
var buffering = false;
|
||||
var list_html =
|
||||
document.querySelectorAll("#list-song-html").length > 0
|
||||
? document.querySelector("#list-song-html").innerHTML
|
||||
: undefined;
|
||||
document.querySelectorAll("#list-song-html").length > 0 ?
|
||||
document.querySelector("#list-song-html").innerHTML :
|
||||
undefined;
|
||||
var unseen = false;
|
||||
var searching = false;
|
||||
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)?)?/;
|
||||
@@ -168,7 +172,9 @@ var fromChannel = false;
|
||||
try {
|
||||
if (navigator.serviceWorker && window.location.host != "zoff.dev") {
|
||||
navigator.serviceWorker
|
||||
.register("/service-worker.js", { scope: "/" })
|
||||
.register("/service-worker.js", {
|
||||
scope: "/"
|
||||
})
|
||||
.then(function (registration) {
|
||||
Helper.log(registration);
|
||||
})
|
||||
@@ -178,12 +184,6 @@ try {
|
||||
} else {
|
||||
Helper.log("Service Worker is not supported in this browser.");
|
||||
}
|
||||
/*
|
||||
navigator.serviceWorker.getRegistration('/').then(function(registration) {
|
||||
if(registration) {
|
||||
registration.unregister();
|
||||
}
|
||||
});*/
|
||||
} catch (event) {}
|
||||
|
||||
window.zoff = {
|
||||
@@ -192,51 +192,6 @@ window.zoff = {
|
||||
list_last_logs: list_last_logs
|
||||
};
|
||||
|
||||
/*if(!Helper.mobilecheck() && (window.location.host != "localhost" && window.location.host != "client.localhost")) {
|
||||
window.onerror = function(e, source, lineno, colno, error) {
|
||||
if(e == "Script error." || e.toString().toLowerCase().indexOf("pagespeed") > -1) return true;
|
||||
Helper.logs.unshift({log: e.toString().replace(/(\r\n|\n|\r)/gm,""), date: new Date(), lineno: lineno, colno: colno, source:source});
|
||||
Helper.logs.unshift({log: chan != "" && chan != undefined ? chan.toLowerCase() : "frontpage", date: new Date()});
|
||||
|
||||
try {
|
||||
document.querySelector(".contact-form-content").remove();
|
||||
document.querySelector("#submit-contact-form").remove();
|
||||
document.querySelector(".contact-modal-header").innerText = "An error occurred";
|
||||
document.querySelector(".contact-container-info").remove();
|
||||
document.querySelector(".contact-modal-footer").insertAdjacentHTML("beforeend", '<a href="#!" class="waves-effect waves-green btn-flat send-error-modal">Send</a>');
|
||||
document.querySelector("#contact-form").setAttribute("id", "error-report-form");
|
||||
document.querySelector("#contact-container").insertAdjacentHTML("afterbegin", '<p>Do you want to send an error-report?</p> \
|
||||
<p class="error-report-success"></p> \
|
||||
<div class="error-code-container"> \
|
||||
<code id="error-report-code"></code> \
|
||||
</div>');
|
||||
} catch(e){}
|
||||
M.Modal.init(document.getElementById("contact"));
|
||||
M.Modal.getInstance(document.getElementById("contact")).open();
|
||||
var cache = [];
|
||||
Helper.setHtml("#error-report-code", JSON.stringify(Helper.logs, function(key, value) {
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
if (cache.indexOf(value) !== -1) {
|
||||
// Duplicate reference found
|
||||
try {
|
||||
// If this value does not reference a parent it can be deduped
|
||||
return JSON.parse(JSON.stringify(value));
|
||||
} catch (error) {
|
||||
// discard key if value cannot be deduped
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Store value in our collection
|
||||
cache.push(value);
|
||||
}
|
||||
return value;
|
||||
}, 4));
|
||||
cache = null;
|
||||
//console.error(e.originalEvent.error);
|
||||
return true;
|
||||
};
|
||||
}*/
|
||||
|
||||
window.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
function () {
|
||||
@@ -251,16 +206,6 @@ window.addEventListener(
|
||||
else if (!fromChannel && window.location.pathname == "/") {
|
||||
Frontpage.init();
|
||||
}
|
||||
var okCookie = true;
|
||||
/*try {
|
||||
okCookie = localStorage.ok_cookie;
|
||||
} catch(e) {
|
||||
okCookie = false;
|
||||
}
|
||||
if(!okCookie){
|
||||
before_toast();
|
||||
//M.toast({html: "This website uses cookies! <a class='waves-effect waves-light btn light-green' href='#' id='cookieok' style='cursor:pointer;pointer-events:all;margin-left:10px;'> ok</a><a class='waves-effect waves-light btn orange lighten' href='#cookies' id='cookieinfo' style='cursor:pointer;pointer-events:all;margin-left:10px;'> info</a>", displayLength: 10000000});
|
||||
}*/
|
||||
if (window.location.hash == "#cookies") {
|
||||
M.Modal.init(document.getElementById("cookie"));
|
||||
M.Modal.getInstance(document.getElementById("cookie")).open();
|
||||
@@ -270,8 +215,7 @@ window.addEventListener(
|
||||
document.querySelectorAll(
|
||||
"script[src='https://www.youtube.com/iframe_api']"
|
||||
).length == 1
|
||||
) {
|
||||
} else {
|
||||
) {} else {
|
||||
tag = document.createElement("script");
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
firstScriptTag = document.getElementsByTagName("script")[0];
|
||||
@@ -279,8 +223,6 @@ window.addEventListener(
|
||||
}
|
||||
Player.loadSoundCloudPlayer();
|
||||
Player.loadSoundCloudIframe();
|
||||
} else if (window.location.pathname == "/" && client) {
|
||||
//Player.loadSoundCloudPlayer();
|
||||
}
|
||||
|
||||
if (Helper.mobilecheck()) {
|
||||
@@ -303,14 +245,6 @@ window.addEventListener(
|
||||
channel: chan != undefined ? chan.toLowerCase() : ""
|
||||
});
|
||||
}
|
||||
|
||||
/*if(chan != undefined && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) !== "")){
|
||||
emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
||||
}*/
|
||||
/*$(".connect_error").fadeOut(function(){
|
||||
$(".connect_error").remove();
|
||||
M.toast({ html: "Connected!", displayLength: 2000, classes: "green lighten"});
|
||||
});*/
|
||||
var to_remove = document.querySelector(".connect_error");
|
||||
if (to_remove != null) {
|
||||
var instance = M.Toast.getInstance(to_remove);
|
||||
@@ -321,25 +255,13 @@ window.addEventListener(
|
||||
displayLength: 2000,
|
||||
classes: "green lighten"
|
||||
});
|
||||
//before_toast();
|
||||
}
|
||||
//Chat.namechange("", true, true);
|
||||
});
|
||||
|
||||
/*socket.on("name", function(data) {
|
||||
if(data.type == "name" && data.accepted) {
|
||||
Crypt.set_name(temp_name, temp_pass);
|
||||
temp_name = "";
|
||||
temp_pass = "";
|
||||
} else {
|
||||
temp_name = "";
|
||||
temp_pass = "";
|
||||
}
|
||||
});*/
|
||||
|
||||
socket.on("self_ping", function () {
|
||||
if (chan != undefined && chan.toLowerCase() != "") {
|
||||
socket.emit("self_ping", { channel: chan.toLowerCase() });
|
||||
socket.emit("self_ping", {
|
||||
channel: chan.toLowerCase()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -377,12 +299,10 @@ initializeCastApi = function() {
|
||||
chromecastListener
|
||||
);
|
||||
updateChromecastMetadata();
|
||||
//chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
|
||||
//castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {
|
||||
type: "nextVideo",
|
||||
videoId: full_playlist[0].id,
|
||||
@@ -418,7 +338,6 @@ initializeCastApi = function() {
|
||||
chromecastListener
|
||||
);
|
||||
updateChromecastMetadata();
|
||||
//chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
@@ -435,7 +354,6 @@ initializeCastApi = function() {
|
||||
value: chromecastInfoShow
|
||||
});
|
||||
loadChromecastVideo();
|
||||
//castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {
|
||||
type: "nextVideo",
|
||||
videoId: full_playlist[0].id,
|
||||
@@ -471,20 +389,6 @@ initializeCastApi = function() {
|
||||
} catch (e) {
|
||||
_chSeen = false;
|
||||
}
|
||||
/*if((!_chSeen || _chSeen != "seen") && !client) {
|
||||
Helper.css(".castButton", "display", "block");
|
||||
showDiscovery = true;
|
||||
var elem = document.querySelector('.tap-target');
|
||||
var instance = M.TapTarget.init(elem);
|
||||
instance.open();
|
||||
tap_target_timeout = setTimeout(function() {
|
||||
instance.close();
|
||||
}, 4000);
|
||||
try {
|
||||
localStorage.setItem("_chSeen", "seen");
|
||||
} catch(e){}
|
||||
Helper.removeClass('.castButton', 'castButton-white-active');
|
||||
}*/
|
||||
Helper.removeClass(".castButton", "castButton-white-active");
|
||||
} else if (event.castState == "NO_DEVICES_AVAILABLE") {
|
||||
cast_ready_connect = false;
|
||||
@@ -602,7 +506,9 @@ function addDynamicListeners() {
|
||||
|
||||
addListener("click", ".accept-delete", function (event) {
|
||||
this.preventDefault();
|
||||
emit("delete_all", { channel: chan.toLowerCase() });
|
||||
emit("delete_all", {
|
||||
channel: chan.toLowerCase()
|
||||
});
|
||||
M.Modal.getInstance(document.getElementById("delete_song_alert")).close();
|
||||
});
|
||||
|
||||
@@ -611,8 +517,6 @@ function addDynamicListeners() {
|
||||
this.stopPropagation();
|
||||
Chat.chat(document.getElementById("chatForm").input);
|
||||
document.getElementById("chat_submit").focus();
|
||||
//return true;
|
||||
//document.getElementById("chatForm").submit();
|
||||
});
|
||||
|
||||
addListener("click", "#chat_help", function (event) {
|
||||
@@ -941,7 +845,6 @@ function addDynamicListeners() {
|
||||
});
|
||||
|
||||
addListener("click", ".prev_page", function (event) {
|
||||
//addListener("click", ".prev_page", function(event){
|
||||
this.preventDefault();
|
||||
List.dynamicContentPage(-1);
|
||||
});
|
||||
@@ -956,19 +859,6 @@ function addDynamicListeners() {
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
addListener("change", ".password_protected", function(event) {
|
||||
this.preventDefault();
|
||||
if(this.checked) {
|
||||
M.Modal.getInstance(document.getElementById("user_password")).open();
|
||||
document.getElementById("user-pass-input").focus();
|
||||
} else {
|
||||
userpass = "";
|
||||
Helper.addClass(".change_user_pass", "hide");
|
||||
Admin.save(true);
|
||||
}
|
||||
});*/
|
||||
|
||||
addListener("submit", "#user-password-channel-form", function (event) {
|
||||
this.preventDefault();
|
||||
if (user_auth_started) {
|
||||
@@ -1029,7 +919,6 @@ function addDynamicListeners() {
|
||||
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");
|
||||
}
|
||||
@@ -1292,7 +1181,9 @@ function addDynamicListeners() {
|
||||
addListener("click", ".export-soundcloud", function (event) {
|
||||
this.preventDefault();
|
||||
window.SC_player = SC_player;
|
||||
SC_player.connect({ display: "page" }).then(function() {
|
||||
SC_player.connect({
|
||||
display: "page"
|
||||
}).then(function () {
|
||||
Helper.removeClass("#playlist_loader_export", "hide");
|
||||
Helper.addClass(".soundcloud-export-button", "hide");
|
||||
Helper.removeClass(".exported-list-container", "hide");
|
||||
@@ -1394,8 +1285,7 @@ function addDynamicListeners() {
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
url:
|
||||
"https://api.soundcloud.com/resolve/?url=" +
|
||||
url: "https://api.soundcloud.com/resolve/?url=" +
|
||||
document.querySelector("#import_soundcloud").value +
|
||||
"&limit=1&client_id=" +
|
||||
api_key.soundcloud +
|
||||
@@ -1430,14 +1320,10 @@ function addDynamicListeners() {
|
||||
continue;
|
||||
}
|
||||
var duration = Math.floor(song.duration / 1000);
|
||||
//var secs=Search.durationToSeconds(duration);
|
||||
var secs = duration;
|
||||
if (longsongs == undefined) longsongs = true;
|
||||
if ((longsongs != undefined && !longsongs) || secs < 720) {
|
||||
var id = song.id;
|
||||
//duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
||||
var thumb = song.artwork_url;
|
||||
//var thumb = null;
|
||||
if (thumb == null) thumb = song.waveform_url;
|
||||
|
||||
var songElement = {
|
||||
@@ -1508,8 +1394,6 @@ function addDynamicListeners() {
|
||||
.value.split("https://open.spotify.com/playlist/");
|
||||
|
||||
if (url.length == 2) {
|
||||
/*url = url[1].split("/");
|
||||
var user = url[0];*/
|
||||
var playlist_id = url[1];
|
||||
playlist_id = playlist_id.replace("?", "");
|
||||
|
||||
@@ -1784,7 +1668,6 @@ function addDynamicListeners() {
|
||||
});
|
||||
|
||||
addListener("click", "#closeSettings", function (event) {
|
||||
//this.preventDefault();
|
||||
Admin.hide_settings();
|
||||
});
|
||||
|
||||
@@ -1838,8 +1721,7 @@ function addDynamicListeners() {
|
||||
);
|
||||
} catch (err) {
|
||||
M.toast({
|
||||
html:
|
||||
"Only numbers are accepted as song start and end parameters..",
|
||||
html: "Only numbers are accepted as song start and end parameters..",
|
||||
displayLength: 3000,
|
||||
classes: "red lighten"
|
||||
});
|
||||
@@ -1878,7 +1760,6 @@ function addDynamicListeners() {
|
||||
var message = document.getElementById("contact-form-message").value;
|
||||
var from = document.getElementById("contact-form-from").value;
|
||||
Helper.send_mail(from, message);
|
||||
//document.getElementById("contact-form").submit();
|
||||
});
|
||||
|
||||
addListener("submit", "#contact-form", function (event) {
|
||||
@@ -1926,12 +1807,10 @@ function addDynamicListeners() {
|
||||
}
|
||||
});
|
||||
return false;
|
||||
//document.getElementById("error-report-form").submit();
|
||||
});
|
||||
|
||||
addListener("submit", "#error-report-form", function (event) {
|
||||
this.preventDefault();
|
||||
//event.preventDefault();
|
||||
|
||||
var captcha_response = grecaptcha.getResponse();
|
||||
|
||||
@@ -2121,14 +2000,6 @@ function addDynamicListeners() {
|
||||
List.vote(id, "del");
|
||||
});
|
||||
|
||||
/*
|
||||
addListener("click", '#toast-container', function(){
|
||||
var toastElement = document.querySelector('.toast');
|
||||
var toastInstance = M.Toast.getInstance(toastElement);
|
||||
toastInstance.dismiss();
|
||||
});
|
||||
*/
|
||||
|
||||
addListener("click", "#embed-area", function (e) {
|
||||
e.select();
|
||||
});
|
||||
@@ -2327,7 +2198,6 @@ function addDynamicListeners() {
|
||||
document.getElementById("main-container").style.transition =
|
||||
"filter .5s";
|
||||
setTimeout(function () {
|
||||
//document.getElementById("main-container").style.transform = "rotate(180deg)";
|
||||
document.getElementById("main-container").style.filter =
|
||||
"invert(100%)";
|
||||
}, 10);
|
||||
@@ -2344,23 +2214,16 @@ function addDynamicListeners() {
|
||||
} else if (_kWay == _kT && _kDone) {
|
||||
_kDone = false;
|
||||
document.getElementById("main-container").style.filter = "invert(0%)";
|
||||
//document.getElementById("main-container").style.transform = "rotate(0deg)";
|
||||
_kT = "";
|
||||
}
|
||||
} else {
|
||||
_kT = "";
|
||||
}
|
||||
if (event.keyCode == 27 && window.location.path != "/") {
|
||||
//$("#results").html("");
|
||||
Helper.addClass("#search-wrapper", "hide");
|
||||
Helper.css(".search_results", "display", "none");
|
||||
Helper.removeClass(".song-title", "hide");
|
||||
if (document.querySelector("#search-btn i").innerText == "close") {
|
||||
/*$("#results").slideUp({
|
||||
complete: function() {
|
||||
$("#results").empty();
|
||||
}
|
||||
});*/
|
||||
document.querySelector("#results").innerHTML = "";
|
||||
document.querySelector("#results_soundcloud").innerHTML = "";
|
||||
document
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
var express = require("express");
|
||||
var router = express.Router();
|
||||
var path = require("path");
|
||||
@@ -29,7 +33,9 @@ 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 {
|
||||
@@ -70,27 +76,41 @@ router.route("/api/rules").get(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 },
|
||||
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 },
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
thumbnail: thumbnail
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection("suggested_thumbnails").remove(
|
||||
{ channel: channel },
|
||||
db.collection("suggested_thumbnails").remove({
|
||||
channel: channel
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -126,7 +146,9 @@ router.route("/api/approve_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
|
||||
) {
|
||||
@@ -140,22 +162,31 @@ router.route("/api/deny_thumbnail").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 },
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
rules: rules
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection("suggested_rules").remove(
|
||||
{ channel: channel },
|
||||
db.collection("suggested_rules").remove({
|
||||
channel: channel
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -189,7 +220,9 @@ router.route("/api/approve_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
|
||||
) {
|
||||
@@ -203,13 +236,18 @@ router.route("/api/deny_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: "" } },
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
rules: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -237,26 +275,39 @@ router.route("/api/remove_rules").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 },
|
||||
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 } },
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
description: description
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection("suggested_descriptions").remove(
|
||||
{ channel: channel },
|
||||
db.collection("suggested_descriptions").remove({
|
||||
channel: channel
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -292,8 +343,9 @@ router.route("/api/approve_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) {
|
||||
res.send(true);
|
||||
@@ -307,17 +359,26 @@ router.route("/api/deny_description").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: "" } },
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: channel
|
||||
}, {
|
||||
$set: {
|
||||
thumbnail: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { thumbnail: "" } },
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
thumbnail: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -350,17 +411,26 @@ router.route("/api/remove_thumbnail").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: "" } },
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: channel
|
||||
}, {
|
||||
$set: {
|
||||
description: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").update(
|
||||
{ views: { $exists: true } },
|
||||
{ $set: { description: "" } },
|
||||
db.collection(channel + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
description: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
db.collection(channel + "_settings").aggregate(
|
||||
[
|
||||
{
|
||||
[{
|
||||
$match: {
|
||||
id: "config"
|
||||
}
|
||||
@@ -392,9 +462,14 @@ router.route("/api/remove_description").post(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 },
|
||||
db.collection("registered_users").find({
|
||||
_id: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
_id: 1,
|
||||
icon: 1
|
||||
},
|
||||
function (err, docs) {
|
||||
res.json(docs);
|
||||
}
|
||||
@@ -408,9 +483,13 @@ 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 } },
|
||||
db.collection("registered_users").update({
|
||||
_id: name
|
||||
}, {
|
||||
$set: {
|
||||
icon: icon
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
if (err) res.send(false);
|
||||
else res.send(true);
|
||||
@@ -424,7 +503,9 @@ router.route("/api/names").post(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
|
||||
) {
|
||||
@@ -440,13 +521,19 @@ router.route("/api/token").get(function(req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
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
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -459,7 +546,11 @@ 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 {
|
||||
@@ -472,7 +563,9 @@ router.route("/api/api_token").delete(function(req, res) {
|
||||
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;
|
||||
@@ -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
|
||||
) {
|
||||
@@ -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 {
|
||||
@@ -529,7 +637,9 @@ router.route("/api/delete").post(function(req, res) {
|
||||
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("frontpage_lists").remove({
|
||||
_id: list
|
||||
}, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
@@ -548,7 +658,9 @@ router.route("/api/remove_token").get(function(req, res) {
|
||||
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 {
|
||||
@@ -563,13 +675,21 @@ router.route("/api/remove_token").get(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 } },
|
||||
db.collection("frontpage_lists").update({
|
||||
pinned: 1
|
||||
}, {
|
||||
$set: {
|
||||
pinned: 0
|
||||
}
|
||||
},
|
||||
function (err, resp) {
|
||||
db.collection("frontpage_lists").update(
|
||||
{ _id: to_pin },
|
||||
{ $set: { pinned: 1 } },
|
||||
db.collection("frontpage_lists").update({
|
||||
_id: to_pin
|
||||
}, {
|
||||
$set: {
|
||||
pinned: 1
|
||||
}
|
||||
},
|
||||
function (err, resp) {
|
||||
res.send(true);
|
||||
}
|
||||
@@ -584,9 +704,15 @@ router.route("/api/pinned").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: "" } },
|
||||
db.collection(to_remove + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
adminpass: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
res.send(true);
|
||||
}
|
||||
@@ -599,9 +725,15 @@ router.route("/api/admin").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: "" } },
|
||||
db.collection(to_remove + "_settings").update({
|
||||
views: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
userpass: ""
|
||||
}
|
||||
},
|
||||
function (err, docs) {
|
||||
res.send(true);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
pathThumbnails
|
||||
} from "../settings/globals";
|
||||
|
||||
|
||||
var express = require("express");
|
||||
const path = require("path");
|
||||
var router = express.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");
|
||||
@@ -110,14 +113,22 @@ router.route("/api/apply").get(function(req, res, next) {
|
||||
|
||||
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 } },
|
||||
.update({
|
||||
token: result[0].token
|
||||
}, {
|
||||
$set: {
|
||||
active: true
|
||||
}
|
||||
},
|
||||
function (e, d) {
|
||||
var data = {
|
||||
year: year,
|
||||
@@ -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,
|
||||
@@ -203,7 +214,9 @@ function root(req, res, next) {
|
||||
data.client = true;
|
||||
}
|
||||
Frontpage.get_frontpage_lists(function (err, docs) {
|
||||
db.collection("connected_users").find({ _id: "total_users" }, function(
|
||||
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,
|
||||
|
||||
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