").attr({id:id,src:file,type:'text/javascript'}).appendTo(jQuery('body'))}
function handleHostJS(){if(typeof window.roleFromAudienceToHost!='undefined'){var scriptList=[{src:jQuery("script#wp-agora-io-agora-deviceTest-js-js").attr('src'),id:"wp-agora-io-agora-deviceTest-js-js"},{src:jQuery("script#wp-agora-io-agora-stream-audioErr-js").attr('src'),id:"wp-agora-io-agora-stream-audioErr-js"},];reload(scriptList)}}
async function createTmpCameraStream(uid,hasVideo){await handleHostJS();const localStream=AgoraRTC.createStream({streamID:uid,audio:!0,video:hasVideo,screen:!1});localStream.setVideoProfile(window.cameraVideoProfile);localStream.on("accessAllowed",function(){if(window.devices.cameras.length===0&&window.devices.mics.length===0){AgoraRTC.Logger.info('[DEBUG] : checking for cameras & mics');window.AGORA_UTILS.getCameraDevices();window.AGORA_UTILS.getMicDevices()}
AgoraRTC.Logger.info("accessAllowed");if(!hasVideo){const msg={text:"USER_JOINED_WITHOUT_PERMISSIONS",messageType:"TEXT"}
console.log('sending message')
window.AGORA_RTM_UTILS.sendChannelMessage(msg,cb)}});localStream.on("accessDenied",function(){AgoraRTC.Logger.warning("accessDenied")});localStream.init(function(){AgoraRTC.Logger.info('getUserMedia successfully');if(window.channel_type=='broadcast'){localStream.play('full-screen-video')}else{localStream.play('local-video')}
window.localStreams.tmpCameraStream=localStream;jQuery('#buttons-container').fadeIn()},function(err){AgoraRTC.Logger.error('[ERROR] : getUserMedia failed',err);if(err.msg==='NotAllowedError'){const msg={text:"USER_JOINED_WITHOUT_PERMISSIONS**"+uid,messageType:"TEXT"}
window.AGORA_RTM_UTILS.sendChannelMessage(msg)
window.AGORA_COMMUNICATION_UI.enableExit()
window.AGORA_UTILS.showPermissionsModal()}})}
function raiseHandRequestsContent(){let html="
";let requests=window.raiseHandRequests;if(Object.keys(window.raiseHandRequests).length==0){html+="
No request!!
"}else{Object.keys(requests).forEach(function(key){html+="
"+requests[key].userDetails+"
"+"
"+"
"})}
html+="
";return html}
function addNewRaiseHandReqContent(){jQuery("body .raise-hand-requests #total-requests").html(Object.keys(window.raiseHandRequests).length);jQuery("body").find("#view-raise-hand-requests-modal #raise-hand-requests-list").html(raiseHandRequestsContent())}
function removeRaiseHandReqContent(memberId){delete window.raiseHandRequests[memberId];jQuery("body #request-row-"+memberId).remove();sessionStorage.setItem("raiseHandRequests",JSON.stringify(window.raiseHandRequests));let totalRequests=Object.keys(window.raiseHandRequests).length;if(totalRequests==0){totalRequests=''}
jQuery("body .raise-hand-requests #total-requests").html(totalRequests)}
jQuery(document).ready(function(){jQuery("body").on("click",".raise-hand-requests button",function(){jQuery("body").find("#view-raise-hand-requests-modal #raise-hand-requests-list").html(raiseHandRequestsContent());jQuery('#view-raise-hand-requests-modal').modal('toggle')});jQuery("body").on("click",".reject-raise-hand",function(){let memberId=jQuery(this).attr('id');const msg={description:undefined,messageType:'TEXT',rawMessage:undefined,text:'RAISE-HAND-REJECTED'}
try{window.AGORA_RTM_UTILS.sendPeerMessage(msg,memberId);removeRaiseHandReqContent(memberId)}catch(e){}});jQuery("body").on("click",".accept-raise-hand",function(){let memberId=jQuery(this).attr('id');const msg={description:undefined,messageType:'TEXT',rawMessage:undefined,text:'RAISE-HAND-ACCEPTED'}
try{window.AGORA_RTM_UTILS.sendPeerMessage(msg,memberId);removeRaiseHandReqContent(memberId)}catch(e){}})});function joinAsAgoraHost(){var params={action:'load_host_view',channel_id:window.channelId,page_title:page_title};window.screenshareClients={};window.remoteStream={};window.removeEventListener('agora.rtm_init',loadChatApp);window.removeEventListener('agora.rtmMessageFromChannel',receiveRTMMessage);if(jQuery("script#wp-agora-io-chat-js").length>0){jQuery("script#wp-agora-io-chat-js").remove()}
if(jQuery("script#wp-agora-raise-hand-js").length>0){jQuery("script#wp-agora-raise-hand-js").remove()}
if(canHandleStateOnRefresh()){sessionStorage.setItem("joinAsHostApprovedUserId",window.userID);sessionStorage.removeItem("raisedHandReqUserId")}
jQuery("link#wp-agora-io-chat-fab-css").remove();window.AGORA_UTILS.agoraApiRequest(ajax_url,params).done(function(res){let mainElm=jQuery('#agora-root').parent();jQuery('#agora-root').remove();mainElm.html(res);appendDivWithAllStreamHiddenInGhostMode();apply_global_colors()}).fail(function(err) {console.error('API Error:',err.responseJSON?err.responseJSON.errors:err)})}
function loadChatApp(){const headTag=document.head||document.getElementsByTagName("head")[0];const chatStyles=document.createElement("link");chatStyles.rel="stylesheet";chatStyles.href=`${window.agora_base_url}css/chat-fab.css`;chatStyles.setAttribute('id','wp-agora-io-chat-fab-css');headTag.appendChild(chatStyles);const arleneLib=document.createElement("script")
arleneLib.type="text/javascript";arleneLib.src=`${window.agora_base_url}js/chat.js`;arleneLib.setAttribute('id','wp-agora-io-chat-js');arleneLib.async=!0;headTag.appendChild(arleneLib)}
function receiveRTMMessage(evt){if(evt.detail&&evt.detail.text){if(evt.detail.text.indexOf('RAISE-HAND-')===0){let sendName=evt.detail.text.split('RAISE-HAND-')[1];showToastMsg('Raised Hand',sendName+" has raised the hand.")}else if(evt.detail.text.indexOf('USER_JOINED_WITHOUT_')===0){const pos=evt.detail.text.indexOf('**')+2;const uid=evt.detail.text.substring(pos)
const titleModal="New user joined"
let contentModal="A new guest user has joined without video";window.AGORA_UTILS.agora_getUserAvatar(uid,function getUserAvatar(avatarData){if(avatarData&&avatarData.user){contentModal=contentModal.replace('A new guest user',avatarData.user.display_name)
contentModal=contentModal.charAt(0).toUpperCase()+contentModal.slice(1)}
document.getElementById('agora-toast-title').innerText=titleModal
document.getElementById('agora-toast-body').innerText=contentModal
jQuery('.toast').toast('show')})}else if(evt.detail.text.indexOf(`CHAT-FILE${window.AGORA_CHAT.TOKEN_SEP}`)==0){const msgData=evt.detail.text;window.AGORA_RTM_UTILS.addRemoteMsg(evt.detail.senderId,msgData)}else if(evt.detail.text.indexOf(`CHAT${window.AGORA_CHAT.TOKEN_SEP}`)===0){const msgData=evt.detail.text.substring(6);window.AGORA_RTM_UTILS.addRemoteMsg(evt.detail.senderId,msgData)}else if(evt.detail.text.indexOf(`CHAT-JOIN${window.AGORA_CHAT.TOKEN_SEP}`)===0){const msgData=evt.detail.text.substring(11);window.AGORA_CHAT.showUserNotify(msgData,'join')}else if(evt.detail.text.indexOf(`CHAT-LEAVE${window.AGORA_CHAT.TOKEN_SEP}`)===0){const msgData=evt.detail.text.substring(12);window.AGORA_CHAT.showUserNotify(msgData,'leave')}}}
let requestedPermission={audio:!1,video:!1}
function getPermConfirmationContent(type){if(requestedPermission.audio&&requestedPermission.video){type='Audio/Video'}else if(requestedPermission.video){type='Video'}else if(requestedPermission.audio){type='Audio'}
let html="";html+="
Do you want to allow "+type+" ?
";html+="
";html+="
";return html}
jQuery(document).ready(function(){jQuery("#view-allow-disallow-permission-modal").on('hidden.bs.modal',function(e){requestedPermission={audio:!1,video:!1}})});window.addEventListener('agora.rtmMessageFromPeer',receivePeerRTMMessage);function allowAccess(){if(requestedPermission.video){jQuery("#video-icon").trigger('click')}
if(requestedPermission.audio){jQuery("#mic-btn").trigger('click')}
jQuery("#view-allow-disallow-permission-modal").modal('toggle')}
function denyAccess(){jQuery("#view-allow-disallow-permission-modal").modal('toggle')}
async function receivePeerRTMMessage(evt){if(evt.detail&&evt.detail.text){if(evt.detail.text.indexOf('CANCEL-RAISE-HAND-REQUEST-')===0){let senderId=evt.detail.senderId;delete window.raiseHandRequests[senderId];let totalRequests=Object.keys(window.raiseHandRequests).length;if(totalRequests==0){totalRequests=''}
removeRaiseHandReqContent(senderId)}else if(evt.detail.text.indexOf('RAISE-HAND-REQUEST-')===0){let userDetails=evt.detail.text.split('RAISE-HAND-REQUEST-')[1];let senderId=evt.detail.senderId;window.raiseHandRequests[senderId]={'userDetails':userDetails,'status':0}
sessionStorage.setItem("raiseHandRequests",JSON.stringify(window.raiseHandRequests));addNewRaiseHandReqContent()}else if(evt.detail.text.indexOf('RAISE-HAND-REJECTED')===0){window.AGORA_AUDIENCE.raiseHandRequestRejected()}else if(evt.detail.text.indexOf('RAISE-HAND-ACCEPTED')===0){let canJoinAsHostByAgoraLimit=await window.AGORA_UTILS.canJoinAsHostByAgoraLimit();if(canJoinAsHostByAgoraLimit){await window.AGORA_AUDIENCE.agoraLeaveChannel();joinAsAgoraHost()}else{showToastMsg('Error',"You cannot raise hand as host limit has been reached.")}}else if(evt.detail.text.indexOf('CONFIRMATION-UNMUTE-AUDIO')===0){requestedPermission.audio=!0;jQuery('#view-allow-disallow-permission-modal #allow-disallow-permissions-content').html(getPermConfirmationContent('audio'));jQuery('#view-allow-disallow-permission-modal').modal('show')}else if(evt.detail.text.indexOf('UNMUTE-AUDIO')===0){jQuery("#mic-btn").trigger('click')}else if(evt.detail.text.indexOf('MUTE-AUDIO')===0){jQuery("#mic-btn").trigger('click')}else if(evt.detail.text.indexOf('CONFIRMATION-UNMUTE-VIDEO')===0){requestedPermission.video=!0;jQuery('#view-allow-disallow-permission-modal #allow-disallow-permissions-content').html(getPermConfirmationContent('video'));jQuery('#view-allow-disallow-permission-modal').modal('show')}else if(evt.detail.text.indexOf('UNMUTE-VIDEO')===0){jQuery("#video-icon").trigger('click')}else if(evt.detail.text.indexOf('MUTE-VIDEO')===0){jQuery("#video-icon").trigger('click')}}}
function checkRaiseHandRequestsOnRefresh(){if(window.isAdminUser){if(sessionStorage.getItem("raiseHandRequests")!=null){if(typeof JSON.parse(sessionStorage.getItem("raiseHandRequests"))!='undefined'){window.raiseHandRequests=JSON.parse(sessionStorage.getItem("raiseHandRequests"));let totalRequests=Object.keys(window.raiseHandRequests).length;if(totalRequests==0){totalRequests=''}
jQuery("body .raise-hand-requests #total-requests").html(totalRequests)}}}}
jQuery(document).on("click","body #change-layout-options-list a",function(event){const view=event.target.id;let localStreamDivId='full-screen-video';if(window.agoraMode=='communication'){localStreamDivId='local-video'}
if(view=='speaker'){window.isSpeakerView=!0;if(canHandleStateOnRefresh()){sessionStorage.setItem("isSpeakerView","1")}
jQuery("body #change-layout-options-list #speaker").addClass("agora-active-view-selected");jQuery("body #change-layout-options-list #grid").removeClass("agora-active-view-selected");if(canHandlePinUnpin()&&window.pinnedUser==''){if(window.isGhostModeEnabled){let visibleStreamId=getCurrentlyVisibleStreamId();if(visibleStreamId!=0){jQuery("body #agora-root #"+visibleStreamId).addClass('activeSpeaker');addStreamInLargeView(visibleStreamId,!0)}
handleLayoutInGhostModeinOneStream()}else{jQuery("body #agora-root #"+localStreamDivId).addClass('activeSpeaker');addStreamInLargeView(localStreamDivId,!0)}}}else{if(window.pinnedUser==''){if(jQuery("body #agora-root .screenshare-container").length>0){const streamId=jQuery("body #agora-root .screenshare-container").attr('id').split('_container')[0];if(!window.screenshareClients.hasOwnProperty(streamId)){removeStreamFromLargeView(streamId)}}
if(window.AGORA_CLOUD_RECORDING.isCloudRecording){window.AGORA_CLOUD_RECORDING.updateLayout()}}
window.isSpeakerView=!1;if(canHandleStateOnRefresh()){sessionStorage.setItem("isSpeakerView","0")}
jQuery("body #change-layout-options-list #grid").addClass("agora-active-view-selected");jQuery("body #change-layout-options-list #speaker").removeClass("agora-active-view-selected")}
showVisibleScreen()});function showRaiseHandInCommunication(){if(window.agoraMode=='communication'){if(Object.keys(window.localStreams.camera.stream).length>0&&(!window.localStreams.camera.stream.getAudioTrack()||!window.localStreams.camera.stream.getAudioTrack().enabled)){jQuery("body #raiseHand").show()}else{jQuery("body #raiseHand").hide()}}}
function showToastMsg(title,msg){document.getElementById('agora-toast-title').innerText=title;document.getElementById('agora-toast-body').innerText=msg;jQuery('.toast').toast('show')}
function canHandleStateOnRefresh(){if(window.userID!=0){return!0}else{return!1}}
async function canJoinAsHostByAgoraLimit(){let obj=window.remoteStreams;let totalRemoteStreams=Object.keys(window.remoteStreams).length;let count=Object.keys(window.remoteStreams).filter(k=>k in window.screenshareClients).length;totalRemoteStreams=totalRemoteStreams-count;if(totalRemoteStreams<17){return!0}else{return!1}}
if(document.addEventListener){document.addEventListener('webkitfullscreenchange',exitHandler,!1);document.addEventListener('mozfullscreenchange',exitHandler,!1);document.addEventListener('fullscreenchange',exitHandler,!1);document.addEventListener('MSFullscreenChange',exitHandler,!1)}
function exitHandler(){if(!document.webkitIsFullScreen&&!document.mozFullScreen&&!document.msFullscreenElement){if(jQuery("body #agora-root").hasClass('agora-fullscreen')){jQuery("body #agora-root").not('.agora-fullscreen-template').removeClass('agora-fullscreen')}}
const remoteEl=document.querySelector('.screenshare-container')
if(remoteEl){const divWidth=remoteEl.getBoundingClientRect().width;remoteEl.style.height=(divWidth/1.35)+'px'}}
恐怖の正体
タイトルとURLをコピーしました