if(typeof(jqac) === 'undefined') {
jqac = jQuery;
}
/*!
jQuery Cookie Plugin v1.4.0
https://github.com/carhartl/jquery-cookie
*/
(function(factory){if(typeof define==='function'&&define.amd){define(['jqac'],factory);}else{factory(jqac);}}(function($){var pluses=/\+/g;function encode(s){return config.raw?s:encodeURIComponent(s);}
function decode(s){return config.raw?s:decodeURIComponent(s);}
function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value));}
function parseCookieValue(s){if(s.indexOf('"')===0){s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,'\\');}
try{s=decodeURIComponent(s.replace(pluses,' '));return config.json?JSON.parse(s):s;}catch(e){}}
function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value;}
var config=$.cookie=function(key,value,options){if(value!==undefined&&!$.isFunction(value)){options=$.extend({},config.defaults,options);if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days);}
return(document.cookie=[encode(key),'=',stringifyCookieValue(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}
var result=key?undefined:{};var cookies=document.cookie?document.cookie.split('; '):[];for(var i=0,l=cookies.length;i<l;i++){var parts=cookies[i].split('=');var name=decode(parts.shift());var cookie=parts.join('=');if(key&&key===name){result=read(cookie,value);break;}
if(!key&&(cookie=read(cookie))!==undefined){result[name]=cookie;}}
return result;};config.defaults={};$.removeCookie=function(key,options){if($.cookie(key)===undefined){return false;}
$.cookie(key,'',$.extend({},options,{expires:-1}));return!$.cookie(key);};}));
(function (a) {
a.arrowchat = function () {
// Cache frequently used jQuery objects;
var $body = a('body');
function runarrowchat() {
if (c_enable_mobile == 1) {
if (a.cookie('ac_hide_mobile') != 1) {
$body.append('<div id="arrowchat_mobiletab"><div id="arrowchat_mobiletab_new"><span class="arrowchat_mobiletab_new_count">0</span></div>' + lang[145] + ' (<span id="arrowchat_mobiletab_count">0</span>)</div>');
$body.append('<div class="arrowchat_notify_box"><div class="arrowchat_notify_box_wrapper"><div class="arrowchat_notify_avatar"></div><div class="arrowchat_notify_info_wrapper"><div class="arrowchat_notify_username"></div><div class="arrowchat_notify_msg"></div></div><div class="arrowchat_clearfix"></div></div></div>');
a("#arrowchat_mobiletab_new").hide();
loadBuddyList();
receiveCore();
a("#arrowchat_mobiletab").click(function () {
window.open(c_ac_path + 'public/mobile/', 'mobiletab', '_blank');
});
}
}
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}
function receiveMessage(id, from, message, sent, self, old) {
if (from != u_id && typeof(uc_name[from]) != "undefined") {
message = stripslashes(message);
a(".arrowchat_notify_avatar").html('<img src="' + uc_avatar[from] + '" alt="" />');
a(".arrowchat_notify_username").html(uc_name[from]);
a(".arrowchat_notify_msg").html(message);
clearTimeout(message_timeout);
a(".arrowchat_notify_box").show("slide", { direction: "up"}, 250);
message_timeout = setTimeout(function () {
a(".arrowchat_notify_box").hide("slide", { direction: "up"}, 250);
}, 5000);
a(".arrowchat_notify_box").unbind('click');
a(".arrowchat_notify_box").click(function() {
clearTimeout(message_timeout);
a(".arrowchat_notify_box").hide();
window.open(c_ac_path + 'public/mobile/#chatwith-' + from, 'mobiletab', '_blank');
});
}
}
function addToCount(number) {
var count = parseInt(a(".arrowchat_mobiletab_new_count").html()) + number;
var fontSize = parseInt(a('#arrowchat_mobiletab').css('font-size'), 10);
a("#arrowchat_mobiletab_new").css("line-height", a("#arrowchat_mobiletab").css("font-size"));
a("#arrowchat_mobiletab_new").css("top", "-" + fontSize/2 + "px");
a("#arrowchat_mobiletab_new").css("right", fontSize/2 + "px");
a(".arrowchat_mobiletab_new_count").html(count);
a("#arrowchat_mobiletab_new").show();
}
function loadBuddyList() {
clearTimeout(Z);
a.ajax({
url: c_ac_path + "includes/json/receive/receive_buddylist.php?mobile=1",
cache: false,
type: "get",
dataType: "json",
success: function (b) {
buildBuddyList(b);
}
});
if (typeof c_list_heart_beat != "undefined") {
var BLHT = c_list_heart_beat * 1000;
} else {
var BLHT = 60000;
}
Z = setTimeout(function () {
loadBuddyList()
}, BLHT)
}
function cancelJSONP() {
if (typeof CHA != "undefined") {
clearTimeout(CHA);
}
if (typeof xOptions != "undefined") {
xOptions.abort();
}
}
function receiveCore() {
cancelJSONP();
var url = c_ac_path + "includes/json/receive/receive_core.php?hash=" + u_hash_id + "&init=" + acsi + "&room=0";
xOptions = a.ajax({
url: url,
dataType: "jsonp",
success: function (b) {
var new_messages = 0;
if (b && b != null) {
a.each(b, function (e, l) {
if (e == "messages") {
a.each(l, function (f, h) {
if (acsi != 1)
receiveMessage(h.id, h.from, h.message, h.sent, h.self, 1);
new_messages++;
});
}
});
}
acsi++;
if (new_messages > 0) {
addToCount(new_messages);
}
}
});
var CHT = c_heart_beat * 9000 * 3;
Z = setTimeout(function () {
receiveCore()
}, CHT)
}
function buildBuddyList(b) {
var onlineNumber = 0;
b && a.each(b, function (i, e) {
if (i == "buddylist") {
a.each(e, function (l, f) {
if (f.s == "available" || f.s == "away" || f.s == "busy")
onlineNumber++;
uc_status[f.id] = f.s;
uc_name[f.id] = f.n;
uc_avatar[f.id] = f.a;
uc_link[f.id] = f.l
});
a("#arrowchat_mobiletab_count").html(onlineNumber);
}
})
}
function scaletab() {
var zoomFactor = window.innerWidth/document.documentElement.clientWidth;
if (zoomFactor < 1) {
a("#arrowchat_mobiletab").hide();
a(".arrowchat_notify_box").hide();
} else {
a("#arrowchat_mobiletab").show();
}
var fontSize = parseInt(a('#arrowchat_mobiletab').css('font-size'), 10);
a("#arrowchat_mobiletab_new").css("line-height", a("#arrowchat_mobiletab").css("font-size"));
a("#arrowchat_mobiletab_new").css("top", "-" + fontSize/2 + "px");
a("#arrowchat_mobiletab_new").css("right", fontSize/2 + "px");
}
window.onresize = window.onscroll = function() {
scaletab();
};
window.onload = function() {
scaletab();
};
var Z,
CHT,
zoomFactor2 = window.innerWidth/document.documentElement.clientWidth,
message_timeout,
push_room = {},
push_uid,
push_arrowchat,
acsi = 1;
arguments.callee.chatWith = function (b) {
window.open(c_ac_path + 'public/mobile/#chatwith-' + b, 'mobiletab', '_blank');
};
arguments.callee.runarrowchat = runarrowchat;
}
})(jqac);
jqac(document).ready(function () {
if (u_logged_in != 1 && c_disable_arrowchat != 1) {
jqac.arrowchat();
jqac.arrowchat.runarrowchat()
}
});