|
|
@@ -1,274 +1,294 @@
|
|
1
|
|
- var wst, objs = {}, lockReconnect = false;
|
|
2
|
|
-
|
|
3
|
|
- function CreateWebSockets() {
|
|
4
|
|
- try {
|
|
5
|
|
-// $("#conn").attr("disabled", "disabled");
|
|
|
1
|
+var wst, objs = {}, lockReconnect = false;
|
|
6
|
2
|
|
|
7
|
|
- Connects();
|
|
8
|
|
- } catch (e) {
|
|
9
|
|
- ReConnect();
|
|
10
|
|
- }
|
|
11
|
|
- }
|
|
12
|
|
- //连接
|
|
13
|
|
- function Connects() {
|
|
14
|
|
-// ws = new WebSocket("ws://192.168.4.18:4006");
|
|
15
|
|
-// ws = new WebSocket("ws://192.168.1.21:2021");
|
|
16
|
|
- wst = new WebSocket("ws://121.196.219.217:8007");
|
|
17
|
|
- wst.onopen = function () {
|
|
18
|
|
- console.log(new Date() + " " + "建立连接");
|
|
19
|
|
-// $("#conn").removeAttr("disabled");
|
|
20
|
|
- var userCode=$.cookie("zx_user");
|
|
21
|
|
- Conn(userCode); //注册
|
|
22
|
|
- lockReconnect = false;
|
|
23
|
|
- };
|
|
24
|
|
- //接收到消息的回调方法
|
|
25
|
|
- wst.onmessage = function (evt) {
|
|
26
|
|
- console.log(new Date() + " receive " + evt.data);
|
|
27
|
|
- var data = JSON.parse(evt.data);
|
|
28
|
|
- if (data) {
|
|
29
|
|
- var ele = $("#" + data.code).find(".chatlist_con")[0];
|
|
30
|
|
- var type = data.action;
|
|
31
|
|
- switch (type.toLowerCase()) {
|
|
32
|
|
- case "serconn":
|
|
33
|
|
- if (!data.state) {
|
|
34
|
|
- $(".error").text(data.msg);
|
|
35
|
|
- }
|
|
36
|
|
- else {
|
|
|
3
|
+function CreateWebSockets() {
|
|
|
4
|
+ try {
|
|
|
5
|
+ // $("#conn").attr("disabled", "disabled");
|
|
37
|
6
|
|
|
38
|
|
- $(".sidebar_list").empty();//sidebar
|
|
39
|
|
- $(".chat_main").empty();
|
|
40
|
|
- }
|
|
41
|
|
- break;
|
|
42
|
|
- case "sersend":
|
|
43
|
|
- if (data.state) {
|
|
44
|
|
- append(ele, "self", data.msg,data.code,data.time);
|
|
45
|
|
- $("#" + data.code).find(".send_content").val("");
|
|
46
|
|
- }
|
|
47
|
|
- else {
|
|
48
|
|
- notice(ele,"notice", data.msg);
|
|
49
|
|
- }
|
|
50
|
|
- break
|
|
51
|
|
- //case "sersenderror":
|
|
52
|
|
- // append("notice", data.msg);
|
|
53
|
|
- // break
|
|
54
|
|
- case "serreceive":
|
|
|
7
|
+ Connects();
|
|
|
8
|
+ } catch (e) {
|
|
|
9
|
+ ReConnect();
|
|
|
10
|
+ }
|
|
|
11
|
+}
|
|
|
12
|
+//连接
|
|
|
13
|
+function Connects() {
|
|
|
14
|
+ // ws = new WebSocket("ws://192.168.4.18:4006");
|
|
|
15
|
+ // ws = new WebSocket("ws://192.168.1.21:2021");
|
|
|
16
|
+ wst = new WebSocket("ws://192.168.8.10:2022");
|
|
|
17
|
+ wst.onopen = function () {
|
|
|
18
|
+ console.log(new Date() + " " + "建立连接");
|
|
|
19
|
+ // $("#conn").removeAttr("disabled");
|
|
|
20
|
+ var userCode = $.cookie("zx_user");
|
|
|
21
|
+ Conn(userCode); //注册
|
|
|
22
|
+ lockReconnect = false;
|
|
|
23
|
+ };
|
|
|
24
|
+ //接收到消息的回调方法
|
|
|
25
|
+ wst.onmessage = function (evt) {
|
|
|
26
|
+ console.log(new Date() + " receive " + evt.data);
|
|
|
27
|
+ var data = JSON.parse(evt.data);
|
|
|
28
|
+ if (data) {
|
|
|
29
|
+ var ele = $("#" + data.code).find(".chatlist_con")[0];
|
|
|
30
|
+ var type = data.action;
|
|
|
31
|
+ switch (type.toLowerCase()) {
|
|
|
32
|
+ case "serconn":
|
|
|
33
|
+ if (!data.state) {
|
|
|
34
|
+ $(".error").text(data.msg);
|
|
|
35
|
+ }
|
|
|
36
|
+ else {
|
|
55
|
37
|
|
|
56
|
|
- if (!ele) {
|
|
57
|
|
- $('.before').show();
|
|
58
|
|
- var first = '';
|
|
59
|
|
- if (!$(".sidebar_list li").length) {
|
|
60
|
|
- first = 'activess';
|
|
61
|
|
- }
|
|
62
|
|
-// var userhtml = '<span class="user ' + first + '" code="' + data.code + '">' + data.name + '</span>';
|
|
63
|
|
- var userhtml = '<li class="user '+ first +' li' + data.code + '" code="' + data.code + '">'+
|
|
64
|
|
- '<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>'+
|
|
65
|
|
- '<p class="chat_name">' + data.name + '</p>'+
|
|
66
|
|
- '<i class="fa fa-circle pie" style="color:red;"></i>'+
|
|
67
|
|
- '<i class="fa fa-remove closeds" onclick="removed(this)"></i>'+
|
|
68
|
|
- '</li>';
|
|
69
|
|
- $(userhtml).appendTo(".sidebar_list").click(function(){
|
|
70
|
|
- $(".user").removeClass("activess");
|
|
71
|
|
-// $(this).siblings('li').removeClass("actives");
|
|
72
|
|
- $(this).addClass("activess");
|
|
73
|
|
- $(this).find('.pie').removeClass('pieShow').addClass('pieHide');
|
|
74
|
|
- $('.open_chat').find('.before').removeClass('show').addClass('hide');
|
|
75
|
|
- $(".tabMain").removeClass("activess");
|
|
76
|
|
- $("#" + $(this).attr("code")).addClass("activess");
|
|
77
|
|
- var conul = $("#" + $(this).attr("code")).find(".chatlist_con");
|
|
78
|
|
- $(conul).scrollTop($(conul)[0].scrollHeight);
|
|
79
|
|
- });
|
|
80
|
|
- var tabhtml = '<div class="tabMain ' + first + '" id="' + data.code + '">'+
|
|
81
|
|
- '<div class="main_message">'+
|
|
82
|
|
- '<ul class="chatlist_con">'+
|
|
83
|
|
- '<a href="javascript:void(0)" class="more" onclick="getmore(\'' + data.code + '\')"><i class="fa fa-clock-o" style="margin-right: 5px;"></i>查看更多信息</a>'+
|
|
84
|
|
- '<input type="hidden" class="hidnum" />' +
|
|
85
|
|
- '</ul>'+
|
|
86
|
|
- '</div>'+
|
|
87
|
|
- '<div class="main_sendMessage ">'+
|
|
88
|
|
- '<textarea name=" " rows=" " cols=" " onkeypress="keySend(event)" placeholder="按Enter 发送 " class="send_content "></textarea>'+
|
|
89
|
|
- '<input type="hidden" class="hidcid" value="' + data.code + '" />'+
|
|
90
|
|
- '<div class="send_btn ">'+
|
|
91
|
|
- '<button class="sendTo " onclick="sendinfo(\'' + data.code + '\') ">发送(S)</button>'+
|
|
92
|
|
- '<span style="color:red; " class="senderror"></span>'+
|
|
93
|
|
- '</div>'+
|
|
94
|
|
- '</div>'+
|
|
95
|
|
- '</div>' ;
|
|
96
|
|
- $(".chat_main").append($(tabhtml));
|
|
97
|
|
- ele = $("#" + data.code).find(".chatlist_con")[0];
|
|
98
|
|
- objs.action = "loglist";
|
|
99
|
|
- objs.code = data.code;
|
|
100
|
|
- Sends();
|
|
101
|
|
- }
|
|
102
|
|
- if (!data.state) {
|
|
103
|
|
- notice(ele, "notice", data.msg);
|
|
104
|
|
- }
|
|
105
|
|
- else {
|
|
106
|
|
- append(ele, "left", data.msg ,data.code,data.time);
|
|
107
|
|
- }
|
|
108
|
|
-
|
|
109
|
|
- break; //收到消息
|
|
110
|
|
- case "loglist":
|
|
111
|
|
- var list = data.data.rows;
|
|
112
|
|
- $(list).each(function (i, n) {
|
|
113
|
|
- var classname = "self";
|
|
114
|
|
- if (n.F_FromUser == data.code) {
|
|
115
|
|
- classname = "left";
|
|
116
|
|
- }
|
|
117
|
|
- insert(ele, classname, n.F_Message, $("#" + data.code).find(".hidnum").val());
|
|
118
|
|
- })
|
|
119
|
|
- if (!data.data.isfirst) {
|
|
120
|
|
- $(ele).find(".more").css("display", "block");
|
|
121
|
|
- $("#" + data.code).find(".hidnum").val(data.data.num);
|
|
122
|
|
- }
|
|
123
|
|
- else {
|
|
124
|
|
- $(ele).find(".more").css("display", "none");
|
|
125
|
|
- }
|
|
|
38
|
+ $(".sidebar_list").empty();//sidebar
|
|
|
39
|
+ $(".chat_main").empty();
|
|
|
40
|
+ }
|
|
|
41
|
+ break;
|
|
|
42
|
+ case "sersend":
|
|
|
43
|
+ if (data.state) {
|
|
|
44
|
+ append(ele, "self", data.msg, data.code, data.time, data.humanclass);
|
|
|
45
|
+ $("#" + data.code).find(".send_content").val("");
|
|
|
46
|
+ }
|
|
|
47
|
+ else {
|
|
|
48
|
+ notice(ele, "notice", data.msg);
|
|
|
49
|
+ }
|
|
|
50
|
+ break
|
|
|
51
|
+ //case "sersenderror":
|
|
|
52
|
+ // append("notice", data.msg);
|
|
|
53
|
+ // break
|
|
|
54
|
+ case "serreceive":
|
|
126
|
55
|
|
|
127
|
|
- break;//聊天记录
|
|
|
56
|
+ if (!ele) {
|
|
|
57
|
+ $('.before').show();
|
|
|
58
|
+ var first = '';
|
|
|
59
|
+ if (!$(".sidebar_list li").length) {
|
|
|
60
|
+ first = 'activess';
|
|
|
61
|
+ }
|
|
|
62
|
+ // var userhtml = '<span class="user ' + first + '" code="' + data.code + '">' + data.name + '</span>';
|
|
|
63
|
+ var userhtml = '<li class="user ' + first + ' li' + data.code + '" code="' + data.code + '">' +
|
|
|
64
|
+ '<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>' +
|
|
|
65
|
+ '<p class="chat_name">' + data.name + '</p>' +
|
|
|
66
|
+ '<i class="fa fa-circle pie" style="color:red;"></i>' +
|
|
|
67
|
+ '<i class="fa fa-remove closeds" onclick="removed(this)"></i>' +
|
|
|
68
|
+ '</li>';
|
|
|
69
|
+ $(userhtml).appendTo(".sidebar_list").click(function () {
|
|
|
70
|
+ $(".user").removeClass("activess");
|
|
|
71
|
+ // $(this).siblings('li').removeClass("actives");
|
|
|
72
|
+ $(this).addClass("activess");
|
|
|
73
|
+ $(this).find('.pie').removeClass('pieShow').addClass('pieHide');
|
|
|
74
|
+ $('.open_chat').find('.before').removeClass('show').addClass('hide');
|
|
|
75
|
+ $(".tabMain").removeClass("activess");
|
|
|
76
|
+ $("#" + $(this).attr("code")).addClass("activess");
|
|
|
77
|
+ var conul = $("#" + $(this).attr("code")).find(".chatlist_con");
|
|
|
78
|
+ $(conul).scrollTop($(conul)[0].scrollHeight);
|
|
|
79
|
+ });
|
|
|
80
|
+ var tabhtml = '<div class="tabMain ' + first + '" id="' + data.code + '">' +
|
|
|
81
|
+ '<div class="main_message">' +
|
|
|
82
|
+ '<ul class="chatlist_con">' +
|
|
|
83
|
+ '<a href="javascript:void(0)" class="more" onclick="getmore(\'' + data.code + '\')"><i class="fa fa-clock-o" style="margin-right: 5px;"></i>查看更多信息</a>' +
|
|
|
84
|
+ '<input type="hidden" class="hidnum" />' +
|
|
|
85
|
+ '</ul>' +
|
|
|
86
|
+ '</div>' +
|
|
|
87
|
+ '<div class="main_sendMessage ">' +
|
|
|
88
|
+ '<textarea name=" " rows=" " cols=" " onkeypress="keySend(event)" placeholder="按Enter 发送 " class="send_content "></textarea>' +
|
|
|
89
|
+ '<input type="hidden" class="hidcid" value="' + data.code + '" />' +
|
|
|
90
|
+ '<div class="send_btn ">' +
|
|
|
91
|
+ '<button class="sendTo " onclick="sendinfo(\'' + data.code + '\') ">发送(S)</button>' +
|
|
|
92
|
+ '<span style="color:red; " class="senderror"></span>' +
|
|
|
93
|
+ '</div>' +
|
|
|
94
|
+ '</div>' +
|
|
|
95
|
+ '</div>';
|
|
|
96
|
+ $(".chat_main").append($(tabhtml));
|
|
|
97
|
+ ele = $("#" + data.code).find(".chatlist_con")[0];
|
|
|
98
|
+ objs.action = "loglist";
|
|
|
99
|
+ objs.code = data.code;
|
|
|
100
|
+ Sends();
|
|
|
101
|
+ }
|
|
|
102
|
+ if (!data.state) {
|
|
|
103
|
+ notice(ele, "notice", data.msg);
|
|
|
104
|
+ }
|
|
|
105
|
+ else {
|
|
|
106
|
+ append(ele, "left", data.msg, data.code, data.time, data.humanclass);
|
|
128
|
107
|
}
|
|
129
|
|
- }
|
|
130
|
|
- };
|
|
131
|
108
|
|
|
132
|
|
- //连接关闭的回调方法
|
|
133
|
|
- wst.onclose = function (evt) {
|
|
134
|
|
- console.log(new Date() + " " + "连接关闭");
|
|
135
|
|
- console.log(new Date() + " " + "开始重连");
|
|
136
|
|
- ReConnect();
|
|
137
|
|
- };
|
|
138
|
|
- //连接发生错误的回调方法
|
|
139
|
|
- wst.onerror = function (evt) {
|
|
140
|
|
- console.log(new Date() + " " + "连接异常");
|
|
141
|
|
- console.log(new Date() + " " + "开始重连");
|
|
142
|
|
- ReConnect();
|
|
143
|
|
- };
|
|
144
|
|
- }
|
|
145
|
|
- //重连
|
|
146
|
|
- function ReConnect() {
|
|
147
|
|
- if (!lockReconnect) {
|
|
148
|
|
- lockReconnect = true;
|
|
149
|
|
- //没连接上会一直重连,设置延迟避免请求过多
|
|
150
|
|
- setTimeout(function () {
|
|
151
|
|
- console.log(new Date() + " " + "重连中……");
|
|
152
|
|
- lockReconnect = false;
|
|
153
|
|
- CreateWebSockets();
|
|
154
|
|
- }, 2000);
|
|
155
|
|
- }
|
|
156
|
|
- }
|
|
157
|
|
- //发送
|
|
158
|
|
- function Sends() {
|
|
159
|
|
- if (wst.readyState != wst.OPEN) {
|
|
160
|
|
- ReConnect();
|
|
161
|
|
- }
|
|
162
|
|
- if (wst.readyState == wst.OPEN) {
|
|
163
|
|
- console.log(new Date() + " send " + JSON.stringify(objs));
|
|
164
|
|
- wst.send(JSON.stringify(objs));
|
|
|
109
|
+ break; //收到消息
|
|
|
110
|
+ case "loglist":
|
|
|
111
|
+ var list = data.data.rows;
|
|
|
112
|
+ $(list).each(function (i, n) {
|
|
|
113
|
+ var classname = "self";
|
|
|
114
|
+ if (n.F_FromUser == data.code) {
|
|
|
115
|
+ classname = "left";
|
|
|
116
|
+ }
|
|
|
117
|
+ insert(ele, classname, n.F_Message, $("#" + data.code).find(".hidnum").val(), n.F_HumanClass);
|
|
|
118
|
+ })
|
|
|
119
|
+ if (!data.data.isfirst) {
|
|
|
120
|
+ $(ele).find(".more").css("display", "block");
|
|
|
121
|
+ $("#" + data.code).find(".hidnum").val(data.data.num);
|
|
|
122
|
+ }
|
|
|
123
|
+ else {
|
|
|
124
|
+ $(ele).find(".more").css("display", "none");
|
|
|
125
|
+ }
|
|
|
126
|
+
|
|
|
127
|
+ break;//聊天记录
|
|
165
|
128
|
}
|
|
166
|
129
|
}
|
|
167
|
|
- //注册
|
|
168
|
|
- function Conn(userCode) {
|
|
169
|
|
- console.log(userCode);
|
|
170
|
|
- objs.action = "serconn";
|
|
171
|
|
- objs.code = userCode;
|
|
172
|
|
- Sends();
|
|
173
|
|
- }
|
|
174
|
|
- //查看更多
|
|
175
|
|
- function getmore(ele) {
|
|
176
|
|
- objs.action = "loglist";
|
|
177
|
|
- objs.code = $("#" + ele).find(".hidcid").val();
|
|
178
|
|
- objs.msg = $("#" + ele).find(".hidnum").val();
|
|
179
|
|
- Sends();
|
|
180
|
|
- }
|
|
181
|
|
- //发送消息
|
|
182
|
|
- function sendinfo(ele) {
|
|
183
|
|
- var msg = $("#" + ele).find(".send_content").val();
|
|
184
|
|
- console.log(msg)
|
|
185
|
|
- if ($.trim(msg)) {
|
|
186
|
|
- objs.action = "sersend";
|
|
187
|
|
- objs.code = $("#" + ele).find(".hidcid").val();
|
|
188
|
|
- objs.msg = msg;
|
|
189
|
|
- Sends();
|
|
190
|
|
- $("#" + ele).find(".senderror").text("");
|
|
191
|
|
- }
|
|
192
|
|
- else {
|
|
193
|
|
- $("#" + ele).find(".send_content").val('');
|
|
194
|
|
- $("#" + ele).find(".senderror").text("请输入内容");
|
|
195
|
|
- }
|
|
196
|
|
- }
|
|
197
|
|
-
|
|
198
|
|
- function append(ele, cname, msg,codes,dates) {
|
|
199
|
|
- var html='<li>' +
|
|
200
|
|
- '<p class="message_time"><span>' + dates + '</span></p>' +
|
|
201
|
|
- '<div class="message_mincon ' + cname + '">'
|
|
202
|
|
- if(cname=='self'){
|
|
203
|
|
- html +='<img class="ver_middle" src="img/kefuTx.png" alt="" width="30" height="30"/>'
|
|
204
|
|
- }else{
|
|
205
|
|
- html +='<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>'
|
|
206
|
|
- }
|
|
207
|
|
-
|
|
208
|
|
- html +='<div class="message_text">' + msg + '</div>' +
|
|
209
|
|
- '</div>' +
|
|
210
|
|
- '</li>'
|
|
211
|
|
- $(html).appendTo(ele);
|
|
212
|
|
- $(ele).scrollTop($(ele)[0].scrollHeight);
|
|
213
|
|
- $('.li'+codes).find('.pie').removeClass('pieHide').addClass('pieShow');
|
|
214
|
|
- $('.open_chat').find('.before').removeClass('hide').addClass('show');
|
|
|
130
|
+ };
|
|
|
131
|
+
|
|
|
132
|
+ //连接关闭的回调方法
|
|
|
133
|
+ wst.onclose = function (evt) {
|
|
|
134
|
+ console.log(new Date() + " " + "连接关闭");
|
|
|
135
|
+ console.log(new Date() + " " + "开始重连");
|
|
|
136
|
+ ReConnect();
|
|
|
137
|
+ };
|
|
|
138
|
+ //连接发生错误的回调方法
|
|
|
139
|
+ wst.onerror = function (evt) {
|
|
|
140
|
+ console.log(new Date() + " " + "连接异常");
|
|
|
141
|
+ console.log(new Date() + " " + "开始重连");
|
|
|
142
|
+ ReConnect();
|
|
|
143
|
+ };
|
|
|
144
|
+}
|
|
|
145
|
+//重连
|
|
|
146
|
+function ReConnect() {
|
|
|
147
|
+ if (!lockReconnect) {
|
|
|
148
|
+ lockReconnect = true;
|
|
|
149
|
+ //没连接上会一直重连,设置延迟避免请求过多
|
|
|
150
|
+ setTimeout(function () {
|
|
|
151
|
+ console.log(new Date() + " " + "重连中……");
|
|
|
152
|
+ lockReconnect = false;
|
|
|
153
|
+ CreateWebSockets();
|
|
|
154
|
+ }, 2000);
|
|
|
155
|
+ }
|
|
|
156
|
+}
|
|
|
157
|
+//发送
|
|
|
158
|
+function Sends() {
|
|
|
159
|
+ if (wst.readyState != wst.OPEN) {
|
|
|
160
|
+ ReConnect();
|
|
|
161
|
+ }
|
|
|
162
|
+ if (wst.readyState == wst.OPEN) {
|
|
|
163
|
+ console.log(new Date() + " send " + JSON.stringify(objs));
|
|
|
164
|
+ wst.send(JSON.stringify(objs));
|
|
|
165
|
+ }
|
|
|
166
|
+}
|
|
|
167
|
+//注册
|
|
|
168
|
+function Conn(userCode) {
|
|
|
169
|
+ console.log(userCode);
|
|
|
170
|
+ objs.action = "serconn";
|
|
|
171
|
+ objs.code = userCode;
|
|
|
172
|
+ Sends();
|
|
|
173
|
+}
|
|
|
174
|
+//查看更多
|
|
|
175
|
+function getmore(ele) {
|
|
|
176
|
+ objs.action = "loglist";
|
|
|
177
|
+ objs.code = $("#" + ele).find(".hidcid").val();
|
|
|
178
|
+ objs.msg = $("#" + ele).find(".hidnum").val();
|
|
|
179
|
+ Sends();
|
|
|
180
|
+}
|
|
|
181
|
+//发送消息
|
|
|
182
|
+function sendinfo(ele) {
|
|
|
183
|
+ var msg = $("#" + ele).find(".send_content").val();
|
|
|
184
|
+ console.log(msg)
|
|
|
185
|
+ if ($.trim(msg)) {
|
|
|
186
|
+ objs.action = "sersend";
|
|
|
187
|
+ objs.code = $("#" + ele).find(".hidcid").val();
|
|
|
188
|
+ objs.msg = msg;
|
|
|
189
|
+ Sends();
|
|
|
190
|
+ $("#" + ele).find(".senderror").text("");
|
|
|
191
|
+ }
|
|
|
192
|
+ else {
|
|
|
193
|
+ $("#" + ele).find(".send_content").val('');
|
|
|
194
|
+ $("#" + ele).find(".senderror").text("请输入内容");
|
|
|
195
|
+ }
|
|
|
196
|
+}
|
|
|
197
|
+
|
|
|
198
|
+function append(ele, cname, msg, codes, dates, humanclass) {
|
|
|
199
|
+ var html = '<li>' +
|
|
|
200
|
+ '<p class="message_time"><span>' + dates + '</span></p>' +
|
|
|
201
|
+ '<div class="message_mincon ' + cname + '">'
|
|
|
202
|
+ if (humanclass) {
|
|
|
203
|
+ if (humanclass == 1)
|
|
|
204
|
+ html += '<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
|
|
|
205
|
+ else if (humanclass == 2)
|
|
|
206
|
+ html += '<img class="ver_middle chat_yhtx" src="img/youkeTx.png" alt="" width="30" height="30" />'
|
|
|
207
|
+ else
|
|
|
208
|
+ html += '<img class="ver_middle chat_yhtx" src="img/robot.png" alt="" width="30" height="30" />'
|
|
|
209
|
+ }
|
|
|
210
|
+ else {
|
|
|
211
|
+ if (cname == 'self') {
|
|
|
212
|
+ html += '<img class="ver_middle" src="img/kefuTx.png" alt="" width="30" height="30"/>'
|
|
|
213
|
+ } else {
|
|
|
214
|
+ html += '<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>'
|
|
215
|
215
|
}
|
|
216
|
|
-
|
|
217
|
|
- function insert(ele, cname, msg, nodown) {
|
|
218
|
|
- var html='<li>' +
|
|
|
216
|
+ }
|
|
|
217
|
+
|
|
|
218
|
+ html += '<div class="message_text">' + msg + '</div>' +
|
|
|
219
|
+ '</div>' +
|
|
|
220
|
+'</li>'
|
|
|
221
|
+ $(html).appendTo(ele);
|
|
|
222
|
+ $(ele).scrollTop($(ele)[0].scrollHeight);
|
|
|
223
|
+ $('.li' + codes).find('.pie').removeClass('pieHide').addClass('pieShow');
|
|
|
224
|
+ $('.open_chat').find('.before').removeClass('hide').addClass('show');
|
|
|
225
|
+}
|
|
|
226
|
+
|
|
|
227
|
+function insert(ele, cname, msg, nodown,humanclass) {
|
|
|
228
|
+ var html = '<li>' +
|
|
219
|
229
|
// '<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
|
|
220
|
|
- '<div class="message_mincon ' + cname + '">'
|
|
221
|
|
- if(cname=='self'){
|
|
222
|
|
- html +='<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
|
|
223
|
|
- }else{
|
|
224
|
|
- html +='<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>'
|
|
225
|
|
- }
|
|
226
|
|
-
|
|
227
|
|
- html +='<div class="message_text">' + msg + '</div>' +
|
|
228
|
|
- '</div>' +
|
|
229
|
|
- '</li>'
|
|
230
|
|
- var list = $(ele).find("li");
|
|
231
|
|
- if (list.length) {
|
|
232
|
|
- $(html).insertBefore(list[0]);
|
|
233
|
|
- }
|
|
234
|
|
- else {
|
|
235
|
|
- $(html).appendTo(ele);
|
|
236
|
|
- }
|
|
237
|
|
- if (!nodown) {
|
|
238
|
|
- $(ele).scrollTop($(ele)[0].scrollHeight);
|
|
239
|
|
- }
|
|
|
230
|
+ '<div class="message_mincon ' + cname + '">'
|
|
|
231
|
+ if (humanclass) {
|
|
|
232
|
+ if (humanclass == 1)
|
|
|
233
|
+ html += '<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
|
|
|
234
|
+ else if (humanclass == 2)
|
|
|
235
|
+ html += '<img class="ver_middle chat_yhtx" src="img/youkeTx.png" alt="" width="30" height="30" />'
|
|
|
236
|
+ else
|
|
|
237
|
+ html += '<img class="ver_middle chat_yhtx" src="img/robot.png" alt="" width="30" height="30" />'
|
|
|
238
|
+ }
|
|
|
239
|
+ else {
|
|
|
240
|
+ if (cname == 'self') {
|
|
|
241
|
+ html += '<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
|
|
|
242
|
+ } else {
|
|
|
243
|
+ html += '<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>'
|
|
240
|
244
|
}
|
|
241
|
|
- function notice(ele,cname, msg){
|
|
242
|
|
- var html = '<li><span class="' + cname + '">' + msg + '</span></li>';
|
|
243
|
|
- $(html).appendTo(ele);
|
|
244
|
|
- $(ele).scrollTop($(ele)[0].scrollHeight);
|
|
245
|
|
- }
|
|
|
245
|
+ }
|
|
|
246
|
+
|
|
|
247
|
+ html += '<div class="message_text">' + msg + '</div>' +
|
|
|
248
|
+ '</div>' +
|
|
|
249
|
+'</li>'
|
|
|
250
|
+ var list = $(ele).find("li");
|
|
|
251
|
+ if (list.length) {
|
|
|
252
|
+ $(html).insertBefore(list[0]);
|
|
|
253
|
+ }
|
|
|
254
|
+ else {
|
|
|
255
|
+ $(html).appendTo(ele);
|
|
|
256
|
+ }
|
|
|
257
|
+ if (!nodown) {
|
|
|
258
|
+ $(ele).scrollTop($(ele)[0].scrollHeight);
|
|
|
259
|
+ }
|
|
|
260
|
+}
|
|
|
261
|
+function notice(ele, cname, msg) {
|
|
|
262
|
+ var html = '<li><span class="' + cname + '">' + msg + '</span></li>';
|
|
|
263
|
+ $(html).appendTo(ele);
|
|
|
264
|
+ $(ele).scrollTop($(ele)[0].scrollHeight);
|
|
|
265
|
+}
|
|
246
|
266
|
// //键盘发送事件
|
|
247
|
|
- function keySend(event){
|
|
248
|
|
- event = event || window.event;
|
|
249
|
|
- if(event.keyCode == 13) {
|
|
250
|
|
- $(".sendTo").click();
|
|
251
|
|
- event.returnValue = false;
|
|
252
|
|
- return false
|
|
253
|
|
- }
|
|
254
|
|
- }
|
|
255
|
|
- function removed(ele){
|
|
256
|
|
- var code=$(ele).parent().attr('code');
|
|
257
|
|
- $(".user").removeClass("activess");
|
|
258
|
|
- $("#" + code).remove();
|
|
259
|
|
- $(ele).parent().remove();
|
|
260
|
|
- $(ele).parent().parent();
|
|
261
|
|
- showChat();
|
|
262
|
|
- }
|
|
263
|
|
- function showChat(){
|
|
264
|
|
- $('.sidebar_list').children("li:first-child").addClass("activess");
|
|
265
|
|
- $('.chat_main').children(".tabMain:first-child").addClass("activess");
|
|
266
|
|
- }
|
|
267
|
|
- $('.open_chat').click(function(){
|
|
268
|
|
- if($('#chat').css('display')=='block'){
|
|
269
|
|
- $('#chat').hide();
|
|
270
|
|
- }else{
|
|
271
|
|
- $('#chat').show();
|
|
272
|
|
- }
|
|
273
|
|
-
|
|
274
|
|
- })
|
|
|
267
|
+function keySend(event) {
|
|
|
268
|
+ event = event || window.event;
|
|
|
269
|
+ if (event.keyCode == 13) {
|
|
|
270
|
+ $(".sendTo").click();
|
|
|
271
|
+ event.returnValue = false;
|
|
|
272
|
+ return false
|
|
|
273
|
+ }
|
|
|
274
|
+}
|
|
|
275
|
+function removed(ele) {
|
|
|
276
|
+ var code = $(ele).parent().attr('code');
|
|
|
277
|
+ $(".user").removeClass("activess");
|
|
|
278
|
+ $("#" + code).remove();
|
|
|
279
|
+ $(ele).parent().remove();
|
|
|
280
|
+ $(ele).parent().parent();
|
|
|
281
|
+ showChat();
|
|
|
282
|
+}
|
|
|
283
|
+function showChat() {
|
|
|
284
|
+ $('.sidebar_list').children("li:first-child").addClass("activess");
|
|
|
285
|
+ $('.chat_main').children(".tabMain:first-child").addClass("activess");
|
|
|
286
|
+}
|
|
|
287
|
+$('.open_chat').click(function () {
|
|
|
288
|
+ if ($('#chat').css('display') == 'block') {
|
|
|
289
|
+ $('#chat').hide();
|
|
|
290
|
+ } else {
|
|
|
291
|
+ $('#chat').show();
|
|
|
292
|
+ }
|
|
|
293
|
+
|
|
|
294
|
+})
|