zoom-meeting.min.js 3.49 KB
!function(){const e={meetingID:atob(zvc_ajx.meeting_id),redirectTo:zvc_ajx.redirect_page,password:!1!==zvc_ajx.meeting_pwd&&atob(zvc_ajx.meeting_pwd),infoContainer:document.querySelector(".vczapi-zoom-browser-meeting--info__browser"),init:function(){this.initSDK(),this.eventHandlers()},initSDK:function(){const e=ZoomMtg.checkSystemRequirements(),n=document.createElement("ul");let t="<li><strong>Browser Info:</strong> "+e.browserInfo+"</li>";t+="<li><strong>Browser Name:</strong> "+e.browserName+"</li>",t+="<li><strong>Browser Version:</strong> "+e.browserVersion+"</li>",n.innerHTML=t,this.infoContainer.appendChild(n),ZoomMtg.preLoadWasm(),ZoomMtg.prepareWebSDK()},eventHandlers:function(){let e=document.getElementById("vczapi-zoom-browser-meeting-join-mtg");null!=e&&(e.onclick=this.handleJoinMeetingButton.bind(this))},loader:function(){const e=document.createElement("span");return e.id="zvc-cover",e},generateSignature:async function(){const e=new FormData;return e.append("action","get_auth"),e.append("noncce",zvc_ajx.zvc_security),e.append("meeting_id",parseInt(this.meetingID)),(await fetch(zvc_ajx.ajaxurl,{method:"POST",body:e})).json()},removeLoader:function(){null!==document.getElementById("zvc-cover")&&document.getElementById("zvc-cover").remove()},handleJoinMeetingButton:function(e){e.preventDefault(),document.body.appendChild(this.loader());const n=document.getElementById("vczapi-jvb-display-name"),t=document.getElementById("vczapi-jvb-email"),o=document.getElementById("meeting_password");return null===n||null!==n.value&&""!==n.value?null===t||null!==t.value&&""!==t.value?null===o||null!==o.value&&""!==o.value?void(null==this.meetingID&&""===this.meetingID||this.generateSignature().then((e=>{if(e.success){this.removeLoader();const i={name:null!==n?n.value:"",password:null!==o?o.value:"",email:null!==t?t.value:""};this.prepBeforeJoin(e,i)}}))):(this.infoContainer.innerHTML="Error: Password is Required!",this.infoContainer.style.color="red",this.removeLoader(),!1):(this.infoContainer.innerHTML="Error: Email is Required!",this.infoContainer.style.color="red",this.removeLoader(),!1):(this.infoContainer.innerHTML="Error: Name is Required!",this.infoContainer.style.color="red",this.removeLoader(),!1)},prepBeforeJoin:function(e,n){const t=e.data.key,o=e.data.sig,i=e.data.type,r=document.getElementById("vczapi-zoom-browser-meeting");null!==r&&r.remove();const a=document.getElementById("meeting_lang"),s={lang:null!==a?a.value:"en-US",leaveUrl:this.redirectTo};let l={meetingNumber:parseInt(this.meetingID,10),userName:n.name,signature:o,userEmail:n.email,passWord:n.password?n.password:this.password,success:function(e){console.log("Join Meeting Success")},error:function(e){console.log(e)}};const c=new URLSearchParams(window.location.search),d=Object.fromEntries(c.entries());null!==d.tk&&(l.tk=d.tk),window.location!==window.parent.location&&(s.leaveUrl=window.location.href),"jwt"===i?l.apiKey=t:"sdk"===i&&(l.sdkKey=t),this.joinMeeting(s,l)},joinMeeting:function(e,n){ZoomMtg.init({leaveUrl:e.leaveUrl,isSupportAV:!0,meetingInfo:zvc_ajx.meetingInfo,disableInvite:zvc_ajx.disableInvite,disableRecord:zvc_ajx.disableRecord,disableJoinAudio:zvc_ajx.disableJoinAudio,isSupportChat:zvc_ajx.isSupportChat,isSupportQA:zvc_ajx.isSupportQA,isSupportBreakout:zvc_ajx.isSupportBreakout,isSupportCC:zvc_ajx.isSupportCC,screenShare:zvc_ajx.screenShare,success:function(){ZoomMtg.i18n.load(e.lang),ZoomMtg.i18n.reload(e.lang),ZoomMtg.join(n)},error:function(e){console.log(e)}})}};document.addEventListener("DOMContentLoaded",e.init())}();