From 5f5049db12477fdc70aac1340e55a652d57e54a2 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 24 Mar 2013 12:23:48 -0500 Subject: [PATCH] Change quotes to be consistent Fixes Issue#11 --- auth.js | 10 +- channel.js | 148 ++++++++++---------- chatcommand.js | 12 +- config.js | 8 +- database.js | 4 +- get-info.js | 26 ++-- server.js | 16 +-- user.js | 98 ++++++------- www/assets/js/acp.js | 64 ++++----- www/assets/js/callbacks.js | 196 +++++++++++++------------- www/assets/js/client.js | 194 +++++++++++++------------- www/assets/js/functions.js | 278 ++++++++++++++++++------------------- 12 files changed, 527 insertions(+), 527 deletions(-) diff --git a/auth.js b/auth.js index 6ad120b7..a3cef709 100644 --- a/auth.js +++ b/auth.js @@ -9,8 +9,8 @@ The above copyright notice and this permission notice shall be included in all c 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 mysql = require('mysql-libmysqlclient'); -var Config = require('./config.js'); +var mysql = require("mysql-libmysqlclient"); +var Config = require("./config.js"); // Check if a name is taken exports.isRegistered = function(name) { @@ -21,7 +21,7 @@ exports.isRegistered = function(name) { console.log("MySQL Connection Failed"); return true; } - var query = 'SELECT * FROM registrations WHERE uname="{}"' + var query = "SELECT * FROM registrations WHERE uname='{}'" .replace(/\{\}/, name); var results = db.querySync(query); var rows = results.fetchAllSync(); @@ -51,7 +51,7 @@ exports.register = function(name, sha256) { console.log("MySQL Connection Failed"); return false; } - var query = 'INSERT INTO registrations VALUES (NULL, "{1}", "{2}", 0)' + var query = "INSERT INTO registrations VALUES (NULL, '{1}', '{2}', 0)" .replace(/\{1\}/, name) .replace(/\{2\}/, sha256); var results = db.querySync(query); @@ -68,7 +68,7 @@ exports.login = function(name, sha256) { console.log("MySQL Connection Failed"); return false; } - var query = 'SELECT * FROM registrations WHERE uname="{1}" AND pw="{2}"' + var query = "SELECT * FROM registrations WHERE uname='{1}' AND pw='{2}'" .replace(/\{1\}/, name) .replace(/\{2\}/, sha256); var results = db.querySync(query); diff --git a/channel.js b/channel.js index 058b20be..0511eafc 100644 --- a/channel.js +++ b/channel.js @@ -9,14 +9,14 @@ The above copyright notice and this permission notice shall be included in all c 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 mysql = require('mysql-libmysqlclient'); -var Config = require('./config.js'); -var Rank = require('./rank.js'); +var mysql = require("mysql-libmysqlclient"); +var Config = require("./config.js"); +var Rank = require("./rank.js"); // I should use the er naming scheme more often -var InfoGetter = require('./get-info.js'); -var Media = require('./media.js').Media; -var ChatCommand = require('./chatcommand.js'); -var Server = require('./server.js'); +var InfoGetter = require("./get-info.js"); +var Media = require("./media.js").Media; +var ChatCommand = require("./chatcommand.js"); +var Server = require("./server.js"); var io = Server.io; var Channel = function(name) { @@ -63,7 +63,7 @@ Channel.prototype.loadMysql = function() { return false; } // Check if channel exists - var query = 'SELECT * FROM channels WHERE name="{}"' + var query = "SELECT * FROM channels WHERE name='{}'" .replace(/\{\}/, this.name); var results = db.querySync(query); if(!results) { @@ -78,7 +78,7 @@ Channel.prototype.loadMysql = function() { this.registered = true; // Load library - var query = 'SELECT * FROM chan_{}_library' + var query = "SELECT * FROM chan_{}_library" .replace(/\{\}/, this.name); var results = db.querySync(query); if(!results) { @@ -91,7 +91,7 @@ Channel.prototype.loadMysql = function() { } // Load bans - var query = 'SELECT * FROM chan_{}_bans' + var query = "SELECT * FROM chan_{}_bans" .replace(/\{\}/, this.name); var results = db.querySync(query); if(!results) { @@ -153,7 +153,7 @@ Channel.prototype.createTables = function() { results = db.querySync(query) || results; // Insert into global channel table - var query = 'INSERT INTO channels (`id`, `name`) VALUES (NULL, "{}")' + var query = "INSERT INTO channels (`id`, `name`) VALUES (NULL, '{}')" .replace(/\{\}/, this.name); results = db.querySync(query) || results; db.closeSync(); @@ -162,20 +162,20 @@ Channel.prototype.createTables = function() { Channel.prototype.tryRegister = function(user) { if(this.registered) { - user.socket.emit('registerChannel', { + user.socket.emit("registerChannel", { success: false, error: "This channel is already registered" }); } else if(!user.loggedIn) { - user.socket.emit('registerChannel', { + user.socket.emit("registerChannel", { success: false, error: "You must log in to register a channel" }); } else if(!Rank.hasPermission(user, "registerChannel")) { - user.socket.emit('registerChannel', { + user.socket.emit("registerChannel", { success: false, error: "You don't have permission to register this channel" }); @@ -184,12 +184,12 @@ Channel.prototype.tryRegister = function(user) { if(this.createTables()) { this.registered = true; this.saveRank(user); - user.socket.emit('registerChannel', { + user.socket.emit("registerChannel", { success: true, }); } else { - user.socket.emit('registerChannel', { + user.socket.emit("registerChannel", { success: false, error: "Unable to register channel, see an admin" }); @@ -197,7 +197,7 @@ Channel.prototype.tryRegister = function(user) { } } -// Retrieves a user's rank from the database +// Retrieves a user"s rank from the database Channel.prototype.getRank = function(name) { if(!this.registered) return Rank.Guest; @@ -208,7 +208,7 @@ Channel.prototype.getRank = function(name) { console.log("MySQL Connection Failed"); return Rank.Guest; } - var query = 'SELECT * FROM chan_{1}_ranks WHERE name="{2}"' + var query = "SELECT * FROM chan_{1}_ranks WHERE name='{2}'" .replace(/\{1\}/, this.name) .replace(/\{2\}/, name); var results = db.querySync(query); @@ -223,7 +223,7 @@ Channel.prototype.getRank = function(name) { return rows[0].rank; } -// Saves a user's rank to the database +// Saves a user"s rank to the database Channel.prototype.saveRank = function(user) { if(!this.registered) return false; @@ -234,14 +234,14 @@ Channel.prototype.saveRank = function(user) { console.log("MySQL Connection Failed"); return false; } - var query = 'UPDATE chan_{1}_ranks SET rank="{2}" WHERE name="{3}"' + var query = "UPDATE chan_{1}_ranks SET rank='{2}' WHERE name='{3}'" .replace(/\{1\}/, this.name) .replace(/\{2\}/, user.rank) .replace(/\{3\}/, user.name); var results = db.querySync(query); // Gonna have to insert a new one, bugger if(!results.fetchAllSync) { - var query = 'INSERT INTO chan_{1}_ranks (`name`, `rank`) VALUES ("{2}", "{3}")' + var query = "INSERT INTO chan_{1}_ranks (`name`, `rank`) VALUES ('{2}', '{3}')" .replace(/\{1\}/, this.name) .replace(/\{2\}/, user.name) .replace(/\{3\}/, user.rank); @@ -264,7 +264,7 @@ Channel.prototype.addToLibrary = function(media) { console.log("MySQL Connection Failed"); return false; } - var query = 'INSERT INTO chan_{1}_library VALUES ("{2}", "{3}", {4}, "{5}", "{6}")' + var query = "INSERT INTO chan_{1}_library VALUES ('{2}', '{3}', {4}, '{5}', '{6}')" .replace(/\{1\}/, this.name) .replace(/\{2\}/, media.id) .replace(/\{3\}/, media.title) @@ -290,7 +290,7 @@ Channel.prototype.banIP = function(banner, bannee) { console.log("MySQL Connection Failed"); return false; } - var query = 'INSERT INTO chan_{1}_bans (`ip`, `name`, `banner`) VALUES ("{2}", "{3}", "{4}")' + var query = "INSERT INTO chan_{1}_bans (`ip`, `name`, `banner`) VALUES ('{2}', '{3}', '{4}')" .replace(/\{1\}/, this.name) .replace(/\{2\}/, bannee.ip) .replace(/\{3\}/, bannee.name) @@ -317,7 +317,7 @@ Channel.prototype.unbanIP = function(ip) { return false; } - var query = 'DELETE FROM chan_{1}_bans WHERE `ip` = "{2}"' + var query = "DELETE FROM chan_{1}_bans WHERE `ip` = '{2}'" .replace(/\{1\}/, this.name) .replace(/\{2\}/, ip); @@ -363,18 +363,18 @@ Channel.prototype.userJoin = function(user) { if(this.users[i].name == user.name) { user.name = ""; user.loggedIn = false; - user.socket.emit('login', { + user.socket.emit("login", { success: false, error: "The username " + user.name + " is already in use on this channel" }); } } } - // If the channel is empty and isn't registered, the first person + // If the channel is empty and isn"t registered, the first person // gets ownership of the channel (temporarily) if(this.users.length == 0 && !this.registered) { user.rank = (user.rank < Rank.Owner) ? Rank.Owner + 7 : user.rank; - user.socket.emit('channelNotRegistered'); + user.socket.emit("channelNotRegistered"); } this.users.push(user); if(user.name != "") { @@ -383,13 +383,13 @@ Channel.prototype.userJoin = function(user) { this.updateUsercount(); // Set the new guy up this.sendPlaylist(user); - user.socket.emit('queueLock', {locked: this.qlocked}); + user.socket.emit("queueLock", {locked: this.qlocked}); this.sendUserlist(user); this.sendRecentChat(user); if(this.poll) { - user.socket.emit('newPoll', this.poll.packUpdate()); + user.socket.emit("newPoll", this.poll.packUpdate()); } - user.socket.emit('channelOpts', this.opts); + user.socket.emit("channelOpts", this.opts); var ents = []; for(var ip in this.ipbans) { if(this.ipbans[ip] != null) { @@ -400,7 +400,7 @@ Channel.prototype.userJoin = function(user) { }); } } - user.socket.emit('banlist', {entries: ents}); + user.socket.emit("banlist", {entries: ents}); if(user.playerReady) this.sendMediaUpdate(user); console.log("/" + user.ip + " joined channel " + this.name); @@ -424,7 +424,7 @@ Channel.prototype.userLeave = function(user) { this.users.splice(idx, 1); this.updateUsercount(); if(user.name != "") { - this.sendAll('userLeave', { + this.sendAll("userLeave", { name: user.name }); } @@ -436,7 +436,7 @@ Channel.prototype.enqueue = function(data) { // Try to look up cached metadata first if(data.id in this.library) { this.queue.splice(idx, 0, this.library[data.id]); - this.sendAll('queue', { + this.sendAll("queue", { media: this.library[data.id].pack(), pos: idx }); @@ -451,11 +451,11 @@ Channel.prototype.enqueue = function(data) { try { // Whoever decided on this variable name should be fired var seconds = data.entry.media$group.yt$duration.seconds; - // This one's slightly better + // This one"s slightly better var title = data.entry.title.$t; var vid = new Media(id, title, seconds, "yt"); chan.queue.splice(idx, 0, vid); - chan.sendAll('queue', { + chan.sendAll("queue", { media: vid.pack(), pos: idx }); @@ -471,7 +471,7 @@ Channel.prototype.enqueue = function(data) { else if(data.type == "tw") { var media = new Media(data.id, "Twitch ~ " + data.id, 0, "tw"); this.queue.splice(idx, 0, media); - this.sendAll('queue', { + this.sendAll("queue", { media: media.pack(), pos: idx }); @@ -479,7 +479,7 @@ Channel.prototype.enqueue = function(data) { else if(data.type == "li") { var media = new Media(data.id, "Livestream ~ " + data.id, 0, "li"); this.queue.splice(idx, 0, media); - this.sendAll('queue', { + this.sendAll("queue", { media: media.pack(), pos: idx }); @@ -495,7 +495,7 @@ Channel.prototype.enqueue = function(data) { var title = data.title; var vid = new Media(id, title, seconds, "sc"); chan.queue.splice(idx, 0, vid); - chan.sendAll('queue', { + chan.sendAll("queue", { media: vid.pack(), pos: idx }); @@ -515,7 +515,7 @@ Channel.prototype.enqueue = function(data) { var title = data.title; var vid = new Media(id, title, seconds, "vi"); chan.queue.splice(idx, 0, vid); - chan.sendAll('queue', { + chan.sendAll("queue", { media: vid.pack(), pos: idx }); @@ -535,7 +535,7 @@ Channel.prototype.enqueue = function(data) { var title = data.title; var vid = new Media(id, title, seconds, "dm"); chan.queue.splice(idx, 0, vid); - chan.sendAll('queue', { + chan.sendAll("queue", { media: vid.pack(), pos: idx }); @@ -552,13 +552,13 @@ Channel.prototype.unqueue = function(data) { return; this.queue.splice(data.pos, 1); - this.sendAll('unqueue', { + this.sendAll("unqueue", { pos: data.pos }); if(data.pos < this.currentPosition) { this.currentPosition--; - this.sendAll('updatePlaylistIdx', { + this.sendAll("updatePlaylistIdx", { idx: this.currentPosition }); } @@ -579,8 +579,8 @@ Channel.prototype.playNext = function() { this.currentMedia = this.queue[this.currentPosition]; this.currentMedia.currentTime = 0; - this.sendAll('mediaUpdate', this.currentMedia.packupdate()); - this.sendAll('updatePlaylistIdx', { + this.sendAll("mediaUpdate", this.currentMedia.packupdate()); + this.sendAll("updatePlaylistIdx", { idx: this.currentPosition }); // Enable autolead for non-twitch @@ -592,7 +592,7 @@ Channel.prototype.playNext = function() { Channel.prototype.setLock = function(locked) { this.qlocked = locked; - this.sendAll('queueLock', {locked: locked}); + this.sendAll("queueLock", {locked: locked}); for(var i = 0; i < this.users.length; i++) { this.sendPlaylist(this.users[i]); } @@ -606,7 +606,7 @@ Channel.prototype.update = function(data) { } else this.currentMedia.currentTime = data.seconds; - this.sendAll('mediaUpdate', this.currentMedia.packupdate()); + this.sendAll("mediaUpdate", this.currentMedia.packupdate()); } // Move something around in the queue @@ -619,7 +619,7 @@ Channel.prototype.moveMedia = function(data) { var media = this.queue[data.src]; this.queue.splice(data.src, 1); this.queue.splice(data.dest, 0, media); - this.sendAll('moveVideo', { + this.sendAll("moveVideo", { src: data.src, dest: data.dest }); @@ -645,11 +645,11 @@ Channel.prototype.chatMessage = function(user, msg) { } Channel.prototype.sendMessage = function(username, msg, msgclass) { - // I don't want HTML from strangers + // I don"t want HTML from strangers msg = msg.replace(//g, ">"); // Match URLs msg = msg.replace(/(((https?)|(ftp))(:\/\/[0-9a-zA-Z\.]+(:[0-9]+)?[^\s$]+))/, "$1"); - this.sendAll('chatMsg', { + this.sendAll("chatMsg", { username: username, msg: msg, msgclass: msgclass @@ -676,8 +676,8 @@ Channel.prototype.promoteUser = function(actor, name) { if(receiver) { // You can only promote someone if you are 2 ranks or higher above - // them. This way you can't promote them to your rank and end - // up in a situation where you can't demote them + // them. This way you can"t promote them to your rank and end + // up in a situation where you can"t demote them if(actor.rank > receiver.rank + 1) { receiver.rank++; if(receiver.loggedIn) { @@ -688,7 +688,7 @@ Channel.prototype.promoteUser = function(actor, name) { } } -// You're fired +// You"re fired Channel.prototype.demoteUser = function(actor, name) { var receiver; for(var i = 0; i < this.users.length; i++) { @@ -699,8 +699,8 @@ Channel.prototype.demoteUser = function(actor, name) { } if(receiver) { - // Wouldn't it be funny if you could demote people who rank higher - // than you? No, it wouldn't. + // Wouldn"t it be funny if you could demote people who rank higher + // than you? No, it wouldn"t. if(actor.rank > receiver.rank) { receiver.rank--; if(receiver.loggedIn) { @@ -711,7 +711,7 @@ Channel.prototype.demoteUser = function(actor, name) { } } -// Manual leader. This shouldn't be necessary since the server autoleads, +// Manual leader. This shouldn"t be necessary since the server autoleads, // but you never know Channel.prototype.changeLeader = function(name) { if(this.leader != null) { @@ -736,11 +736,11 @@ Channel.prototype.changeLeader = function(name) { } // Send the userlist to a client -// Do you know you're all my very best friends? +// Do you know you"re all my very best friends? Channel.prototype.sendUserlist = function(user) { var users = []; for(var i = 0; i < this.users.length; i++) { - // Skip people who haven't logged in + // Skip people who haven"t logged in if(this.users[i].name != "") { users.push({ name: this.users[i].name, @@ -749,21 +749,21 @@ Channel.prototype.sendUserlist = function(user) { }); } } - user.socket.emit('userlist', users) + user.socket.emit("userlist", users) } Channel.prototype.updateUsercount = function() { - this.sendAll('usercount', { + this.sendAll("usercount", { count: this.users.length }); } // Send the play queue Channel.prototype.sendPlaylist = function(user) { - user.socket.emit('playlist', { + user.socket.emit("playlist", { pl: this.queue }); - user.socket.emit('updatePlaylistIdx', { + user.socket.emit("updatePlaylistIdx", { idx: this.currentPosition }); } @@ -771,32 +771,32 @@ Channel.prototype.sendPlaylist = function(user) { // Send the last 15 messages for context Channel.prototype.sendRecentChat = function(user) { for(var i = 0; i < this.recentChat.length; i++) { - user.socket.emit('chatMsg', this.recentChat[i]); + user.socket.emit("chatMsg", this.recentChat[i]); } } // Send a sync packet Channel.prototype.sendMediaUpdate = function(user) { if(this.currentMedia != null) { - user.socket.emit('mediaUpdate', this.currentMedia.packupdate()); + user.socket.emit("mediaUpdate", this.currentMedia.packupdate()); } else { - console.log('currentMedia is null'); + console.log("currentMedia is null"); } } // Sent when someone logs in, to add them to the user list Channel.prototype.broadcastNewUser = function(user) { - this.sendAll('addUser', { + this.sendAll("addUser", { name: user.name, rank: user.rank, leader: this.leader == user }); } -// Someone's rank changed, or their leadership status changed +// Someone"s rank changed, or their leadership status changed Channel.prototype.broadcastRankUpdate = function(user) { - this.sendAll('updateUser', { + this.sendAll("updateUser", { name: user.name, rank: user.rank, leader: this.leader == user @@ -804,19 +804,19 @@ Channel.prototype.broadcastRankUpdate = function(user) { } Channel.prototype.broadcastPoll = function() { - this.sendAll('newPoll', this.poll.packUpdate()); + this.sendAll("newPoll", this.poll.packUpdate()); } Channel.prototype.broadcastPollUpdate = function() { - this.sendAll('updatePoll', this.poll.packUpdate()); + this.sendAll("updatePoll", this.poll.packUpdate()); } Channel.prototype.broadcastPollClose = function() { - this.sendAll('closePoll'); + this.sendAll("closePoll"); } Channel.prototype.broadcastOpts = function() { - this.sendAll('channelOpts', this.opts); + this.sendAll("channelOpts", this.opts); } Channel.prototype.broadcastIpbans = function() { @@ -830,7 +830,7 @@ Channel.prototype.broadcastIpbans = function() { }); } } - this.sendAll('banlist', {entries: ents}); + this.sendAll("banlist", {entries: ents}); } // Send to ALL the clients! @@ -840,7 +840,7 @@ Channel.prototype.sendAll = function(message, data) { // Autolead yay function channelVideoUpdate(chan, id) { - // Someone changed the video or there's a manual leader, so your + // Someone changed the video or there"s a manual leader, so your // argument is invalid if(chan.currentMedia == null || id != chan.currentMedia.id || chan.leader != null) return; @@ -853,7 +853,7 @@ function channelVideoUpdate(chan, id) { } // Every ~5 seconds send a sync packet to everyone else if(chan.i % 5 == 0) - chan.sendAll('mediaUpdate', chan.currentMedia.packupdate()); + chan.sendAll("mediaUpdate", chan.currentMedia.packupdate()); chan.i++; // Do it all over again in about a second setTimeout(function() { channelVideoUpdate(chan, id); }, 1000); diff --git a/chatcommand.js b/chatcommand.js index bca3cbfb..342aa73e 100644 --- a/chatcommand.js +++ b/chatcommand.js @@ -9,8 +9,8 @@ The above copyright notice and this permission notice shall be included in all c 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 Rank = require('./rank.js'); -var Poll = require('./poll.js').Poll; +var Rank = require("./rank.js"); +var Poll = require("./poll.js").Poll; function handle(chan, user, msg) { if(msg.indexOf("/me ") == 0) @@ -23,13 +23,13 @@ function handle(chan, user, msg) { } } else if(msg.indexOf("/kick ") == 0) { - handleKick(chan, user, msg.substring(6).split(' ')); + handleKick(chan, user, msg.substring(6).split(" ")); } else if(msg.indexOf("/ban ") == 0) { - handleBan(chan, user, msg.substring(5).split(' ')); + handleBan(chan, user, msg.substring(5).split(" ")); } else if(msg.indexOf("/unban ") == 0) { - handleUnban(chan, user, msg.substring(7).split(' ')); + handleUnban(chan, user, msg.substring(7).split(" ")); } else if(msg.indexOf("/poll ") == 0) { handlePoll(chan, user, msg.substring(6)); @@ -74,7 +74,7 @@ function handleUnban(chan, user, args) { function handlePoll(chan, user, msg) { if(Rank.hasPermission(user, "poll")) { - var args = msg.split(','); + var args = msg.split(","); var title = args[0]; args.splice(0, 1); var poll = new Poll(user.name, title, args); diff --git a/config.js b/config.js index 75d744cb..ecff86c0 100644 --- a/config.js +++ b/config.js @@ -9,8 +9,8 @@ The above copyright notice and this permission notice shall be included in all c 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. */ -exports.MYSQL_SERVER = ''; -exports.MYSQL_DB = ''; -exports.MYSQL_USER = ''; -exports.MYSQL_PASSWORD = ''; +exports.MYSQL_SERVER = ""; +exports.MYSQL_DB = ""; +exports.MYSQL_USER = ""; +exports.MYSQL_PASSWORD = ""; exports.IO_PORT = 1337; diff --git a/database.js b/database.js index 09cde31e..02dd0c86 100644 --- a/database.js +++ b/database.js @@ -9,8 +9,8 @@ The above copyright notice and this permission notice shall be included in all c 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 mysql = require('mysql-libmysqlclient'); -var Config = require('./config.js'); +var mysql = require("mysql-libmysqlclient"); +var Config = require("./config.js"); var initialized = false; diff --git a/get-info.js b/get-info.js index 74132839..00cb2240 100644 --- a/get-info.js +++ b/get-info.js @@ -9,19 +9,19 @@ The above copyright notice and this permission notice shall be included in all c 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 http = require('http'); -var https = require('https'); +var http = require("http"); +var https = require("https"); // Helper function for making an HTTP request and getting the result // as JSON function getJSON(options, callback) { var req = http.request(options, function(res){ - var buffer = ''; - res.setEncoding('utf8'); - res.on('data', function (chunk) { + var buffer = ""; + res.setEncoding("utf8"); + res.on("data", function (chunk) { buffer += chunk; }); - res.on('end', function() { + res.on("end", function() { try { var data = JSON.parse(buffer); } @@ -39,12 +39,12 @@ function getJSON(options, callback) { // Dailymotion uses HTTPS for anonymous requests... [](/picard) function getJSONHTTPS(options, callback) { var req = https.request(options, function(res){ - var buffer = ''; - res.setEncoding('utf8'); - res.on('data', function (chunk) { + var buffer = ""; + res.setEncoding("utf8"); + res.on("data", function (chunk) { buffer += chunk; }); - res.on('end', function() { + res.on("end", function() { try { var data = JSON.parse(buffer); } @@ -72,13 +72,13 @@ exports.getYTInfo = function(id, callback) { } // Look up Soundcloud metadata -// Whoever designed this should rethink it. I'll submit a feedback +// Whoever designed this should rethink it. I"ll submit a feedback // form on their website. exports.getSCInfo = function(url, callback) { - const SC_CLIENT = '2e0c82ab5a020f3a7509318146128abd'; + const SC_CLIENT = "2e0c82ab5a020f3a7509318146128abd"; // SoundCloud is dumb // I have to request the API URL for the given input URL - // Because the sound ID isn't in the URL + // Because the sound ID isn"t in the URL getJSON({ host: "api.soundcloud.com", port: 80, diff --git a/server.js b/server.js index a07d737a..2528b4d8 100644 --- a/server.js +++ b/server.js @@ -9,17 +9,17 @@ The above copyright notice and this permission notice shall be included in all c 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 Config = require('./config.js'); -var connect = require('connect'); -var app = connect.createServer(connect.static(__dirname+'/www')).listen(Config.IO_PORT); -exports.io = require('socket.io').listen(app); -var User = require('./user.js').User; -var Database = require('./database.js'); +var Config = require("./config.js"); +var connect = require("connect"); +var app = connect.createServer(connect.static(__dirname+"/www")).listen(Config.IO_PORT); +exports.io = require("socket.io").listen(app); +var User = require("./user.js").User; +var Database = require("./database.js"); Database.init(); exports.channels = {}; -exports.io.sockets.on('connection', function(socket) { +exports.io.sockets.on("connection", function(socket) { var user = new User(socket, socket.handshake.address.address); - console.log('New connection from /' + user.ip); + console.log("New connection from /" + user.ip); }); diff --git a/user.js b/user.js index 7e5fe83f..92e9d2f8 100644 --- a/user.js +++ b/user.js @@ -9,11 +9,11 @@ The above copyright notice and this permission notice shall be included in all c 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 Rank = require('./rank.js'); -var Auth = require('./auth.js'); -var Channel = require('./channel.js').Channel; -var Server = require('./server.js'); -var Database = require('./database.js'); +var Rank = require("./rank.js"); +var Auth = require("./auth.js"); +var Channel = require("./channel.js").Channel; +var Server = require("./server.js"); +var Database = require("./database.js"); // Represents a client connected via socket.io var User = function(socket, ip) { @@ -27,7 +27,7 @@ var User = function(socket, ip) { this.initCallbacks(); if(Server.announcement != null) { - this.socket.emit('announcement', Server.announcement); + this.socket.emit("announcement", Server.announcement); } }; @@ -35,12 +35,12 @@ var User = function(socket, ip) { // Set up socket callbacks User.prototype.initCallbacks = function() { // What a shame - this.socket.on('disconnect', function() { + this.socket.on("disconnect", function() { if(this.channel != null) this.channel.userLeave(this); }.bind(this)); - this.socket.on('joinChannel', function(data) { + this.socket.on("joinChannel", function(data) { if(!data.name.match(/^[a-zA-Z0-9]+$/)) return; // Channel already loaded @@ -56,23 +56,23 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('login', function(data) { + this.socket.on("login", function(data) { if(this.name == "") this.login(data.name, data.sha256); }.bind(this)); - this.socket.on('register', function(data) { + this.socket.on("register", function(data) { this.register(data.name, data.sha256); }.bind(this)); - this.socket.on('assignLeader', function(data) { + this.socket.on("assignLeader", function(data) { if(Rank.hasPermission(this, "assignLeader")) { if(this.channel != null) this.channel.changeLeader(data.name); } }.bind(this)); - this.socket.on('promote', function(data) { + this.socket.on("promote", function(data) { if(Rank.hasPermission(this, "promote")) { if(this.channel != null) { this.channel.promoteUser(this, data.name); @@ -80,7 +80,7 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('demote', function(data) { + this.socket.on("demote", function(data) { if(Rank.hasPermission(this, "promote")) { if(this.channel != null) { this.channel.demoteUser(this, data.name); @@ -88,20 +88,20 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('chatMsg', function(data) { + this.socket.on("chatMsg", function(data) { if(this.name != "" && this.channel != null) { this.channel.chatMessage(this, data.msg); } }.bind(this)); - this.socket.on('playerReady', function() { + this.socket.on("playerReady", function() { if(this.channel != null) { this.channel.sendMediaUpdate(this); } this.playerReady = true; }.bind(this)); - this.socket.on('queue', function(data) { + this.socket.on("queue", function(data) { if(this.channel == null) return; if(Rank.hasPermission(this, "queue") || @@ -116,7 +116,7 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('unqueue', function(data) { + this.socket.on("unqueue", function(data) { if(this.channel == null) return; if(Rank.hasPermission(this, "queue") || @@ -126,7 +126,7 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('moveMedia', function(data) { + this.socket.on("moveMedia", function(data) { if(this.channel == null) return; if(Rank.hasPermission(this, "queue") || @@ -136,7 +136,7 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('playNext', function() { + this.socket.on("playNext", function() { if(this.channel == null) return; if(Rank.hasPermission(this, "queue") || @@ -149,7 +149,7 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('queueLock', function(data) { + this.socket.on("queueLock", function(data) { if(Rank.hasPermission(this, "qlock")) { if(this.channel != null) { this.channel.setLock(data.locked); @@ -157,21 +157,21 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('mediaUpdate', function(data) { + this.socket.on("mediaUpdate", function(data) { if(this.channel != null && this.channel.leader == this) { this.channel.update(data); } }.bind(this)); - this.socket.on('searchLibrary', function(data) { + this.socket.on("searchLibrary", function(data) { if(this.channel != null && Rank.hasPermission(this, "search")) { - this.socket.emit('librarySearchResults', { + this.socket.emit("librarySearchResults", { results: this.channel.searchLibrary(data.query) }); } }.bind(this)); - this.socket.on('closePoll', function() { + this.socket.on("closePoll", function() { if(Rank.hasPermission(this, "poll")) { if(this.channel != null && this.channel.poll) { this.channel.poll = null; @@ -180,16 +180,16 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('vote', function(data) { + this.socket.on("vote", function(data) { if(this.channel != null && this.channel.poll) { this.channel.poll.vote(this.ip, data.option); this.channel.broadcastPollUpdate(); } }.bind(this)); - this.socket.on('registerChannel', function(data) { + this.socket.on("registerChannel", function(data) { if(this.channel == null) { - this.socket.emit('channelRegistration', { + this.socket.emit("channelRegistration", { success: false, error: "You're not in any channel!" }); @@ -199,25 +199,25 @@ User.prototype.initCallbacks = function() { } }.bind(this)); - this.socket.on('adm', function(data) { + this.socket.on("adm", function(data) { if(Rank.hasPermission(this, "acp")) { this.handleAdm(data); } }.bind(this)); - this.socket.on('announce', function(data) { + this.socket.on("announce", function(data) { if(Rank.hasPermission(this, "announce")) { if(data.clear) { Server.announcement = null; } else { - Server.io.sockets.emit('announcement', data); + Server.io.sockets.emit("announcement", data); Server.announcement = data; } } }.bind(this)); - this.socket.on('channelOpts', function(data) { + this.socket.on("channelOpts", function(data) { if(Rank.hasPermission(this, "channelOpts") && this.channel != null) { this.channel.opts = data; this.channel.broadcastOpts(); @@ -239,7 +239,7 @@ User.prototype.handleAdm = function(data) { nowplaying: nowplaying }); } - this.socket.emit('adm', { + this.socket.emit("adm", { cmd: "listchannels", chans: chans }); @@ -255,7 +255,7 @@ User.prototype.handleAdm = function(data) { rank: dbusers[i].global_rank }; } - this.socket.emit('adm', { + this.socket.emit("adm", { cmd: "listusers", users: users }); @@ -263,7 +263,7 @@ User.prototype.handleAdm = function(data) { else if(data.cmd == "listchannelranks") { if(data.chan == undefined) return; - this.socket.emit('adm', { + this.socket.emit("adm", { cmd: "listchannelranks", ranks: Database.listChannelRanks(data.chan) }); @@ -276,7 +276,7 @@ User.prototype.login = function(name, sha256) { if(this.channel != null && name != "") { for(var i = 0; i < this.channel.users.length; i++) { if(this.channel.users[i].name == name) { - this.socket.emit('login', { + this.socket.emit("login", { success: false, error: "The username " + name + " is already in use on this channel" }); @@ -286,9 +286,9 @@ User.prototype.login = function(name, sha256) { } // No password => try guest login if(sha256 == "") { - // Sorry bud, can't take that name + // Sorry bud, can"t take that name if(Auth.isRegistered(name)) { - this.socket.emit('login', { + this.socket.emit("login", { success: false, error: "That username is already taken" }); @@ -296,7 +296,7 @@ User.prototype.login = function(name, sha256) { } // YOUR ARGUMENT IS INVALID else if(!Auth.validateName(name)) { - this.socket.emit('login', { + this.socket.emit("login", { success: false, error: "Invalid username. Usernames must be 1-20 characters long and consist only of alphanumeric characters and underscores" }); @@ -306,10 +306,10 @@ User.prototype.login = function(name, sha256) { console.log(this.ip + " signed in as " + name); this.name = name; this.loggedIn = false; - this.socket.emit('login', { + this.socket.emit("login", { success: true }); - this.socket.emit('rank', { + this.socket.emit("rank", { rank: this.rank }); if(this.channel != null) { @@ -323,17 +323,17 @@ User.prototype.login = function(name, sha256) { var row; if((row = Auth.login(name, sha256))) { this.loggedIn = true; - this.socket.emit('login', { + this.socket.emit("login", { success: true }); console.log(this.ip + " logged in as " + name); - // Sweet, let's look up our rank + // Sweet, let"s look up our rank var chanrank = (this.channel != null) ? this.channel.getRank(name) : Rank.Guest; var rank = (chanrank > row.global_rank) ? chanrank : row.global_rank; this.rank = (this.rank > rank) ? this.rank : rank; - this.socket.emit('rank', { + this.socket.emit("rank", { rank: this.rank }); this.name = name; @@ -345,7 +345,7 @@ User.prototype.login = function(name, sha256) { } // Wrong password else { - this.socket.emit('login', { + this.socket.emit("login", { success: false, error: "Invalid username/password pair" }); @@ -358,34 +358,34 @@ User.prototype.login = function(name, sha256) { User.prototype.register = function(name, sha256) { if(sha256 == "") { // Sorry bud, password required - this.socket.emit('register', { + this.socket.emit("register", { success: false, error: "You must provide a password" }); return false; } else if(Auth.isRegistered(name)) { - this.socket.emit('register', { + this.socket.emit("register", { success: false, error: "That username is already taken" }); return false; } else if(!Auth.validateName(name)) { - this.socket.emit('register', { + this.socket.emit("register", { success: false, error: "Invalid username. Usernames must be 1-20 characters long and consist only of alphanumeric characters and underscores" }); } else if(Auth.register(name, sha256)) { console.log(this.ip + " registered " + name); - this.socket.emit('register', { + this.socket.emit("register", { success: true }); this.login(name, sha256); } else { - this.socket.emit('register', { + this.socket.emit("register", { success: false, error: "[](/ppshrug) Registration Failed." }); diff --git a/www/assets/js/acp.js b/www/assets/js/acp.js index 0a0f4948..b89d3b58 100644 --- a/www/assets/js/acp.js +++ b/www/assets/js/acp.js @@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ var RANK = 0; -var uname = readCookie('sync_uname'); -var pw = readCookie('sync_pw'); +var uname = readCookie("sync_uname"); +var pw = readCookie("sync_pw"); var manageChannel = false; var Rank = { @@ -27,44 +27,44 @@ initCallbacks(); function initCallbacks() { - socket.on('adm', function(data) { + socket.on("adm", function(data) { console.log(data); if(data.cmd == "listchannels") handleChannelList(data); }); - socket.on('login', function(data) { - if(data.success && $('#password').val()) { - createCookie('sync_uname', uname, 1); - createCookie('sync_pw', pw, 1); + socket.on("login", function(data) { + if(data.success && $("#password").val()) { + createCookie("sync_uname", uname, 1); + createCookie("sync_pw", pw, 1); } if(data.success) { - $('#loggedin').css('display', ''); - $('#logoutform').css('display', ''); - $('#loginform').css('display', 'none'); + $("#loggedin").css("display", ""); + $("#logoutform").css("display", ""); + $("#loginform").css("display", "none"); } - socket.emit('adm', { + socket.emit("adm", { cmd: "listchannels" }); }); } function handleChannelList(data) { - if($('#chanlist').children.length > 1) - $($('#chanlist').children()[1]).remove(); + if($("#chanlist").children.length > 1) + $($("#chanlist").children()[1]).remove(); for(var i = 0; i < data.chans.length; i++) { - var row = $('').appendTo($('#chanlist')); - var name = $('').appendTo(row).text(data.chans[i].name); - var usercount = $('').appendTo(row).text(data.chans[i].usercount); - var nowplaying = $('').appendTo(row).text(data.chans[i].nowplaying); + var row = $("").appendTo($("#chanlist")); + var name = $("").appendTo(row).text(data.chans[i].name); + var usercount = $("").appendTo(row).text(data.chans[i].usercount); + var nowplaying = $("").appendTo(row).text(data.chans[i].nowplaying); } } var params = {}; if(window.location.search) { - var parameters = window.location.search.substring(1).split('&'); + var parameters = window.location.search.substring(1).split("&"); for(var i = 0; i < parameters.length; i++) { - var s = parameters[i].split('='); + var s = parameters[i].split("="); if(s.length != 2) continue; params[s[0]] = s[1]; @@ -72,37 +72,37 @@ if(window.location.search) { } if(uname != null && pw != null && pw != "false") { - socket.emit('login', { + socket.emit("login", { name: uname, sha256: pw }); } function loginClick() { - uname = $('#username').val(); - if($('#password').val() == "") + uname = $("#username").val(); + if($("#password").val() == "") pw = ""; else - pw = SHA256($('#password').val()); - socket.emit('login', { + pw = SHA256($("#password").val()); + socket.emit("login", { name: uname, sha256: pw }); }; -$('#login').click(loginClick); -$('#username').keydown(function(ev) { +$("#login").click(loginClick); +$("#username").keydown(function(ev) { if(ev.key == 13) loginClick(); }); -$('#password').keydown(function(ev) { +$("#password").keydown(function(ev) { if(ev.key == 13) loginClick(); }); -$('#logout').click(function() { - eraseCookie('sync_uname'); - eraseCookie('sync_pw'); +$("#logout").click(function() { + eraseCookie("sync_uname"); + eraseCookie("sync_pw"); document.location.reload(true); }); @@ -119,10 +119,10 @@ function createCookie(name,value,days) { function readCookie(name) { var nameEQ = name + "="; - var ca = document.cookie.split(';'); + 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); + while (c.charAt(0)==" ") c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index f7ebf428..9a41e7c6 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -12,120 +12,120 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI // Wrapped in a function so I can ensure that the socket // is defined before these statements are run function initCallbacks() { - socket.on('disconnect', function() { - $('
').addClass('alert').addClass('alert-error') - .insertAfter($('.row')[0])[0] + socket.on("disconnect", function() { + $("
").addClass("alert").addClass("alert-error") + .insertAfter($(".row")[0])[0] .innerHTML = "

Disconnected from server

"; }); - socket.on('channelNotRegistered', function() { + socket.on("channelNotRegistered", function() { showChannelRegistration(); }); - socket.on('announcement', function(data) { + socket.on("announcement", function(data) { showAnnouncement(data.title, data.text); }); - socket.on('registerChannel', function(data) { + socket.on("registerChannel", function(data) { if(data.success) { - $('#chregnotice').remove(); + $("#chregnotice").remove(); } else { alert(data.error); } }); - socket.on('rank', function(data) { + socket.on("rank", function(data) { if(data.rank >= Rank.Moderator) { - $('#playlist_controls').css("display", "block"); - $('#playlist_controls button').each(function() { - $(this).attr('disabled', false); + $("#playlist_controls").css("display", "block"); + $("#playlist_controls button").each(function() { + $(this).attr("disabled", false); }); - $('#qlockbtn').css("display", "block"); - var poll = $('#pollcontainer .active'); + $("#qlockbtn").css("display", "block"); + var poll = $("#pollcontainer .active"); if(poll.length > 0) { - $('