3 lines
37 KiB
JavaScript
3 lines
37 KiB
JavaScript
layui.define(["layer","laytpl","upload"],function(X){var Z="2.0.0",n=layui.jquery,v=layui.layer,y=layui.laytpl,U=0,w=null,$a="layim-show",M="layim-this",Y=50,S=1e3,c={},h={},p={},f=function(){this.v=Z,n(document).on("click","*[chatroom-event]",function(a){var e=n(this),i=e.attr("chatroom-event");g[i]&&g[i].call(this,e,a)}),n(window).ready(function(){n("body").on("change",".group_chat_img",function(){La(this)}),n("#group-msg-input").on("blur",function(){setTimeout(function(){var a=document.documentElement.scrollTop||document.body.scrollTop||0;window.scrollTo(0,Math.max(a-1,0))},300)})}),n(window).resize(function(){setTimeout(function(){var a=document.documentElement.scrollTop||document.body.scrollTop||0;window.scrollTo(0,Math.max(a-1,0))},300)})};window.coverError=function(){var a=event.target;if(parseInt(a.dataset.errorcount)==0){var e=a.dataset.source;a.setAttribute("data-errorcount",1),a.src=e}},layui.data.substr=function(a,e){return a==""||a==null||typeof a!="string"?"":a.length<e?a:a.substring(0,e)+"..."},layui.data.avatar=function(a,e,i){if(a.indexOf("http://")>-1||a.indexOf("https://")>-1)return a;var t="";return e==1?t=a.replace(/([^.]*).([^.]*)$/g,"$1!large.$2"):e==2?t=a.replace(/([^.]*).([^.]*)$/g,"$1!medium.$2"):e==3?i?t=a.replace(/([^.]*).([^.]*)$/g,"$1!small.$2"):t=a.replace(/([^.]*).([^.]*)$/g,"$1!80_80.$2"):t=a,(window.cdnPath||"")+""+t},layui.data.escape=function(a){var e=document.createElement("div"),i=document.createTextNode(a);return e.appendChild(i),e.innerHTML},layui.data.img2str=function(a){var e=a.replace(/img\[([^\s]+?)\]/g,function(i){return"[\u56FE\u7247]"});return e},layui.data.content=function(a,e){var i="",t="audio[";if(a.indexOf(t)>-1){var r=a.split(",");a=r[0],i=r[1]||0}var s=function(l){return new RegExp("\\n*\\["+(l||"")+"(pre|div|p|table|thead|th|tbody|tr|td|ul|li|ol|li|dl|dt|dd|h2|h3|h4|h5)([\\s\\S]*?)\\]\\n*","g")};return a=(a||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/@(\S+)(\s+?|$)/g,'@<a href="javascript:;">$1</a>$2').replace(/\s{2}/g," ").replace(/img\[([^\s]+?)\]/g,function(l){var o=(window.cdnPath||"")+""+l.replace(/(^img\[)|(\]$)/g,""),d=o.replace("!medium",""),m=d.replace(/([^.]*).([^.]*)$/g,"$1!small.$2");return'<img class="layui-layim-photos" chatroom-event="showimg" src="'+m+'" data-errorcount="0" onerror="coverError()" data-source="'+o+'" />'}).replace(/audio\[([^\s]+?)\]/g,function(l){var o=(window.cdnPath||"")+""+l.replace(/(^audio\[)|(\]$)/g,"");return'<div class="group_msg_audio js_msg_audio">'+i+'<audio ><source onended="audioPlayEnd(this)" src="'+o+'" type="audio/mpeg"></audio></div>'}).replace(/file\([\s\S]+?\)\[[\s\S]*?\]/g,function(l){var o=(l.match(/file\(([\s\S]+?)\)\[/)||[])[1],d=(l.match(/\)\[([\s\S]*?)\]/)||[])[1];return o?'<a class="layui-layim-file" href="'+o+'" target="_blank"><i class="layui-icon"></i><cite>'+(d||o)+"</cite></a>":l}).replace(/face\[([^\s\[\]]+?)\]/g,function(l){var o=l.replace(/^face/g,"");return'<img style="max-width:24px;" alt="'+o+'" title="'+o+'" src="'+O[o]+'">'}).replace(/a\([\s\S]+?\)\[[\s\S]*?\]/g,function(l){var o=(l.match(/a\(([\s\S]+?)\)\[/)||[])[1],d=(l.match(/\)\[([\s\S]*?)\]/)||[])[1];return o?'<a href="'+o+'" target="_blank">'+(d||o)+"</a>":l}).replace(s(),"<$1 $2>").replace(s("/"),"</$1>").replace(/\n/g,"<br>"),a},layui.data.date=function(a){var e=new Date(a||new Date);return e.getFullYear()+"-"+b(e.getMonth()+1)+"-"+b(e.getDate())+" "+b(e.getHours())+":"+b(e.getMinutes())+":"+b(e.getSeconds())},layui.data.datetotime=function(a){var e=new Date(a||new Date);return b(e.getHours())+":"+b(e.getMinutes())+":"+b(e.getSeconds())},layui.data.humanitytime=function(a){var e=1e3*60,i=e*60,t=i*24,r=t*15,s=t*30,l=new Date().getTime(),o=l-a;o<0;var d=o/s,m=o/(7*t),u=o/t,k=o/i,_=o/e;return d>=1?result=parseInt(d)+"\u4E2A\u6708\u524D":m>=1?result=parseInt(m)+"\u4E2A\u661F\u671F\u524D":u>=1?result=parseInt(u)+"\u5929\u524D":k>=1?result=parseInt(k)+"\u4E2A\u5C0F\u65F6\u524D":_>=1?result=parseInt(_)+"\u5206\u949F\u524D":result="\u521A\u521A",result};var b=function(a){return a<10?"0"+(a|0):a};f.prototype.cache=function(){return p},f.prototype.me=function(){return c},f.prototype.chat=function(a){g.chat(a)},f.prototype.on=function(a,e){return typeof e=="function"&&(h[a]?h[a].push(e):h[a]=[e]),this},f.prototype.init=function(a){var e=a.userinfo,i=["1","2","3","4"];c.avatar=e.avatar,c.client_id=e.client_id,c.groupid=e.groupid,c.name=layui.data.escape(e.name),c.uid=e.uid,c.groupid=e.groupid,c.cam=e.cam,c.mic=e.mic,c.assistant=e.assistant,p.course=a.course,p.room_config={},p.room_config.gag=a.room_config.gag,p.room_config.allow_raise=a.room_config.allow_raise,p.course.courseWareType=="0"?p.course.islive=0:i.indexOf(p.course.courseWareType)!=-1?(p.course.islive=1,liveType=1):(p.course.islive=1,liveType=4);var t=layui.data("layim")[c.uid]||{};t.sendHotKey==null&&(t.sendHotKey="Enter"),layui.data("layim",{key:c.uid,value:t}),z();var r={};r.me=c,r.cache=p,layui.each(h.init,function(l,o){o&&o(r)});var s='<div class="more_chatList"><span class="chatList_left"></span><span class="chatList_content" chatroom-event="getChatList" clicked="true">\u65B0\u8FDB\u5165<span style="color:#42a4e5;">\u70B9\u51FB</span>\u53EF\u67E5\u770B\u6700\u8FD1100\u6761\u6D88\u606F</span><span class="chatList_right"></span></div>';n(".more_chatList").length==0&&n("#content-list").append(s)},f.prototype.initPublic=function(a){var e=["1","2","3","4","5"];p.course=a.course||{},p.room_config={};var i=p.course&&p.course.courseWareType;e.indexOf(i)!=-1?i=="5"?(p.course.islive=1,liveType=4):(p.course.islive=1,liveType=1):p.course.islive=0},f.prototype.addOnlineList=function(a,e){return ma(a,e)},f.prototype.flashMaker=function(a,e,i,t,r,s,l){return Ta(a,e,i,t,r,s,l),this},f.prototype.newUserJoin=function(a){return ya(a),this},f.prototype.AppendBlack=function(a){return da(a),this},f.prototype.setOnlineCount=function(a){return Oa(a),this},f.prototype.newMsgTips=function(a){return ga(a),this},f.prototype.flushOnlineList=function(a,e){return ha(a,e),this},f.prototype.appendMessage=function(a){return _a(a),this},f.prototype.beforeMessage=function(a,e){return wa(a,e),this},f.prototype.getMessage=function(a){return xa(a),this},f.prototype.appendShield=function(a){return ba(a),this},f.prototype.userLeave=function(a){return ka(a),this},f.prototype.setGagStatus=function(a){return ua(a),this},f.prototype.addUserCamera=function(a){return fa(a),this},f.prototype.delUserCamera=function(a){return pa(a),this},f.prototype.setRaiseStatus=function(a){return va(a),this};function q(){if(window.localStorage){var a=localStorage.getItem("onlineChat"),e=JSON.parse(a)||{};return e}}function Q(a,e){if(window.localStorage){var i=q(),t=a.uid||"";e&&i.hasOwnProperty(t)?delete i[t]:i.hasOwnProperty(t)||(i[t]=a),localStorage.setItem("onlineChat",JSON.stringify(i))}}function V(a){if(window.localStorage){var e={};a.forEach(function(i){var t=i.uid||"";e[t]=i}),localStorage.setItem("onlineChat",JSON.stringify(e))}}function A(){var a="";if(window.localStorage){var e=localStorage.getItem("courseInfo")||"{}";courseInfo=JSON.parse(e);var i=courseInfo.gmtCourseStartTimeStamp,t=new Date(i);a=t.getHours()+"\u65F6"+t.getMinutes()+"\u5206"}return a}function I(a,e){var i=a.uid,t={};if(e){var r=q();t=r[i]||{}}else t=a;var s=t.groupid||"";if(s==="5"&&n(".js_live_wait").length>0){var l=A(),o=e?l+"\u5F00\u8BFE\uFF0C\u8001\u5E08\u5C1A\u672A\u8FDB\u5165\u6559\u5BA4\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85~":"\u8001\u5E08\u5DF2\u8FDB\u5165\u6559\u5BA4\uFF0C\u6B63\u5728\u51C6\u5907\u8D44\u6599...";sessionStorage.setItem("waitLiveInfo",o)}Q(a,e)}var aa=['<div class="msg_box tips-box online_box">','<div class="tips-content">',"{{ layui.data.escape(d.name) }}","\u8FDB\u5165\u4E86\u6559\u5BA4","</div>","</div>"].join(""),ea=['<div class="msg_box tips-box">','<div class="tips-content">',"{{ d.content }}","</div>","</div>"].join(""),P=["{{# layui.each(d, function(index, item){ }}","{{# if(item.name != undefined){ }}",'<div class="tall_list_once" id="online_list_{{ item.client_id }}" data-hasmenu="1" data-type="friendMsg" data-avatar="{{ layui.data.escape(layui.data.avatar(item.avatar)) }}" data-name="{{ layui.data.escape(item.name) }}" data-uid="{{ item.uid }}" data-groupid="{{ item.groupid }}" assistant="{{ item.assistant }}" data-client_id="{{ item.client_id }}" data-raise="{{# if(item.raise == false){ }}0{{# }else{ }}1{{# } }}" data-blacklist="{{# if(item.is_black_list == false){ }}0{{# }else{ }}1{{# } }}" >','<div class="online_blackRadius" style="display:{{# if(item.is_black_list == false){ }}none{{# }else{ }}block{{# } }};"></div>','<img src="{{ layui.data.escape(layui.data.avatar(item.avatar,3)) }}" chatroom-event="chat" data-islist="1" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(item.avatar)) }}" alt=""/>','<p class="list_name" chatroom-event="chat" data-islist="1" style="{{# if(item.groupid == 5){ }}{{# if(item.assistant){ }}color:#f39c12;{{# }else{ }}color:red;{{# } } }}">{{ layui.data.escape(layui.data.substr(item.name,13)) ||"\u4F5A\u540D" }}</p>','<span class="hand" {{# if(item.raise == false){ }}style="display:none;"{{# } }}></span>','<div class="maike_video">',"<ul>",'<li class="maike {{# if(item.raise == false){ }} {{# if(item.open_mic == false){ }}maike_back_on {{# }else{ }}maike_back_open{{# } }} {{# }else{ }} {{# if(item.open_mic == false){ }} maike_back_statr{{# } }} {{# } }}"></li>','<li class="video {{# if(item.raise == false){ }}{{# if(item.open_cam == false){ }}video_back_on{{# }else{ }}video_back_open{{# } }}{{# }else{ }} {{# if(item.open_cam == false){ }} video_back_statr{{# } }} {{# } }}"></li>',"</ul>","</div>","</div>","{{# } }}","{{# }); }}"].join(""),ia=["{{# if(d.name != undefined){ }}",'<div class="tall_list_once" id="online_list_{{ d.client_id }}" data-hasmenu="1" data-type="friendMsg" data-avatar="{{ layui.data.escape(layui.data.avatar(d.avatar)) }}" data-name="{{ layui.data.escape(d.name) }}" data-uid="{{ d.uid }}" data-groupid="{{ d.groupid }}" assistant="{{ d.assistant }}" data-client_id="{{ d.client_id }}" data-raise="{{# if(d.raise == false){ }}0{{# }else{ }}1{{# } }}" data-blacklist="{{# if(d.is_black_list == false){ }}0{{# }else{ }}1{{# } }}" >','<div class="online_blackRadius" style="display:{{# if(d.is_black_list == false){ }}none{{# }else{ }}block{{# } }};"></div>','<img src="{{ layui.data.escape(layui.data.avatar(d.avatar,3)) }}" chatroom-event="chat" data-islist="1" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.avatar)) }}" alt=""/>','<p class="list_name" chatroom-event="chat" data-islist="1" style="{{# if(d.groupid == 5){ }}{{# if(d.assistant){ }}color:#f39c12;{{# }else{ }}color:red;{{# } } }}">{{ layui.data.escape(layui.data.substr(d.name,13)) ||"\u4F5A\u540D" }}</p>','<span class="close_radius" title="\u5DF2\u5C4F\u853D\u53D1\u8A00" style="display:none;"></span>','<span class="close_black" style="display:none;">\u53D6\u6D88\u5C4F\u853D</span>','<span class="hand" {{# if(d.raise == false){ }}style="display:none;"{{# } }}></span>','<div class="maike_video">',"<ul>",'<li class="maike {{# if(d.raise == false){ }} {{# if(d.open_mic == false){ }}maike_back_on {{# }else{ }}maike_back_open{{# } }} {{# }else{ }} {{# if(d.open_mic == false){ }} maike_back_statr{{# } }} {{# } }}"></li>','<li class="video {{# if(d.raise == false){ }}{{# if(d.open_cam == false){ }}video_back_on{{# }else{ }}video_back_open{{# } }}{{# }else{ }} {{# if(d.open_cam == false){ }} video_back_statr{{# } }} {{# } }}"></li>',"</ul>","</div>","</div>","{{# } }}"].join(""),ta=["{{# layui.each(d, function(index, item){ }}","{{# if(item.name != undefined){ }}",'<div class="tall_list_once" id="online_list_{{ item.client_id }}" data-type="friendMsg" data-avatar="{{ layui.data.escape(layui.data.avatar(item.avatar)) }}" data-name="{{ layui.data.escape(item.name) }}" data-uid="{{ item.uid }}" data-client_id="{{ item.client_id }}" data-groupid="{{ item.groupid }}" data-blacklist="{{# if(item.is_black_list == false){ }}0{{# }else{ }}1{{# } }}">','<img src="{{ layui.data.escape(layui.data.avatar(item.avatar,3)) }}" chatroom-event="chat" data-islist="1" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(item.avatar)) }}" alt=""/>','<p class="list_name" chatroom-event="chat" data-islist="1">{{ layui.data.escape(layui.data.substr(item.name,13)) ||"\u4F5A\u540D" }}</p>','<span class="close_radius" title="\u5DF2\u5C4F\u853D\u53D1\u8A00" style="display:none;"></span>','<span class="close_black" style="display:none;">\u53D6\u6D88\u5C4F\u853D</span>',"</div>","{{# } }}","{{# }); }}"].join(""),L=["{{# if(d.userOnline.groupid == 5 || d.userOnline.groupid == 4 ){ }}",'<div class="msg_box tall_teacher {{# if(d.userOnline.groupid == 4 ){ }} assistant {{# } }}">','<div class="teacher_top">','<img src="{{ layui.data.escape(layui.data.avatar(d.userOnline.avatar,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.userOnline.avatar)) }}" alt=""/>','<span class="teacher_name">','{{# if(d.userOnline.icon != undefined){ }}<img class="vipIcon" src="{{ layui.data.escape(layui.data.avatar(d.userOnline.icon,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.userOnline.icon)) }}" />{{# } }}{{ layui.data.escape(layui.data.substr(d.userOnline.name,12)) ||"\u4F5A\u540D" }}{{# if(d.userOnline.groupid == 4 ){ }} (\u52A9\u6559) {{# } }}</span>','<span class="teacher_timer">{{ layui.data.datetotime(d.timestamp) }}</span>',"</div>",'<div class="teacher_txt">{{# if(d.isbarrage == 1){ }}<div class="barrageicon"></div>{{# } }}{{ layui.data.content(d.content||" ",d) }}</div>',"</div>","{{# }else{ }}","{{# if(d.userOnline.uid == d.mine.uid){ }}",'<div class="msg_box tall_self">','<div class="self_top">','<img src="{{ layui.data.escape(layui.data.avatar(d.userOnline.avatar,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.userOnline.avatar)) }}" alt=""/>','<span class="self_name">','{{# if(d.userOnline.icon != undefined){ }}<img class="vipIcon" src="{{ layui.data.escape(layui.data.avatar(d.userOnline.icon,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.userOnline.icon)) }}" />{{# } }}{{ layui.data.escape(layui.data.substr(d.userOnline.name,12)) ||"\u4F5A\u540D" }}</span>','<span class="self_timer">{{ layui.data.datetotime(d.timestamp) }}</span>',"</div>",'<div class="self_txt">{{# if(d.isbarrage == 1){ }}<div class="barrageicon"></div>{{# } }}{{ layui.data.content(d.content||" ",d) }}</div>',"</div>","{{# }else{ }}",'<div id="friend_{{ d.userOnline.client_id }}" class="msg_box tall_friend" style="position:relative;" data-uid="{{ d.userOnline.uid }}" data-client_id="{{ d.userOnline.client_id }}" blacklist="false">','<div class="addBlack" data-uid="{{ d.userOnline.uid }}" data-client_id="{{ d.userOnline.client_id }}" style="display:none;">\u7981\u8A00</div>','<div class="addBlack_chat" data-uid="{{ d.userOnline.uid }}" data-client_id="{{ d.userOnline.client_id }}" style="display:none;">\u5C4F\u853D\u53D1\u8A00</div>','<div class="blacklist_radius"></div>','<div class="blacklist_radius_chat" style="display:none;"></div>','<div class="firend_top">','<img src="{{ layui.data.escape(layui.data.avatar(d.userOnline.avatar,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{layui.data.escape(layui.data.avatar(d.userOnline.avatar))}}" alt=""/>','<span class="friend_name">','{{# if(d.userOnline.icon != undefined){ }}<img class="vipIcon" src="{{ layui.data.escape(layui.data.avatar(d.userOnline.icon,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.userOnline.icon)) }}" />{{# } }}{{ layui.data.escape(layui.data.substr(d.userOnline.name,12)) ||"\u4F5A\u540D" }}</span>','<span class="friend_timer">{{ layui.data.datetotime(d.timestamp) }}</span>',"</div>",'<div class="friend_txt">{{# if(d.isbarrage == 1){ }}<div class="barrageicon"></div>{{# } }}{{ layui.data.content(d.content||" ",d) }}</div>',"</div>","{{# } }}","{{# } }}"].join(""),na='<li class="layim-chatlist-{{ d.data.type }}{{ d.data.uid }} layim-this" layim-event="tabChat"><img src="{{ layui.data.escape(layui.data.avatar(d.data.avatar,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.data.avatar)) }}" /><span>{{ layui.data.escape(d.data.name) ||"\u4F5A\u540D" }}</span><i class="layui-icon" layim-event="closeChat">ဇ</i></li>',ra=['<div class="layim-chat layim-chat-{{d.data.type}}">','<div class="layim-chat-title">','<a class="layim-chat-other">','<img src="{{ d.data.avatar }}"><span layim-event="{{ d.data.type==="group" ? "groupMembers" : "" }}">{{ layui.data.escape(d.data.name) ||"\u4F5A\u540D" }} {{d.data.temporary ? "<cite>\u4E34\u65F6\u4F1A\u8BDD</cite>" : ""}} {{# if(d.data.type==="group"){ }} <em class="layim-chat-members"></em><i class="layui-icon"></i> {{# } }}</span>',"</a>","</div>",'<div class="chat_delate layui-icon" chatroom-event="closeThisChat"></div>','<div class="layim-chat-main">',"<ul></ul>","</div>",'<div class="layim-chat-footer">','<div class="layim-chat-tool" data-json="{{encodeURIComponent(JSON.stringify(d.data))}}">','<span class="layui-icon layim-tool-face" title="\u9009\u62E9\u8868\u60C5" chatroom-event="face"></span>','<span class="layui-icon layim-tool-image" title="\u4E0A\u4F20\u56FE\u7247" chatroom-event="image"><input type="file" name="Filedata"></span>',"{{# if(d.base && d.base.uploadFile){ }}",'<span class="layui-icon layim-tool-image" title="\u53D1\u9001\u6587\u4EF6" layim-event="image" data-type="file"><input type="file" name="file"></span>',"{{# }; }}","{{# if(d.base && d.base.chatLog){ }}",'<span class="layim-tool-log" layim-event="chatLog"><i class="layui-icon"></i>\u804A\u5929\u8BB0\u5F55</span>',"{{# }; }}","</div>",'<div class="layim-chat-textarea"><div class="send_out" chatroom-event="send"><span class="layim-send-btn"></span></div><textarea placeholder="\u8BF7\u8F93\u5165\u5185\u5BB9"></textarea></div>',"</div>","</div>"].join(""),$=['<li {{ d.mine ? "class=layim-chat-mine" : "" }}>','<div class="layim-chat-user"><img src="{{ layui.data.escape(layui.data.avatar(d.from.avatar,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.from.avatar)) }}" /><cite>',"{{# if(d.mine){ }}",'<i>{{ layui.data.date(d.timestamp) }}</i>{{ layui.data.escape(d.from.name) ||"\u4F5A\u540D" }}',"{{# } else { }}",'{{ layui.data.escape(d.from.name) ||"\u4F5A\u540D" }}<i>{{ layui.data.date(d.timestamp) }}</i>',"{{# } }}","</cite></div>",'<div class="layim-chat-text">{{ layui.data.content(d.content||" ",d) }}</div>',"</li>"].join(""),la=['<div data-type="friendMsg" class="news_img" chatroom-event="chat" data-islist="0" data-avatar="{{ layui.data.escape(layui.data.avatar(d.from.avatar)) }}" data-name="{{ layui.data.escape(d.from.name) }}" data-uid="{{ d.from.uid }}" data-tips="true">','<img src="{{ layui.data.escape(layui.data.avatar(d.from.avatar,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.from.avatar)) }}" alt=""/>',"</div>"].join(""),sa=['<div id="recent_{{ d.client_id }}" class="privatecha_list_once" data-type="friendMsg" data-avatar="{{ layui.data.escape(layui.data.avatar(d.avatar)) }}" data-name="{{ layui.data.escape(d.name) }}" data-uid="{{ d.uid }}" data-client_id="{{ d.client_id }}">',"<dl>","<dt>",'<img src="{{ layui.data.escape(layui.data.avatar(d.avatar,3)) }}" chatroom-event="chat" data-islist="2" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.avatar)) }}" alt=""/>',"</dt>","<dd>",'<div class="privatecha_name" chatroom-event="chat" data-islist="2"><span class="name_length">{{ layui.data.escape(layui.data.substr(d.name,8)) ||"\u4F5A\u540D" }}</span> <span class="privatecha_time">{{ layui.data.humanitytime(d.timestamp) }}</span></div>','<p class="privatecha_text">{{ layui.data.substr(layui.data.img2str(d.content),14) }}</p>',"</dd>","</dl>","</div>"].join(""),oa=['<div id="blacklist_{{ d.client_id }}" class="blacklist_once" data-avatar="{{ layui.data.escape(layui.data.avatar(d.avatar)) }}" data-name="{{ layui.data.escape(d.name) }}" data-uid="{{ d.uid }}" data-client_id="{{ d.client_id }}">',"<dl>","<dt>",'<img src="{{ layui.data.escape(layui.data.avatar(d.avatar,3)) }}" data-errorcount="0" onerror="coverError()" data-source="{{ layui.data.escape(layui.data.avatar(d.avatar)) }}" alt=""/>',"</dt>","<dd>",'<div class="blacklist_name">','<span class="blacklist_name_length">{{ layui.data.escape(layui.data.substr(d.name,8)) ||"\u4F5A\u540D" }}</span>',"</div>","</dd>","</dl>","</div>"].join(""),x,F,ca=function(a){var e={};a&&(e={avatar:layui.data.escape(a.avatar),client_id:a.client_id,name:layui.data.escape(a.name),type:a.type,uid:a.uid});var i={data:e,local:layui.data("layim")[c.uid]};if(!a.uid)return v.msg("\u975E\u6CD5\u7528\u6237");if(a.uid!=c.uid){v.close(F);var t=F=v.open({type:1,area:["100%","100%"],skin:"layui-box layui-layim-chat",id:"layui-layim-chat",title:"​",shade:!1,moveType:1,maxmin:!1,closeBtn:0,content:y('<ul class="layim-chat-list">'+na+"</ul>"+ra).render(i),success:function(r){x=r;var s=n(document).height()-83;n(".layim-chat-main").css("height",s+"px"),n(window).resize(function(){var l=n(document).height()-83;n(".layim-chat-main").css("height",l+"px")}),n(".layui-layim-chat").css("left","100%"),n(".tall_all").css("marginTop",n(".course_video").height()+"px"),Ia(),Sa()},min:function(){return!1},end:function(){v.closeAll("tips")}})}},da=function(a){var e={};typeof a.uid=="undefined"?(e.uid=n(a).data("uid"),e.name=n(a).data("name"),e.avatar=n(a).data("avatar"),e.client_id=n(a).data("client_id")):(e.uid=a.uid,e.name=a.name,e.avatar=a.avatar,e.client_id=a.client_id),n("#black-list").append(y(oa).render(e))},ua=function(a){p.room_config.gag=a},fa=function(a){if(typeof hlsplayurl!="undefined"){var e=hlsplayurl.replace("[liveid]",liveid+"_"+a.uid),i='<a id="camera_'+a.uid+'" href="javascript:;" class="video_once" hlsurl="'+e+'">'+a.name+"</a>";n("#camera_list").append(i)}},pa=function(a){n("#camera_"+a.uid).remove()},va=function(a){p.room_config.allow_raise=a},ma=function(a,e){if(e!==!1&&e!=="first")var i=e.attr("data-client_id");n("#online_list_"+a.client_id).length>0&&n("#online_list_"+a.client_id).remove(),n(".tall_list_once[data-uid="+a.uid+"]").length>0&&n(".tall_list_once[data-uid="+a.uid+"]").remove(),a.client_id==i&&e!==!1&&e!=="first"&&(e.prevObject.length>0?e=e.prevObject[0]:e="first"),y(ia).render(a,function(t){e==="first"?n("#online-list").prepend(t):e===!1?a.groupid==5?a.assistant&&n(".tall_list_once[data-groupid=5]").length>0?n(".tall_list_once[data-groupid=5]").last().after(t):n("#online-list").prepend(t):n("#online-list").append(t):n(e).after(t)})},ya=function(a){var e=a.userinfo||{};I(e),y(aa).render(a.userinfo,function(i){n(".online_box").hide(),n("#content-list").append(i),n("#content-list").scrollTop(n("#content-list")[0].scrollHeight),setTimeout(function(){n(".online_box").fadeOut()},2e3)})},ga=function(a){y(ea).render(a,function(e){n("#content-list").append(e),n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)})},ha=function(a,e){V(a);var i=a.filter(function(o){return o.groupid==="5"});if(i.length>0)i.forEach(function(o){I(o)});else{var t=A(),r=t+"\u5F00\u8BFE\uFF0C\u8001\u5E08\u5C1A\u672A\u8FDB\u5165\u6559\u5BA4\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85~";sessionStorage.setItem("waitLiveInfo",r)}if(e!==!1){var s=e;n(".online_count").html("("+s+")")}var l="";p.course.islive==1?(c.groupid==5,l=P):l=ta,a.mygroupid=c.groupid,y(l).render(a,function(o){n("#online-list").html(o)})},_a=function(a){a.mine=c,y(L).render(a,function(e){if(n("#content-list").append(e),n(".msg_box").length>S){var i=n(".msg_box").length-S;n(".msg_box:lt("+i+")").remove()}var t=a.content,r=/img\[([^\s]+?)\]/;clearTimeout(w),r.test(t)?w=setTimeout(function(){n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)},300):n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)}),window.onload=function(){var e=a.content,i=/img\[([^\s]+?)\]/;clearTimeout(w),i.test(e)?w=setTimeout(function(){n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)},300):n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)}},wa=function(a,e){var i=a.length;if(i>0){for(var t=0;t<i;t++){var r=a[t];if(r.mine=c,a[t].hasOwnProperty("userOnline")){try{a[t].userOnline.client_id=a[t].userOnline.uid}catch(d){console.log("\u540E\u7AEF\u5B57\u6BB5\u53C8\u5C11\u4E86\u4E48:",d)}y(L).render(r,function(d){n(".more_chatList").before(d)})}}if(n(".chatList_content").html("\u4EE5\u4E0A\u4E3A\u6700\u8FD1\u6D88\u606F"),n(".chatList_content").attr("clicked","false"),n(".more_chatList")[0].scrollIntoView(!1),e){var s=blackList.length;if(s>0)for(var t=0;t<s;t++){var l=blackList[t].uid,o=n(".tall_friend[data-uid="+l+"]");o.attr("blacklist",!0)}}}else n(".chatList_content").html("\u6682\u65E0\u6700\u8FD1\u6D88\u606F")},ba=function(a){if(c.uid!=a.userOnline.uid)var e=check();else var e=!0;a.mine=c;try{a.userOnline.client_id=a.userOnline.uid}catch(i){console.log("\u540E\u7AEF\u5B57\u6BB5\u53C8\u5C11\u4E86\u4E48:",i)}y(L).render(a,function(i){if(a.userOnline.groupid=="5"&&n("#content-list").append(i),n(".msg_box").length>S){var t=n(".msg_box").length-S;n(".msg_box:lt("+t+")").remove()}if(n("#recent-list").scrollTop(n("#recent-list")[0].scrollHeight),e){var r=a.content,s=/img\[([^\s]+?)\]/;clearTimeout(w),s.test(r)?w=setTimeout(function(){n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)},300):n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)}}),window.onload=function(){if(e){var i=a.content,t=/img\[([^\s]+?)\]/;clearTimeout(w),t.test(i)?w=setTimeout(function(){n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)},300):n("#content-list").scrollTop(n("#content-list")[0].scrollHeight)}}},ka=function(a){var e=a.uid||"";I({uid:e},!0),n("#online_list_"+a.client_id).remove()},E=function(){if(!(p.room_config.gag&&c.groupid==6&&liveObj.blackSend)){var a=100,e=n("#group-msg-input").val();if(e.replace(/\s/g,"")!==""){if(e.length>a)return v.msg("\u5185\u5BB9\u6700\u957F\u4E0D\u80FD\u8D85\u8FC7"+a+"\u4E2A\u5B57\u7B26");param={type:"groupMsg",content:e},layui.each(h.sendGroupMessage,function(i,t){t&&t(param)})}n("#group-msg-input").val("")}},H=function(){var a={type:"friendMsg",from:c,mine:!0},e=T(),i=e.elem.find(".layim-chat-main ul"),t=100;if(a.content=e.textarea.val(),a.content.replace(/\s/g,"")!==""){if(a.content.length>t)return v.msg("\u5185\u5BB9\u6700\u957F\u4E0D\u80FD\u8D85\u8FC7"+t+"\u4E2A\u5B57\u7B26");i.append(y($).render(a)),D();var r={content:a.content,type:"friendMsg",toid:e.data.uid},s={type:"friendMsg",from:c,to:e.data,id:e.data.uid,content:a.content,timestamp:new Date().getTime()};G(s);var l=e.data;l.content=a.content,l.timestamp=new Date().getTime(),j(l),layui.each(h.sendMessage,function(o,d){d&&d(r)})}e.textarea.val("")},Ta=function(a,e,i,t,r,s,l){var o="10.0.0",d="",m={};m.quality="high",m.allowscriptaccess="sameDomain",m.allowfullscreen="true",m.wmode="transparent";var u={};u.id=e,u.name=i,u.align="middle",swfobject.embedSWF(a,e,t,r,o,d,s,m,u,l),swfobject.createCSS("#"+e,"display:block;text-align:left;")},xa=function(a){a=a||{};var e=n(".layim-chatlist-"+a.type+a.id),i={},t=e.index();a.timestamp=a.timestamp||new Date().getTime(),G(a);var r=a.from;if(r.content=a.content,r.timestamp=new Date().getTime(),j(r),!x&&a.content||t===-1){Ca(a);return}var s=x.find(".layim-chat").eq(t),l=s.find(".layim-chat-main ul");a.content.replace(/\s/g,"")!==""&&(l.append(y($).render(a)),D())},Oa=function(a){n(".online_count").html("("+a+")")},Ca=function(a){n("#new_message_tips").html(y(la).render(a)),n("#new_message_tips").show()},j=function(a){var e=layui.data("layim")[c.uid]||{},i=e.recentlog||new Array;layui.each(i,function(t,r){r.uid==a.uid&&i.splice(t,1)}),i.push(a),i.length>20&&i.shift(),e.recentlog=i,layui.data("layim",{key:c.uid,value:e}),z()},z=function(){var a=layui.data("layim")[c.uid]||{};recentlog=a.recentlog||new Array,recentlog.reverse(),n("#recent-list").html(""),layui.each(recentlog,function(e,i){n("#recent-list").append(y(sa).render(i))})},G=function(a){a.from.uid==c.uid?a.mine=!0:a.mine=!1;var e=layui.data("layim")[c.uid]||{},i=e.chatlog||{};i[a.type+a.id]?(i[a.type+a.id].push(a),i[a.type+a.id].length>Y&&i[a.type+a.id].shift()):i[a.type+a.id]=[a],e.chatlog=i,layui.data("layim",{key:c.uid,value:e})},Sa=function(){var a=layui.data("layim")[c.uid]||{},e=T(),i=a.chatlog||{},t=e.elem.find(".layim-chat-main ul");layui.each(i[e.data.type+e.data.uid],function(r,s){t.append(y($).render(s))}),D()},D=function(){var a=T(),e=a.elem.find(".layim-chat-main"),i=e.find("ul");e.scrollTop(e[0].scrollHeight),e.find("ul li:last").find("img").load(function(){e.scrollTop(e[0].scrollHeight)})},Ma=function(){var a=n(".chatList_content").attr("clicked"),e={type:"chatlist",state:a};layui.each(h.getChatListFun,function(i,t){t&&t(e)})},T=function(){var a=n(".layim-chat-list ."+M).index(),e=x.find(".layim-chat").eq(a),i=JSON.parse(decodeURIComponent(e.find(".layim-chat-tool").data("json")));return{elem:e,data:i,textarea:e.find("textarea")}},Ia=function(){var a=T(),e=a.textarea;e.off("keydown").on("keydown",function(i){var t=layui.data("layim")[c.uid]||{},r=i.keyCode;if(r==8){var s="",l=n(this).get(0);if(l.setSelectionRange){var o=l.selectionStart,d=l.selectionEnd,m=l.value.substring(o-1,o),u=l.value.substring(0,o-1),k=l.value.substring(d);if(s=u+k,m=="]"&&u.indexOf("face[")>-1){var _=u.match(/face(\[[^\s\[\]]*)$/g);face_str=_+"]",face_str.match(/face\[([^\s\[\]]+?)\]/g)&&(s=u.substring(0,u.lastIndexOf("face["))+k)}if(m=="]"&&u.indexOf("img[")>-1){var _=u.match(/img(\[[^\s\[\]]*)$/g);img_str=_+"]",img_str.match(/img\[([^\s\[\]]+?)\]/g)&&(s=u.substring(0,u.lastIndexOf("img["))+k)}return l.value=s,l.focus(),l.setSelectionRange(o-1,o-1),!1}else return!0}if(t.sendHotKey==="Ctrl+Enter"){i.ctrlKey&&r===13&&H();return}if(r===13){if(i.ctrlKey)return e.val(e.val()+`
|
|
`);if(i.shiftKey)return;i.preventDefault(),H()}})},O=function(){var a=["[\u7231\u4F60]","[\u767D\u773C]","[\u9F3B\u6D95]","[\u95ED\u5634]","[\u5472\u7259]","[\u5927\u7B11]","[\u5F97\u610F]","[\u6076\u5FC3]","[\u53D1\u70E7]","[\u5C34\u5C2C]","[\u9B3C\u8138]","[\u597D\u5403]","[\u778C\u7761]","[\u53E3\u6C34]","[\u53E3\u7F69]","[\u5BBD\u6170]","[\u51B7]","[\u96BE\u8FC7]","[\u4FCF\u76AE]","[\u4EB2\u4EB2]","[\u70ED]","[\u53D7\u4F24]","[\u7761\u7740\u4E86]","[\u8BF4\u8C0E]","[\u601D\u8003]","[\u5410\u4E86]","[\u5410\u820C]","[\u54C7\u585E]","[\u5FAE\u7B11]","[\u559C\u6B22]","[\u7B11\u54ED]","[\u865A\u5F31]","[\u5618]","[\u6655\u7729]","[100\u5206]","[\u7231\u5FC3]","[\u62DC\u6258]","[\u5927\u54ED]","[\u62C5\u5FE7]","[\u9F13\u638C]","[\u54C8\u6B20]","[\u52A0\u6CB9]","[\u60CA\u6050]","[\u60CA\u8BB6]","[\u6CAE\u4E27]","[\u805A\u4F1A]","[\u6073\u6C42]","[\u54ED\u6CE3]","[\u8138\u7EA2]","[\u73AB\u7470]","[\u8FF7\u60D1]","[\u58A8\u955C]","[\u725B\u4ED4]","[\u75B2\u60EB]","[\u5F3A\u58EE]","[\u751F\u6C14]","[\u80DC\u5229]","[\u5C0F\u4E11]","[\u5FC3\u788E]","[\u773C\u955C]","[\u8D5E]","[\u5492\u9A82]","[OK]"],e={};return layui.each(a,function(i,t){e[t]=layui.cache.dir+"images/emoji/"+i+".png"}),e}(),C=layui.stope,J=function(a,e){var i,t=a.value;a.focus(),document.selection?(i=document.selection.createRange(),document.selection.empty(),i.text=e):(i=[t.substring(0,a.selectionStart),e,t.substr(a.selectionEnd)],a.focus(),a.value=i.join(""))},R=function(a){var e=new RegExp("(^|&)"+a+"=([^&]*)(&|$)"),i=window.location.search.substr(1).match(e);return i!=null?unescape(i[2]):null},La=function(a){var e=n(a).val(),i=n(a).attr("isfriend"),t=e.substr(e.lastIndexOf(".")).toLowerCase(),r=n(a)[0].files[0],s=Math.round(r.size/1024*100)/100;if(t!=".jpg"&&t!=".png"){v.msg("\u4E0D\u652F\u6301\u8BE5\u6587\u4EF6\u683C\u5F0F",{icon:2});return}else if(s>2048)if(s>20480){v.msg("\u56FE\u7247\u4E0D\u5F97\u8FC7\u5927",{icon:2});return}else new Compressor(r,{quality:.4,success(l){K(2,l,i,r)}});else K(1,r,i)},K=function(a,e,i,t){var r=R("key")==null?n.cookie("token"):R("key"),s=new FormData;s.append("busType","chat_image"),a==1?s.append("file",e):s.append("file",e,t.name),n.ajax({url:"/api/common/upload",type:"POST",cache:!1,processData:!1,contentType:!1,headers:{token:r},data:s,dataType:"json",success:function(l){var o=l.success;if(o){n(".group_chat_img").val("");var d=l.data.sourcePath;if(i=="0"){var m=R("cwid"),u="img["+(d||"")+"]",k={type:"groupMsg",from:c,to:m,content:u,timestamp:new Date().getTime()};N(u,function(){layui.each(h.sendGroupMessage,function(_,W){W&&W(k)})})}else N(u,function(){var _=T();J(_.textarea[0],u)})}else n(".group_chat_img").val(""),v.msg(l.message,{icon:2})}})},N=function(a,e){a.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/@(\S+)(\s+?|$)/g,'@<a href="javascript:;">$1</a>$2').replace(/\s{2}/g," ").replace(/img\[([^\s]+?)\]/g,function(i){var t=(window.cdnPath||"")+""+i.replace(/(^img\[)|(\]$)/g,""),r=t.replace("!medium",""),s=r.replace(/([^.]*).([^.]*)$/g,"$1!small.$2"),l="";l+='<img class="preloadingImg" src="'+s+'" data-errorcount="0" onerror="coverError()" data-source="'+t+'" style="width:0px;height:0;" />',n("body").append(l),setTimeout(function(){e(),n("body").find(".preloadingImg").remove()},2e3)})},B="layui-anim-up",g={sendGroup:function(){E()},send:function(){H()},chat:function(a){return;var e,i;if(i=="1")var t;else if(i=="2")var t=a.parents(".privatecha_list_once");else var t=a;var r},setSend:function(a,e){var i=a.siblings(".layim-menu-box"),t=function(){i.hide().removeClass(B)},r=a.attr("lay-type");if(r==="show")C(e),i.show().addClass(B),n(document).off("click",t).on("click",t);else{a.addClass(M).siblings().removeClass(M);var s=layui.data("layim")[c.uid]||{};s.sendHotKey=r,layui.data("layim",{key:c.uid,value:s})}},face:function(a,e){var i="",t=T(),r=function(){v.close(g.face.index)};for(var s in O)i+='<li title="'+s+'"><img src="'+O[s]+'"></li>';i='<ul class="layui-clear layim-face-list">'+i+"</ul>",g.face.index=v.tips(i,a,{tips:1,time:0,fix:!0,skin:"layui-box layui-layim-face",success:function(l){l.find(".layim-face-list>li").on("touchstart",function(o){C(o)}).on("touchstart",function(){t.textarea[0].value=t.textarea[0].value+" face"+this.title+" ",v.close(g.face.index)})}}),n(document).off("touchstart",r).on("touchstart",r),n(window).off("resize",r).on("resize",r),C(e)},closeThisChat:function(){n(".layui-layim-chat").animate({left:"100%"},500,function(){n("#tall_all").css("marginTop","0px"),x.remove(),n(".loading").css("display")=="none"&&(n("#_video").show(),n("#tall_all").css("margin","0"))})},image:function(a){var e=a.data("type")||"images",i={images:"/im/upload.html?uptype=pic"},t=T();layui.upload({url:i[e],method:"POST",elem:a.find("input")[0],unwrap:!0,type:e,success:function(r){r.state=="SUCCESS"?e==="images"&&J(t.textarea[0],"img["+(r.url_path||"")+"]"):v.msg(r.msg||"\u4E0A\u4F20\u5931\u8D25")}})},group_chat_img:function(a){var e=a.data("type")||"images",i={images:"/im/upload.html?uptype=pic"};layui.upload({url:i[e],method:"POST",elem:a.find("input")[0],unwrap:!0,type:e,success:function(t){t.state=="SUCCESS"?e==="images"&&(param={type:"groupMsg",from:c,to:room_id,content:"img["+(t.url_path||"")+"]",timestamp:new Date().getTime()},layui.each(h.sendGroupMessage,function(r,s){s&&s(param)})):v.msg(t.msg||"\u4E0A\u4F20\u5931\u8D25")}})},showimg:function(a){v.close(U);var e=a[0].dataset.source,i="";e.indexOf("!medium")>-1?i=e.replace("!medium",""):i=e,v.photos({photos:{data:[{alt:"\u5927\u56FE\u6A21\u5F0F",src:i}]},shade:.01,closeBtn:2,success:function(t,r){U=r}})},qqface:function(a,e){var i=n("#group-msg-input").is(":focus");i?(n("#group-msg-input").blur(),setTimeout(function(){g.qqFaceShow(a,e)},500)):g.qqFaceShow(a,e)},qqFaceShow:function(a,e){var i="",t=function(){v.close(g.face.index)},r=0;for(var s in O)r+=1,r<=44&&(i+='<li title="'+s+'"><img src="'+O[s]+'"></li>');i='<ul class="layui-clear layim-face-list">'+i+"</ul>",g.face.index=v.tips(i,a,{tips:1,time:0,fix:!0,skin:"layui-box layui-layim-face",success:function(l){l.find(".layim-face-list>li").on("touchstart",function(o){C(o)}).on("touchstart",function(){n("#group-msg-input").val(n("#group-msg-input").val()+"face"+this.title+" "),v.close(g.face.index)})}}),n(document).off("touchstart",t).on("touchstart",t),n(window).off("resize",t).on("resize",t),C(e)},getChatList:function(){Ma()}};n("#group-msg-input").keydown(function(a){var a=a||window.event,e=liveObj.blackSend,i=liveObj.allowSend;if(keycode=a.which||a.keyCode,keycode==13)return typeof i=="undefined"||typeof e=="undefined"?(E(),!1):(i&&e&&E(),!1);if(keycode==8){var t="",r=n(this).get(0);if(r.setSelectionRange){var s=r.selectionStart,l=r.selectionEnd,o=r.value.substring(s-1,s),d=r.value.substring(0,s-1),m=r.value.substring(l);if(t=d+m,o=="]"&&d.indexOf("face[")>-1){var u=d.match(/face(\[[^\s\[\]]*)$/g);face_str=u+"]",face_str.match(/face\[([^\s\[\]]+?)\]/g)&&(t=d.substring(0,d.lastIndexOf("face["))+m)}if(o=="]"&&d.indexOf("img[")>-1){var u=d.match(/img(\[[^\s\[\]]*)$/g);img_str=u+"]",img_str.match(/img\[([^\s\[\]]+?)\]/g)&&(t=d.substring(0,d.lastIndexOf("img["))+m)}return r.value=t,r.focus(),r.setSelectionRange(s-1,s-1),!1}else return!0}}),X("chatroom",new f)});
|