diff --git a/channel.js b/channel.js index a975aeb9..1e382056 100644 --- a/channel.js +++ b/channel.js @@ -965,7 +965,7 @@ Channel.prototype.broadcastChatFilters = function() { Channel.prototype.broadcastVoteskipUpdate = function() { var amt = this.voteskip ? this.voteskip.counts[0] : 0; var count = this.users.length - this.afkers.length; - var need = this.voteskip ? parseInt(count * this.opts.voteskip_ratio) : 0; + var need = this.voteskip ? Math.ceil(count * this.opts.voteskip_ratio) : 0; for(var i = 0; i < this.users.length; i++) { if(Rank.hasPermission(this.users[i], "seeVoteskip") || this.leader == this.users[i]) { @@ -1563,7 +1563,7 @@ Channel.prototype.checkVoteskipPass = function () { return false; var count = this.users.length - this.afkers.length; - var need = parseInt(count * this.opts.voteskip_ratio); + var need = Math.ceil(count * this.opts.voteskip_ratio); if(this.server.cfg["debug"]) { console.log("afkers=", this.afkers.length); console.log("users =", this.users.length); diff --git a/package.json b/package.json index 2d5703dc..0aaf3ede 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "2.2.2", + "version": "2.2.3", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index 5ba38b12..34dffed7 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ var Logger = require("./logger"); var Channel = require("./channel"); var User = require("./user"); -const VERSION = "2.2.2"; +const VERSION = "2.2.3"; function getIP(req) { var raw = req.connection.remoteAddress; diff --git a/user.js b/user.js index ba946344..47d2c225 100644 --- a/user.js +++ b/user.js @@ -83,7 +83,8 @@ User.prototype.noflood = function(name, hz) { User.prototype.setAFK = function (afk) { if(this.channel === null) return; - var changed = this.meta.afk != afk; + if(this.meta.afk === afk) + return; var chan = this.channel; this.meta.afk = afk; if(afk) { @@ -96,7 +97,10 @@ User.prototype.setAFK = function (afk) { this.autoAFK(); } chan.checkVoteskipPass(); - chan.broadcastUserUpdate(this); + chan.sendAll("setAFK", { + name: this.name, + afk: afk + }); } User.prototype.autoAFK = function () { @@ -113,6 +117,7 @@ User.prototype.autoAFK = function () { User.prototype.initCallbacks = function() { this.socket.on("disconnect", function() { + this.awaytimer && clearTimeout(this.awaytimer); if(this.channel != null) this.channel.userLeave(this); }.bind(this)); diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index ee64c7bb..f5ae5fc2 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -660,6 +660,24 @@ Callbacks = { }, + setAFK: function (data) { + var users = $("#userlist").children(); + for(var i = 0; i < users.length; i++) { + var name = users[i].children[1].innerHTML; + // Reformat user + if(name == data.name) { + var u = $(users[i]); + u.find(".icon-time").remove(); + $(users[i].children[1]).css("font-style", ""); + if(data.afk) { + $("").addClass("icon-time") + .appendTo(users[i].children[0]); + $(users[i].children[1]).css("font-style", ""); + } + } + } + }, + userLeave: function(data) { var users = $("#userlist").children(); for(var i = 0; i < users.length; i++) { diff --git a/www/assets/js/paginator.js b/www/assets/js/paginator.js index 3b862ed4..efaa6ad6 100644 --- a/www/assets/js/paginator.js +++ b/www/assets/js/paginator.js @@ -26,8 +26,8 @@ return; var ul = $("