filesbox/web/dist/design/designstatic/newJS/chatroom/playCommon.js
2024-07-26 14:10:54 +08:00

12 lines
16 KiB
JavaScript

(function(D){if(D.$){let x=function(){$("#setting_dialog .dialog_close").click(),$(".zeromodal-close").length>0&&$(".zeromodal-close").click()},k=function(){var e=/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent);if(e)return{f:0,v:0};var t=0,n=0;if(document.all){var i=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");i&&(t=1,VSwf=i.GetVariable("$version"),n=parseInt(VSwf.split(" ")[1].split(",")[0]))}else if(navigator.plugins&&navigator.plugins.length>0){var i=navigator.plugins["Shockwave Flash"];if(i){t=1;for(var a=i.description.split(" "),l=0;l<a.length;++l)isNaN(parseInt(a[l]))||(n=parseInt(a[l]))}}return{f:t,v:n}},b=function(){$("#danmu").danmu("setOpacity",0)},w=function(){$("#danmu").danmu("setOpacity",1),$("#danmu").danmu("danmuResume")},O=function(e,t,n){var i=S(n),a=new Date;a.setTime(a.getTime()+i*1),document.cookie=e+"="+escape(t)+";expires="+a.toGMTString()},A=function(e){for(var t=document.cookie,n=t.split("; "),i=0;i<n.length;i++){var a=n[i].split("=");if(a[0]==e)return a[1]}return""},S=function(e){var t=e.substring(1,e.length)*1,n=e.substring(0,1);if(n=="s")return t*1e3;if(n=="h")return t*60*60*1e3;if(n=="d")return t*24*60*60*1e3},y=function(){$("#danmu").danmu({left:0,top:0,zindex:2222223,height:"100%",width:"100%",speed:7e3,opacity:1,font_size_small:16,font_size_big:24,top_botton_danmu_time:6e3,maxCountInScreen:5e3,maxCountPerSec:5e3}),$("#danmu").css({"pointer-events":"none"});var e=document.createElement("style");e.classList.add("BULLET_ANIMATE");var t="from { visibility: visible; transform: translateX(".concat($("#danmu").width(),"px); }"),n="@keyframes RightToLeft { ".concat(t," ").concat("to { visibility: visible; transform: translateX(-100%); }"," }");e.innerHTML=n+`
.bullet-item-style {
cursor: pointer;
position: absolute;
left: 0;
animation-name: RightToLeft;
animation-timing-function: linear;
backface-visibility: hidden;
will-change: transform;
}
`,document.head.appendChild(e),C.clearInterval(),C.setInterval(function(){if((window.acceptDmList||[]).length){let i=window.acceptDmList.shift();i.time=$("#danmu").data("nowTime")+1,$("#danmu").danmu("addDanmu",i)}},50)},I=function(e={}){const t=$("#danmu").data("nowTime")+1,{color:n,position:i,size:a,text:l,isMy:h}=e;let g={color:`#${n}`,xposition:d.position,position:0,size:d.size,text:l,time:t};h?(g.isnew="",$("#danmu").danmu("addDanmu",g)):window.acceptDmList=[...window.acceptDmList||[],g]},F=function(){const e=$(".live_wap_bar input").val();liveObj.sendDm({type:"barrage",color:d.color.replace("#",""),position:d.position,text:e}),$(".live_wap_bar input").val("")},v=function(e){var t=new RegExp("(^|&)"+e+"=([^&]*)(&|$)","i"),n=new RegExp("(^|/)"+e+"/([^/]*)(/|$)","i"),i=window.location.search.substr(1).match(t),a=window.location.pathname.substr(1).match(n);return i!=null?unescape(i[2]):a!=null?unescape(a[2]):null};var B=x,M=k,P=b,X=w,H=O,W=A,G=S,N=y,J=I,V=F,U=v;let m=!1,d={color:"#ffffff",opacity:1,size:1,position:0};$(function(){$(document).on("click",".js_msg_audio",function(){const o=$(this);o.toggleClass("audio_stop");const s=o.find("audio")[0],r=s.paused;$(".js_msg_audio").not(this).each(function(){$(this).removeClass("audio_stop").find("audio")[0].pause()}),r?s.play():s.pause()}),$(document).on("click",".tall-top-btn",function(){$("#content-list").animate({scrollTop:0})}),$(document).on("click",".tall-bottom-btn",function(){var o=$("#content-list"),s=parseInt($("#content-list > div:last").offset().top)+o.scrollTop();o.animate({scrollTop:s})}),$(document).on("touchstart",".menuBox",function(){var o=$(".operation_box"),s=$(".operation_shadow");o.hasClass("open")?(o.removeClass("open"),s.removeClass("open")):(o.addClass("open"),s.addClass("open"))}),$(document).on("click",".operation_close, .shareBox",function(){var o=$(".operation_box"),s=$(".operation_shadow");o.removeClass("open"),s.removeClass("open")});var e="";$(document).on("click",".hide-video-btn",function(){var o=$(this),s=parseInt($(".tab_box").height()),r=parseInt($("body").height()),c=$("#tall_all"),p=$("#tall_all .layui-tab-content"),u=$("#content-list"),f=$(".bottom_operation").height();o.hasClass("hide")?($("#course_video").removeClass("hide"),o.removeClass("hide"),$(".live_wap_bar").css("display",e)):($("#course_video").addClass("hide"),o.addClass("hide"),e=$(".live_wap_bar").css("display"),$(".live_wap_bar").hide()),liveObj.selfZoom()});var t=navigator.userAgent,n=!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);console.log("isiOS",n),n&&($(".all-screen-btn").hide(),$(".live_wap_bar").css("right","50px"),$(".hide-video-btn").css("right","12px")),$(document).on("click",".all-screen-btn",function(){var o=$(".video video")[0];if($(this).hasClass("hide"))return!1;o?(o.requestFullscreen&&o.requestFullscreen(),o.webkitRequestFullScreen&&o.webkitRequestFullScreen()):layer.msg("\u64AD\u653E\u5668\u8FD8\u672A\u521B\u5EFA")}),$(document).on("click",".js_play_notice",function(){const o=$(this),s=o.parents(".studio_notice_box");o.toggleClass("header_up"),s.find(".studio_notice").slideToggle()}),$(document).on("click",".close_Btn_notice",function(){var o=$(this),s=o.parents(".studio_notice_box");s.remove()});const i=40;$(".js_inter_move").on({mousedown:function(o){let s=o.pageX;$(document).on("mousemove.drag",function(r){let c=event.pageX;if(c>i){const u=$(".camrem_list_box").width()+s-c;$(".camrem_list_box").width(u),s=c}}).on("mouseup",function(r){$(document).off("mousemove.drag")})}});const a=o=>{const s=`${o}% 100%`,r=o/100;if($("#whiteboard_box").find("object").length<1){const u=$("#online")[0];u&&(u.volume=r)}else window.getPlayer&&getPlayer("online").volume(r);$(".voice_change .percent").text(`${o}%`);const p=o!==0?"volume":"mute";$(".js_voice_btn img").attr("src",`/design/designstatic/chatroom/studio/img/${p}.png`),$(".js_bar_range").css({"background-size":s})};$(document).on("click",".js_voice_btn",function(){const o=!$(this).data("voice");$(this).data("voice",o);const s=o?100:0;$(".js_bar_range").val(s),$(".js-volume_panel").hide(),a(s)}),$(document).on("click",".js-voice-player-tip",function(){$(".js-volume_panel").hide(),window.localStorage.setItem("voicePlayerTip",1)}),$(document).on("change",".js_bar_range",function(){const o=+$(".js_bar_range").val();a(o)});function l(o){for(var s=o.split(","),r=s[0].match(/:(.*?);/)[1],c=atob(s[1]),p=c.length,u=new Uint8Array(p);p--;)u[p]=c.charCodeAt(p);return new Blob([u],{type:r})}function h(){if($("#online").length<1||$(".onLine_bak").css("display")==="block"){layer.msg("\u8001\u5E08\u4E0A\u8BFE\u671F\u95F4\u624D\u53EF\u622A\u5C4F");return}html2canvas(document.querySelector("#online")).then(function(o){const s=o.getContext("2d"),r=document.getElementById("online");s.drawImage(r,0,0,o.width,o.height);const c=o.toDataURL("image/png"),p=artTemplate("temp_capture",{imgSrc:c});$("#capture_layer").html(p),$("#cropperImg").cropper({crop:function(f){$(".btn-x span").text(parseInt(f.x)),$(".btn-y span").text(parseInt(f.y)),$(".btn-width span").text(parseInt(f.width)),$(".btn-height span").text(parseInt(f.height)),$(".btn-rotate span").text(parseInt(f.rotate))}});function u(){$("#capture_layer").html("")}$(".js_capture_sure").click(function(){$(this).text("\u6B63\u5728\u53D1\u9001").removeClass("js_capture_sure");const f=$("#cropperImg").cropper("getCroppedCanvas").toDataURL(),_=`${new Date().getTime()}.png`,E=l(f,_),q=new File([E],_,{type:"image/png",lastModified:Date.now()});captureUploadBase(q,()=>{u()})}),$(".js_capture_save").click(function(){const T=$("#cropperImg").cropper("getCroppedCanvas").toDataURL("image/png"),_=document.createElement("a");_.download="image"+new Date().getTime()+".png",_.href=T,$("body").append(_),_.click(),$(_).remove()}),$(".js_capture_cancel").click(()=>{u()}),$(".btn-reset").on("click",function(){$("#cropperImg").cropper("reset")}),$(".zoom-in").on("click",function(){$("#cropperImg").cropper("zoom",.1)}),$(".zoom-out").on("click",function(){$("#cropperImg").cropper("zoom",-.1)}),$(".rotate-left").on("click",function(){$("#cropperImg").cropper("rotate",-45)}),$(".rotate-right").on("click",function(){$("#cropperImg").cropper("rotate",45)})})}window.videoCapture=h;let g=!1;const j=["troom/looklive.html","troom/assistantlive.html","myroom/livecourse.html"];function R(o){let s=!1;const r=j.length;for(var c=0;c<r;c++)if(o.indexOf(j[c])>-1){s=!0;break}return s}$(document).on("click",".js-player",function(){if($(this).data("type"))window.localStorage.setItem("isFlashPlayerError",1),window.localStorage.setItem("isSwitchFlash",0),location.reload();else if(window.localStorage.setItem("isSwitchFlash",1),k().f===1)location.reload();else{const r=document.createElement("a");r.setAttribute("href","//www.adobe.com/go/getflash"),r.setAttribute("target","_blank"),r.click()}})});const z=e=>{$(e).parents(".js_msg_audio").removeClass("audio_stop")};window.audioPlayEnd=z,$(document).on("click",".js_tea_inter_mute li",function(){const e=$(this),t=e.parents(".js_tea_inter_mute").data("uid"),n=e.parents(".remote_camera").find(".voice_level_box"),i=e.data("type"),a=e.data("mute"),l=!a;switch(i){case"single":{const h=a?"\u9759\u97F3":"\u53D6\u6D88\u9759\u97F3";e.data("mute",l).text(h),interactiveFun.sendSin(t,l),l?n.addClass("voice_mute_box"):n.removeClass("voice_mute_box");break}case"all":{const h=a?"\u5168\u4F53\u9759\u97F3":"\u53D6\u6D88\u5168\u4F53\u9759\u97F3",g=a?"\u9759\u97F3":"\u53D6\u6D88\u9759\u97F3";$(".js_tea_sing").data("mute",l).text(g),$(".js_tea_all").data("mute",l).text(h),interactiveFun.sendAll(l),l?$(".voice_level_box").addClass("voice_mute_box"):$(".voice_level_box").removeClass("voice_mute_box");break}case"closeCamera":ws.send(JSON.stringify({type:"close_camera",uid:t}));default:break}});const L={isSupport(){return document.fullscreenEnable||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled},fullScreen(e){this.isSupport()&&(e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen())},exitFullscreen(){document.fullscreenElement&&(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen())}};window.ScreenFull=L,window.closeSetting=x;const C={intervalTimer:null,timeoutTimer:null,setTimeout(e,t){let n=Date.now,i=n(),a=i,l=()=>{this.timeoutTimer=requestAnimationFrame(l),a=n(),a-i>=t&&(e(),cancelAnimationFrame(this.timeoutTimer))};return this.timeoutTimer=requestAnimationFrame(l),this.timeoutTimer},clearTimeout(){cancelAnimationFrame(this.timeoutTimer)},setInterval(e,t){let n=Date.now,i=n(),a=i,l=()=>{this.intervalTimer=requestAnimationFrame(l),a=n(),a-i>=t&&(i=n(),a=i,e())};return this.intervalTimer=requestAnimationFrame(l),this.intervalTimer},clearInterval(){cancelAnimationFrame(this.intervalTimer)}};$(document).on("click",".js_bar_switch",function(){$(this).toggleClass("text_open"),$(".js_danmu").toggle(),$("#danmu").length<1&&($("#live_content").length>=1?$("#live_content").append('<div id="danmu"></div>'):$("#studio_play_content").length>=1?$("#studio_play_content").prepend('<div id="danmu"></div>'):$("#whiteboard_box").length>=1&&$("#whiteboard_box").prepend('<div id="danmu"></div>'),y()),m=!m,window.localStorage.setItem("isOpenBarrage",m?1:0),m?w():b()}),$(document).on("click","#live_shop",function(){var e=$("body").find("#liveShop_play");if(e.length){window.liveShopDialog.open();return}var t=window.location.href.indexOf("assistantlive.html")>-1;if(window.location.href.indexOf("views/common/smallclass.html")>-1){var n=liveObj.courseData||{};t=n.userType==2}var i=v("courseId"),a=v("cwid");window.liveShopDialog=new ebhDialog({id:"liveShop_play",title:t?"\u76F4\u64AD\u5E26\u8D27":"\u63A8\u8350\u8D2D\u4E70",width:1e3,height:600,iframeId:"iframe_liveShopList",iframe:location.protocol+"//"+location.host+(t?"/aroom/#/simplify/sendgoods?courseId=":"/myroom/#/nolimit/sendgoods?courseId=")+i+"&courseWareId="+a}),window.liveShopDialog.open()}),$(document).on("click","#live_shop_review",function(){var e=$("body").find("#liveShop_play");if(e.length){window.liveShopDialog.open();return}var t=!0,n=v("courseId"),i=v("cwid");window.liveShopDialog=new ebhDialog({id:"liveShop_play",title:"\u76F4\u64AD\u5E26\u8D27",width:1e3,height:600,iframeId:"iframe_liveShopList",iframe:location.protocol+"//"+location.host+(t?"/aroom/#/simplify/sendgoods?courseId=":"/myroom/#/nolimit/sendgoods?courseId=")+n+"&courseWareId="+i}),window.liveShopDialog.open()}),$(document).on("click","#live_shop_stu",function(){var e=$("body").find("#liveShop_play");if(e.length){window.liveShopDialog.open();return}var t=v("courseId"),n=v("cwid");window.liveShopDialog=new ebhDialog({id:"liveShop_play",title:"\u63A8\u8350\u8D2D\u4E70",width:1e3,height:600,iframeId:"iframe_liveShopList",iframe:location.protocol+"//"+location.host+"/myroom/#/nolimit/sendgoods?courseId="+t+"&courseWareId="+n}),window.liveShopDialog.open()}),$(document).on("click","#live_shop_wap",function(){var e=$(".liveshopwap_box"),t=$(".liveshopwap_shadow"),n=$("#liveshopwapIframe"),i=v("courseId"),a=v("cwid"),l=liveObj.wareInfo||{},h=l.userType==2;e.hasClass("open")?(e.removeClass("open"),t.removeClass("open")):(e.addClass("open"),t.addClass("open"),n.attr("src",location.protocol+"//"+location.host+(h?"/aroom/#/simplify/sendgoods?courseId=":"/myroom/#/nolimit/sendgoods?courseId=")+i+"&courseWareId="+a))}),$(document).on("click",".liveshopwap_close",function(){var e=$(".liveshopwap_box"),t=$(".liveshopwap_shadow");e.removeClass("open"),t.removeClass("open")}),$(document).on("click",".eyecaremode_box",function(){$(this).toggleClass("eyecaremode_open"),$("#online").toggleClass("eyecaremodefilter")}),$(document).on("click",".js_send_bar",function(e){if(e.stopPropagation(),m){const t=artTemplate("temp_bar_model");$("#bar_layer").html(t),((liveObj.studioChat||{}).isGag||liveObj.isGag)&&($(".bar_box .js_bar_send").css("background","#ccc"),$(".bar_box .js_bar_send").attr("disabled","disabled"))}$(".bar_setting_box").hide()}),$(document).on("keyup",".bar_box_model input",function(){const e=$(".bar_box_model input").val().length;let t=20-e<0?0:20-e;$(".bar_box_model .test_area_surplusSize").html(t)}),$(document).on("click",".js_bar_send",function(){const e=$(".bar_box_model input").val();liveObj.sendDm({type:"barrage",color:d.color.replace("#",""),position:d.position,text:e}),$("#bar_layer").html("")}),window.acceptDM=I,$(document).on("click",".bar_setting",function(e){e.stopPropagation(),$(".bar_setting_box").toggle(),$("#bar_layer").html("")}),$(document).on("click",".bar_setting_box ,.bar_box_model",function(e){e.stopPropagation()}),$.fn.getBackgroundColor=function(){var e=$(this).css("background-color");if(e>=0)return e;{let n=function(i){return("0"+parseInt(i).toString(16)).slice(-2)};var t=n;e=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/),e="#"+n(e[1])+n(e[2])+n(e[3])}return e},$(document).on("click",".color_content .block",function(){$(".color_content .block").removeClass("active");const e=$(this);e.addClass("active");const t=e.getBackgroundColor();$(".color_hex").text(t),$(".color_show").css({backgroundColor:t}),d.color=t}),$(document).on("click",".bar_pos .pos_content div",function(){const e=$(this),t=e.data("type");switch($(".bar_pos .pos_content div").removeClass("top_hover").removeClass("mid_hover").removeClass("bot_hover").removeClass("random_hover"),t){case 0:{d.position=0,e.addClass("top_hover");break}case 1:{d.position=1,e.addClass("mid_hover");break}case 2:{d.position=2,e.addClass("bot_hover");break}case 3:{d.position=3,e.addClass("random_hover");break}}}),$(document).on("click",".bar_size p",function(){const e=$(this);$(".bar_size p").removeClass("active"),e.addClass("active"),d.size=e.data("type")}),$(document).on("change",".op_box input",function(){const e=$(this).val();$(".op_box span").text(`${e}%`);const t=e/100;$("#danmu").danmu("setOpacity",t),d.opacity=t}),$(document).on("click",".bar_btn",function(){$("#danmu").length<1&&($(".mui-content").append('<div id="danmu"></div>'),y()),m=!m,window.localStorage.setItem("isOpenBarrage",m?1:0),d.size=0,m?w():b(),$(this).toggleClass("bar_btn_hover"),$(".live_wap_bar input").toggle()}),$(document).on("keypress",".live_wap_bar input",function(e){e.keyCode=="13"&&F()})}})(window);