...
|
...
|
@@ -12,7 +12,10 @@ var $ = require('yoho-jquery'), |
|
|
emojiMap = require('./emoji-map'),
|
|
|
editArea = require('./edit-area'),
|
|
|
broswer = require('./broswer'),
|
|
|
cursor = require('./cursor'),
|
|
|
send = require('./socket/send'),
|
|
|
edit = require('./socket/edit'),
|
|
|
util = require('./utility'),
|
|
|
socketChat = require('./socket/chat'),
|
|
|
socketConf = require('./socket/config'),
|
|
|
clipPaste = require('./clip-paste');
|
...
|
...
|
@@ -24,7 +27,6 @@ var allRTs, |
|
|
socketConfCM,
|
|
|
assetsPrefix,
|
|
|
cursorPosition,
|
|
|
configDomains,
|
|
|
hasMore = true,
|
|
|
titleInterval,
|
|
|
$html = $('html'),
|
...
|
...
|
@@ -59,13 +61,12 @@ var processInfo = { |
|
|
savedEval: false // 是否保存过评论
|
|
|
};
|
|
|
|
|
|
var key,
|
|
|
urls = {
|
|
|
makeEval: '/evalute/saveEvalute',
|
|
|
leaveMsg: '/leavemessage/saveLeavemessage',
|
|
|
msgHistory: '/conversationMessage/pageList',
|
|
|
evalReason: '/evalute/queryReasonByConversationId'
|
|
|
};
|
|
|
var urls = {
|
|
|
makeEval: '/evalute/saveEvalute',
|
|
|
leaveMsg: '/leavemessage/saveLeavemessage',
|
|
|
msgHistory: '/conversationMessage/pageList',
|
|
|
evalReason: '/evalute/queryReasonByConversationId'
|
|
|
};
|
|
|
|
|
|
require('bootstrap');
|
|
|
require('../common');
|
...
|
...
|
@@ -79,11 +80,18 @@ encryptedUid = $encryptedUid.val(); |
|
|
assetsPrefix = $assetsPrefix.val();
|
|
|
socketConfCM = socketConf.conversationMessage;
|
|
|
socketConfCM.encryptedUid = encryptedUid;
|
|
|
// 原始配置信息用于重新连线
|
|
|
originConf = JSON.parse(JSON.stringify(socketConf));
|
|
|
originConf = JSON.parse(JSON.stringify(socketConf)); // 原始配置
|
|
|
|
|
|
|
|
|
// url前缀添加
|
|
|
for (var key in urls) {
|
|
|
if (urls.hasOwnProperty(key)) {
|
|
|
urls[key] = gDomains.imCs + urls[key];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 页面初始化
|
|
|
function pageInit() {
|
|
|
var _loadPage = function() {
|
|
|
/**
|
|
|
* 添加新的消息
|
|
|
*/
|
...
|
...
|
@@ -93,48 +101,6 @@ function pageInit() { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 表情设置
|
|
|
* @param e
|
|
|
*/
|
|
|
function setEmoji(e) {
|
|
|
var i,
|
|
|
pos,
|
|
|
start,
|
|
|
end,
|
|
|
newVal,
|
|
|
textDom,
|
|
|
emojiText,
|
|
|
tag = $(e.target),
|
|
|
area = $('.msg-area'),
|
|
|
val = area.val(),
|
|
|
len = emojiMap.length,
|
|
|
emojiId = tag.data('id'),
|
|
|
comp = $('.emoji-component');
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
if (emojiMap[i].file === emojiId.toString()) {
|
|
|
emojiText = emojiMap[i].text;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (cursorPosition) {
|
|
|
start = val.substring(0, cursorPosition);
|
|
|
end = val.substring(cursorPosition);
|
|
|
newVal = [start, emojiText, end].join('');
|
|
|
} else {
|
|
|
newVal = [val, emojiText].join('');
|
|
|
}
|
|
|
|
|
|
comp.hide();
|
|
|
area.val(newVal);
|
|
|
cursorPosition += emojiText.length;
|
|
|
|
|
|
textDom = area[0];
|
|
|
pos = cursorPosition ? cursorPosition : newVal.length;
|
|
|
broswer.setCursor(textDom, pos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 系统通知
|
|
|
* @param tip 具体消息
|
|
|
*/
|
...
|
...
|
@@ -967,7 +933,7 @@ function pageInit() { |
|
|
dataType: 'json',
|
|
|
acceptFileTypes: /(\.|\/)(bmp|gif|jpe?g|png)$/i,
|
|
|
maxFileSize: 5000000, // 5M
|
|
|
url: configDomains.imCs + '/fileManage/uploadFile',
|
|
|
url: gDomains.imCs + '/fileManage/uploadFile',
|
|
|
progressall: function(e, data) {
|
|
|
var progress = parseInt(data.loaded / data.total * 100, 10);
|
|
|
|
...
|
...
|
@@ -1124,7 +1090,7 @@ function pageInit() { |
|
|
});
|
|
|
|
|
|
// 设置表情
|
|
|
$document.on('click', '.emoji-component .emoji', setEmoji);
|
|
|
$document.on('click', '.emoji-component .emoji', edit.setEmoji);
|
|
|
|
|
|
// 表情组件隐藏
|
|
|
$document.on('click', function(e) {
|
...
|
...
|
@@ -1160,7 +1126,7 @@ function pageInit() { |
|
|
|
|
|
// 失去焦点更新鼠标位置
|
|
|
$msgArea.on('blur', function() {
|
|
|
cursorPosition = $(this).getCursorPosition();
|
|
|
$(this).recordCursor();
|
|
|
});
|
|
|
|
|
|
// 消息图片放大显示
|
...
|
...
|
@@ -1194,34 +1160,14 @@ function pageInit() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
// 拉取域名信息
|
|
|
(function() {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/service/domains',
|
|
|
success: function(domains) {
|
|
|
configDomains = domains;
|
|
|
|
|
|
// url前缀添加
|
|
|
for (key in urls) {
|
|
|
if (urls.hasOwnProperty(key)) {
|
|
|
urls[key] = configDomains.imCs + urls[key];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 检查支持性
|
|
|
(function() {
|
|
|
if (!window.WebSocket) {
|
|
|
$('.un-support').show();
|
|
|
return false;
|
|
|
} else {
|
|
|
socketConf.servers.push(configDomains.imSocket);
|
|
|
pageInit();
|
|
|
}
|
|
|
}());
|
|
|
}
|
|
|
});
|
|
|
}());
|
|
|
// 检查支持性
|
|
|
if (util.isSupport()) {
|
|
|
socketConf.servers.push(gDomains.imSocket);
|
|
|
_loadPage();
|
|
|
} else {
|
|
|
$('.un-support').show();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 点击刷新提示
|
|
|
window.onbeforeunload = function() {
|
...
|
...
|
|