mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
10 minutes chat history, limit of 20 messages
This commit is contained in:
@@ -89,8 +89,8 @@ var Chat = {
|
||||
return;
|
||||
},
|
||||
|
||||
allchat: function(inp) {
|
||||
if(inp.msg.substring(0,1) == ":" && !chat_active) {
|
||||
allchat: function(inp, time_sent, disable_blink) {
|
||||
if(inp.msg.substring(0,1) == ":" && !chat_active && !disable_blink) {
|
||||
Chat.all_received += 1;
|
||||
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
||||
unseen = true;
|
||||
@@ -123,6 +123,9 @@ var Chat = {
|
||||
color = Helper.hexToRgb(color.substring(0,6));
|
||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||
var _time = new Date();
|
||||
if(time_sent) {
|
||||
_time = new Date(time_sent);
|
||||
}
|
||||
var time = Helper.pad(_time.getHours()) + ":" + Helper.pad(_time.getMinutes());
|
||||
$("#chatall").append("<li title='"+inp.channel+"'><span class='time_color'>" + time + "</span> " + icon_add + "<span style='color:"+color_temp+";'>"+inp.from+"</span><span class='channel-info-all-chat'> " + inp.channel + " </span></li>");
|
||||
var in_text = document.createTextNode(inp.msg);
|
||||
@@ -130,8 +133,8 @@ var Chat = {
|
||||
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
||||
},
|
||||
|
||||
channelchat: function(data) {
|
||||
if(data.msg.substring(0,1) == ":" && !chat_active) {
|
||||
channelchat: function(data, time_sent, disable_blink) {
|
||||
if(data.msg.substring(0,1) == ":" && !chat_active && !disable_blink) {
|
||||
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
||||
unseen = true;
|
||||
chat_unseen = true;
|
||||
@@ -162,6 +165,9 @@ var Chat = {
|
||||
color = Helper.hexToRgb(color.substring(0,6));
|
||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||
var _time = new Date();
|
||||
if(time_sent) {
|
||||
_time = new Date(time_sent);
|
||||
}
|
||||
var time = Helper.pad(_time.getHours()) + ":" + Helper.pad(_time.getMinutes());
|
||||
$("#chatchannel").append("<li><span class='time_color'>" + time + "</span> " + icon_add + "<span style='color:"+color_temp+";'>"+data.from+"</span></li>");
|
||||
var in_text = document.createTextNode(data.msg);
|
||||
|
||||
@@ -310,6 +310,7 @@ function init(){
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {version: parseInt(localStorage.getItem("VERSION")), channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
}
|
||||
|
||||
if(!Helper.mobilecheck()) {
|
||||
$("#viewers").tooltip({
|
||||
delay: 5,
|
||||
@@ -368,6 +369,9 @@ function init(){
|
||||
setup_list_listener();
|
||||
setup_chat_listener();
|
||||
|
||||
socket.emit("get_history", {channel: chan.toLowerCase(), all: false});
|
||||
socket.emit("get_history", {channel: chan.toLowerCase(), all: true});
|
||||
|
||||
if(!Helper.mobilecheck() && $("#alreadychannel").length === 0) setup_host_initialization();
|
||||
|
||||
if(!Helper.msieversion() && !Helper.mobilecheck()) Notification.requestPermission();
|
||||
@@ -748,6 +752,16 @@ function setup_admin_listener(){
|
||||
}
|
||||
|
||||
function setup_chat_listener(){
|
||||
socket.on("chat_history", function(msg) {
|
||||
var data = msg.data;
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
if(msg.all) {
|
||||
Chat.allchat(data[i], data[i].createdAt, true);
|
||||
} else {
|
||||
Chat.channelchat(data[i], data[i].createdAt, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
socket.on("chat.all", Chat.allchat);
|
||||
socket.on("chat", Chat.channelchat);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user