my-chat.ejs
30.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
<!DOCTYPE html>
<html>
<head>
<title> </title>
<% include ../utils.ejs %>
<script src="http://res.websdk.rongcloud.cn/RongIMClient-0.9.13.min.js"></script>
<script src="/js/ueditor/ueditor.config.js"></script>
<script src="/js/ueditor/ueditor.all.js"></script>
<script src="/js/ueditor/zh-cn.js"></script>
</head>
<body class="office-chat">
<!-- <div class="chat-banner center-align " id="chat-banner">
<div class="banner-wrap">
轻松通过您的设置来
<a>实现桌面提醒</a>
<a class="right porent"><i class="fa fa-close pointer " id="chat-banner-close"></i></a>
</div>
</div>
<div class="chat-container">
<div class="chat-menu" id="chat-menu">
<div class="menu-item team-menu">
<span class="team-name">谈华芳项目组</span>
<div class="members">
<div class="menuber">
<i class="fa fa-circle online"></i>
<span class="name">fanwh</span>
</div>
<div class="menuber">
<i class="fa fa-circle offline"></i>
<span class="name">tanhf</span>
</div>
</div>
</div>
<div class="menu-item channel-menu">
<span class="channel-name">消息频道</span>
<div class="channels">
<div class="channel">
<span class="name">#日常通知</span>
</div>
<div class="channel">
<span class="name">#其他通知</span>
</div>
</div>
<div class="add-channel"><a >创建一个新的频道</a></div>
</div>
<div class="menu-item message-menu">
<span class="message-name">直接消息</span>
<div class="messages">
<div class="message">
<i class="fa fa-heart "></i>
<span class="name">对话机器人</span>
<span class="new badge">4</span>
</div>
</div>
</div>
<div class="menu-item group-menu">
<span class="group-name">私人群组</span>
<div class="groups">
<div class="group">
<span class="name">#前端team</span>
</div>
</div>
<div class="add-group"><a >创建一个新的私人群组</a></div>
</div>
<div class="menu-item add-member-menu">
<span class="add-name">目前还没有人加入</span>
<div class="add-member"> <i class="fa fa-plus "></i><a >邀请他人加入</a></div>
</div>
<div class="quick-btn pointer effeckt-modal-button" data-effeckt-type="from-below" data-effeckt-target="#switcher-modal">
<span class="fa-stack fa-lg quick-ico">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-search fa-stack-1x"></i>
</span>
<span class="quick-title">快速切换</span>
</div>
</div>
<div class="chat-content">
<div class="chat-head-nav">
<div class="chat-title">
<span class="main-title normal-color">#</span>
<span class="main-title">公告通知</span><i class="fa fa-chevron-down"></i>
<span class="sub-title">公司的公告和工作为基础的事项</span>
</div>
<div class="chat-head-quick-btn right">
<div class="calendar-icon image-icon-btn inline-block"></div>
<div class="userinfo-icon image-icon-btn inline-block"></div>
<div class="companyinfo-icon image-icon-btn inline-block"></div>
<div class="inline-block chat-head-search"><input type="text"></div>
<div class="push-icon image-icon-btn inline-block"></div>
<div class="favorite-icon image-icon-btn inline-block"></div>
<div class="more-icon image-icon-btn inline-block"></div>
</div>
</div>
<div class="chat-body-wrap">
<div class="chat-body-content">
<div class="message-wrap">
<div class="channel-meta">
<h5 class="small_bottom_margin channel_meta_name">
<span class="normal">#</span>公告通知
</h5>
<p class="small_bottom_margin" id="channel_meta_others_info">
这将是你创建的项目组<a href="#">公告通知</a>的频道,这个频道目的就是让你
的团队在此交流想法或者宣布公告,所有团队成员都在这个频道里。(<a href="#">点击编辑</a>)
</p>
<ul class="end_display_actions">
<li class="inline-block"><a >
<i class="fa fa-plus"></i>
从e-mail通讯录批量导入</a></li>
<li class="inline-block"><a ><i class="fa fa-user"></i>
邀请其他人加入企业在线</a></li>
</ul>
</div>
<div class="time-dividing">
<hr>
<div class="divider-label">今天</div>
</div>
</div>
<div class="chat-body-footer"></div>
</div>
<div class="chat-body-tools"></div>
</div>
</div>
</div> -->
<div id="switcher-modal" class="effeckt-wrap effeckt-modal-wrap">
<!-- for centering transform -->
<div class="effeckt-content effeckt-modal">
<h3>切换频道</h3>
<div class="effeckt-modal-content">
<p>选中一个你需要的频道.</p>
<button class="effeckt-modal-close">关闭</button>
</div>
</div>
</div>
<!-- menu start -->
<script id="chat-content-template" type="text/x-handlebars-template">
<div class="chat-head-nav">
<div class="chat-title">
<span class="main-title normal-color">#</span>
<span class="main-title">公告通知</span><i class="fa fa-chevron-down"></i>
<span class="sub-title">公司的公告和工作为基础的事项</span>
</div>
<div class="chat-head-quick-btn right">
<div class="calendar-icon image-icon-btn inline-block"><i class="fa fa-calendar"></i></div>
<div class="userinfo-icon image-icon-btn inline-block"><i class="fa fa-user-secret"></i></div>
<div class="companyinfo-icon image-icon-btn inline-block"><i class="fa fa-info"></i></div>
<div class="inline-block chat-head-search">
<i class="fa fa-search"></i><input type="text" placeholder="请输入搜索信息">
</div>
<div class="push-icon image-icon-btn inline-block"><i class="fa fa-at"></i></div>
<div class="favorite-icon image-icon-btn inline-block"><i class="fa fa-star-o"></i></div>
<div class="more-icon image-icon-btn inline-block"><i class="fa fa-ellipsis-h"></i></div>
</div>
</div>
<div class="chat-body-wrap">
<div class="chat-body-content">
<div class="message-wrap">
<div id="end_display_padder" style="height: 300px;"></div>
<div class="channel-meta">
<div class="channel-meta-name">
<span class="normal">#</span>公告通知
</div>
<p class="small-bottom-margin" >
这将是你创建的项目组<a href="#">公告通知</a>的频道,这个频道目的就是让你
的团队在此交流想法或者宣布公告,所有团队成员都在这个频道里。(<a href="#">点击编辑</a>)
</p>
<ul class="end-display-actions">
<li class="inline-block"><a >
<i class="fa fa-plus"></i>
从e-mail通讯录批量导入</a></li>
<li class="inline-block"><a ><i class="fa fa-user"></i>
邀请其他人加入企业在线</a></li>
</ul>
</div>
<div class="message-body">
<div class="time-dividing">
<hr>
<div class="divider-label">今天</div>
</div>
<div class="message-div first">
<a style="background-image: url('/imgs/portrait.png')" class="member-image"></a>
<a class="message-sender"> fanwh</a>
<a class="timestamp" >4:07 PM</a>
<span class="message-content">
joined #general
</span>
</div>
</div>
</div>
<div class="chat-body-footer">
<div class="messages-input-container" id="messages-input-container" style="height: 42px;">
<a class="file-upload-btn">
<i class="fa fa-plus"></i>
</a>
<form id="message-form">
<a aria-label="Emoji menu" class="emo_menu">
<i class="ts_icon ts_icon_circle_fill"></i>
<i class="ts_icon ts_icon_smile_o"></i>
<i class="ts_icon ts_icon_happy_smile"></i>
</a>
<textarea class="with-emoji-menu" id="chat-message-input" ></textarea>
<div class="" id="message-input-message"><span></span></div>
<input type="file" multiple="multiple" class="hide" id="file-upload">
</form>
</div>
</div>
</div>
<div class="chat-body-tools"></div>
</div>
</script>
<script id="chat-quick-menu" type="text/x-handlebars-template">
<span class="fa-stack fa-lg quick-ico">
<i class="fa fa-th-large "></i>
</span>
<span class="quick-title">进入HR管理后台</span>
</script>
<script id="chat-member-menu" type="text/x-handlebars-template">
<div class="add-name padding-left-15">常用功能定制
<span class="fa-stack right pointer">
<i class="fa fa-genderless fa-stack-2x"></i>
<i class="fa fa-plus fa-stack-1x fa-padding"></i>
</span>
</div>
<div class="add-member padding-left-20">
<a ><i class="fa fa-plus "></i>
添加其他功能入口</a>
</div>
</script>
<script id="chat-group-menu" type="text/x-handlebars-template">
<div class="group-name padding-left-15">私人群组
<span class="fa-stack right pointer">
<i class="fa fa-genderless fa-stack-2x"></i>
<i class="fa fa-plus fa-stack-1x fa-padding"></i>
</span>
</div>
<div class="groups padding-left-20">
<div class="group">
<span class="name">#前端team</span>
</div>
</div>
<div class="add-group padding-left-20"><a >创建一个新的私人群组</a></div>
</script>
<script id="chat-message-menu" type="text/x-handlebars-template">
<div class="message-name padding-left-15">直接消息
<span class="fa-stack right pointer">
<i class="fa fa-genderless fa-stack-2x"></i>
<i class="fa fa-plus fa-stack-1x fa-padding"></i>
</span>
</div>
<div class="messages padding-left-20">
<div class="message">
<i class="fa fa-heart "></i>
<span class="name">对话机器人</span>
<span class="message-badge">4</span>
</div>
</div>
<div class="padding-left-20">
#我的经理
</div>
</script>
<script id="chat-channel-menu" type="text/x-handlebars-template">
<div class="channel-name padding-left-15" id="create-channel-btn">消息频道
<span class="fa-stack right pointer">
<i class="fa fa-genderless fa-stack-2x"></i>
<i class="fa fa-plus fa-stack-1x fa-padding"></i>
</span>
</div>
<div class="channels">
{{#each items}}
<div class="channel padding-left-20 activate" data-channel-id="{{uuid}}" onClick="getChannel(this);">
<span class="name">#{{name}}</span>
</div>
{{/each}}
</div>
<div class="add-channel padding-left-20"><a >创建一个新的频道</a></div>
</script>
<script id="chat-team-menu" type="text/x-handlebars-template">
<span class="team-name padding-left-15">谈华芳项目组</span>
<div class="members">
<div class="menuber padding-left-20">
<i class="fa fa-circle online"></i>
<span class="name">fanwh</span>
</div>
<div class="menuber padding-left-20">
<i class="fa fa-circle offline"></i>
<span class="name">tanhf</span>
</div>
</div>
</script>
<!-- menu end -->
<script type="text/javascript">
(function($,window,document,undefined){
$(".quick-btn").click(function(e){
});
var MessageInput=function(ele,opt){
this.$ele=$('#chat-message-input');
this.defaults={
scrollTop:41
}
this.options=$.extend({},this.defaults,opt);
}
MessageInput.prototype={
init:function(){
this.bindEve();
},
bindEve:function(){
var messageInput=this;
$(document).on('keyup','#chat-message-input',
$.proxy(messageInput['setHight'], messageInput));
},
setHight:function(){
var scrollHeight=$('#chat-message-input')[0].scrollHeight;
var messageCss={};
console.log(scrollHeight);
if(this.options.scrollTop==scrollHeight)
return
else{
this.options.scrollTop=scrollHeight;
}
var messageHeight=scrollHeight;
if(messageHeight>130){
messageHeight=130;
messageCss['overflow-y']='scroll'
}else{
messageCss['overflow-y']='hidden'
}
messageCss['flex']='0 0 '+(messageHeight+45)+'px';
$('#chat-message-input').height(scrollHeight-18);
$('.chat-body-footer').css(messageCss);
$('#end_display_padder').height(300-(messageHeight-60));
}
}
var QuickMenu=function(ele,opt){
this.$parent=ele.find('#quick-btn');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
QuickMenu.prototype={
getTemplate:function(){
return Handlebars.compile($('#chat-quick-menu').html())({});
},
init:function(){
this.$parent.append(this.getTemplate());
}
}
var MemberMenu=function(ele,opt){
this.$parent=ele.find('#add-member-menu');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
MemberMenu.prototype={
getTemplate:function(){
return Handlebars.compile($('#chat-member-menu').html())({});
},
init:function(){
this.$parent.append(this.getTemplate());
}
}
var GroupMenu=function(ele,opt){
this.$parent=ele.find('#group-menu');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
GroupMenu.prototype={
getTemplate:function(){
return Handlebars.compile($('#chat-group-menu').html())({});
},
init:function(){
this.$parent.append(this.getTemplate());
}
}
var MessageMenu=function(ele,opt){
this.$parent=ele.find('#message-menu');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
MessageMenu.prototype={
getTemplate:function(){
return Handlebars.compile($('#chat-message-menu').html())({});
},
init:function(){
this.$parent.append(this.getTemplate());
}
}
var ChannelMenu=function(ele,opt){
this.$parent=ele.find('#channel-menu');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
ChannelMenu.prototype={
getTemplate:function(){
return Handlebars.compile($('#chat-channel-menu').html())({});
},
init:function(){
this.$parent.append(this.getTemplate());
}
}
var TeamMenu=function(ele,opt){
this.$parent=ele.find('#team-menu');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
TeamMenu.prototype={
getTemplate:function(){
return Handlebars.compile($('#chat-team-menu').html())({});
},
init:function(){
this.$parent.append(this.getTemplate());
}
}
var ChatMenu=function(ele,opt){
this.$parent=ele.find('#chat-menu');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
ChatMenu.prototype={
getTemplate:function(){
var temp=[
'<div class="menu-item team-menu" id="team-menu">',
'</div>',
'<div class="menu-item channel-menu" id="channel-menu">',
'</div>',
'<div class="menu-item message-menu" id="message-menu">',
'</div>',
'<div class="menu-item group-menu" id="group-menu">',
'</div>',
'<div class="menu-item add-member-menu" id="add-member-menu">',
'</div>',
'<a href="/home"><div class="quick-btn pointer" id="quick-btn" >',
'</div></a>'
]
return temp.join("");
},
init:function(){
this.$parent.append(this.getTemplate());
var team = new TeamMenu(this.$parent,this.options);
team.init();
var channel = new ChannelMenu(this.$parent,this.options);
channel.init();
var message = new MessageMenu(this.$parent,this.options);
message.init();
var group = new GroupMenu(this.$parent,this.options);
group.init();
var member= new MemberMenu(this.$parent,this.options);
member.init();
var quick= new QuickMenu(this.$parent,this.options);
quick.init();
}
}
var ChatBanner=function(ele,opt){
this.$parent=ele.find('#chat-banner');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
};
ChatBanner.prototype={
getTemplate:function(){
var temp=[
'<div class="banner-wrap">',
'轻松通过您的设置来',
'<a>实现桌面提醒</a>',
'<a class="right porent"><i class="fa fa-close pointer " id="chat-banner-close"></i></a>',
'</div>'
]
return temp.join("");
},
init:function(){
this.$parent.append(this.getTemplate());
this.bindEve();
},
bindEve:function(){
this.$parent.find("#chat-banner-close").click(this.hideBanner);
},
showBanner:function(){
$('#chat-banner').removeClass("close-banner");
},
hideBanner:function(){
$('#chat-banner').addClass("close-banner");
}
}
var OfficeChat=function(ele,opt){
this.$ele=ele;
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
OfficeChat.prototype={
init:function(){
this.layout();
var banner= new ChatBanner(this.$ele,this.options);
banner.init();
this.banner=banner;
var menu = new ChatMenu(this.$ele,this.options);
menu.init();
this.menu=menu;
var content= new ChatContent(this.$ele,this.options);
content.init();
},
layout:function(){
var temp=[
'<div class="chat-banner center-align hide" id="chat-banner">',
'</div>',
'<div class="chat-container">',
'<div class="chat-menu" id="chat-menu">',
'</div>',
'<div class="chat-content" id="chat-content">',
'</div>',
'</div>'
];
this.$ele.append(temp.join(""))
}
}
var ChatContent=function(ele,opt){
this.$parent=ele.find('#chat-content');
this.defaults={
}
this.options=$.extend({},this.defaults,opt);
}
ChatContent.prototype={
getTemplate:function(){
return Handlebars.compile($('#chat-content-template').html())({});
},
init:function(){
this.$parent.append(this.getTemplate());
var message=new MessageInput(this.$parent,this.options);
message.init();
}
}
$.fn.officeChat = function(options) {
var chat = new OfficeChat(this,options);
chat.init();
return chat;
}
var myChat=$('.office-chat').officeChat({});
// $("#chat-banner-close").click(function(e){
// $('#chat-banner').addClass("close-banner");
// });
$("#show-banner").click(function(e){
myChat.banner.showBanner();
});
$('.more-icon').click(function(e){
$('.chat-body-tools').addClass('open-tools');
})
$(document).on('click','#create-channel-btn',function(e){
e.preventDefault();
$.post("/chat/creatChannel",{
'name':'公告测试1',
'discription':'这是一个公告测试频道1',
"topic":{},
"purpose":{}
},function(data){
console.log(data);
});
});
$.post("/chat/listChannels",{},function(data){
$('#channel-menu').html(
Handlebars.compile($('#chat-channel-menu').html())(data)
);
console.log(data);
});
//融云消息监听
RongIMClient.init("0vnjpoadnffgz");
var token = "<%=token%>";
// 连接融云服务器。
RongIMClient.connect(token,{
onSuccess: function (userId) {
// 此处处理连接成功。
console.log("Login successfully." + userId);
},
onError: function (errorCode) {
// 此处处理连接错误。
var info = '';
switch (errorCode) {
case RongIMClient.callback.ErrorCode.TIMEOUT:
info = '超时';
break;
case RongIMClient.callback.ErrorCode.UNKNOWN_ERROR:
info = '未知错误';
break;
case RongIMClient.ConnectErrorStatus.UNACCEPTABLE_PROTOCOL_VERSION:
info = '不可接受的协议版本';
break;
case RongIMClient.ConnectErrorStatus.IDENTIFIER_REJECTED:
info = 'appkey不正确';
break;
case RongIMClient.ConnectErrorStatus.SERVER_UNAVAILABLE:
info = '服务器不可用';
break;
case RongIMClient.ConnectErrorStatus.TOKEN_INCORRECT:
info = 'token无效';
break;
case RongIMClient.ConnectErrorStatus.NOT_AUTHORIZED:
info = '未认证';
break;
case RongIMClient.ConnectErrorStatus.REDIRECT:
info = '重新获取导航';
break;
case RongIMClient.ConnectErrorStatus.PACKAGE_ERROR:
info = '包名错误';
break;
case RongIMClient.ConnectErrorStatus.APP_BLOCK_OR_DELETE:
info = '应用已被封禁或已被删除';
break;
case RongIMClient.ConnectErrorStatus.BLOCK:
info = '用户被封禁';
break;
case RongIMClient.ConnectErrorStatus.TOKEN_EXPIRE:
info = 'token已过期';
break;
case RongIMClient.ConnectErrorStatus.DEVICE_ERROR:
info = '设备号错误';
break;
}
console.log("失败:" + info);
}
});
// 设置连接监听状态 ( status 标识当前连接状态)
// 连接状态
RongIMClient.setConnectionStatusListener({
onChanged: function (status) {
switch (status) {
//链接成功
case RongIMClient.ConnectionStatus.CONNECTED:
console.log('链接成功');
break;
//正在链接
case RongIMClient.ConnectionStatus.CONNECTING:
console.log('正在链接');
break;
//重新链接
case RongIMClient.ConnectionStatus.RECONNECT:
console.log('重新链接');
break;
//其他设备登陆
case RongIMClient.ConnectionStatus.OTHER_DEVICE_LOGIN:
//连接关闭
case RongIMClient.ConnectionStatus.CLOSURE:
//未知错误
case RongIMClient.ConnectionStatus.UNKNOWN_ERROR:
//登出
case RongIMClient.ConnectionStatus.LOGOUT:
//用户已被封禁
case RongIMClient.ConnectionStatus.BLOCK:
break;
}
}});
// 消息监听器
RongIMClient.getInstance().setOnReceiveMessageListener({
// 接收到的消息
onReceived: function (message) {
// 判断消息类型
switch(message.getMessageType()){
case RongIMClient.MessageType.TextMessage:
// do something...
break;
case RongIMClient.MessageType.ImageMessage:
// do something...
break;
case RongIMClient.MessageType.VoiceMessage:
// do something...
break;
case RongIMClient.MessageType.RichContentMessage:
// do something...
break;
case RongIMClient.MessageType.LocationMessage:
// do something...
break;
case RongIMClient.MessageType.DiscussionNotificationMessage:
// do something...
break;
case RongIMClient.MessageType.InformationNotificationMessage:
// do something...
break;
case RongIMClient.MessageType.ContactNotificationMessage:
// do something...
break;
case RongIMClient.MessageType.ProfileNotificationMessage:
// do something...
break;
case RongIMClient.MessageType.CommandNotificationMessage:
// do something...
break;
case RongIMClient.MessageType.UnknownMessage:
// do something...
break;
default:
// 自定义消息
// do something...
}
}
});
UE.Editor.prototype.getActionUrl = function(action) {}
var ue = UE.getEditor('editor',{
toolbars: [
[
'fullscreen', //全屏
'source', //源代码
'undo',
'redo',
'bold',
'indent', //首行缩进
'italic', //斜体
'underline', //下划线
'strikethrough', //删除线
'subscript', //下标
'fontborder', //字符边框
'superscript', //上标
'formatmatch', //格式刷
'blockquote', //引用
'pasteplain', //纯文本粘贴模式
'horizontal', //分隔线
'removeformat', //清除格式
'time', //时间
'date', //日期
'unlink', //取消链接
'insertrow', //前插入行
'insertcol', //前插入列
'mergeright', //右合并单元格
'mergedown', //下合并单元格
'deleterow', //删除行
'deletecol', //删除列
'splittorows', //拆分成行
'splittocols', //拆分成列
'splittocells', //完全拆分单元格
'deletecaption', //删除表格标题
'inserttitle', //插入标题
'mergecells', //合并多个单元格
'deletetable', //删除表格
'cleardoc', //清空文档
'insertparagraphbeforetable', //"表格前插入行"
'insertcode', //代码语言
'fontfamily', //字体
'fontsize', //字号
'paragraph', //段落格式
'edittable', //表格属性
'edittd', //单元格属性
'link', //超链接
'emotion', //表情
'spechars', //特殊字符
'searchreplace', //查询替换
'map', //Baidu地图
'gmap', //Google地图
'insertvideo', //视频
'help', //帮助
'justifyleft', //居左对齐
'justifyright', //居右对齐
'justifycenter', //居中对齐
'justifyjustify', //两端对齐
'forecolor', //字体颜色
'backcolor', //背景色
'insertorderedlist', //有序列表
'insertunorderedlist', //无序列表
'directionalityltr', //从左向右输入
'directionalityrtl', //从右向左输入
'rowspacingtop', //段前距
'rowspacingbottom', //段后距
'pagebreak', //分页
'insertframe', //插入Iframe
'imagenone', //默认
'imageleft', //左浮动
'imageright', //右浮动
'attachment', //附件
'imagecenter', //居中
'wordimage', //图片转存
'lineheight', //行间距
'edittip ', //编辑提示
'customstyle', //自定义标题
'autotypeset', //自动排版
'webapp', //百度应用
'touppercase', //字母大写
'tolowercase', //字母小写
'background', //背景
'template', //模板
'scrawl', //涂鸦
'music', //音乐
'inserttable', //插入表格
'drafts', // 从草稿箱加载
'charts', // 图表
'print', //打印
'preview', //预览
]
]
});
})(jQuery,window,document);
function getChannel(ele){
// $.post("/chat/getChannel",{
// "channelId":$(ele).data('channel-id')
// },function(data){
// console.log(data);
// });
// $.post("/chat/updateChannel",{
// "purpose":"{'test':1}",
// "topic":"{'tes2':2}",
// "channelId":$(ele).data('channel-id')
// },function(data){
// console.log(data);
// });
// $.post("/chat/delChannel",{
// "channelId":$(ele).data('channel-id')
// },function(data){
// console.log(data);
// });
// $.post("/chat/subscribeChannel",{
// "channelId":$(ele).data('channel-id'),
// "channelName":'订阅1'
// },function(data){
// console.log(data);
// });
// $.post("/chat/listSubscriptions",{
// "channelId":$(ele).data('channel-id')
// },function(data){
// console.log(data);
// // $.post("/chat/unsubscribeChannel",{
// // "channelId":$(ele).data('channel-id'),
// // "subscriptionId":data.items[0].uuid
// // },function(d){
// // console.log(d);
// // });
// });
$.post("/chat/sendMessage",{
"channel_id": $(ele).data('channel-id'),
"type": "RC:TxtMsg",
"content": {"content": "this is test!!"},
"to": [{"type": "all"}]
},function(data){
console.log(data);
});
}
</script>
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
</body>
</html>