Implement new themes; fixes
This commit is contained in:
parent
ac89c87e29
commit
d410b4663d
|
@ -125,7 +125,7 @@ function init(user) {
|
|||
s.on("acp-gban-delete", handleGlobalBanDelete.bind(this, user));
|
||||
s.on("acp-list-users", handleListUsers.bind(this, user));
|
||||
s.on("acp-set-rank", handleSetRank.bind(this, user));
|
||||
s.on("acp-reset-password", handleResetPassword(this, user));
|
||||
s.on("acp-reset-password", handleResetPassword.bind(this, user));
|
||||
|
||||
db.listGlobalBans(function (err, bans) {
|
||||
if (err) {
|
||||
|
|
787
lib/user-old.js
787
lib/user-old.js
|
@ -1,787 +0,0 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2013 Calvin Montgomery
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var Channel = require("./channel.js").Channel;
|
||||
var Logger = require("./logger.js");
|
||||
var $util = require("./utilities");
|
||||
var ActionLog = require("./actionlog");
|
||||
var Server = require("./server");
|
||||
var ACP = require("./acp");
|
||||
var InfoGetter = require("./get-info");
|
||||
|
||||
// Represents a client connected via socket.io
|
||||
var User = function (socket) {
|
||||
this.ip = socket._ip;
|
||||
this.server = Server.getServer();
|
||||
this.socket = socket;
|
||||
this.loggedIn = false;
|
||||
this.loggingIn = false;
|
||||
this.saverank = false;
|
||||
this.rank = -1
|
||||
this.global_rank = -1;
|
||||
this.channel = null;
|
||||
this.pendingChannel = null;
|
||||
this.name = "";
|
||||
this.meta = {
|
||||
afk: false,
|
||||
icon: false,
|
||||
aliases: []
|
||||
};
|
||||
this.queueLimiter = $util.newRateLimiter();
|
||||
this.chatLimiter = $util.newRateLimiter();
|
||||
this.rankListLimiter = $util.newRateLimiter();
|
||||
this.profile = {
|
||||
image: "",
|
||||
text: ""
|
||||
};
|
||||
this.awaytimer = false;
|
||||
this.autoAFK();
|
||||
|
||||
this.initCallbacks();
|
||||
if (this.server.announcement !== null) {
|
||||
this.socket.emit("announcement", this.server.announcement);
|
||||
}
|
||||
};
|
||||
|
||||
User.prototype.inChannel = function () {
|
||||
return this.channel !== null && !this.channel.dead;
|
||||
};
|
||||
|
||||
User.prototype.inPendingChannel = function () {
|
||||
return this.pendingChannel != null && !this.pendingChannel.dead;
|
||||
};
|
||||
|
||||
User.prototype.setAFK = function (afk) {
|
||||
if (!this.inChannel())
|
||||
return;
|
||||
if (this.meta.afk === afk)
|
||||
return;
|
||||
var chan = this.channel;
|
||||
this.meta.afk = afk;
|
||||
if (afk) {
|
||||
if (chan.voteskip)
|
||||
chan.voteskip.unvote(this.ip);
|
||||
} else {
|
||||
this.autoAFK();
|
||||
}
|
||||
chan.checkVoteskipPass();
|
||||
chan.sendAll("setAFK", {
|
||||
name: this.name,
|
||||
afk: afk
|
||||
});
|
||||
};
|
||||
|
||||
User.prototype.autoAFK = function () {
|
||||
var self = this;
|
||||
if (self.awaytimer)
|
||||
clearTimeout(self.awaytimer);
|
||||
|
||||
if (!self.inChannel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var timeout = parseFloat(self.channel.opts.afk_timeout);
|
||||
if (isNaN(timeout)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeout <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.awaytimer = setTimeout(function () {
|
||||
self.setAFK(true);
|
||||
}, timeout * 1000);
|
||||
};
|
||||
|
||||
User.prototype.kick = function (reason) {
|
||||
this.socket.emit("kick", { reason: reason });
|
||||
this.socket.disconnect(true);
|
||||
};
|
||||
|
||||
User.prototype.initCallbacks = function () {
|
||||
var self = this;
|
||||
self.socket.on("disconnect", function () {
|
||||
self.awaytimer && clearTimeout(self.awaytimer);
|
||||
if (self.inChannel())
|
||||
self.channel.userLeave(self);
|
||||
else if (self.inPendingChannel())
|
||||
self.pendingChannel.userLeave(self);
|
||||
});
|
||||
|
||||
self.socket.on("joinChannel", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel() || self.inPendingChannel()) {
|
||||
return;
|
||||
}
|
||||
if (typeof data.name != "string") {
|
||||
return;
|
||||
}
|
||||
if (!data.name.match(/^[\w-_]{1,30}$/)) {
|
||||
self.socket.emit("errorMsg", {
|
||||
msg: "Invalid channel name. Channel names may consist of"+
|
||||
" 1-30 characters in the set a-z, A-Z, 0-9, -, and _"
|
||||
});
|
||||
self.kick("Invalid channel name");
|
||||
return;
|
||||
}
|
||||
data.name = data.name.toLowerCase();
|
||||
self.pendingChannel = self.server.getChannel(data.name);
|
||||
if (self.loggedIn) {
|
||||
// TODO fix
|
||||
// I'm not sure what I meant by "fix", but I suppose I'll find out soon
|
||||
self.pendingChannel.getRank(self.name, function (err, rank) {
|
||||
if (!err && rank > self.rank)
|
||||
self.rank = rank;
|
||||
});
|
||||
}
|
||||
self.pendingChannel.join(self);
|
||||
});
|
||||
|
||||
self.socket.on("channelPassword", function (pw) {
|
||||
if (!self.inChannel() && self.inPendingChannel()) {
|
||||
self.pendingChannel.userJoin(self, pw);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("login", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
var name = (typeof data.name === "string") ? data.name : "";
|
||||
var pw = (typeof data.pw === "string") ? data.pw : "";
|
||||
var session = (typeof data.session === "string") ? data.session : "";
|
||||
if (pw.length > 100)
|
||||
pw = pw.substring(0, 100);
|
||||
if (session.length > 64)
|
||||
session = session.substring(0, 64);
|
||||
|
||||
if (self.loggedIn)
|
||||
return;
|
||||
|
||||
if (self.loggingIn) {
|
||||
var j = 0;
|
||||
// Wait until current login finishes
|
||||
var i = setInterval(function () {
|
||||
j++;
|
||||
if (!self.loggingIn) {
|
||||
clearInterval(i);
|
||||
if (!self.loggedIn)
|
||||
self.login(name, pw, session);
|
||||
return;
|
||||
}
|
||||
// Just in case to prevent the interval from going wild
|
||||
if (j >= 4)
|
||||
clearInterval(i);
|
||||
}, 1000);
|
||||
} else {
|
||||
self.login(name, pw, session);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("assignLeader", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryChangeLeader(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("setChannelRank", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.trySetRank(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("unban", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryUnban(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("chatMsg", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
if (typeof data.msg !== "string") {
|
||||
return;
|
||||
}
|
||||
if (data.msg.indexOf("/afk") !== 0) {
|
||||
self.setAFK(false);
|
||||
self.autoAFK();
|
||||
}
|
||||
self.channel.tryChat(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("newPoll", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryOpenPoll(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("playerReady", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.sendMediaUpdate(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("requestPlaylist", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.sendPlaylist(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("queue", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryQueue(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("setTemp", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.trySetTemp(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("delete", function (data) {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryDequeue(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("uncache", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryUncache(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("moveMedia", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryMove(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("jumpTo", function (data) {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryJumpTo(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("playNext", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryPlayNext(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("clearPlaylist", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryClearqueue(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("shufflePlaylist", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryShufflequeue(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("togglePlaylistLock", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryToggleLock(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("mediaUpdate", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryUpdate(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("searchMedia", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
if (typeof data.query !== "string") {
|
||||
return;
|
||||
}
|
||||
// Soft limit to prevent someone from making a massive query
|
||||
if (data.query.length > 255) {
|
||||
data.query = data.query.substring(0, 255);
|
||||
}
|
||||
if (data.source === "yt") {
|
||||
var searchfn = InfoGetter.Getters.ytSearch;
|
||||
searchfn(data.query.split(" "), function (e, vids) {
|
||||
if (!e) {
|
||||
self.socket.emit("searchResults", {
|
||||
source: "yt",
|
||||
results: vids
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
self.channel.search(data.query, function (vids) {
|
||||
if (vids.length === 0) {
|
||||
var searchfn = InfoGetter.Getters.ytSearch;
|
||||
searchfn(data.query.split(" "), function (e, vids) {
|
||||
if (!e) {
|
||||
self.socket.emit("searchResults", {
|
||||
source: "yt",
|
||||
results: vids
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
self.socket.emit("searchResults", {
|
||||
source: "library",
|
||||
results: vids
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("closePoll", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryClosePoll(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("vote", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryVote(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("registerChannel", function (data) {
|
||||
if (!self.inChannel()) {
|
||||
self.socket.emit("channelRegistration", {
|
||||
success: false,
|
||||
error: "You're not in any channel!"
|
||||
});
|
||||
} else {
|
||||
self.channel.tryRegister(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("unregisterChannel", function () {
|
||||
if (!self.inChannel()) {
|
||||
return;
|
||||
}
|
||||
if (self.rank < 10) {
|
||||
self.kick("Attempted unregisterChannel with insufficient permission");
|
||||
return;
|
||||
}
|
||||
self.channel.unregister(self);
|
||||
});
|
||||
|
||||
self.socket.on("setOptions", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryUpdateOptions(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("setPermissions", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryUpdatePermissions(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("setChannelCSS", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.trySetCSS(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("setChannelJS", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.trySetJS(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("updateFilter", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryUpdateFilter(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("removeFilter", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryRemoveFilter(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("moveFilter", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryMoveFilter(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("setMotd", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryUpdateMotd(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("requestLoginHistory", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.sendLoginHistory(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("requestBanlist", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.sendBanlist(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("requestChatFilters", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.sendChatFilters(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("requestChannelRanks", function () {
|
||||
if (self.inChannel()) {
|
||||
if (self.rankListLimiter.throttle({
|
||||
burst: 0,
|
||||
sustained: 0.1,
|
||||
cooldown: 10
|
||||
})) {
|
||||
self.socket.emit("noflood", {
|
||||
action: "channel ranks",
|
||||
msg: "You may only refresh channel ranks once every 10 seconds"
|
||||
});
|
||||
} else {
|
||||
self.channel.sendChannelRanks(self);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("voteskip", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryVoteskip(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("listPlaylists", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.name === "" || self.rank < 1) {
|
||||
self.socket.emit("listPlaylists", {
|
||||
pllist: [],
|
||||
error: "You must be logged in to manage playlists"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
self.server.db.listUserPlaylists(self.name, function (err, list) {
|
||||
if (err)
|
||||
list = [];
|
||||
for(var i = 0; i < list.length; i++) {
|
||||
list[i].time = $util.formatTime(list[i].time);
|
||||
}
|
||||
self.socket.emit("listPlaylists", {
|
||||
pllist: list
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
self.socket.on("savePlaylist", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (typeof data.name !== "string") {
|
||||
return;
|
||||
}
|
||||
// Soft limit to prevent someone from saving a list with a massive name
|
||||
if (data.name.length > 200) {
|
||||
data.name = data.name.substring(0, 200);
|
||||
}
|
||||
if (self.rank < 1) {
|
||||
self.socket.emit("savePlaylist", {
|
||||
success: false,
|
||||
error: "You must be logged in to manage playlists"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self.inChannel()) {
|
||||
self.socket.emit("savePlaylist", {
|
||||
success: false,
|
||||
error: "Not in a channel"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof data.name != "string") {
|
||||
return;
|
||||
}
|
||||
|
||||
var pl = self.channel.playlist.items.toArray();
|
||||
self.server.db.saveUserPlaylist(pl, self.name, data.name,
|
||||
function (err, res) {
|
||||
if (err) {
|
||||
self.socket.emit("savePlaylist", {
|
||||
success: false,
|
||||
error: err
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
self.socket.emit("savePlaylist", {
|
||||
success: true
|
||||
});
|
||||
|
||||
self.server.db.listUserPlaylists(self.name,
|
||||
function (err, list) {
|
||||
if (err)
|
||||
list = [];
|
||||
for(var i = 0; i < list.length; i++) {
|
||||
list[i].time = $util.formatTime(list[i].time);
|
||||
}
|
||||
self.socket.emit("listPlaylists", {
|
||||
pllist: list
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
self.socket.on("queuePlaylist", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryQueuePlaylist(self, data);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("deletePlaylist", function (data) {
|
||||
data = (typeof data !== "object") ? {} : data;
|
||||
if (typeof data.name != "string") {
|
||||
return;
|
||||
}
|
||||
|
||||
self.server.db.deleteUserPlaylist(self.name, data.name,
|
||||
function () {
|
||||
self.server.db.listUserPlaylists(self.name,
|
||||
function (err, list) {
|
||||
if (err)
|
||||
list = [];
|
||||
for(var i = 0; i < list.length; i++) {
|
||||
list[i].time = $util.formatTime(list[i].time);
|
||||
}
|
||||
self.socket.emit("listPlaylists", {
|
||||
pllist: list
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
self.socket.on("readChanLog", function () {
|
||||
if (self.inChannel()) {
|
||||
self.channel.tryReadLog(self);
|
||||
}
|
||||
});
|
||||
|
||||
self.socket.on("acp-init", function () {
|
||||
if (self.global_rank >= 255)
|
||||
ACP.init(self);
|
||||
});
|
||||
|
||||
self.socket.on("borrow-rank", function (rank) {
|
||||
if (self.global_rank < 255)
|
||||
return;
|
||||
if (rank > self.global_rank)
|
||||
return;
|
||||
|
||||
self.rank = rank;
|
||||
self.socket.emit("rank", rank);
|
||||
if (self.inChannel()) {
|
||||
self.channel.sendAll("setUserRank", {
|
||||
name: self.name,
|
||||
rank: rank
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
var lastguestlogin = {};
|
||||
User.prototype.guestLogin = function (name) {
|
||||
var self = this;
|
||||
|
||||
if (self.ip in lastguestlogin) {
|
||||
var diff = (Date.now() - lastguestlogin[self.ip])/1000;
|
||||
if (diff < self.server.cfg["guest-login-delay"]) {
|
||||
self.socket.emit("login", {
|
||||
success: false,
|
||||
error: "Guest logins are restricted to one per IP address "+
|
||||
"per " + self.server.cfg["guest-login-delay"] +
|
||||
" seconds."
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$util.isValidUserName(name)) {
|
||||
self.socket.emit("login", {
|
||||
success: false,
|
||||
error: "Invalid username. Usernames must be 1-20 characters "+
|
||||
"long and consist only of characters a-z, A-Z, 0-9, -, "+
|
||||
"and _"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the loggingIn flag to avoid race conditions with the callback
|
||||
self.loggingIn = true;
|
||||
self.server.db.isUsernameTaken(name, function (err, taken) {
|
||||
self.loggingIn = false;
|
||||
if (err) {
|
||||
self.socket.emit("login", {
|
||||
success: false,
|
||||
error: "Internal error: " + err
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (taken) {
|
||||
self.socket.emit("login", {
|
||||
success: false,
|
||||
error: "That username is registered and protected."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.inChannel()) {
|
||||
var lname = name.toLowerCase();
|
||||
for(var i = 0; i < self.channel.users.length; i++) {
|
||||
if (self.channel.users[i].name.toLowerCase() === lname) {
|
||||
self.socket.emit("login", {
|
||||
success: false,
|
||||
error: "That name is already in use on this channel"
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
lastguestlogin[self.ip] = Date.now();
|
||||
self.rank = 0;
|
||||
Logger.syslog.log(self.ip + " signed in as " + name);
|
||||
self.server.db.recordVisit(self.ip, name);
|
||||
self.name = name;
|
||||
self.loggedIn = false;
|
||||
self.socket.emit("login", {
|
||||
success: true,
|
||||
name: name
|
||||
});
|
||||
self.socket.emit("rank", self.rank);
|
||||
if (self.inChannel()) {
|
||||
self.channel.logger.log(self.ip + " signed in as " + name);
|
||||
self.channel.broadcastNewUser(self);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Attempt to login
|
||||
User.prototype.login = function (name, pw, session) {
|
||||
var self = this;
|
||||
// No password => try guest login
|
||||
if (pw === "" && session === "") {
|
||||
this.guestLogin(name);
|
||||
} else {
|
||||
self.loggingIn = true;
|
||||
self.server.db.userLogin(name, pw, session, function (err, row) {
|
||||
if (err) {
|
||||
self.loggingIn = false;
|
||||
ActionLog.record(self.ip, name, "login-failure",
|
||||
err);
|
||||
self.socket.emit("login", {
|
||||
success: false,
|
||||
error: err
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (self.inChannel()) {
|
||||
var n = name.toLowerCase();
|
||||
for(var i = 0; i < self.channel.users.length; i++) {
|
||||
if (self.channel.users[i].name.toLowerCase() === n) {
|
||||
if (self.channel.users[i] === self) {
|
||||
Logger.errlog.log("Wat: user.login() but user "+
|
||||
"already logged in on channel");
|
||||
break;
|
||||
}
|
||||
self.channel.kick(self.channel.users[i],
|
||||
"Duplicate login");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Record logins for administrator accounts
|
||||
if (self.global_rank >= 255)
|
||||
ActionLog.record(self.ip, name, "login-success");
|
||||
self.loggedIn = true;
|
||||
self.loggingIn = false;
|
||||
self.socket.emit("login", {
|
||||
success: true,
|
||||
session: row.session_hash,
|
||||
name: name
|
||||
});
|
||||
Logger.syslog.log(self.ip + " logged in as " + name);
|
||||
self.server.db.recordVisit(self.ip, name);
|
||||
self.profile = {
|
||||
image: row.profile_image,
|
||||
text: row.profile_text
|
||||
};
|
||||
self.global_rank = row.global_rank;
|
||||
var afterRankLookup = function () {
|
||||
self.socket.emit("rank", self.rank);
|
||||
self.name = name;
|
||||
if (self.inChannel()) {
|
||||
self.channel.logger.log(self.ip + " logged in as " +
|
||||
name);
|
||||
self.channel.broadcastNewUser(self);
|
||||
} else if (self.inPendingChannel()) {
|
||||
self.pendingChannel.userJoin(self);
|
||||
}
|
||||
};
|
||||
if (self.inChannel() || self.inPendingChannel()) {
|
||||
var chan = self.channel != null ? self.channel : self.pendingChannel;
|
||||
chan.getRank(name, function (err, rank) {
|
||||
if (!err) {
|
||||
self.saverank = true;
|
||||
self.rank = rank;
|
||||
} else {
|
||||
// If there was an error in retrieving the rank,
|
||||
// don't overwrite it with a bad value
|
||||
self.saverank = false;
|
||||
self.rank = self.global_rank;
|
||||
}
|
||||
afterRankLookup();
|
||||
});
|
||||
} else {
|
||||
self.rank = self.global_rank;
|
||||
afterRankLookup();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = User;
|
|
@ -1,202 +0,0 @@
|
|||
doctype html
|
||||
html(lang="en")
|
||||
head
|
||||
include head
|
||||
mixin head()
|
||||
link(href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css", rel="stylesheet")
|
||||
body
|
||||
#wrap
|
||||
nav.navbar.navbar-inverse.navbar-fixed-top(role="navigation")
|
||||
include nav
|
||||
mixin navheader()
|
||||
#nav-collapsible.collapse.navbar-collapse
|
||||
- var cname = "/r/" + channelName
|
||||
ul.nav.navbar-nav
|
||||
mixin navdefaultlinks(cname)
|
||||
li: a(href="#", onclick="javascript:showUserOptions()") Options
|
||||
li: a#showchansettings(href="#", onclick="javascript:$('#channeloptions').modal()") Channel Settings
|
||||
mixin navloginlogout(cname)
|
||||
section#mainpage
|
||||
.container
|
||||
#motdrow.row
|
||||
.col-lg-12.col-md-12
|
||||
#motdwrap.well
|
||||
button#togglemotd.close.pull-right(type="button")
|
||||
span.glyphicon.glyphicon-minus
|
||||
#motd
|
||||
.clear
|
||||
#announcements.row
|
||||
#drinkbarwrap.row
|
||||
#drinkbar.col-lg-12.col-md-12
|
||||
h1#drinkcount
|
||||
#videowrap.col-md-8.col-md-offset-2
|
||||
p#currenttitle Nothing Playing
|
||||
#ytapiplayer
|
||||
#rightcontrols.col-md-8.col-md-offset-2
|
||||
.btn-group.pull-right
|
||||
button#mediarefresh.btn.btn-sm.btn-default(title="Reload the video player")
|
||||
span.glyphicon.glyphicon-retweet
|
||||
button#getplaylist.btn.btn-sm.btn-default(title="Retrieve playlist links")
|
||||
span.glyphicon.glyphicon-link
|
||||
button#voteskip.btn.btn-sm.btn-default(title="Voteskip")
|
||||
span.glyphicon.glyphicon-step-forward
|
||||
#main.row
|
||||
|
||||
#playlistrow.row
|
||||
#rightpane.col-md-6
|
||||
#rightpane-inner.row
|
||||
.col-md-12
|
||||
#plcontrol.btn-group
|
||||
button#showsearch.btn.btn-sm.btn-default(title="Search for a video", data-toggle="collapse", data-target="#searchcontrol")
|
||||
span.glyphicon.glyphicon-search
|
||||
button#showmediaurl.btn.btn-sm.btn-default(title="Add video from URL", data-toggle="collapse", data-target="#addfromurl")
|
||||
span.glyphicon.glyphicon-plus
|
||||
button#showcustomembed.btn.btn-sm.btn-default(title="Embed a custom frame", data-toggle="collapse", data-target="#customembed")
|
||||
span.glyphicon.glyphicon-th-large
|
||||
button#clearplaylist.btn.btn-sm.btn-default(title="Clear the playlist")
|
||||
span.glyphicon.glyphicon-trash
|
||||
button#shuffleplaylist.btn.btn-sm.btn-default(title="Shuffle the playlist")
|
||||
span.glyphicon.glyphicon-sort
|
||||
button#qlockbtn.btn.btn-sm.btn-danger(title="Playlist locked")
|
||||
span.glyphicon.glyphicon-lock
|
||||
#addfromurl.collapse.plcontrol-collapse.col-lg-12.col-md-12
|
||||
.vertical-spacer
|
||||
.input-group
|
||||
input#mediaurl.form-control(type="text", placeholder="Media URL")
|
||||
span.input-group-btn
|
||||
button#queue_next.btn.btn-default Next
|
||||
span.input-group-btn
|
||||
button#queue_end.btn.btn-default At End
|
||||
#searchcontrol.collapse.plcontrol-collapse.col-lg-12.col-md-12
|
||||
.vertical-spacer
|
||||
.input-group
|
||||
input#library_query.form-control(type="text", placeholder="Search query")
|
||||
span.input-group-btn
|
||||
button#library_search.btn.btn-default Library
|
||||
span.input-group-btn
|
||||
button#youtube_search.btn.btn-default YouTube
|
||||
ul#library.videolist.col-lg-12.col-md-12
|
||||
#customembed.collapse.plcontrol-collapse.col-lg-12.col-md-12
|
||||
.vertical-spacer
|
||||
.input-group
|
||||
input#customembed-title.form-control(type="text", placeholder="Title (optional)")
|
||||
span.input-group-btn
|
||||
button#ce_queue_next.btn.btn-default Next
|
||||
span.input-group-btn
|
||||
button#ce_queue_end.btn.btn-default At End
|
||||
| Paste the embed code below and click Next or At End.
|
||||
| Acceptable embed codes are <code><iframe></code> and <code><object></code> tags.
|
||||
textarea#customembed-content.input-block-level.form-control(rows="3")
|
||||
#queuefail.col-lg-12.col-md-12
|
||||
.vertical-spacer
|
||||
.col-lg-12.col-md-12
|
||||
ul#queue.videolist
|
||||
#plmeta
|
||||
span#plcount 0 items
|
||||
span#pllength 00:00:00
|
||||
#chatwrap.col-md-6
|
||||
#chatheader
|
||||
i#userlisttoggle.glyphicon.glyphicon-chevron-up.pull-left.pointer(title="Show/Hide Userlist")
|
||||
span#usercount.pointer Not Connected
|
||||
span#modflair.label.label-default.pull-right.pointer M
|
||||
span#adminflair.label.label-default.pull-right.pointer A
|
||||
#userlist
|
||||
#messagebuffer
|
||||
input#chatline.form-control(type="text", maxlength="240", style="display: none")
|
||||
#guestlogin.input-group
|
||||
span.input-group-addon Guest login
|
||||
input#guestname.form-control(type="text", placeholder="Name")
|
||||
#leftcontrols.col-lg-5.col-md-5
|
||||
button#newpollbtn.btn.btn-sm.btn-default New Poll
|
||||
#leftpane.col-lg-5.col-md-5
|
||||
#leftpane-inner.row
|
||||
#pollwrap.col-lg-12.col-md-12
|
||||
#playlistmanagerwrap.col-lg-12.col-md-12
|
||||
button#showplaylistmanager.btn.btn-default.btn-block(data-toggle="collapse", data-target="#playlistmanager") Playlist Manager
|
||||
#playlistmanager.collapse
|
||||
.row.vertical-spacer
|
||||
.col-lg-12.col-md-12
|
||||
.input-group
|
||||
input#userpl_name.form-control(type="text", placeholder="Playlist Name")
|
||||
span.input-group-btn
|
||||
button#userpl_save.btn.btn-default Save
|
||||
ul#userpl_list.col-lg-12.col-md-12
|
||||
#resizewrap.row
|
||||
.col-lg-5.col-md-5
|
||||
#videowidth.col-lg-7.col-md-7
|
||||
#sitefooter
|
||||
include pagefooter
|
||||
#useroptions.modal.fade(tabindex="-1", role="dialog", aria-hidden="true")
|
||||
.modal-dialog
|
||||
.modal-content
|
||||
.modal-header
|
||||
button.close(data-dismiss="modal", aria-hidden="true") ×
|
||||
h4 User Preferences
|
||||
ul.nav.nav-tabs
|
||||
li: a(href="#us-general", data-toggle="tab") General
|
||||
li: a(href="#us-playback", data-toggle="tab") Playback
|
||||
li: a(href="#us-chat", data-toggle="tab") Chat
|
||||
li: a(href="#us-mod", data-toggle="tab", style="") Moderator
|
||||
.modal-body
|
||||
.tab-content
|
||||
include useroptions
|
||||
mixin us-general()
|
||||
mixin us-playback()
|
||||
mixin us-chat()
|
||||
mixin us-mod()
|
||||
.modal-footer
|
||||
button.btn.btn-primary(type="button", data-dismiss="modal", onclick="javascript:saveUserOptions()") Save
|
||||
button.btn.btn-default(type="button", data-dismiss="modal") Close
|
||||
#channeloptions.modal.fade(tabindex="-1", role="dialog", aria-hidden="true")
|
||||
.modal-dialog
|
||||
.modal-content
|
||||
.modal-header
|
||||
button.close(data-dismiss="modal", aria-hidden="true") ×
|
||||
h4 Channel Settings
|
||||
ul.nav.nav-tabs
|
||||
li: a(href="#cs-miscoptions", data-toggle="tab") General Settings
|
||||
li: a(href="#cs-adminoptions", data-toggle="tab") Admin Settings
|
||||
li.dropdown
|
||||
a#cs-edit-dd-toggle(href="#", data-toggle="dropdown") Edit
|
||||
span.caret
|
||||
ul.dropdown-menu
|
||||
li: a(href="#cs-chatfilters", data-toggle="tab", onclick="javascript:socket.emit('requestChatFilters')") Chat Filters
|
||||
li: a(href="#cs-motdeditor", data-toggle="tab", tabindex="-1") MOTD
|
||||
li: a(href="#cs-csseditor", data-toggle="tab", tabindex="-1") CSS
|
||||
li: a(href="#cs-jseditor", data-toggle="tab", tabindex="-1") Javascript
|
||||
li: a(href="#cs-permedit", data-toggle="tab", tabindex="-1") Permissions
|
||||
li: a(href="#cs-chanranks", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestChannelRanks')") Moderators
|
||||
li: a(href="#cs-banlist", data-toggle="tab", tabindex="-1", onclick="javascript:socket.emit('requestBanlist')") Ban list
|
||||
li: a(href="#cs-chanlog", data-toggle="tab", onclick="javascript:socket.emit('readChanLog')") Log
|
||||
.modal-body
|
||||
.tab-content
|
||||
include channeloptions
|
||||
mixin miscoptions()
|
||||
mixin adminoptions()
|
||||
mixin motdeditor()
|
||||
mixin csseditor()
|
||||
mixin jseditor()
|
||||
mixin banlist()
|
||||
mixin recentjoins()
|
||||
mixin chanranks()
|
||||
mixin chatfilters()
|
||||
mixin chanlog()
|
||||
mixin permeditor()
|
||||
.modal-footer
|
||||
button.btn.btn-default(type="button", data-dismiss="modal") Close
|
||||
include footer
|
||||
mixin footer()
|
||||
script(src=sioSource)
|
||||
script(src="/assets/js/data.js")
|
||||
script(src="/sioconfig")
|
||||
script(src="/assets/js/util.js")
|
||||
script(src="/assets/js/player.js")
|
||||
script(src="/assets/js/paginator.js")
|
||||
script(src="/assets/js/ui.js")
|
||||
script(src="/assets/js/callbacks.js")
|
||||
script(defer, src="https://www.youtube.com/iframe_api")
|
||||
script(defer, src="//api.dmcdn.net/all.js")
|
||||
script(defer, src="/assets/js/jwplayer.js")
|
||||
script(defer, src="/assets/js/sc.js")
|
||||
script(defer, src="/assets/js/froogaloop.min.js")
|
||||
script(defer, src="/assets/js/swf.js")
|
|
@ -62,7 +62,7 @@ html(lang="en")
|
|||
span.glyphicon.glyphicon-sort
|
||||
button#qlockbtn.btn.btn-sm.btn-danger(title="Playlist locked")
|
||||
span.glyphicon.glyphicon-lock
|
||||
.btn-group.pull-right
|
||||
#videocontrols.btn-group.pull-right
|
||||
button#mediarefresh.btn.btn-sm.btn-default(title="Reload the video player")
|
||||
span.glyphicon.glyphicon-retweet
|
||||
button#getplaylist.btn.btn-sm.btn-default(title="Retrieve playlist links")
|
||||
|
|
|
@ -9,7 +9,8 @@ mixin head()
|
|||
//link(href="/css/bootstrap-theme.min.css", rel="stylesheet")
|
||||
link(href="/css/sticky-footer-navbar.css", rel="stylesheet")
|
||||
link(href="/css/cytube.css", rel="stylesheet")
|
||||
link(href="/css/colors/default.css", rel="stylesheet")
|
||||
link(id="usertheme", href="/css/themes/default.css", rel="stylesheet")
|
||||
script(src="/js/theme.js")
|
||||
//[if lt IE 9]
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
doctype html
|
||||
html(lang="en")
|
||||
head
|
||||
include head
|
||||
mixin head()
|
||||
body
|
||||
#wrap
|
||||
nav.navbar.navbar-inverse.navbar-fixed-top(role="navigation")
|
||||
include nav
|
||||
mixin navheader()
|
||||
#nav-collapsible.collapse.navbar-collapse
|
||||
ul.nav.navbar-nav
|
||||
mixin navdefaultlinks("/test")
|
||||
mixin navloginform("/test")
|
||||
|
||||
include footer
|
||||
mixin footer()
|
|
@ -30,8 +30,9 @@ mixin us-general
|
|||
.col-sm-8
|
||||
select#us-theme.form-control
|
||||
option(value="default") Default
|
||||
option(value="/css/bootstrap-theme.min.css") Bootstrap
|
||||
//option(value="/css/dark.css") Dark
|
||||
option(value="/css/themes/bootstrap-theme.min.css") Bootstrap
|
||||
option(value="/css/themes/slate.css") Slate
|
||||
option(value="/css/themes/cyborg.css") Cyborg
|
||||
.form-group
|
||||
label.control-label.col-sm-4(for="#us-layout") Layout
|
||||
.col-sm-8
|
||||
|
|
|
@ -66,8 +66,8 @@ $("#usercount").mouseenter(function (ev) {
|
|||
// re-using profile-box class for convenience
|
||||
var popup = $("<div/>")
|
||||
.addClass("profile-box")
|
||||
.css("top", (ev.pageY + 5) + "px")
|
||||
.css("left", (ev.pageX) + "px")
|
||||
.css("top", (ev.clientY + 5) + "px")
|
||||
.css("left", (ev.clientX) + "px")
|
||||
.appendTo($("#usercount"));
|
||||
|
||||
var contents = "";
|
||||
|
@ -84,8 +84,8 @@ $("#usercount").mousemove(function (ev) {
|
|||
if(popup.length == 0)
|
||||
return;
|
||||
|
||||
popup.css("top", (ev.pageY + 5) + "px");
|
||||
popup.css("left", (ev.pageX) + "px");
|
||||
popup.css("top", (ev.clientY + 5) + "px");
|
||||
popup.css("left", (ev.clientX) + "px");
|
||||
});
|
||||
|
||||
$("#usercount").mouseleave(function () {
|
||||
|
|
|
@ -603,6 +603,7 @@ function showUserOptions() {
|
|||
|
||||
function saveUserOptions() {
|
||||
USEROPTS.theme = $("#us-theme").val();
|
||||
createCookie("cytube-theme", USEROPTS.theme, 1000);
|
||||
USEROPTS.layout = $("#us-layout").val();
|
||||
USEROPTS.ignore_channelcss = $("#us-no-channelcss").prop("checked");
|
||||
USEROPTS.ignore_channeljs = $("#us-no-channeljs").prop("checked");
|
||||
|
@ -629,6 +630,7 @@ function saveUserOptions() {
|
|||
}
|
||||
|
||||
storeOpts();
|
||||
applyOpts();
|
||||
}
|
||||
|
||||
function storeOpts() {
|
||||
|
@ -638,6 +640,7 @@ function storeOpts() {
|
|||
}
|
||||
|
||||
function applyOpts() {
|
||||
if ($("#usertheme").attr("href") !== USEROPTS.theme) {
|
||||
$("#usertheme").remove();
|
||||
if(USEROPTS.theme != "default") {
|
||||
$("<link/>").attr("rel", "stylesheet")
|
||||
|
@ -646,6 +649,8 @@ function applyOpts() {
|
|||
.attr("href", USEROPTS.theme)
|
||||
.appendTo($("head"));
|
||||
}
|
||||
fixWeirdButtonAlignmentIssue();
|
||||
}
|
||||
|
||||
switch (USEROPTS.layout) {
|
||||
case "synchtube-fluid":
|
||||
|
@ -905,13 +910,7 @@ function handlePermissionChange() {
|
|||
setVisible("#clearplaylist", hasPermission("playlistclear"));
|
||||
setVisible("#shuffleplaylist", hasPermission("playlistshuffle"));
|
||||
|
||||
// Weird things happen to the alignment in chromium when I toggle visibility
|
||||
// of the above buttons
|
||||
// This fixes it?
|
||||
var wtf = $("#rightcontrols .pull-right").removeClass("pull-right")
|
||||
setTimeout(function () {
|
||||
wtf.addClass("pull-right");
|
||||
}, 1);
|
||||
fixWeirdButtonAlignmentIssue();
|
||||
|
||||
setVisible("#newpollbtn", hasPermission("pollctl"));
|
||||
$("#voteskip").attr("disabled", !hasPermission("voteskip") ||
|
||||
|
@ -942,6 +941,16 @@ function handlePermissionChange() {
|
|||
rebuildPlaylist();
|
||||
}
|
||||
|
||||
function fixWeirdButtonAlignmentIssue() {
|
||||
// Weird things happen to the alignment in chromium when I toggle visibility
|
||||
// of the above buttons
|
||||
// This fixes it?
|
||||
var wtf = $("#videocontrols").removeClass("pull-right");
|
||||
setTimeout(function () {
|
||||
wtf.addClass("pull-right");
|
||||
}, 1);
|
||||
}
|
||||
|
||||
/* search stuff */
|
||||
|
||||
function clearSearchResults() {
|
||||
|
@ -1417,7 +1426,7 @@ function hdLayout() {
|
|||
.prependTo($("#rightpane-inner"));
|
||||
|
||||
$("#plcontrol").detach().appendTo(plcontrolwrap);
|
||||
$("#rightcontrols .btn-group.pull-right").detach()
|
||||
$("#videocontrols").detach()
|
||||
.appendTo(plcontrolwrap);
|
||||
|
||||
$("#controlswrap").remove();
|
||||
|
@ -1669,8 +1678,10 @@ function errDialog(err) {
|
|||
var cp = $("#chatwrap").offset();
|
||||
var x = cp.left + cw/2 - div.width()/2;
|
||||
var y = cp.top + ch/2 - div.height()/2;
|
||||
div.css("left", x + "px");
|
||||
div.css("top", y + "px");
|
||||
div.css("left", x + "px")
|
||||
.css("top", y + "px")
|
||||
.css("position", "absolute");
|
||||
return div;
|
||||
}
|
||||
|
||||
function queueMessage(data, type) {
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
body {
|
||||
background-color: #222222;
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
#ytapiplayer {
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
#userlist, #messagebuffer {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.drink {
|
||||
border-color: #0000cc;
|
||||
}
|
||||
|
||||
.queue_entry {
|
||||
background-color: #000000;
|
||||
border-color: #aaaaaa;
|
||||
}
|
||||
|
||||
.queue_entry > a {
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
.queue_active {
|
||||
background-color: #666666;
|
||||
}
|
||||
|
||||
.profile-box {
|
||||
background-color: #111111;
|
||||
}
|
||||
|
||||
.user-dropdown {
|
||||
background-color: #111111;
|
||||
}
|
||||
|
||||
.dropdown-menu, .dropdown-menu > li > a {
|
||||
color: #cccccc;
|
||||
background-color: #222222;
|
||||
}
|
||||
|
||||
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:active,
|
||||
.dropdown-menu > li > a:focus {
|
||||
color: #cccccc;
|
||||
background-color: #444444;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
background-color: #000000;
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
.btn, .btn:hover, .btn:active, .btn.active {
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
.btn-default {
|
||||
background-color: #000000;
|
||||
border-color: #555555;
|
||||
}
|
||||
|
||||
.btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active {
|
||||
background-color: #222222;
|
||||
border-color: #555555;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background-color: #006600;
|
||||
border-color: #009900;
|
||||
}
|
||||
|
||||
.btn-success:hover, .btn-success:focus, .btn-success:active, .btn-success.active {
|
||||
background-color: #008800;
|
||||
border-color: #009900;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background-color: #660000;
|
||||
border-color: #990000;
|
||||
}
|
||||
|
||||
.btn-danger:hover, .btn-danger:focus, .btn-danger:active, .btn-danger.active {
|
||||
background-color: #880000;
|
||||
border-color: #990000;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
border-color: #0000cc;
|
||||
background-color: #000066;
|
||||
}
|
||||
|
||||
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active {
|
||||
border-color: #0000cc;
|
||||
background-color: #000088;
|
||||
}
|
||||
|
||||
.btn-info {
|
||||
border-color: #0000cc;
|
||||
background-color: #000066;
|
||||
}
|
||||
|
||||
.btn-info:hover, .btn-info:focus, .btn-info:active, .btn-info.active {
|
||||
border-color: #0000cc;
|
||||
background-color: #000088;
|
||||
}
|
||||
|
||||
.well {
|
||||
background-color: #222222;
|
||||
border: 1px solid #555555;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: #222222!important;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #222222;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
border-top-color: #aaaaaa;
|
||||
}
|
||||
|
||||
.nav .open > li > a {
|
||||
color: #cccccc;
|
||||
background-color: #222222;
|
||||
}
|
||||
|
||||
.nav > li > a {
|
||||
color: #cccccc;
|
||||
border-color: #aaaaaa;
|
||||
}
|
||||
|
||||
.nav > li:hover > a {
|
||||
background-color: #444444;
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
.nav > li.active > a, .nav > li.active > a:hover, .nav > li.active > a:focus {
|
||||
background-color: #222222;
|
||||
color: #cccccc;
|
||||
}
|
7720
www/css/themes/cyborg.css
Normal file
7720
www/css/themes/cyborg.css
Normal file
File diff suppressed because it is too large
Load diff
8007
www/css/themes/slate.css
Normal file
8007
www/css/themes/slate.css
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,39 +0,0 @@
|
|||
var Callbacks = {
|
||||
/* Connection failed */
|
||||
error: function (reason) {
|
||||
if (reason && reason.returnValue === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var fail = $('<div/>').addClass('alert alert-error')
|
||||
.appendTo($('#announcements'));
|
||||
|
||||
$('<h3/>').text('Uh-oh!').appendTo(fail);
|
||||
$('<p/>').html('The socket.io connection failed. Please check that '+
|
||||
'the connection was not blocked by a firewall or '+
|
||||
'antivirus software.');
|
||||
},
|
||||
|
||||
/* Connection succeeded */
|
||||
connect: function () {
|
||||
socket.emit('join', {
|
||||
channel: CHANNEL
|
||||
});
|
||||
|
||||
/* if rejoining after the connection failed, resend password */
|
||||
if (CHANNEL.opts.password) {
|
||||
socket.once('needPassword', function () {
|
||||
socket.emit('channelPassword', {
|
||||
password: CHANNEL.opts.password
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* guest login */
|
||||
if (NAME && !LOGGEDIN) {
|
||||
socket.emit('login', {
|
||||
name: NAME
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
|
@ -1,184 +0,0 @@
|
|||
|
||||
function addVideo(data, position) {
|
||||
var item = $('<li/>');
|
||||
item.data('id', data.id);
|
||||
item.data('temp', data.temp);
|
||||
var btnstrip = $('<div/>').addClass('btn-group video-buttons')
|
||||
.appendTo(item);
|
||||
var title = $('<a/>', {
|
||||
href: videoLink(data.id),
|
||||
target: '_blank',
|
||||
class: 'video-title'
|
||||
}).text(data.title).appendTo(item);
|
||||
var duration = $('<span/>').addClass('video-time')
|
||||
.text(formatTime(data.duration))
|
||||
.appendTo(item);
|
||||
|
||||
if (position === 'first') {
|
||||
item.prependTo($('#playlist'));
|
||||
} else if (position === 'last') {
|
||||
item.appendTo($('#playlist'));
|
||||
} else {
|
||||
var prev = findVideo(position);
|
||||
if (prev.length > 0) {
|
||||
item.insertAfter(prev);
|
||||
}
|
||||
}
|
||||
addVideoButtons(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
function addVideoButtons(li) {
|
||||
var btns = li.find('.video-buttons');
|
||||
if (btns.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (can('playlistjump')) {
|
||||
$('<button/>').addClass('btn btn-xs btn-default')
|
||||
.html('<span class="glyphicon glyphicon-play"></span>')
|
||||
.click(function () {
|
||||
SOCKET.emit('playVideo', {
|
||||
id: li.data('id')
|
||||
});
|
||||
})
|
||||
.appendTo(btns);
|
||||
}
|
||||
|
||||
if (can('playlistmove')) {
|
||||
$('<button/>').addClass('btn btn-xs btn-default')
|
||||
.html('<span class="glyphicon glyphicon-share-alt"></span>')
|
||||
.click(function () {
|
||||
SOCKET.emit('moveVideo', {
|
||||
id: li.data('id'),
|
||||
after: CURRENT.id
|
||||
});
|
||||
})
|
||||
.appendTo(btns);
|
||||
}
|
||||
|
||||
if (can('playlistsettemp')) {
|
||||
$('<button/>').addClass('btn btn-xs btn-default')
|
||||
.html('<span class="glyphicon glyphicon-flag"></span>')
|
||||
.click(function () {
|
||||
SOCKET.emit('setTemp', {
|
||||
id: li.data('id'),
|
||||
temp: !li.data('temp')
|
||||
});
|
||||
})
|
||||
.appendTo(btns);
|
||||
}
|
||||
|
||||
if (can('playlistsettemp')) {
|
||||
$('<button/>').addClass('btn btn-xs btn-default')
|
||||
.html('<span class="glyphicon glyphicon-trash"></span>')
|
||||
.click(function () {
|
||||
SOCKET.emit('deleteVideo', {
|
||||
id: li.data('id'),
|
||||
temp: !li.data('temp')
|
||||
});
|
||||
})
|
||||
.appendTo(btns);
|
||||
}
|
||||
}
|
||||
|
||||
function videoLink(data) {
|
||||
data = data.split(':');
|
||||
var type = data[0];
|
||||
var id = data[1];
|
||||
if (type === void 0 || id === void 0) {
|
||||
return '#';
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case 'yt':
|
||||
return 'http://youtu.be/' + id;
|
||||
default:
|
||||
return '#';
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(seconds) {
|
||||
var h = parseInt(seconds / 3600);
|
||||
var m = parseInt((seconds % 3600) / 60);
|
||||
var s = seconds % 60;
|
||||
|
||||
var time = '';
|
||||
if (h !== 0) {
|
||||
h = '' + h;
|
||||
if (h.length < 2) {
|
||||
h = '0' + h;
|
||||
}
|
||||
time += h + ':';
|
||||
}
|
||||
|
||||
m = '' + m;
|
||||
if (m.length < 2) {
|
||||
m = '0' + m;
|
||||
}
|
||||
time += m + ':';
|
||||
|
||||
s = '' + s;
|
||||
if (s.lengts < 2) {
|
||||
s = '0' + s;
|
||||
}
|
||||
time += s;
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
function addChatMessage(data, buffer) {
|
||||
var last = buffer.data('lastmessagename');
|
||||
var div = $('<div/>').addClass('chatmsg')
|
||||
.addClass('chatmsg-' + data.name);
|
||||
var timestamp = $('<span/>').addClass('chat-timestamp').appendTo(div)
|
||||
.text('[' + new Date(data.time).toTimeString().split(' ')[0] + '] ');
|
||||
var username = $('<span/>').addClass('chat-name').appendTo(div);
|
||||
var message = $('<span/>').appendTo(div).text(data.message);
|
||||
if (data.msgclass === 'action') {
|
||||
username.text(data.name + ' ');
|
||||
} else {
|
||||
username.text(data.name + ': ');
|
||||
}
|
||||
switch(data.msgclass) {
|
||||
case 'action':
|
||||
timestamp.addClass('action');
|
||||
username.addClass('action');
|
||||
message.addClass('action');
|
||||
break;
|
||||
case 'spoiler':
|
||||
message.addClass('spoiler');
|
||||
break;
|
||||
case 'greentext':
|
||||
message.addClass('greentext');
|
||||
break;
|
||||
case 'shout':
|
||||
timestamp.addClass('shout');
|
||||
username.addClass('shout');
|
||||
message.addClass('shout');
|
||||
break;
|
||||
case 'drink':
|
||||
div.addClass('drink');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!data.msgclass.match(/action|shout|drink/) &&
|
||||
data.name === last) {
|
||||
if (!data.message.match(/^\s*<strong>.+?\s*:/)) {
|
||||
username.remove();
|
||||
}
|
||||
}
|
||||
buffer.data('lastmessagename', data.name);
|
||||
|
||||
if (data.flair) {
|
||||
username.addClass(data.flair);
|
||||
}
|
||||
|
||||
div.appendTo(buffer);
|
||||
}
|
||||
|
||||
function can(what) {
|
||||
return true;
|
||||
}
|
152
www/js/init.js
152
www/js/init.js
|
@ -1,152 +0,0 @@
|
|||
/* Local client data */
|
||||
var RANK = -1;
|
||||
var LEADER = false;
|
||||
var LEADTIMER = false;
|
||||
var PL_DRAGFROM = false;
|
||||
var PL_DRAGTO = false;
|
||||
var PL_CURRENT
|
||||
var NAME = false;
|
||||
var LOGGEDIN = false;
|
||||
var SUPERADMIN = false;
|
||||
/* Channel data */
|
||||
var CHANNEL = {
|
||||
opts: {},
|
||||
openqueue: false,
|
||||
perms: {},
|
||||
css: '',
|
||||
js: '',
|
||||
motd: '',
|
||||
motd_text: '',
|
||||
name: false,
|
||||
usercount: 0
|
||||
};
|
||||
|
||||
/* Video player data */
|
||||
var PLAYER = false;
|
||||
|
||||
/* Chat data */
|
||||
var IGNORED = [];
|
||||
var CHATHIST = [];
|
||||
var CHATTHROTTLE = false;
|
||||
var SCROLLCHAT = true;
|
||||
var LASTCHATNAME = false;
|
||||
var LASTCHATTIME = 0;
|
||||
var CHATSOUND = new Audio('/sounds/boop.wav');
|
||||
|
||||
/* Page data */
|
||||
var FOCUSED = true;
|
||||
var PAGETITLE = 'CyTube';
|
||||
var TITLE_BLINK = false;
|
||||
|
||||
/* Playlist data */
|
||||
var PLAYLIST = {
|
||||
from: false,
|
||||
to: false,
|
||||
current: false,
|
||||
waitScroll: false
|
||||
};
|
||||
|
||||
/* Check if localStorage is available */
|
||||
var NOSTORAGE = typeof localStorage === 'undefined' || localStorage === null;
|
||||
|
||||
/**
|
||||
* Retrieve an option from localStorage, or from a cookie
|
||||
* if localStorage is not available
|
||||
*/
|
||||
function getOpt(k) {
|
||||
return NOSTORAGE ? readCookie(k) : localStorage.getItem(k);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an option to localStorage, or to a cookie
|
||||
* if localStorage is not available
|
||||
*/
|
||||
function setOpt(k, v) {
|
||||
if (NOSTORAGE) {
|
||||
setCookie(k, v, 1000)
|
||||
} else {
|
||||
localStorage.setItem(k, v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a stored value, or return the default if the stored value
|
||||
* is null. Also handles parsing of values stored as strings.
|
||||
*/
|
||||
function getOrDefault(k, def) {
|
||||
var v = getOpt(k);
|
||||
if (v == null) {
|
||||
return def;
|
||||
} else if (v === 'true') {
|
||||
return true;
|
||||
} else if (v === 'false') {
|
||||
return false;
|
||||
} else if (v.match(/^\d+$/)) {
|
||||
return parseInt(v);
|
||||
} else if (v.match(/^[\d\.]+$/)) {
|
||||
return parseFloat(v);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
/* User options */
|
||||
var USEROPTS = {
|
||||
theme : getOrDefault("theme", "default"),
|
||||
css : getOrDefault("css", ""),
|
||||
layout : getOrDefault("layout", "default"),
|
||||
synch : getOrDefault("synch", true),
|
||||
hidevid : getOrDefault("hidevid", false),
|
||||
show_timestamps : getOrDefault("show_timestamps", true),
|
||||
modhat : getOrDefault("modhat", false),
|
||||
blink_title : getOrDefault("blink_title", false),
|
||||
sync_accuracy : getOrDefault("sync_accuracy", 2),
|
||||
wmode_transparent : getOrDefault("wmode_transparent", true),
|
||||
chatbtn : getOrDefault("chatbtn", false),
|
||||
altsocket : getOrDefault("altsocket", false),
|
||||
joinmessage : getOrDefault("joinmessage", true),
|
||||
qbtn_hide : getOrDefault("qbtn_hide", false),
|
||||
qbtn_idontlikechange : getOrDefault("qbtn_idontlikechange", false),
|
||||
first_visit : getOrDefault("first_visit", true),
|
||||
ignore_channelcss : getOrDefault("ignore_channelcss", false),
|
||||
ignore_channeljs : getOrDefault("ignore_channeljs", false),
|
||||
sort_rank : getOrDefault("sort_rank", false),
|
||||
sort_afk : getOrDefault("sort_afk", false),
|
||||
default_quality : getOrDefault("default_quality", "#quality_auto"),
|
||||
boop : getOrDefault("boop", false),
|
||||
secure_connection : getOrDefault("secure_connection", false)
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a cookie with the provided name, value, and expiration time
|
||||
*/
|
||||
function setCookie(name,value,days) {
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||
var expires = "; expires="+date.toGMTString();
|
||||
}
|
||||
else var expires = "";
|
||||
document.cookie = name+"="+value+expires+"; path=/";
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a cookie with the provided name
|
||||
*/
|
||||
function readCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(";");
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==" ") c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase a cookie
|
||||
*/
|
||||
function eraseCookie(name) {
|
||||
createCookie(name,"",-1);
|
||||
}
|
23
www/js/theme.js
Normal file
23
www/js/theme.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
(function () {
|
||||
var c = document.cookie.split(";").map(function (s) {
|
||||
return s.trim();
|
||||
});
|
||||
|
||||
var theme = "default";
|
||||
for (var i = 0; i < c.length; i++) {
|
||||
if (c[i].indexOf("cytube-theme=") === 0) {
|
||||
theme = c[i].split("=")[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (theme !== "default") {
|
||||
var cur = document.getElementById("usertheme");
|
||||
cur.parentNode.removeChild(cur);
|
||||
var css = document.createElement("link");
|
||||
css.setAttribute("rel", "stylesheet");
|
||||
css.setAttribute("type", "text/css");
|
||||
css.setAttribute("href", theme);
|
||||
document.head.appendChild(css);
|
||||
}
|
||||
})();
|
Loading…
Reference in a new issue