");
a("#arrowchat_popout_text_" + b).scrollTop(5E4);
G[b] = 1
}
}
function ya(b) {
if (uc_name[b] == null || uc_name[b] == "") setTimeout(function () {
ya(b)
}, 500);
else j != b && a("#arrowchat_popout_user_" + b).click()
}
function playNewMessageSound() {
ion.sound.play("new_message");
}
function I(b, c, d, e, l, f, h) {
if (!(b == null || b == "")) if (uc_name[b] == null || uc_name[b] == "") if (aa[b] != 1) {
aa[b] = 1;
a.ajax({
url: c_ac_path + "includes/json/receive/receive_user.php",
data: {
userid: b
},
type: "post",
cache: false,
success: function (o) {
if (o) {
c = uc_name[b] = o.n;
d = uc_status[b] = o.s;
e = uc_avatar[b] = o.a;
l = uc_link[b] = o.l;
if (G[b] != null) {
a("#arrowchat_popout_user_" + b + " .arrowchat_closebox_bottom_status").removeClass("arrowchat_available").removeClass("arrowchat_busy").removeClass("arrowchat_offline").addClass("arrowchat_" + d);
}
aa[b] = 0;
if (c != null) {
qa(b, c, d, e, l, f, h)
} else {
a.post(c_ac_path + "includes/json/send/send_settings.php", {
userid: u_id,
unfocus_chat: b
}, function () {})
}
}
}
})
} else setTimeout(function () {
I(b, uc_name[b], uc_status[b], uc_avatar[b], uc_link[b], f, h)
}, 500);
else qa(b, uc_name[b], uc_status[b], uc_avatar[b], uc_link[b], f, h)
}
function formatTimestamp(b, noHTML) {
var c = "am",
d = b.getHours(),
i = b.getMinutes(),
e = b.getDate();
b = b.getMonth(); var g = d;
if (d > 11) c = "pm";
if (d > 12) d -= 12;
if (d == 0) d = 12;
if (d < 10) d = d;
if (i < 10) i = "0" + i;
var l = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
f = "th";
if (e == 1 || e == 21 || e == 31) f = "st";
else if (e == 2 || e == 22) f = "nd";
else if (e == 3 || e == 23) f = "rd";
if (noHTML) {
if (c_us_time != 1) {
return e != Na ? '' + g + ":" + i + " " + e + f + " " + l[b] + "" : '' + g + ":" + i + ""
} else {
return e != Na ? '' + d + ":" + i + c + " " + e + f + " " + l[b] + "" : '' + d + ":" + i + c + ""
}
} else {
if (c_us_time != 1) {
return e != Na ? '' + g + ":" + i + " " + e + f + " " + l[b] + "" : '' + g + ":" + i + ""
} else {
return e != Na ? '' + d + ":" + i + c + " " + e + f + " " + l[b] + "" : '' + d + ":" + i + c + ""
}
}
}
function receiveHistory(b, times) {
if (times) {} else times = 1;
if (times > 1) {
a('
').prependTo(a("#arrowchat_popout_text_" + b));
}
a.ajax({
cache: false,
url: c_ac_path + "includes/json/receive/receive_history.php",
data: {
chatbox: b,
history: times
},
type: "post",
dataType: "json",
success: function (c) {
a(".arrowchat_message_history_loading").remove();
history_ids[b] = 0;
numMessages = 0;
if (c) {
if (times == 1)
a("#arrowchat_popout_user_" + b + "_convo .arrowchat_popout_convo").html("");
last_sent[b] = null;
var d = "",
i = uc_name[b],
init = false,
unhide_avatars = [];
a.each(c, function (e, l) {
e == "messages" && a.each(l, function (f, h) {
f = "";
numMessages++;
if (h.self == 1) {
fromname = u_name;
fromid = u_id;
f = " arrowchat_self";
_aa5 = _aa4 = "";
avatar = u_avatar;
} else {
fromname = i;
fromid = b;
_aa4 = '';
_aa5 = "";
avatar = uc_avatar[h.from];
}
if (last_name[h.from] != fromid && typeof(last_name[h.from]) != "undefined") {
unhide_avatars.push(last_id[h.from]);
}
var image_msg = "";
var o = new Date(h.sent * 1E3);
tooltip = formatTimestamp(o, 1);
if (c_show_full_name != 1) {
if (fromname.indexOf(" ") != -1) fromname = fromname.slice(0, fromname.indexOf(" "));
}
if (h.message.substr(0, 4) == "
");
}
if (a("#arrowchat_message_" + last_id[b]).length) {
a("#arrowchat_message_" + last_id[b]).children('.arrowchat_chatboxmessagefrom').children('.arrowchat_chatbox_avatar').removeClass('arrowchat_single_avatar_hide');
}
a.each(unhide_avatars, function(key, value) {
if (a("#arrowchat_message_" + value).length) {
a("#arrowchat_message_" + value).children('.arrowchat_chatboxmessagefrom').children('.arrowchat_chatbox_avatar').removeClass('arrowchat_single_avatar_hide');
}
});
showTimeAndTooltip();
if (c_disable_avatars == 1 || a("#arrowchat_setting_names_only :input").is(":checked")) {
setAvatarVisibility(1);
}
var previous_height = 0;
current_top_element.prevAll().each(function() {
previous_height += a(this).outerHeight();
});
if (times == 1)
a("#arrowchat_popout_text_" + b).scrollTop(5E4);
else
a("#arrowchat_popout_text_" + b).scrollTop(previous_height);
a("#arrowchat_popout_text_" + b).scroll(function(){
if (a("#arrowchat_popout_text_" + b).scrollTop() < 50 && history_ids[b] != 1) {
history_ids[b] = 1;
if (numMessages == 20) {
times++;
receiveHistory(b, times);
}
}
});
if (times == 1) {
a(".arrowchat_chatboxmessagecontent>div>img,.arrowchat_emoji_text>img").one("load", function() {
a("#arrowchat_popout_text_" + b).scrollTop(5E4);
}).each(function() {
if(this.complete) a(this).load();
});
}
}
}
});
}
function ea(atid) {
a.post(c_ac_path + "includes/json/send/send_typing.php", {
userid: u_id,
typing: atid,
untype: 1
}, function () {});
fa = -1
}
function chatroomKeydown(key, $element, id) {
if (key.keyCode == 13 && key.shiftKey == 0) {
var i = $element.val();
i = i.replace(/^\s+|\s+$/g, "");
$element.val("");
$element.focus();
if (c_send_room_msg == 1 && i != "") {
displayMessage("arrowchat_chatroom_message_flyout", lang[209], "error");
} else {
i != "" && a.ajax({
url: c_ac_path + "includes/json/send/send_message_chatroom.php",
type: "post",
cache: false,
dataType: "json",
data: {
userid: u_id,
username: u_name,
chatroomid: Ccr,
message: i
},
error: function () {
displayMessage("arrowchat_chatroom_message_flyout", lang[135], "error");
},
success: function (o) {
if (o) {
var is_json = true;
if (a.isNumeric(o)) is_json = false;
var no_error = true;
if (is_json) {
o && a.each(o, function (i, e) {
if (i == "error") {
a.each(e, function (l, f) {
no_error = false;
displayMessage("arrowchat_chatroom_message_flyout", f.m, "error");
});
}
});
}
if (no_error) {
addMessageToChatroom(o, u_name, i, id);
var data_array = [o, u_name, i, id, Ccr];
lsClick(JSON.stringify(data_array), 'send_chatroom_message');
a("#arrowchat_popout_user_" + id + "_convo .arrowchat_popout_convo").scrollTop(a("#arrowchat_popout_user_" + id + "_convo .arrowchat_popout_convo")[0].scrollHeight)
}
}
}
});
}
return false
}
}
function O(b, c, d) {
clearTimeout(pa);
pa = setTimeout(function () {
ea(d)
}, 5E3);
if (fa != d) {
a.post(c_ac_path + "includes/json/send/send_typing.php", {
userid: u_id,
typing: d
}, function () {});
fa = d
}
if (b.keyCode == 13 && b.shiftKey == 0) {
var i = a(c).val();
i = i.replace(/^\s+|\s+$/g, "");
a(c).val("");
a(c).focus();
if (c_send_priv_msg == 1 && i != "") {
displayMessage("arrowchat_chatroom_message_flyout", lang[209], "error");
} else {
i != "" && a.post(c_ac_path + "includes/json/send/send_message.php", {
userid: u_id,
to: d,
message: i
}, function (e) {
if (e) {
var time = Math.floor((new Date).getTime() / 1E3);
addMessageToChatbox(d, i, "1", "1", e, 1, time);
var data_array = [e, d, i, time, 1, 1];
lsClick(JSON.stringify(data_array), 'private_message');
a("#arrowchat_popout_user_" + d + "_convo .arrowchat_popout_convo").scrollTop(a("#arrowchat_popout_user_" + d + "_convo .arrowchat_popout_convo")[0].scrollHeight)
}
K = 1;
if (D > E) {
D = E;
clearTimeout(Y);
Y = setTimeout(function () {
receiveCore()
}, E)
}
});
}
return false
}
}
function Ca(b, c, d) {
if (a("#arrowchat_popout_user_" + d + "_convo .arrowchat_smiley_popout").is(":visible")) {
a("#arrowchat_popout_user_" + d + "_convo .arrowchat_smiley_popout").children(".arrowchat_more_popout").hide();
}
a("#arrowchat_popout_user_" + d + "_popup .arrowchat_popout_convo").scrollTop(a("#arrowchat_popout_user_" + d + "_convo .arrowchat_popout_convo")[0].scrollHeight)
}
function qa(b, c, d, e, l, f) {
if (G[b] != null || a("#arrowchat_popout_user_"+b+"_convo").length > 0) {
if (!a("#arrowchat_user_" + b).hasClass("arrowchat_tabclick") && f != 1) {
j = b;
a(".arrowchat_popout_convo_wrapper").removeClass("arrowchat_popout_convo_focused");
a(".arrowchat_popout_tab").removeClass("arrowchat_popout_focused");
a("#arrowchat_popout_user_" + b + "_convo").addClass("arrowchat_popout_convo_focused");
a("#arrowchat_popout_user_" + b).addClass("arrowchat_popout_focused");
if (ca[b] != 1) {
receiveHistory(b);
ca[b] = 1
}
}
} else {
shortname = renderHTMLString(c).length > 12 ? renderHTMLString(c).substr(0, 12) + "..." : c;
longname = renderHTMLString(c).length > 24 ? renderHTMLString(c).substr(0, 24) + "..." : c;
a("").attr("id", "arrowchat_popout_user_" + b).addClass("arrowchat_popout_tab").html('
' + shortname + '
').appendTo(a("#arrowchat_popout_container"));
var status = uc_status[b];
if (status == "available")
status = lang[1];
if (status == "away")
status = lang[240];
if (status == "offline")
status = lang[241];
if (status == "busy")
status = lang[216];
var url = uc_link[b];
url = url.replace(c_ac_path, "");
a("").attr("id", "arrowchat_popout_user_" + b + "_convo").addClass("arrowchat_popout_convo_wrapper").html('