2192 lines
62 KiB
JavaScript
2192 lines
62 KiB
JavaScript
define(function (require, exports, module) {
|
|
require("../../extend/swfobject");
|
|
var logger = require("../../lib/pkroom/logger");
|
|
var eventUtil = require("../../lib/pkroom/eventUtil");
|
|
var md5 = require("../../lib/pkroom/md5");
|
|
var pubEvent = eventUtil.getInstance("pub");
|
|
var yyapi = require("../../lib/pkroom/yyapi");
|
|
var util = require("../../lib/pkroom/util");
|
|
//公屏组件
|
|
(function ($) {
|
|
$.uiwidget = $.uiwidget || {};
|
|
$.uiwidget.PublicUI = function (target, cfg) {
|
|
this.target = target;
|
|
$.extend(this, cfg);
|
|
this.init();
|
|
};
|
|
|
|
$.uiwidget.PublicUI.prototype = {
|
|
context: null
|
|
, chatInput: null
|
|
, chatInputConifg: null
|
|
, chatList: null
|
|
, listSize: 0
|
|
, maxRow: 100
|
|
, customImageQueue: [] //max size = maxRow * 2
|
|
, msgQueue: []
|
|
, readyFlag: false
|
|
, msgFreshRate: 200//公屏消息刷新频率,单位毫秒
|
|
, noticeHandle: null
|
|
, flowerCfg: { url: 'http://c1.web.yy.com/img/gift/flower24x24.jpg', h: 24, w: 24 }
|
|
, customImageCfg: {
|
|
defaultSrc: 'http://file.do.yy.com/group3/M02/CC/A1/tz0MYFcwQnyABIaOAAAAK7cKkkM864.gif'
|
|
}
|
|
, isOnMouseEnter: false
|
|
|
|
, privateChat: null //私聊DIV容器对象
|
|
, privateChatCfg: null //私聊配置
|
|
|
|
, init: function () {
|
|
var t = this;
|
|
if (!t.context) {
|
|
return;
|
|
}
|
|
t.target.mouseenter(function () {
|
|
t.onMouseenter();
|
|
});
|
|
t.target.mouseleave(function () {
|
|
t.onMouseleave();
|
|
});
|
|
|
|
t.initScrollbar();//初始化滚动条,可自定义
|
|
t.chatList = this.target.find(".chatlist");
|
|
if (t.chatInputConifg) {
|
|
t.chatInputConifg.cfg.context = t.context;
|
|
t.chatInput = $("#" + t.chatInputConifg.id).chatInput(t.chatInputConifg.cfg);
|
|
|
|
t.chatInput.init();//输入框及发送按钮
|
|
t.chatInput.publicUI = t;
|
|
t.chatInput.addMsgSendListener(function () {
|
|
t.scrollbar.scrollToBottom();
|
|
}, t);
|
|
}
|
|
|
|
/*
|
|
t.chatList.on("click",".name",function(){
|
|
var span = this;
|
|
pubEvent.trigerEvent("pubNickClick",{target:span,type:'pubMsg'});
|
|
})
|
|
*/
|
|
|
|
t.chatList.on("mousedown", ".name", function (e) {
|
|
if (3 == e.which) {
|
|
var span = this;
|
|
var uid = $(span).attr("data-uid") || "";
|
|
var nick = $(span).attr("data-nick") || "";
|
|
var role = $(span).attr("data-role") || 0;
|
|
if (uid == "")
|
|
return;
|
|
yyapi.showUserMenu(parseInt(uid), nick, parseInt(role));
|
|
}
|
|
})
|
|
t.chatList.on("mousedown", ".notice-user", function (e) {
|
|
if (3 == e.which) {
|
|
var span = this;
|
|
var uid = $(span).attr("data-uid") || "";
|
|
var nick = $(span).attr("data-nick") || "";
|
|
var role = $(span).attr("data-role") || 0;
|
|
if (uid == "")
|
|
return;
|
|
yyapi.showUserMenu(parseInt(uid), nick, parseInt(role));
|
|
}
|
|
})
|
|
t.chatList.on("dblclick", ".name", function () {
|
|
var span = this;
|
|
var uid = $(span).attr("data-uid") || "";
|
|
if (uid == yyapi.getMyUserInfo().uid)
|
|
return;
|
|
t.privateChat.showInChatBox();
|
|
pubEvent.trigerEvent("pubNickClick", { target: span, type: 'pubMsg' });
|
|
})
|
|
t.chatList.on("click", ".pub-custom-img", function () {
|
|
var img = this;
|
|
t.onCustomImageClick(img);
|
|
})
|
|
|
|
pubEvent.addEvent("increaseZindex", function (opt) {
|
|
if (opt.type == 'opr-box') {
|
|
t.increaseOperationAreaZindex();
|
|
}
|
|
});
|
|
|
|
//私聊
|
|
|
|
if (t.privateChatCfg) {
|
|
t.privateChatCfg.context = t.context;
|
|
t.privateChatCfg.pubicChat = t;
|
|
var privbox = $(t.privateChatCfg.selector);
|
|
if (privbox.length) {
|
|
t.privateChat = privbox.privateUI(t.privateChatCfg);
|
|
t.privateChat.init();
|
|
}
|
|
}
|
|
|
|
t.readyFlag = true;
|
|
//初始化公屏相关(滚动条,显示屏,各种消息、通知,输入框,表情,发送按钮)
|
|
t.start();
|
|
|
|
}
|
|
, startPrivateChatByUid: function (uid) {
|
|
if(!uid)
|
|
return;
|
|
var t = this;
|
|
var chatList = this.target.find(".chatlist");
|
|
var span = chatList.find("span[data-uid='" + uid + "']");
|
|
var nick = "";
|
|
var role = 0;
|
|
var yyno = "";
|
|
if(span.length == 0)
|
|
{
|
|
var user = yyapi.getUserInfo(uid);
|
|
nick = user.name;
|
|
role = user.role;
|
|
yyno = user.imid;
|
|
}
|
|
else
|
|
{
|
|
nick = $(span).text();
|
|
role = $(span).attr('data-role') || "";
|
|
yyno = $(span).attr('data-yyno') || "";
|
|
}
|
|
if (uid == yyapi.getMyUserInfo().uid)
|
|
return;
|
|
t.privateChat.showInChatBox();
|
|
t.privateChat.addUserToList(uid,nick,role,yyno);
|
|
|
|
}
|
|
, start: function () {
|
|
var t = this;
|
|
|
|
var historyData = t.readHistory();
|
|
for(var i = 0; i < historyData.length; i++)
|
|
{
|
|
var item = historyData[i];
|
|
if(item.type == 0)
|
|
{
|
|
t.receiveMessage(item);
|
|
}
|
|
else if(item.type == 1)
|
|
{
|
|
t.informSysMsg(item);
|
|
}
|
|
}
|
|
setInterval(function () {//定时刷新公屏消息
|
|
t.showChatList();
|
|
}, t.msgFreshRate);
|
|
}
|
|
, initScrollbar: function () {
|
|
this.scrollbar.obj = this.target;
|
|
if (this.scrollbar.obj) {
|
|
this.scrollbar.init(this);
|
|
}
|
|
}
|
|
, receiveData: function (obj) {
|
|
this.receiveMessage(obj);
|
|
},
|
|
receiveImageUrl: function (obj) {//接受自定义图片
|
|
var t = this;
|
|
|
|
logger.info(["receiveImageUrl", obj]);
|
|
while (t.customImageQueue.length > t.maxRow * 2) {
|
|
t.customImageQueue.shift();
|
|
}
|
|
var md5 = t.md5(obj.url);
|
|
obj.key = md5;
|
|
t.customImageQueue.push(obj);
|
|
}
|
|
, receivePrivateMessage: function (obj) {
|
|
logger.info(["receivePrivateMessage", obj]);
|
|
var t = this;
|
|
if (t.privateChat && t.privateChat.receMsg) {
|
|
t.privateChat.receMsg(obj);
|
|
}
|
|
}
|
|
, receiveMessage: function (obj) {
|
|
logger.info(["receiveMessage", obj]);
|
|
var t = this;
|
|
if (t.isMyself(obj.fromUser) && !obj.local) {
|
|
//return;
|
|
}
|
|
var msg = "";
|
|
try {
|
|
msg = decodeURI(obj.msg);
|
|
} catch (e) {
|
|
msg = obj.msg;
|
|
}
|
|
if (msg.length > t.chatInput.maxInputSize) {
|
|
return;
|
|
}
|
|
if (t.filterMsg) {
|
|
msg = t.filterMsg(msg);
|
|
}
|
|
msg = t.chatInput.filterContent(msg);
|
|
if (t.filterVipFace) {
|
|
msg = t.filterVipFace(msg);
|
|
}
|
|
if (t.filterAirTicket) {
|
|
msg = t.filterAirTicket(msg);
|
|
}
|
|
if (t.filterAirTicket2) {
|
|
msg = t.filterAirTicket2(msg);
|
|
}
|
|
if (t.filterCustomImage) {
|
|
msg = t.filterCustomImage(msg);
|
|
}
|
|
if (t.fileterWeiDeng) {
|
|
msg = t.fileterWeiDeng(msg,obj.extraInfo.weidengs);
|
|
}
|
|
var mj = _mjManager.getMj(obj.fromUser.role, obj.fromUser.gender);//改成图片或样式
|
|
var yylevel ="";
|
|
if (t.fileterYYLevel) {
|
|
yylevel = t.fileterYYLevel(obj.fromUser.yylevel );
|
|
}
|
|
var lianghao = "";
|
|
if (t.fileterLianghao) {
|
|
lianghao = t.fileterLianghao(obj.extraInfo.lianghao);
|
|
}
|
|
var identity = "";
|
|
if (t.fileterIdentity) {
|
|
identity = t.fileterIdentity(obj.extraInfo.identitys);
|
|
}
|
|
|
|
var yyno = "";
|
|
if (obj.fromUser.yyno) {
|
|
yyno = '<span class="time">('+ obj.fromUser.yyno + ')</span>';
|
|
}
|
|
if(obj.fromUser.role >= 150)//大于等于粉马
|
|
yylevel = "";
|
|
if(obj.fromUser.role < 150)//小于粉马
|
|
mj = "";
|
|
|
|
var time = t.getTimeHTML(obj);
|
|
|
|
var nickName = "" + t.wrapFromUser(obj.fromUser) + yyno + lianghao + time;
|
|
var msgStyle = t.getMessageStyle(obj.fontInfo);
|
|
var content = '<li><p>' + mj + yylevel + identity + nickName + '</p><p class="text-content" style="' + msgStyle + '">' + msg + '</p></li>';
|
|
t.addPubChatMsgQueue(content);
|
|
if (t.saveHistory && obj.isHistory == undefined) {
|
|
t.saveHistory(obj, 0);
|
|
}
|
|
}
|
|
, getMessageStyle: function (obj) {
|
|
if (!obj)
|
|
return;
|
|
var t = this;
|
|
var msgStyle = "";
|
|
//字体
|
|
if ("font_name" in obj) {
|
|
msgStyle += 'font-family:' + obj.font_name + ';';
|
|
}
|
|
//颜色
|
|
if ("color" in obj) {
|
|
if (obj.color > 0) {
|
|
msgStyle += "color:" + t.intColorToHex(obj.color) + ";"
|
|
}
|
|
|
|
}
|
|
|
|
if ("font_size" in obj) {
|
|
|
|
if (obj.font_size > 0) {
|
|
msgStyle += "font-size:" + obj.font_size + "px;";
|
|
}
|
|
|
|
}
|
|
if ("font_weight" in obj) {
|
|
if (obj.font_weight)
|
|
msgStyle += "font-weight:bold;";
|
|
}
|
|
if ("font_italic" in obj) {
|
|
if (obj.font_italic)
|
|
msgStyle += "font-style:italic;";
|
|
}
|
|
if ("font_underline" in obj) {
|
|
if (obj.font_underline)
|
|
msgStyle += "text-decoration:underline;";
|
|
}
|
|
|
|
return msgStyle;
|
|
}
|
|
, informNotify: function (obj) {
|
|
logger.info(["informNotify", obj]);
|
|
var t = this;
|
|
//console.info("cbEventObjs informNotify");
|
|
if (t.isMyself(obj.admin)) {
|
|
if (obj.fromClient) {
|
|
t.setPubNotice(obj);
|
|
}
|
|
} else {
|
|
t.setPubNotice(obj);
|
|
}
|
|
}
|
|
, informSysMsg: function (obj) {
|
|
var t = this;
|
|
t.setPubNotice2(obj);
|
|
}
|
|
, getIncreaseZindex: function () {
|
|
var t = this;
|
|
t.autoZindex = t.autoZindex || 0;
|
|
return ++t.autoZindex;l
|
|
},
|
|
increaseOperationAreaZindex: function () {
|
|
var t = this;
|
|
var box = t.target.parent().parent().find(".opr-box");
|
|
var index = t.getIncreaseZindex();
|
|
box.css("z-index", index);
|
|
}
|
|
,
|
|
onCustomImageClick: function (img) {
|
|
var t = this;
|
|
var target = $(img);
|
|
var key = target.attr("data-key");
|
|
if (key != "true") {
|
|
var it = t.getCustomImageByKey(key);
|
|
target.attr("src", it.imageUrl);
|
|
target.load(function () {
|
|
$(this).attr("data-key", true);
|
|
});
|
|
}
|
|
else {
|
|
var url = target.attr("src");
|
|
window.open(url,"_blank");
|
|
}
|
|
},
|
|
getCustomImageByKey: function (key) {
|
|
var t = this;
|
|
var i = 0, len = t.customImageQueue.length;
|
|
for (; i < len; i++) {
|
|
var it = t.customImageQueue[i];
|
|
if (it.key == key) {
|
|
return it;
|
|
}
|
|
}
|
|
|
|
var res = yyapi.getImageInfo(key);
|
|
if (res.ret == 0) {
|
|
res.key = key;
|
|
t.customImageQueue.push(res);
|
|
}
|
|
return res;
|
|
},
|
|
intColorToHex: function (intColor) {
|
|
var hex = (intColor).toString(16);
|
|
hex = hex.slice(2, hex.length);
|
|
return "#" + hex;
|
|
},
|
|
intColorToHex2: function (intColor) {
|
|
var hex = (intColor).toString(16);
|
|
|
|
//补0
|
|
var fix = "000000";
|
|
hex = fix.slice(0, fix.length - hex.length) + hex;
|
|
//反转成rrggbb
|
|
var rgb = hex.slice(4, 6) + hex.slice(2, 4) + hex.slice(0, 2);
|
|
return "#" + rgb;
|
|
}
|
|
, isMyself: function (user) {
|
|
return user && user.uid == this.context.getMyUserInfo().uid;
|
|
}
|
|
|
|
, addPubChatMsgQueue: function (content) {
|
|
this.msgQueue.push(content);
|
|
}
|
|
, onMouseenter: function () {
|
|
this.isOnMouseEnter = true;
|
|
|
|
}
|
|
|
|
, onMouseleave: function () {
|
|
this.isOnMouseEnter = false;
|
|
}
|
|
|
|
, showChatList: function () {
|
|
var t = this;
|
|
var msgQueue = t.msgQueue;
|
|
if (msgQueue.length > 0) {
|
|
var showMsgArry = msgQueue.splice(0, msgQueue.length);
|
|
t.chatList.append(showMsgArry.join("\n"));
|
|
t.listSize += showMsgArry.length;
|
|
if (t.listSize > t.maxRow) {
|
|
t.chatList.children().each(function () {
|
|
|
|
if (t.listSize > t.maxRow) {
|
|
$(this).remove();
|
|
t.listSize--;
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
t.freshPubScreenScrollbar();
|
|
}
|
|
}
|
|
|
|
, cleanPubScreen: function () {
|
|
this.listSize = 0;
|
|
this.chatList.empty();
|
|
this.freshPubScreenScrollbar();
|
|
}
|
|
|
|
, freshPubScreenScrollbar: function () {
|
|
var t = this;
|
|
t.scrollbar.scrollToBottom();
|
|
}
|
|
|
|
, scrollbar: {
|
|
api: null
|
|
, obj: null
|
|
, config: { scrollbarWidth: 20, mouseWheelSpeed: 20, stickToBottom: true }
|
|
, panne: null
|
|
, init: function (panne) {
|
|
var t = this;
|
|
t.panne = panne;
|
|
if (!t.obj) return;
|
|
$(t.obj).slimscroll({
|
|
color:"#cfcfcf",
|
|
size: '10px',
|
|
distance: "3px",
|
|
start: "bottom",
|
|
alwaysVisible: true
|
|
});
|
|
|
|
}
|
|
, extendsConfig: function (config) {
|
|
var t = this;
|
|
if (config) {
|
|
t.config = $.extend({}, t.config, config);
|
|
}
|
|
}
|
|
, scrollToBottom: function () {
|
|
var t = this;
|
|
|
|
var it2 = setTimeout(function () {
|
|
clearTimeout(it2);
|
|
$(t.obj).slimScroll({ scrollTo: '9999px' });
|
|
}, 200);
|
|
|
|
}
|
|
}
|
|
|
|
,
|
|
//通知处理
|
|
setPubNotice: function (obj) {
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
var t = this;
|
|
var notice = '', noticeType = 1;
|
|
switch (obj.notifyName) {
|
|
//创建频道消息
|
|
case InformEvent.ADD_SUBCHANNEL_INFO:
|
|
if (obj.param.length > 1) {
|
|
notice = "管理员 [" + obj.admin.nickname + "] 创建子频道 [" + obj.param[0].name + "] >> [" + obj.param[1].name + "]。";
|
|
} else {
|
|
notice = "管理员 [" + obj.admin.nickname + "] 创建子频道 [" + obj.param[0].name + "]。";
|
|
}
|
|
break;
|
|
//移除频道消息
|
|
case InformEvent.REMOVE_SUBCHANNEL_INFO:
|
|
if (obj.param.length > 1) {
|
|
notice = "管理员 [" + obj.admin.nickname + "] 删除子频道 [" + obj.param[0].name + "] >> [" + obj.param[1].name + "]。";
|
|
} else {
|
|
notice = "管理员 [" + obj.admin.nickname + "] 删除子频道 [" + obj.param[0].name + "]。";
|
|
}
|
|
break;
|
|
//清空麦序
|
|
case InformEvent.MIC_KICK_ALL_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname + "] 已将麦序清空。";
|
|
break;
|
|
//抱上麦序消息
|
|
case InformEvent.MIC_DRAG_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname + "] 已将 [" + obj.user.nickname + "] 抱上麦序。";
|
|
break;
|
|
//麦序双倍时间消息
|
|
case InformEvent.MIC_DOUBLE_TIME_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname +
|
|
"] 将 [" + obj.user.nickname + "] 的麦序时间增加一倍。";
|
|
break;
|
|
//麦序时间上限
|
|
case InformEvent.MIC_TIME_MAX:
|
|
notice = "管理员 [" + obj.admin.nickname +
|
|
"] 已将 [" + obj.user.nickname + "] 的麦序时间增加至上限 9999 秒。";
|
|
break;
|
|
//离开麦序消息
|
|
case InformEvent.MIC_KICK_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname +
|
|
"] 已将 [" + obj.user.nickname + "] 从麦序移除。";
|
|
break;
|
|
//不允许抢麦
|
|
case InformEvent.MIC_DISABLE_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname +
|
|
"] 将频道设置为禁止抢麦,暂时无法抢麦。";
|
|
break;
|
|
//允许抢麦
|
|
case InformEvent.MIC_ABLE_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname +
|
|
"] 将频道设置为允许抢麦,可以点击抢麦按钮排队发言。";
|
|
break;
|
|
//管理员控麦消息
|
|
case InformEvent.MIC_IS_MUTE_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname + "] 控麦,首位麦序上的人暂时不能说话。";
|
|
break;
|
|
//管理员放麦消息
|
|
case InformEvent.MIC_NOT_MUTE_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname + "] 放麦,首位麦序上的人可以说话了。";
|
|
break;
|
|
//麦序上移消息
|
|
case InformEvent.MIC_UP_MOVE_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname +
|
|
"] 将 [" + obj.user.nickname + "] 的麦序上移。";
|
|
break;
|
|
//麦序下移
|
|
case InformEvent.MIC_DOWN_MOVE_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname +
|
|
"] 将 [" + obj.user.nickname + "] 的麦序下移。";
|
|
break;
|
|
//移到二号麦
|
|
case InformEvent.MIC_SECOND_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname + "] 将 [" +
|
|
obj.user.nickname + "] 的麦序调整为2号麦。";
|
|
break;
|
|
//管理员发起连麦
|
|
case InformEvent.MIC_CONNECT_INFO:
|
|
notice = "管理员 [" + obj.admin.nickname + "] 已将 [" +
|
|
obj.user.nickname + "]加入连麦模式。";
|
|
break;
|
|
//连麦结束
|
|
case InformEvent.MIC_DISCONNECT_INFO:
|
|
notice = " [" + obj.admin.nickname + "] 和 [" +
|
|
obj.user.nickname + "]连麦结束。";
|
|
break;
|
|
//邀请连麦
|
|
case InformEvent.MIC_INVITE_CONNECT_INFO:
|
|
break;
|
|
//加入连麦
|
|
case InformEvent.MIC_JOIN_CONNECT_INFO:
|
|
notice = " [" + obj.admin.nickname + "]加入连麦模式。";
|
|
break;
|
|
//献花通知
|
|
case InformEvent.GIVE_FLOWER_INFO:
|
|
notice = t.flowerNoticeInfo(obj);
|
|
noticeType = 2;
|
|
break;
|
|
case InformEvent.MIC_IS_ME_SEND_FLOWER:
|
|
notice = "鲜花只能送给他人!", false;
|
|
break;
|
|
case InformEvent.MIC_NULL_SEND_FLOWER:
|
|
notice = "对不起,当前麦序为空,不能送出鲜花!";
|
|
break;
|
|
case InformEvent.NOT_MIC_SEND_FLOWER:
|
|
notice = "对不起,您只能在麦序模式下赠送鲜花给1号麦!";
|
|
break;
|
|
//修改权限
|
|
case InformEvent.USER_CAPABILITY_CHANGED_INFO:
|
|
notice = t.userCapalibilityInfo(obj);
|
|
break;
|
|
//角色改变
|
|
case InformEvent.USER_ROLE_CHANGED_INFO:
|
|
notice = t.userRoleChangedInfo(obj);
|
|
break;
|
|
//频道惩罚
|
|
case InformEvent.CHANNEL_PUNISH_INFO:
|
|
notice = t.channelPunishInfo(obj);
|
|
break;
|
|
//接待频道设置
|
|
case InformEvent.ADIMT_SUBCHANNEL_CHANGED_INFO:
|
|
notice = t.adimtSubChannelChange(obj);
|
|
break;
|
|
//取消接待频道
|
|
case InformEvent.CANCEL_ADMIT_CHANNEL:
|
|
notice = t.cancelAdmitChannelInfo(obj);
|
|
break;
|
|
//新加一个消息
|
|
case InformEvent.NORMAL_INFORM_MSG:
|
|
notice = obj.param;
|
|
break;
|
|
// 送礼物
|
|
case InformEvent.GIFT_SEND_INFO:
|
|
notice = t.giftNoticeInfo(obj.data);
|
|
noticeType = 2;
|
|
break;
|
|
}
|
|
|
|
if (notice) {
|
|
if (noticeType == 1) {
|
|
notice = t.normalNoticeInfo(notice);
|
|
}
|
|
t.addPubChatMsgQueue(notice);
|
|
if (t.saveHistory && obj.isHistory == undefined) {
|
|
t.saveHistory(obj, 1);
|
|
}
|
|
if (t.noticeHandle) {
|
|
t.noticeHandle.call(t, obj);
|
|
}
|
|
}
|
|
}
|
|
,
|
|
//通知处理
|
|
setPubNotice2: function (obj) {
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
var t = this;
|
|
var msg = eval('(' + obj.msg + ')'), noticeType = obj.type;
|
|
var notice = "";
|
|
var uid;
|
|
var tcount = 0;
|
|
var fontInfo = {};
|
|
var msgStyle = "";
|
|
if(msg.text){
|
|
|
|
notice = t.filterSysMsg(msg.text);
|
|
}
|
|
else if(msg.YYMessageItem && msg.YYMessageItem.length > 0){
|
|
|
|
var treg=/([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])/g;
|
|
for(var i=0;i < msg.YYMessageItem.length;i++){
|
|
var context = msg.YYMessageItem[i].text;
|
|
notice += context;
|
|
if(msg.YYMessageItem[i].KItemLinkKey == "linKey_User")
|
|
uid = msg.YYMessageItem[i].KItemLinkValue;
|
|
|
|
if(treg.test(context))
|
|
{
|
|
tcount++;
|
|
if(tcount>1)
|
|
notice +="</br>";
|
|
}
|
|
|
|
}
|
|
notice = t.filterSysMsg(notice);
|
|
}
|
|
if(msg.font)
|
|
{
|
|
fontInfo.font_name = msg.font.family;
|
|
fontInfo.font_size = (msg.font.pointSize /72) * 96;
|
|
fontInfo.font_weight = msg.font.bold;
|
|
fontInfo.font_italic = msg.font.italic;
|
|
fontInfo.font_underline = msg.font.underline;
|
|
fontInfo.color = msg.font.rgba;
|
|
msgStyle = t.getMessageStyle(fontInfo);
|
|
|
|
}
|
|
if (notice) {
|
|
notice = '<span style="' + msgStyle + '">' + notice + '</span>';
|
|
notice = t.normalNoticeInfo2(notice,uid);
|
|
t.addPubChatMsgQueue(notice);
|
|
if (t.saveHistory && obj.isHistory == undefined) {
|
|
t.saveHistory(obj, 1);
|
|
}
|
|
if (t.noticeHandle) {
|
|
t.noticeHandle.call(t, obj);
|
|
}
|
|
}
|
|
}
|
|
//一般通知消息
|
|
, normalNoticeInfo2: function (appendText,uid) {
|
|
var content = '';
|
|
if(uid)
|
|
content = '<li class="nt notice-user" data-uid="'+uid+'"><span class="notice"></span>';
|
|
else
|
|
content = '<li class="nt"><span class="notice"></span>';
|
|
content += appendText;
|
|
content += '</li>';
|
|
return content;
|
|
}
|
|
//一般通知消息
|
|
, normalNoticeInfo: function (appendText) {
|
|
var content = '<li class="nt"><span class="notice"></span>';
|
|
content += ' 通知:';
|
|
content += appendText;
|
|
content += '</li>';
|
|
return content;
|
|
}
|
|
,//送花通知
|
|
flowerNoticeInfo: function (vo) {
|
|
if (vo.param.count > 0 && vo.param.count <= 8) {
|
|
var t = this;
|
|
//显示鲜花图片,暂时用文字表示
|
|
var content = t.wrapFromUser(vo.admin) + t.getGiveHTML() + t.wrapToUser(vo.user) + t.getImagesHTML(t.flowerCfg.url, t.flowerCfg.w, t.flowerCfg.h, "鲜花", vo.param.count);
|
|
content = '<li>' + content + '</li>'
|
|
return content;
|
|
}
|
|
return null;
|
|
}
|
|
,//自定义图片
|
|
getCustomImage: function (imgVo) {
|
|
|
|
}
|
|
//送礼物
|
|
,giftNoticeInfo: function (data) {
|
|
var content = [];
|
|
|
|
for (var i = 0; i < data.count; i++) {
|
|
content[i] = '<li class="gift-pub-msg"><em>' + data.sendernickname + '</em>送给' + data.recvernickname + '<img src="' + data.img + '"/><em>' + (i + 1) + '个</em></li>';
|
|
}
|
|
|
|
return content.join('');
|
|
}
|
|
,
|
|
// 用户权限发生变化通知
|
|
userCapalibilityInfo: function (vo) {
|
|
var capabilityVo = vo.param;
|
|
var msg = '';
|
|
switch (capabilityVo.capability) {
|
|
case UserCapability.DISABLE_TEXT:
|
|
//管理员_[%1]_禁止_[%2]_使用文字聊天。
|
|
msg = "管理员 [" + vo.admin.nickname + "] 禁止 [" + vo.user.nickname + "] 使用文字聊天。";
|
|
break;
|
|
case UserCapability.DISABLE_VOICE:
|
|
//管理员_[%1]_禁止_[%2]_使用语音聊天。
|
|
msg = "管理员 [" + vo.admin.nickname + "] 禁止 [" + vo.user.nickname + "] 使用语音聊天。";
|
|
break;
|
|
case UserCapability.ENABLE_TEXT:
|
|
//管理员_[%1]_允许_[%2]_使用文字聊天。
|
|
msg = "管理员 [" + vo.admin.nickname + "] 允许 [" + vo.user.nickname + "] 使用文字聊天。";
|
|
break;
|
|
case UserCapability.ENABLE_VOICE:
|
|
//管理员_[%1]_允许_[%2]_使用语音聊天。
|
|
msg = "管理员 [" + vo.admin.nickname + "] 允许 [" + vo.user.nickname + "] 使用语音聊天。";
|
|
break;
|
|
}
|
|
return msg;
|
|
}
|
|
,
|
|
/**
|
|
* 用户角色发生变化通知
|
|
*/
|
|
userRoleChangedInfo: function (vo) {
|
|
var roleChangedVo = vo.param;
|
|
var time = this.formatCurrentTime();
|
|
var msg = '';
|
|
switch (roleChangedVo.role) {
|
|
//子频道管理员(CA1)
|
|
case UserRole.CMANAGER:
|
|
msg = "[" + vo.user.nickname + "] 的权限被 [" + vo.admin.nickname + "] 从 [" + _mjManager.getMjName(roleChangedVo.oldRole) + "] 变成子频道 [" + roleChangedVo.channel_name + "] 的 [" + _mjManager.getMjName(roleChangedVo.role) + "]。" + time;
|
|
break;
|
|
//二级子频道管理员(CA2)
|
|
case UserRole.SECOND_CMANAGER:
|
|
msg = "[" + vo.user.nickname + "] 的权限被 [" + vo.admin.nickname + "] 从 [" + _mjManager.getMjName(roleChangedVo.oldRole) + "] 变成子频道 [" + roleChangedVo.channel_name + "] 的 [" + _mjManager.getMjName(roleChangedVo.role) + "]。" + time;
|
|
break;
|
|
case UserRole.DELETED:
|
|
break;
|
|
//全频道管理员(MA)
|
|
case UserRole.MANANGER:
|
|
msg = "[" + vo.user.nickname + "] 的权限被 [" + vo.admin.nickname + "] 从 [" + _mjManager.getMjName(roleChangedVo.oldRole) + "] 变成 [" + _mjManager.getMjName(roleChangedVo.role) + "]。" + time;
|
|
break;
|
|
//会员(R)
|
|
case UserRole.MEMBER:
|
|
msg = "[" + vo.user.nickname + "] 的权限被 [" + vo.admin.nickname + "] 从 [" + _mjManager.getMjName(roleChangedVo.oldRole) + "] 变成 [" + _mjManager.getMjName(roleChangedVo.role) + "]。" + time;
|
|
break;
|
|
//游客(U)
|
|
case UserRole.NORMAL:
|
|
if (roleChangedVo.oldRole != UserRole.TMPVIP && roleChangedVo.oldRole != UserRole.VIP) {
|
|
msg = "[" + vo.user.nickname + "] 的权限被 [" + vo.admin.nickname + "] 从 [" + _mjManager.getMjName(roleChangedVo.oldRole) + "] 变成 [" + _mjManager.getMjName(roleChangedVo.role) + "]。" + time;
|
|
}
|
|
//频道所有者(OW)
|
|
case UserRole.OWNER:
|
|
break;
|
|
case UserRole.PMANAGER:
|
|
break;
|
|
//歪歪官方人员
|
|
case UserRole.SA:
|
|
break;
|
|
//临时嘉宾(G)
|
|
case UserRole.TMPVIP:
|
|
break;
|
|
//频道总管理(VP)
|
|
case UserRole.VICE_OWNER:
|
|
msg = "[" + vo.user.nickname + "] 的权限被 [" + vo.admin.nickname + "] 从 [" + _mjManager.getMjName(roleChangedVo.oldRole) + "] 变成 [" + _mjManager.getMjName(roleChangedVo.role) + "]。" + time;
|
|
break;
|
|
//嘉宾(VIP)
|
|
case UserRole.VIP:
|
|
break;
|
|
}
|
|
return msg;
|
|
}
|
|
,
|
|
/**
|
|
* 频道惩罚消息通知
|
|
*/
|
|
channelPunishInfo: function (vo) {
|
|
var punishVo = vo.param;
|
|
var msg = '';
|
|
switch (punishVo.event) {
|
|
case ChannelPunish.BAN_ID:
|
|
msg = "用户 [" + vo.user.nickname + "] 被管理员 [" + vo.admin.nickname + "] 请出 [" + _api.getChannel().getChannelInfoBySid(punishVo.topSid).name + "] 频道,且被封了ID,理由:[" + punishVo.reason + "]。";
|
|
break;
|
|
case ChannelPunish.BAN_IP:
|
|
msg = "用户 [" + vo.user.nickname + "] 被管理员 [" + vo.admin.nickname + "] 请出 [" + _api.getChannel().getChannelInfoBySid(punishVo.topSid).name + "] 频道,且被封了IP,理由:[" + punishVo.reason + "]。";
|
|
break;
|
|
case ChannelPunish.KICK_OUT:
|
|
msg = "用户 [" + vo.user.nickname + "] 被管理员 [" + vo.admin.nickname + "] 请出 [" + _api.getChannel().getChannelInfoBySid(punishVo.topSid).name + "] 频道,理由:[" + punishVo.reason + "]。";
|
|
break;
|
|
case ChannelPunish.KICK_UP:
|
|
msg = "用户 [" + vo.user.nickname + "] 被管理员 [" + vo.admin.nickname + "] 请出 [" + punishVo.channelName + "] 频道,理由:[" + punishVo.reason + "]。";
|
|
break;
|
|
}
|
|
return msg;
|
|
}
|
|
,
|
|
/**
|
|
* 设置接待频道
|
|
*/
|
|
adimtSubChannelChange: function (vo) {
|
|
return "管理员 [" + vo.admin.nickname + "] 已将子频道 [" + vo.param.name + "] 设置为接待频道。";
|
|
},
|
|
|
|
/**
|
|
* 取消接待频道
|
|
*/
|
|
cancelAdmitChannelInfo: function (vo) {
|
|
return "管理员 [" + vo.admin.nickname + "] 已将子频道 [" + vo.param.name + "] 取消接待设置。";
|
|
}
|
|
|
|
, getNickHTML: function (user) {
|
|
var attr = {
|
|
uid: user.uid,
|
|
role: user.role,
|
|
nick: user.nickname,
|
|
yyno : user.yyno
|
|
};
|
|
|
|
if(user.svip >= 100)
|
|
return this.getSpanHTML(user.nickname, 'name yellowname', attr);
|
|
else if(user.purplename)
|
|
return this.getSpanHTML(user.nickname, 'name purplename', attr);
|
|
else if(user.readname)
|
|
return this.getSpanHTML(user.nickname, 'name readname', attr);
|
|
else
|
|
return this.getSpanHTML(user.nickname, 'name', attr);
|
|
}
|
|
, getGiveHTML: function (txt) {
|
|
txt = txt || '送给';
|
|
return this.getSpanHTML(txt, 'give');
|
|
}
|
|
, formatCurrentTime: function () {
|
|
var date = new Date();
|
|
var hours = date.getHours();
|
|
var minutes = date.getMinutes();
|
|
var seconds = date.getSeconds();
|
|
var time = "(" + (hours < 10 ? ("0" + hours) : hours) + ":" + (minutes < 10 ? ("0" + minutes) : minutes) + ":" + (seconds < 10 ? ("0" + seconds) : seconds) + ")";
|
|
return time;
|
|
}
|
|
|
|
, getTimeHTML: function (obj) {
|
|
var timeStr = obj.time;
|
|
if (!timeStr) {
|
|
obj.time = this.formatCurrentTime();
|
|
}
|
|
return this.getSpanHTML(obj.time, 'time');
|
|
}
|
|
|
|
, getSpanHTML: function (content, css, attr) {
|
|
var attrText = '';
|
|
if (attr) {
|
|
for (var key in attr) {
|
|
attrText = attrText + ' data-' + key + '="' + attr[key] + '"';
|
|
}
|
|
}
|
|
return '<span ' + attrText + ' class="' + css + '">' + content + '</span>';
|
|
}
|
|
|
|
, getImagesHTML: function (url, w, h, alt, count) {
|
|
var html = '';
|
|
for (var i = 0; i < count; i++) {
|
|
html += '<img src="' + url + '" alt="' + alt + '" width="' + w + '" height="' + h + '">';
|
|
}
|
|
return html;
|
|
}
|
|
, wrapFromUser: function (user) {
|
|
return this.getNickHTML(user);
|
|
}
|
|
, wrapToUser: function (user) {
|
|
return this.getNickHTML(user);
|
|
},
|
|
md5: function (key) {
|
|
return $.md5(key);
|
|
}
|
|
};
|
|
|
|
//聊天输入及按钮
|
|
$.uiwidget.ChatInput = function (target, cfg) {
|
|
this.target = target;
|
|
$.extend(this, cfg);
|
|
};
|
|
|
|
$.uiwidget.ChatInput.prototype = {
|
|
context: null
|
|
, sendButtonId: ''
|
|
, tipsId: ''
|
|
, contentObj: null//特殊内容,如:表情
|
|
, maxInputSize: 500
|
|
, lastSendTimeSecMil: 0
|
|
, joinRommTime: 0
|
|
, chDetail: null
|
|
, init: function () {
|
|
//console.info("ChatInput init ....");
|
|
var t = this;
|
|
t.joinRommTime = new Date().getTime();
|
|
t.initContent();//初始化输入内容
|
|
t.noticeInit();
|
|
$("#" + t.sendButtonId).click(function () {
|
|
t.sendMessage();
|
|
|
|
});
|
|
t.msgInputKeyDown();
|
|
t.contentObj.addChangeListener(function (data) {
|
|
this.insertAtCursor(data);
|
|
}, t);
|
|
|
|
t.contentObj.addEventListener("beforeShow", function () {
|
|
if (!t.isSendMsg()) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
|
|
$("#pub_msg_input").bind("keydown", function (event) {
|
|
|
|
if (event.keyCode == 86 && event.ctrlKey) {
|
|
var res = yyapi.getClipboardImage();
|
|
var clipboardImageUrl = res.imageUrl;
|
|
if(clipboardImageUrl && clipboardImageUrl!="")
|
|
{
|
|
var imageMd5 = "[Image]" + $.md5(clipboardImageUrl) + "[/Image]";
|
|
t.insertAtCursor(imageMd5);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
, chnageFontInfo: function (data) {
|
|
var t = this;
|
|
var obj = data;
|
|
if (!obj)
|
|
return;
|
|
var target = $("#pub_msg_input");
|
|
//字体
|
|
if ("font_name" in obj) {
|
|
target.css('font-family', obj.font_name);
|
|
}
|
|
//颜色
|
|
if ("color" in obj) {
|
|
//FIXME 取消字体颜
|
|
target.css('color', t.publicUI.intColorToHex(obj.color));
|
|
}
|
|
|
|
if ("font_size" in obj) {
|
|
if (obj.font_size > 0) {
|
|
target.css('font-size', obj.font_size + "px;");
|
|
}
|
|
}
|
|
if ("font_weight" in obj) {
|
|
if (obj.font_weight)
|
|
target.css('font-weight', "bold");
|
|
else
|
|
target.css('font-weight', "normal");
|
|
}
|
|
if ("font_italic" in obj) {
|
|
if (obj.font_italic)
|
|
target.css('font-style', "italic");
|
|
else
|
|
target.css('font-style', "normal");
|
|
}
|
|
if ("font_underline" in obj) {
|
|
if (obj.font_underline)
|
|
target.css('text-decoration', "underline");
|
|
else
|
|
target.css('text-decoration', "none");
|
|
}
|
|
|
|
}
|
|
, initContent: function () {
|
|
if (this.contentObj) {
|
|
this.contentObj.init();//表情
|
|
}
|
|
}
|
|
, filterContent: function (msg) {
|
|
if (this.contentObj) {
|
|
return this.contentObj.filter(msg);//表情
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
, msgInputKeyDown: function () {
|
|
var t = this;
|
|
t.target.bind("keydown", function (event) {
|
|
if (event.keyCode == 13 && event.ctrlKey) {
|
|
t.insertAtCursor("\n");
|
|
return true;
|
|
}
|
|
else if (event.keyCode == 13 && !event.ctrlKey) {
|
|
t.sendMessage();// 往服务器发送信息代码
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
|
|
, insertAtCursor: function (myValue) {
|
|
var myField = this.target[0];
|
|
//IE support
|
|
if (document.selection) {
|
|
myField.focus();
|
|
sel = document.selection.createRange();
|
|
sel.text = myValue;
|
|
sel.select();
|
|
}
|
|
|
|
else if (myField.selectionStart || myField.selectionStart == '0') {//MOZILLA/NETSCAPE support
|
|
myField.blur()
|
|
var startPos = myField.selectionStart;
|
|
var endPos = myField.selectionEnd;
|
|
var restoreTop = myField.scrollTop;
|
|
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
|
|
if (restoreTop > 0) {
|
|
myField.scrollTop = restoreTop;
|
|
}
|
|
myField.focus();
|
|
myField.selectionStart = startPos + myValue.length;
|
|
myField.selectionEnd = startPos + myValue.length;
|
|
} else {
|
|
myField.value += myValue;
|
|
myField.focus();
|
|
}
|
|
}
|
|
, addMsgSendListener: function (fn, obj) {
|
|
this.addEventListener("sendMessage", fn, obj);
|
|
}
|
|
|
|
, addEventListener: function (evt, fn, obj) {
|
|
var t = this;
|
|
t.target.bind(evt, { fn: fn, obj: obj }, function (e, data) {
|
|
var fn = e.data.fn;
|
|
if (fn) {
|
|
var obj = e.data.obj || t;
|
|
fn.call(obj, data);
|
|
}
|
|
});
|
|
}
|
|
, isSendMsg: function () {
|
|
return true;
|
|
}
|
|
, sendMessage: function () {
|
|
var t = this;
|
|
var msg = t.target.val();
|
|
var isSendMsg = t.isSendMsg();
|
|
|
|
if (t.noticeTimeout) {
|
|
t.noticeClose();
|
|
}
|
|
if (!isSendMsg) {
|
|
return;
|
|
}
|
|
if (!msg || msg == t.defaultText || util.trim(msg)=="") {
|
|
t.noticeMe("请输入要发言的内容!");
|
|
return;
|
|
}
|
|
if (msg.length > t.maxInputSize) {
|
|
//t.noticeMe("输入字数最大不能已超过" + t.maxInputSize);
|
|
//return;
|
|
msg = msg.substring(0,500);
|
|
}
|
|
if (!t.context || !t.context.isReady) {
|
|
return;
|
|
}
|
|
t.chDetail = t.context.getChannelDetail();
|
|
|
|
logger.log(t.chDetail);
|
|
|
|
if (!t.validInput()) {
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
var isPrivMode = false;
|
|
if (t.publicUI.privateChat && t.publicUI.privateChat.isPrivateChatMode() && t.publicUI.privateChat.isExpandPri) {
|
|
isPrivMode = true;
|
|
}
|
|
|
|
|
|
logger.debug(["private chat mode:", isPrivMode]);
|
|
var sendObj;
|
|
var sendRs;
|
|
if (isPrivMode) {
|
|
sendObj = t.publicUI.privateChat.sendPrivReq(msg);
|
|
if (!sendObj) return;
|
|
sendRs = sendObj.result;
|
|
if (sendRs == SendMessageResult.SUCCEESS) {
|
|
t.target.val("");
|
|
}
|
|
} else {
|
|
sendObj = t.sendReq(msg);
|
|
if (!sendObj) return;
|
|
if (sendObj.result == undefined)
|
|
sendObj.result = 0;
|
|
sendRs = sendObj.result;
|
|
if (sendRs == SendMessageResult.SUCCEESS) {
|
|
t.target.val("");
|
|
t.target.trigger("sendMessage", true);
|
|
t.lastSendTimeSecMil = new Date().getTime();
|
|
if (t.sendSucess) {
|
|
t.sendSucess(msg);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
logger.info("sendRs------>" + sendRs);
|
|
if (sendRs != SendMessageResult.SUCCEESS) {
|
|
t.handleSendResult(sendRs);
|
|
}
|
|
|
|
}
|
|
, sendReq: function (msg) {
|
|
return this.sendYYPubReq(msg);
|
|
}
|
|
, sendYYPubReq: function (msg) {
|
|
return this.context.send('sendMessage', msg);
|
|
}
|
|
, validInput: function () {
|
|
var t = this;
|
|
var chDetail = t.chDetail;
|
|
var limit_intervel = chDetail.text_limit_intervel;
|
|
//var limit_guest_only = chDetail.text_limit_guest_only;
|
|
|
|
if (chDetail.band_phone_limit) {
|
|
t.noticeMe("该页面暂不支持绑定用户手机,无法发言,先送送鲜花给主播吧~");
|
|
return false;
|
|
}
|
|
var is_text_limit = chDetail.is_text_limit;
|
|
if (t.lastSendTimeSecMil > 0 && is_text_limit && limit_intervel > 0) {
|
|
var diff = parseInt((new Date().getTime() - t.lastSendTimeSecMil) / 1000);
|
|
if (diff < limit_intervel) {
|
|
t.noticeMe("管理员限制打字数度,请" + (limit_intervel - diff) + "秒后重试");
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
, handleSendResult: function (sendRs) {
|
|
var t = this;
|
|
var tips = "";
|
|
switch (sendRs) {
|
|
case SendMessageResult.ALL_NO_SEND:
|
|
tips = "管理员禁止所有人打字。";
|
|
break;
|
|
case SendMessageResult.VISITOR_NO_SEND:
|
|
tips = "管理员禁止游客打字。";
|
|
break;
|
|
case SendMessageResult.GUEST_LOGIN_SEND:
|
|
tips = "登录后才可以开麦发言哦。";
|
|
//return t.context.login();
|
|
break;
|
|
case SendMessageResult.GUEST_NEED_WAIT:
|
|
//游客等待时间不足(游客需要加入频道一段时间才能打字,由管理员设定)
|
|
var nowTime = parseInt(new Date().getTime() / 1000);
|
|
var waitTime = nowTime - parseInt(t.joinRommTime / 1000);
|
|
var leaveTime = t.chDetail.guest_wait_time * 60 - waitTime;
|
|
if (leaveTime > 0) {
|
|
tips = "管理员规定了游客发言时间!请" + leaveTime + "秒后发言。";
|
|
}
|
|
break;
|
|
case SendMessageResult.MAX_TEXT_ERROR:
|
|
var _maxTextLength = t.chDetail.guest_max_text;
|
|
tips = "管理员限制游客字数,已超过" + (t.target.val().length - _maxTextLength) + "字。";
|
|
break;
|
|
case SendMessageResult.NO_ALLOW_TEXT:
|
|
tips = "您被管理员禁止打字。";
|
|
break;
|
|
case SendMessageResult.MESSAGE_REPETITION:
|
|
tips = "请不要发送重复信息。";
|
|
break;
|
|
case SendMessageResult.MEMBER_SEND_URL_LIMIT:
|
|
tips = "管理员禁止嘉宾和会员发送URL和飞机票";
|
|
break;
|
|
case SendMessageResult.VISITOR_SEND_URL_LIMIT:
|
|
tips = "管理员禁止游客发送URL和飞机票";
|
|
break;
|
|
case SendMessageResult.VISITOR_SEND_IMAGE_LIMIT:
|
|
tips = "<a href='http://vip.yy.com/vip/introduction?src=channelpic#16'>发图功能暂支持不超过500人在线的子频道</a>";
|
|
break;
|
|
case SendMessageResult.VISITOR_SEND_IMAGE_LIMIT2:
|
|
tips = "<a href='http://vip.yy.com/vip/introduction?src=channelpic#16' target='_blank'>频道会员或YY会员到达VIP1才能发图。>>了解详情</a>";
|
|
break;
|
|
case SendMessageResult.LIMIT_SEND_MESSAGE:
|
|
tips = "当前频道限制了文字聊天";
|
|
break;
|
|
case 15 || 266:
|
|
tips = "为了您的账户安全,请绑定手机后发言。<a href='http://aq.yy.com/welcome.do' target='_blank'>\n<font color='#ff0000'>绑定手机</font></a>";
|
|
break;
|
|
default:
|
|
tips = sendRs + "";
|
|
break;
|
|
}
|
|
if(sendRs == 15 || sendRs == 266)
|
|
t.noticeMe(tips);
|
|
}
|
|
|
|
, noticeMe: function (msg) {
|
|
if (!msg) return;
|
|
var t = this;
|
|
if (t.noticeTimeout) {
|
|
clearTimeout(t.noticeTimeout);
|
|
t.noticeTimeout = null;
|
|
}
|
|
$("#" + t.tipsId + " p").html(msg);
|
|
$("#" + t.tipsId).show();
|
|
t.noticeTimeout = setTimeout(function () { $("#" + t.tipsId).hide(); t.noticeTimeout = null; }, 3000);
|
|
}
|
|
|
|
, noticeClose: function () {
|
|
$("#" + this.tipsId).hide();
|
|
}
|
|
, noticeInit: function () {
|
|
$("#" + this.tipsId + " a").click(function () {
|
|
$(this).parent().hide();
|
|
});
|
|
}
|
|
|
|
};
|
|
|
|
$.uiwidget.SmilerUI = function (target, cfg) {
|
|
this.target = target;
|
|
$.extend(this, cfg);
|
|
};
|
|
|
|
$.uiwidget.SmilerUI.prototype = {
|
|
displayState: null
|
|
, smilarTagMap: {}
|
|
, matchPrefix: "/{"
|
|
, minKeyLen: 2
|
|
, maxKeyLen: 6//最小最大表情字母
|
|
, selectAreaId: ''
|
|
, selectBtId: ''//表情选择按钮
|
|
, init: function () {
|
|
//console.info("SmilerUI init ....");
|
|
var smilerListObj = this.smilerListObj;
|
|
var len = smilerListObj.length;
|
|
var html = '';
|
|
for (var i = 0; i < len; i++) {
|
|
html = '<tr>';
|
|
for (var j = 0; j < smilerListObj[i].length; j++) {
|
|
var item = smilerListObj[i][j];
|
|
html += '<td title="/{' + item.tag + ' ' + item.text + '"><span class="face-icon ' + (item.css || item.tag) + '" tag="' + item.tag + '"></span></td>';
|
|
this.smilarTagMap[item.tag] = item.css || item.tag;
|
|
}
|
|
html += '</tr>';
|
|
this.target.find(" tbody").append(html);
|
|
}
|
|
this.smilePopUp();
|
|
this.smileIdentify(this.target);
|
|
//console.info("SmilerUI end ....");
|
|
}
|
|
, filter: function (msg, beginPostion) {
|
|
beginPostion = beginPostion || 0;
|
|
var t = this;
|
|
var firstIndex = msg.indexOf(t.matchPrefix, beginPostion);
|
|
var matchLastIndex = firstIndex + t.matchPrefix.length;
|
|
|
|
if (firstIndex != -1 && msg.length >= (matchLastIndex + t.minKeyLen)) {//表示必须是满足4个字符:/{XX
|
|
var eachMatchLastIndex = matchLastIndex;
|
|
for (var i = t.minKeyLen; i < t.maxKeyLen; i++) {
|
|
eachMatchLastIndex = matchLastIndex + i;
|
|
if (msg.length < eachMatchLastIndex) {
|
|
break;
|
|
}
|
|
var smRp = msg.substr(matchLastIndex, i);
|
|
if (t.smilarTagMap[smRp]) {
|
|
msg = msg.replace(new RegExp(t.matchPrefix + smRp, "gm"), '<span class="face-icon ' + t.smilarTagMap[smRp] + '"></span>');
|
|
break;
|
|
}
|
|
}
|
|
beginPostion = eachMatchLastIndex - 1;
|
|
return t.filter(msg, beginPostion);
|
|
}
|
|
return msg;
|
|
}
|
|
, isShowPopup: function () {
|
|
return true;
|
|
}
|
|
, smilePopUp: function () {
|
|
var t = this;
|
|
t.displayState = 0;
|
|
|
|
yyapi.addSmileboxListener(function (data) {
|
|
t.renderSmile(data.shortcut);
|
|
});
|
|
|
|
|
|
$("#" + t.selectBtId).click(function (event) {
|
|
|
|
pubEvent.trigerEvent("increaseZindex", { type: 'opr-box' });
|
|
|
|
if (!t.isShowPopup()) {
|
|
return false;
|
|
}
|
|
|
|
if (t.displayState == 0) {
|
|
//console.info("smilePopUp show");
|
|
//var smilebox = t.target;
|
|
//smilebox.show();
|
|
//t.displayState=1;
|
|
//t.tableHover();
|
|
//t.clickHide(smilebox);
|
|
var px = event.screenX - 5;
|
|
var py = event.screenY - 320;
|
|
if (px + 422 > window.screen.width)
|
|
px = window.screen.width - 422;
|
|
yyapi.showSmilebox(px, py);
|
|
}
|
|
else {
|
|
//console.info("hideSmilebox");
|
|
t.hideSmilebox();
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;//停止冒泡
|
|
});
|
|
}
|
|
|
|
, tableHover: function () {
|
|
this.target.find("table td").hover(function () {
|
|
$(this).addClass("on");
|
|
}, function () {
|
|
$(this).removeClass("on");
|
|
});
|
|
}
|
|
|
|
, smileIdentify: function (smilebox) {
|
|
var t = this;
|
|
var smilebox = t.target;
|
|
smilebox.find("table td span").click(function () {
|
|
var tag = $(this).attr("tag");
|
|
t.renderSmile(tag);
|
|
t.hideSmilebox();
|
|
return false;//停止冒泡
|
|
});
|
|
}
|
|
, clickHide: function (smilebox) {
|
|
var t = this;
|
|
$("body").bind("click", { t: t }, t.hideSmilebox);
|
|
}
|
|
, hideSmilebox: function (e) {
|
|
var t = e ? e.data.t : this;
|
|
var smilebox = t.target;
|
|
smilebox.hide();
|
|
t.displayState = 0;
|
|
$("body").unbind("click", t.hideSmilebox);
|
|
}
|
|
, renderSmile: function (tag) {
|
|
//this.inputObj.insertAtCursor('/{'+tag);
|
|
//this.target.trigger("contentChange",this.matchPrefix + tag);
|
|
this.target.trigger("contentChange", tag);
|
|
}
|
|
|
|
, addChangeListener: function (fn, obj) {
|
|
this.addEventListener("contentChange", fn, obj);
|
|
}
|
|
|
|
, addEventListener: function (evt, fn, obj) {
|
|
var t = this;
|
|
t.target.bind(evt, { fn: fn, obj: obj }, function (e, data) {
|
|
var fn = e.data.fn;
|
|
if (fn) {
|
|
var obj = e.data.obj || t;
|
|
return fn.call(obj, data);
|
|
}
|
|
});
|
|
}
|
|
|
|
, smilerListObj: [
|
|
[
|
|
{ tag: "dx", text: "大笑" },
|
|
{ tag: "pz", text: "撇嘴" },
|
|
{ tag: "fn", text: "发怒" },
|
|
{ tag: "tp", text: "调皮" },
|
|
{ tag: "jy", text: "惊讶" },
|
|
{ tag: "ot", text: "呕吐" },
|
|
{ tag: "ng", text: "难过" },
|
|
{ tag: "hk", text: "很酷" },
|
|
{ tag: "kz", text: "口罩" },
|
|
{ tag: "wx", text: "微笑" },
|
|
{ tag: "se", text: "色" },
|
|
{ tag: "tx", text: "偷笑" }
|
|
],
|
|
|
|
[
|
|
{ tag: "lh", text: "流汗" },
|
|
{ tag: "hp", text: "害怕" },
|
|
{ css: "am", tag: "am", text: "傲慢" },
|
|
{ tag: "kun", text: "困" },
|
|
{ tag: "by", text: "白眼" },
|
|
{ tag: "ka", text: "可爱" },
|
|
{ tag: "cy", text: "抽烟" },
|
|
{ tag: "kx", text: "开心" },
|
|
{ tag: "ll", text: "流泪" },
|
|
{ tag: "fd", text: "奋斗" },
|
|
{ tag: "yw", text: "疑问" },
|
|
{ tag: "xu", text: "嘘" }
|
|
],
|
|
|
|
[
|
|
{ tag: "yun", text: "晕" },
|
|
{ tag: "zs", text: "衰" },
|
|
{ tag: "88", css: "bb", text: "拜拜" },
|
|
{ tag: "qd", text: "敲打" },
|
|
{ tag: "kl", text: "骷髅" },
|
|
{ tag: "dy", text: "得意" },
|
|
{ tag: "hx", text: "害羞" },
|
|
{ tag: "bz", text: "闭嘴" },
|
|
{ tag: "yb", text: "拥抱" },
|
|
{ tag: "dai", text: "发呆" },
|
|
{ tag: "sj", text: "睡觉" },
|
|
{ tag: "zt", text: "猪头" }
|
|
],
|
|
|
|
[
|
|
{ tag: "gz", text: "鼓掌" },
|
|
{ tag: "qq", text: "亲亲" },
|
|
{ tag: "kb", text: "抠鼻" },
|
|
{ tag: "wq", text: "委屈" },
|
|
{ tag: "yx", text: "阴险" },
|
|
{ tag: "kel", text: "可怜" },
|
|
{ tag: "bs", text: "鄙视" },
|
|
{ tag: "zk", text: "抓狂" },
|
|
{ tag: "bq", text: "抱拳" },
|
|
{ tag: "ok", text: "OK" },
|
|
{ tag: "zan", text: "赞" },
|
|
{ tag: "ruo", text: "弱" }
|
|
],
|
|
|
|
[
|
|
{ tag: "ws", text: "握手" },
|
|
{ tag: "sl", text: "胜利" },
|
|
{ tag: "mg", text: "玫瑰" },
|
|
{ tag: "kw", text: "枯萎" },
|
|
{ tag: "wen", text: "吻" },
|
|
{ tag: "xd", text: "心动" },
|
|
{ tag: "xs", text: "心碎" },
|
|
{ tag: "lw", text: "礼物" },
|
|
{ tag: "sd", text: "闪电" },
|
|
{ tag: "zd", text: "炸弹" },
|
|
{ tag: "dao", text: "刀子" },
|
|
{ tag: "cc", text: "臭臭" }
|
|
]
|
|
]
|
|
};
|
|
|
|
$.uiwidget.PrivateUI = function (target, cfg) {
|
|
this.target = target;
|
|
$.extend(this, cfg);
|
|
};
|
|
|
|
$.uiwidget.PrivateUI.prototype = {
|
|
context: null,
|
|
pubicChat: null,
|
|
privChatlist: null,
|
|
expandbar: null,
|
|
primsgBtn: null,
|
|
closePriBtn: null,
|
|
userDropdownListObj: null,
|
|
messageTip: null,
|
|
receMesssageState: 0,//0表示没有新消息
|
|
init: function () {
|
|
var t = this;
|
|
logger.debug(['privateUI init', t]);
|
|
|
|
t.privChatlist = t.target.find(".priv-chatlist");
|
|
t.userDropdownListObj = t.target.find(".user-list");
|
|
t.expandbar = t.target.find(".expand-bar");
|
|
t.messageTip = $("#primsg_bt");
|
|
t.primsgBtn = $("#primsg_bt");
|
|
t.closePriBtn = $("#close_pri_bt");
|
|
|
|
t.target.click(function () {
|
|
t.increasePrivChatBoxZindex();
|
|
})
|
|
|
|
t.target.mouseenter(function () {
|
|
t.onMouseenter();
|
|
});
|
|
t.target.mouseleave(function () {
|
|
t.onMouseleave();
|
|
});
|
|
t.expandbar.click(function () {
|
|
//t.expandChatInputBox();
|
|
});
|
|
t.messageTip.click(function () {
|
|
//t.togglePrivChatBox();
|
|
});
|
|
|
|
t.primsgBtn.click(function () {
|
|
t.togglePrivChatBox();
|
|
});
|
|
|
|
t.closePriBtn.click(function () {
|
|
t.togglePrivChatBox();
|
|
});
|
|
|
|
t.privChatlist.on("click", "span.name", function () {
|
|
var span = this;
|
|
pubEvent.trigerEvent("pubNickClick", { target: span, type: 'privMsg' });
|
|
});
|
|
t.privChatlist.on("click", ".pub-custom-img", function () {
|
|
var img = this;
|
|
t.publicChat.onCustomImageClick(img);
|
|
})
|
|
|
|
t.createScrollbar();
|
|
t.createUserList();
|
|
t.expandChatInputBox();
|
|
t.minChatBox();
|
|
t.togglePrivChatBox();
|
|
t.togglePrivChatBox();
|
|
},
|
|
increasePrivChatBoxZindex: function () {
|
|
var t = this;
|
|
var box = t.target;
|
|
var index = t.pubicChat.getIncreaseZindex();
|
|
box.css("z-index", index);
|
|
},
|
|
isExpandPri: false,
|
|
//关闭私聊
|
|
minChatBox: function () {
|
|
var t = this;
|
|
//resize pub
|
|
t.isExpandPri = false;
|
|
t.target.hide();
|
|
yyapi.minChatBox();
|
|
t.pubicChat.scrollbar.scrollToBottom();
|
|
},
|
|
//打开私聊
|
|
maxChatBox: function () {
|
|
var t = this;
|
|
t.isExpandPri = true;
|
|
t.target.show();
|
|
yyapi.maxChatBox();
|
|
t.pubicChat.scrollbar.scrollToBottom();
|
|
},
|
|
createUserList: function () {
|
|
var t = this;
|
|
t.userDropdownListObj.on("click", ".user-val,.dd-status", function () {
|
|
|
|
if ($(this).hasClass("dd-status-close")) {//如果是关闭按钮
|
|
var dd = t.userDropdownListObj.find("li:first");
|
|
t.changeChatTargetUser(dd);
|
|
} else {
|
|
t.toggleUserDropdownBox()
|
|
}
|
|
|
|
t.increasePrivChatBoxZindex();
|
|
|
|
return false;
|
|
});
|
|
t.userDropdownListObj.on("click", "li", function () {
|
|
t.changeChatTargetUser(this);
|
|
});
|
|
pubEvent.addEvent("pubNickClick", function (obj) {
|
|
var span = obj.target;
|
|
var uid = $(span).attr("data-uid") || "",
|
|
yyno = $(span).attr("data-yyno") || "",
|
|
nick = $(span).text(),
|
|
role = $(span).attr('data-role') || "";
|
|
t.addUserToList(uid,nick,role,yyno);
|
|
});
|
|
|
|
},
|
|
changeChatTargetUser: function (target) {
|
|
var t = this,
|
|
li = $(target),
|
|
textbox = t.userDropdownListObj.find(".user-val .tex"),
|
|
ddstatus = t.userDropdownListObj.find(".dd-status");
|
|
|
|
var text = li.text();
|
|
var uid = li.attr("data-uid");
|
|
textbox.text(text).attr({ "data-uid": uid });
|
|
|
|
if (uid) {
|
|
ddstatus.addClass("dd-status-close");
|
|
} else {
|
|
ddstatus.removeClass("dd-status-close");
|
|
}
|
|
|
|
},
|
|
togglePrivChatBox: function () {
|
|
var t = this;
|
|
if (t.target.hasClass("private-chat-min")) {
|
|
t.target.removeClass("private-chat-min");
|
|
t.target.show();
|
|
t.maxChatBox();
|
|
} else {
|
|
t.target.addClass("private-chat-min");
|
|
t.target.hide();
|
|
t.minChatBox();
|
|
}
|
|
|
|
t.receMesssageState = 0;
|
|
t.checkMessageTipStatus();
|
|
t.scrollbar.scrollToBottom();
|
|
},
|
|
showInChatBox: function () {
|
|
var t = this;
|
|
if (t.target.hasClass("private-chat-min")) {
|
|
t.target.removeClass("private-chat-min");
|
|
t.target.show();
|
|
t.maxChatBox();
|
|
}
|
|
|
|
t.receMesssageState = 0;
|
|
t.checkMessageTipStatus();
|
|
t.scrollbar.scrollToBottom();
|
|
},
|
|
isEpandChatInputFLag: false,
|
|
//扩大或缩小输入区域
|
|
expandChatInputBox: function () {
|
|
var t = this;
|
|
if (!t.isEpandChatInputFLag) {
|
|
t.isEpandChatInputFLag = true;
|
|
$(".chat-opr").height(40 * 1.3);
|
|
$("#pub_msg_input").height(16 * 1.5);
|
|
$(".expand-bar").addClass("expand-bar-up");
|
|
$(".chatNotice").css("bottom", 40 * 1.3 + "px");
|
|
t.minChatBox();
|
|
}
|
|
else {
|
|
t.isEpandChatInputFLag = false;
|
|
$(".chat-opr").height(85);
|
|
$("#pub_msg_input").height(70);
|
|
$(".expand-bar").removeClass("expand-bar-up");
|
|
$(".chatNotice").css("bottom", "86px");
|
|
t.minChatBox();
|
|
}
|
|
},
|
|
isChatBoxMinimize: function () {
|
|
var t = this;
|
|
return t.target.hasClass("private-chat-min");
|
|
},
|
|
toggleUserDropdownBox: function () {
|
|
var t = this;
|
|
var dd = t.userDropdownListObj.find(".user-dd");
|
|
if (dd.is(":visible")) {
|
|
t.hideUserDropdownBox({ data: { target: dd } });
|
|
} else {
|
|
t.showUserDropdownBox(dd);
|
|
}
|
|
$(dd).css("top","-" + $(dd).height() + "px");
|
|
},
|
|
showUserDropdownBox: function (dd) {
|
|
var t = this;
|
|
dd.show();
|
|
$("body").on("click", { target: dd }, t.hideUserDropdownBox);
|
|
},
|
|
hideUserDropdownBox: function (e) {
|
|
var t = this;
|
|
var box = e.data.target;
|
|
box.hide();
|
|
$("body").unbind("click", t.hideUserDropdownBox);
|
|
},
|
|
addUserToList: function (uid,nick,role,yyno) {
|
|
var t = this;
|
|
if (uid == yyapi.getMyUserInfo().uid)
|
|
return;
|
|
nick = util.html_encode(nick);
|
|
if(yyno)
|
|
yyno = "(" + yyno +")";
|
|
var li = '<li data-yyno="'+yyno+'" data-uid="' + uid + '" data-nick="" data-role="' + role + '">' + nick + yyno + '</li>';
|
|
|
|
|
|
|
|
var ul = t.userDropdownListObj.find(".user-dd ul");
|
|
var oldli = ul.find("li[data-uid='" + uid + "']");
|
|
if (oldli.length) {
|
|
t.changeChatTargetUser(oldli);
|
|
} else {
|
|
ul.append(li);
|
|
t.changeChatTargetUser(li);
|
|
}
|
|
|
|
if (ul.find("li").length > 10) {
|
|
ul.find("li:eq(1)").remove();
|
|
}
|
|
|
|
|
|
},
|
|
createScrollbar: function () {
|
|
var t = this;
|
|
t.scrollbar.obj = t.target.find(".priv-text");
|
|
t.scrollbar.init(t);
|
|
},
|
|
scrollbar: {
|
|
api: null
|
|
, obj: null
|
|
, config: { autoReinitialise: true, scrollbarWidth: 20, mouseWheelSpeed: 20, stickToBottom: true }
|
|
, panne: null
|
|
, init: function (panne) {
|
|
var t = this;
|
|
t.panne = panne;
|
|
if (!t.obj) return;
|
|
$(t.obj).slimscroll({
|
|
color:"#cfcfcf",
|
|
size: '10px',
|
|
distance : "3px",
|
|
start : "bottom",
|
|
height : "125px",
|
|
alwaysVisible: true
|
|
});
|
|
}
|
|
|
|
, extendsConfig: function (config) {
|
|
var t = this;
|
|
if (config) {
|
|
t.config = $.extend({}, t.config, config);
|
|
}
|
|
}
|
|
, scrollToBottom: function () {
|
|
var t = this;
|
|
|
|
var it2 = setTimeout(function() {
|
|
clearTimeout(it2);
|
|
$(t.obj).slimScroll({ scrollTo: '9999px' });
|
|
}, 200);
|
|
|
|
}
|
|
}
|
|
, onMouseenter: function () {
|
|
this.isOnMouseEnter = true;
|
|
|
|
}
|
|
, onMouseleave: function () {
|
|
this.isOnMouseEnter = false;
|
|
|
|
},
|
|
isPrivateChatMode: function () {
|
|
var t = this;
|
|
var uid = t.getCurrentPrivChatUid();
|
|
return uid != undefined && uid != "";
|
|
},
|
|
getCurrentPrivChatUid: function () {
|
|
var t = this;
|
|
var uid = t.target.find(".user-val .tex").attr("data-uid");
|
|
return uid;
|
|
},
|
|
getCurrentPrivChatNick: function () {
|
|
var t = this;
|
|
var nick = t.target.find(".user-val .tex").text();
|
|
return nick;
|
|
},
|
|
checkMessageTipStatus: function () {
|
|
var t = this;
|
|
if (t.messageTipTimer) {
|
|
clearInterval(t.messageTipTimer);
|
|
}
|
|
if (t.isChatBoxMinimize() && t.receMesssageState == 1) {//最小化
|
|
t.messageTipTimer = setInterval(function () {
|
|
t.messageTip.toggleClass("ico-primsg-ling");
|
|
}, 300);
|
|
} else {
|
|
clearInterval(t.messageTipTimer);
|
|
t.messageTip.removeClass("ico-primsg-ling");
|
|
}
|
|
},
|
|
sendPrivReq: function (msg) {
|
|
var t = this;
|
|
var uid = t.getCurrentPrivChatUid();
|
|
var nick = t.getCurrentPrivChatNick();
|
|
var param = {
|
|
msg: msg,
|
|
toUid: uid,
|
|
toUser: {
|
|
nickname: util.html_encode(nick),
|
|
uid: uid
|
|
},
|
|
fontInfo: t.pubicChat.getFontInfo()
|
|
};
|
|
var res = t.context.send('sendPrivateMessage', param);
|
|
logger.debug(["send priv msg res", res]);
|
|
var sendRs = res.result;
|
|
if (sendRs == SendMessageResult.SUCCEESS)
|
|
t.buildSendPrivReq(param)
|
|
|
|
return res;
|
|
},
|
|
buildSendPrivReq: function (obj) {
|
|
var t = this;
|
|
|
|
var msg = "";
|
|
try {
|
|
msg = decodeURI(obj.msg);
|
|
} catch (e) {
|
|
msg = obj.msg;
|
|
}
|
|
if (t.pubicChat.filterMsg) {
|
|
msg = t.pubicChat.filterMsg(msg);
|
|
}
|
|
msg = t.pubicChat.chatInput.filterContent(msg);
|
|
if (t.pubicChat.filterVipFace) {
|
|
msg = t.pubicChat.filterVipFace(msg);
|
|
}
|
|
if (t.pubicChat.filterAirTicket) {
|
|
msg = t.pubicChat.filterAirTicket(msg);
|
|
}
|
|
if (t.pubicChat.filterAirTicket2) {
|
|
msg = t.pubicChat.filterAirTicket2(msg);
|
|
}
|
|
if (t.pubicChat.filterCustomImage) {
|
|
msg = t.pubicChat.filterCustomImage(msg);
|
|
}
|
|
var time = t.pubicChat.getTimeHTML(obj);
|
|
|
|
var yyno = "";
|
|
if (obj.toUser.yyno) {
|
|
yyno = '<span class="time">('+ obj.toUser.yyno + ')</span>';
|
|
}
|
|
|
|
var nickName = t.pubicChat.wrapFromUser(obj.toUser);
|
|
var msgStyle = t.pubicChat.getMessageStyle(obj.fontInfo);
|
|
var content = '<li><p><span class="prvi-chat-name">你</span> '
|
|
+ '<span class="priv-chat-label">对</span> <span class="prvi-chat-name">'
|
|
+ nickName + yyno + '</span><span class="priv-chat-label"> 说:</span>' + time + '</p>'
|
|
+ '<p class="text-content" style="' + msgStyle + '">' + msg + '</p></li>';
|
|
|
|
|
|
t.privChatlist.append(content);
|
|
|
|
t.scrollbar.scrollToBottom();
|
|
|
|
},
|
|
receMsg: function (obj) {
|
|
var t = this;
|
|
var msg = "";
|
|
try {
|
|
msg = decodeURI(obj.msg);
|
|
} catch (e) {
|
|
msg = obj.msg;
|
|
}
|
|
if (t.pubicChat.filterMsg) {
|
|
msg = t.pubicChat.filterMsg(msg);
|
|
}
|
|
msg = t.pubicChat.chatInput.filterContent(msg);
|
|
if (t.pubicChat.filterVipFace) {
|
|
msg = t.pubicChat.filterVipFace(msg);
|
|
}
|
|
if (t.pubicChat.filterAirTicket) {
|
|
msg = t.pubicChat.filterAirTicket(msg);
|
|
}
|
|
if (t.pubicChat.filterAirTicket2) {
|
|
msg = t.pubicChat.filterAirTicket2(msg);
|
|
}
|
|
var time = t.pubicChat.getTimeHTML(obj);
|
|
var yyno = "";
|
|
if (obj.fromUser.yyno) {
|
|
yyno = '<span class="time">('+ obj.fromUser.yyno + ')</span>';
|
|
}
|
|
var nickName = " " + t.pubicChat.wrapFromUser(obj.fromUser);
|
|
var msgStyle = t.pubicChat.getMessageStyle(obj.fontInfo);
|
|
|
|
var content = '<li><p><span class="prvi-chat-name">'
|
|
+ nickName + yyno + '</span> '
|
|
+ '<span class="priv-chat-label">对</span> <span class="prvi-chat-name">你</span><span class="priv-chat-label"> 说:</span>' + time + '</p>'
|
|
+ '<p class="text-content" style="' + msgStyle + '">' + msg + '</p></li>';
|
|
|
|
|
|
t.privChatlist.append(content);
|
|
|
|
t.receMesssageState = 1;
|
|
|
|
t.checkMessageTipStatus();
|
|
|
|
t.scrollbar.scrollToBottom();
|
|
}
|
|
};
|
|
|
|
$.fn.chatInput = function (cfg) {
|
|
return new $.uiwidget.ChatInput(this, cfg);
|
|
}
|
|
|
|
$.fn.smilerUI = function (cfg) {
|
|
return new $.uiwidget.SmilerUI(this, cfg);
|
|
}
|
|
|
|
$.fn.publicUI = function (cfg) {
|
|
return new $.uiwidget.PublicUI(this, cfg);
|
|
}
|
|
$.fn.privateUI = function (cfg) {
|
|
return new $.uiwidget.PrivateUI(this, cfg);
|
|
}
|
|
})(jQuery);
|
|
|
|
var _mjManager = {
|
|
/**
|
|
* 根据马甲代号和性别取马甲
|
|
*/
|
|
getMj: function (role, sex) {
|
|
sex = sex == 1 ? 'm' : 'f';
|
|
var mjMaxType = '';
|
|
switch (role) {
|
|
case UserRole.VIP:
|
|
mjMaxType = 1;
|
|
break;
|
|
case UserRole.TMPVIP:
|
|
mjMaxType = 2;
|
|
break;
|
|
case UserRole.OWNER:
|
|
mjMaxType = 3;
|
|
break;
|
|
case UserRole.NORMAL:
|
|
mjMaxType = 4;
|
|
break;
|
|
case UserRole.VICE_OWNER:
|
|
mjMaxType = 5;
|
|
break;
|
|
case UserRole.MANANGER:
|
|
mjMaxType = 6;
|
|
break;
|
|
case UserRole.CMANAGER:
|
|
mjMaxType = 7;
|
|
break;
|
|
case UserRole.SECOND_CMANAGER:
|
|
mjMaxType = 8;
|
|
break;
|
|
case UserRole.SA:
|
|
mjMaxType = 9;
|
|
break;
|
|
case UserRole.MEMBER:
|
|
mjMaxType = 10;
|
|
break;
|
|
case UserRole.NUL_ROLE:
|
|
mjMaxType = 11;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
//console.info("role:"+role+",sex:"+sex);
|
|
if (mjMaxType) {
|
|
|
|
return '<span class="mj mj-' + sex + mjMaxType + '"></span>';
|
|
}
|
|
return "";
|
|
},
|
|
/**
|
|
* 根据role获取马甲含义
|
|
*/
|
|
getMjName: function (role) {
|
|
var str = "";
|
|
switch (role) {
|
|
case UserRole.CMANAGER:
|
|
str = "子频道管理员(CA1)";
|
|
break;
|
|
case UserRole.SECOND_CMANAGER:
|
|
str = "子频道管理员(CA2)";
|
|
break;
|
|
case UserRole.MANANGER:
|
|
str = "全频道管理员(MA)";
|
|
break;
|
|
case UserRole.MEMBER:
|
|
str = "会员(R)";
|
|
break;
|
|
case UserRole.NORMAL:
|
|
str = "游客(U)";
|
|
break;
|
|
case UserRole.OWNER:
|
|
str = "频道所有者(OW)";
|
|
break;
|
|
case UserRole.SA:
|
|
str = "歪歪官方人员";
|
|
break;
|
|
case UserRole.TMPVIP:
|
|
str = "临时嘉宾(G)";
|
|
break;
|
|
case UserRole.VICE_OWNER:
|
|
str = "频道总管理(VP)";
|
|
break;
|
|
case UserRole.VIP:
|
|
str = "嘉宾(VIP)";
|
|
break;
|
|
}
|
|
return str;
|
|
}
|
|
};
|
|
|
|
//选择“禁止/允许说话” “禁止/允许打字”时发出
|
|
var UserCapability = {
|
|
ENABLE_TEXT: 0,//允许打字
|
|
DISABLE_TEXT: 1,//禁止打字
|
|
ENABLE_VOICE: 2,//允许说话
|
|
DISABLE_VOICE: 3//禁止说话
|
|
};
|
|
|
|
var ChannelPunish = {
|
|
/// 禁用ID
|
|
BAN_ID: 3,
|
|
/// 禁用IP
|
|
BAN_IP: 4,
|
|
/// 踢出频道
|
|
KICK_OUT: 2,
|
|
/// 踢到上级频道
|
|
KICK_UP: 5
|
|
}
|
|
|
|
//用户角色
|
|
var UserRole = {
|
|
/// CA 子频道管理员
|
|
CMANAGER: 175,
|
|
/// UNUSE 未亡人
|
|
DELETED: 50,
|
|
/// CS 歪歪官方人员 + 全频道管理员
|
|
KEFU: 300,
|
|
/// MAN 全频道管理员
|
|
MANANGER: 200,
|
|
/// R 会员
|
|
MEMBER: 100,
|
|
/// U 游客
|
|
NORMAL: 25,
|
|
/// NULL 出错啦!
|
|
NUL_ROLE: 0,
|
|
/// OW 频道所有者
|
|
OWNER: 255,
|
|
/// PAP 管理员
|
|
PMANAGER: 180,
|
|
/// SA 歪歪官方人员
|
|
SA: 1000,
|
|
/// 二级子频道管理员
|
|
SECOND_CMANAGER: 150,
|
|
/// TMPVIP 临时嘉宾
|
|
TMPVIP: 66,
|
|
/// VO 频道总管理
|
|
VICE_OWNER: 230,
|
|
/// VIP 嘉宾
|
|
VIP: 88,
|
|
/// VISITOR 灰马
|
|
VISITOR: 20
|
|
}
|
|
|
|
//频道通知事件
|
|
var InformEvent = {
|
|
ADD_SUBCHANNEL_INFO: "add_subchannel_info",
|
|
/// 管理员设置接待频道 参数是 ChannelInfo
|
|
ADIMT_SUBCHANNEL_CHANGED_INFO: "admit_subchannel_changed_info",
|
|
/// 是否允许游客抢麦 参数是 ChannelDetailVo
|
|
ALLOW_GUEST_JOIN_MIC: "allow_guest_join_mic",
|
|
/// 是否允许游客说话 参数是 ChannelDetailVo
|
|
ALLOW_GUEST_SPEAK_MIC: "allow_guest_join_mic",
|
|
/// 取消接待频道 参数是 ChannelInfo
|
|
CANCEL_ADMIT_CHANNEL: "cancel_admit_channel",
|
|
//调度通知
|
|
CHANNEL_DRAG_NOTIFY: "channel_drag_notify",
|
|
/// 频道惩罚 (包括踢出子频道,禁ip等) 参数是 ChannelPunish
|
|
CHANNEL_PUNISH_INFO: "channel_punish_info",
|
|
//打字权限改变 (禁止所有人打字,禁止游客打字,允许所有人打字等设置改变)
|
|
CHANNEL_TEXT_LIMIT_CHANGED: "channel_text_limit_changed",
|
|
//默认麦序时间改变
|
|
DEFAULT_MIC_TIME_CHANGED: "default_mic_time_changed",
|
|
/// 鲜花通知 参数是 FlowerInfoVo
|
|
GIVE_FLOWER_INFO: "give_flower_info",
|
|
/// 匿名登陆说话(错误提示)
|
|
GUEST_LOGIN_TALK: "guest_login_talk",
|
|
/// 游客打字的最大长度变化 参数是 ChannelDetailVo
|
|
GUEST_MAX_TEXT_CHANGED: "guest_max_text_changed",
|
|
/// 游客不能输入变化 参数是 ChannelDetailVo
|
|
GUEST_NO_ENTER: "guest_no_enter_changed",
|
|
/// 游客等待时间改变 参数是 ChannelDetailVo
|
|
GUEST_WAIT_TIME: "guest_wait_time_changed",
|
|
/// 是否限制游客改变 参数是 ChannelDetailVo
|
|
IS_GUEST_LIMIT: "guest_limit_changed",
|
|
/// 是否限制打字改变 参数是 ChannelDetailVo
|
|
IS_TEXT_LIMIT: "is_text_limit_changed",
|
|
/// 允许抢麦
|
|
MIC_ABLE_INFO: "mic_able_info",
|
|
/// 管理员发起连麦
|
|
MIC_CONNECT_INFO: "mic_connect_info",
|
|
/// 不允许抢麦
|
|
MIC_DISABLE_INFO: "mic_disable_info",
|
|
/// 连麦结束
|
|
MIC_DISCONNECT_INFO: "mic_disconnect_info",
|
|
/// 麦序双倍时间消息
|
|
MIC_DOUBLE_TIME_INFO: "mic_double_time_info",
|
|
/// 麦序下移
|
|
MIC_DOWN_MOVE_INFO: "mic_down_mute_info",
|
|
/// 抱上麦序消息
|
|
MIC_DRAG_INFO: "mic_drag_info",
|
|
/// 邀请连麦
|
|
MIC_INVITE_CONNECT_INFO: "mic_invite_connect_info",
|
|
/// 麦序上的人是自己
|
|
MIC_IS_ME_SEND_FLOWER: "mic_is_me_send_flower",
|
|
/// 管理员控麦消息
|
|
MIC_IS_MUTE_INFO: "mic_mute_info",
|
|
/// 加入连麦
|
|
MIC_JOIN_CONNECT_INFO: "mic_add_connect_info",
|
|
/// 清空麦序
|
|
MIC_KICK_ALL_INFO: "mic_kick_all_info",
|
|
/// 离开麦序消息
|
|
MIC_KICK_INFO: "mic_kick_info",
|
|
/// 管理员放麦消息
|
|
MIC_NOT_MUTE_INFO: "mic_not_mute_info",
|
|
/// 当前麦序上没人 送花失败
|
|
MIC_NULL_SEND_FLOWER: "mic_null_send_flower",
|
|
/// 移到二号麦
|
|
MIC_SECOND_INFO: "mic_second_info",
|
|
/// 模式切换消息
|
|
MIC_STYLE_CHANGED_INFO: "mic_style_changed_info",
|
|
/// 麦序时间超过9999秒
|
|
MIC_TIME_MAX: "mic_time_max",
|
|
/// 麦序上移消息
|
|
MIC_UP_MOVE_INFO: "mic_up_move_info",
|
|
/// 不是麦序模式送花
|
|
NOT_MIC_SEND_FLOWER: "not_mic_send_flower",
|
|
/// 移除频道消息 参数是 Vector类型元素是ChannelInfo
|
|
REMOVE_SUBCHANNEL_INFO: "remove_subchannel_info",
|
|
/// 被管理员设为按键说话
|
|
SET_KET_TALK_INFO: "set_ket_talk_info",
|
|
/// 麦序模式改变 参数是 ChannelDetailVo
|
|
STYLE_CHANGED: "micqueue_style_changed",
|
|
/// 限制打字是否只对游客有效改变 参数是 ChannelDetailVo
|
|
TEXT_LIMIT_GUEST_ONLY: "text_limit_guest_only_changed",
|
|
/// 限制文字打字时间 参数是 ChannelDetailVo
|
|
TEXT_LIMIT_INTERVEL: "text_limit_internal_changed",
|
|
/// 频道的用户权限改变 参数是 UserCapability
|
|
USER_CAPABILITY_CHANGED_INFO: "channel_user_capability_channge_info",
|
|
/// 用户马甲发生改变
|
|
USER_ROLE_CHANGED_INFO: "user_role_changed_info",
|
|
NORMAL_INFORM_MSG: "normal_inform_msg",
|
|
/// 送礼物的公屏信息
|
|
GIFT_SEND_INFO: "gift_send_info"
|
|
};
|
|
|
|
var SendMessageResult = {
|
|
/// 管理员禁止所有人打字
|
|
ALL_NO_SEND: 6,
|
|
/// 匿名登录发消息
|
|
GUEST_LOGIN_SEND: 1,
|
|
/// 游客等待时间不足(游客需要加入频道一段时间才能打字,由管理员设定)
|
|
GUEST_NEED_WAIT: 7,
|
|
/// 当前频道限制了文字聊天
|
|
LIMIT_SEND_MESSAGE: 4,
|
|
/// 超过最大字数限制
|
|
MAX_TEXT_ERROR: 2,
|
|
/// 管理员禁止嘉宾和会员发送URL和飞机票
|
|
MEMBER_SEND_URL_LIMIT: 11,
|
|
/// 消息内容为空
|
|
MESSAGE_IS_NULL: 9,
|
|
/// 说话内容重复 发送失败
|
|
MESSAGE_REPETITION: 8,
|
|
/// 被管理员禁止打字
|
|
NO_ALLOW_TEXT: 5,
|
|
/// 发送成功
|
|
SUCCEESS: 0,
|
|
/// 当前频道游客不能打字
|
|
VISITOR_NO_SEND: 3,
|
|
/// 管理员禁止游客发送URL和飞机票
|
|
VISITOR_SEND_URL_LIMIT: 10,
|
|
/// 发图功能暂支持不超过500人在线的子频道
|
|
VISITOR_SEND_IMAGE_LIMIT: 18,
|
|
/// 频道会员或YY会员到达VIP1才能发图。>>了解详情
|
|
VISITOR_SEND_IMAGE_LIMIT2: 19
|
|
};
|
|
|
|
|
|
|
|
}) |