var enabledExtendedServices=!1,enabledGroupServices=!1;const availableLang=["ja","zh-hans","zh","ru","tr","nl"];var wssServer=getDbItem("wssServer",null),profileUserID=getDbItem("profileUserID",null),profileUser=getDbItem("profileUser",null),profileName=getDbItem("profileName",null),WebSocketPort=getDbItem("WebSocketPort",null),ServerPath=getDbItem("ServerPath",null),SipUsername=getDbItem("SipUsername",null),SipPassword=getDbItem("SipPassword",null),StunServer=getDbItem("StunServer",""),TransportConnectionTimeout=parseInt(getDbItem("TransportConnectionTimeout",15)),TransportReconnectionAttempts=parseInt(getDbItem("TransportReconnectionAttempts",99)),TransportReconnectionTimeout=parseInt(getDbItem("TransportReconnectionTimeout",15)),userAgentStr=getDbItem("UserAgentStr","Roundpin (SipJS - 0.11.6)"),hostingPrefex=getDbItem("HostingPrefex",""),RegisterExpires=parseInt(getDbItem("RegisterExpires",300)),WssInTransport="1"==getDbItem("WssInTransport","1"),IpInContact="1"==getDbItem("IpInContact","1"),IceStunCheckTimeout=parseInt(getDbItem("IceStunCheckTimeout",500)),AutoAnswerEnabled="1"==getDbItem("AutoAnswerEnabled","0"),DoNotDisturbEnabled="1"==getDbItem("DoNotDisturbEnabled","0"),CallWaitingEnabled="1"==getDbItem("CallWaitingEnabled","1"),RecordAllCalls="1"==getDbItem("RecordAllCalls","0"),StartVideoFullScreen="0"==getDbItem("StartVideoFullScreen","1"),AutoGainControl="1"==getDbItem("AutoGainControl","1"),EchoCancellation="1"==getDbItem("EchoCancellation","1"),NoiseSuppression="1"==getDbItem("NoiseSuppression","1"),MirrorVideo=getDbItem("VideoOrientation","rotateY(180deg)"),maxFrameRate=getDbItem("FrameRate",""),videoHeight=getDbItem("VideoHeight",""),videoAspectRatio=getDbItem("AspectRatio",""),NotificationsActive="1"==getDbItem("Notifications","0"),StreamBuffer=parseInt(getDbItem("StreamBuffer",50)),PosterJpegQuality=parseFloat(getDbItem("PosterJpegQuality",.6)),VideoResampleSize=getDbItem("VideoResampleSize","HD"),RecordingVideoSize=getDbItem("RecordingVideoSize","HD"),RecordingVideoFps=parseInt(getDbItem("RecordingVideoFps",12)),RecordingLayout=getDbItem("RecordingLayout","them-pnp"),DidLength=parseInt(getDbItem("DidLength",6)),MaxDidLength=parseInt(getDbItem("maximumNumberLength",16)),DisplayDateFormat=getDbItem("DateFormat","YYYY-MM-DD"),DisplayTimeFormat=getDbItem("TimeFormat","h:mm:ss A"),Language=getDbItem("Language","auto"),EnableTextMessaging="1"==getDbItem("EnableTextMessaging","1"),DisableFreeDial="1"==getDbItem("DisableFreeDial","0"),DisableBuddies="1"==getDbItem("DisableBuddies","0"),EnableTransfer="1"==getDbItem("EnableTransfer","1"),EnableConference="1"==getDbItem("EnableConference","1"),AutoAnswerPolicy=getDbItem("AutoAnswerPolicy","allow"),DoNotDisturbPolicy=getDbItem("DoNotDisturbPolicy","allow"),CallWaitingPolicy=getDbItem("CallWaitingPolicy","allow"),CallRecordingPolicy=getDbItem("CallRecordingPolicy","allow"),EnableAccountSettings="1"==getDbItem("EnableAccountSettings","1"),EnableAudioVideoSettings="1"==getDbItem("EnableAudioVideoSettings","1"),EnableAppearanceSettings="1"==getDbItem("EnableAppearanceSettings","1"),EnableChangeUserPasswordSettings="1"==getDbItem("EnableChangeUserPasswordSettings","1"),EnableChangeUserEmailSettings="1"==getDbItem("EnableChangeUserEmailSettings","1"),EnableCloseUserAccount="1"==getDbItem("EnableCloseUserAccount","1"),EnableAlphanumericDial="1"==getDbItem("EnableAlphanumericDial","1"),EnableVideoCalling="1"==getDbItem("EnableVideoCalling","1"),winVideoConf=null,winVideoConfCheck=0,localDB=window.localStorage,userAgent=null,voicemailSubs=null,BlfSubs=[],CanvasCollection=[],Buddies=[],isReRegister=!1,dhtmlxPopup=null,selectedBuddy=null,selectedLine=null,alertObj=null,confirmObj=null,promptObj=null,windowsCollection=null,messagingCollection=null,HasVideoDevice=!1,HasAudioDevice=!1,HasSpeakerDevice=!1,AudioinputDevices=[],VideoinputDevices=[],SpeakerDevices=[],Lines=[],lang={},audioBlobs={},newLineNumber=0,videoAudioCheck=0,RCLoginCheck=0,decSipPass="",currentChatPrivKey="",sendFileCheck=0,upFileName="",sendFileChatErr="",pubKeyCheck=0,splitMessage={};function uID(){return Date.now()+Math.floor(1e4*Math.random()).toString(16).toUpperCase()}function utcDateNow(){return moment().utc().format("YYYY-MM-DD HH:mm:ss UTC")}function getDbItem(e,t){var i=window.localStorage;return null!=i.getItem(e)?i.getItem(e):t}function getAudioSrcID(){var e=localDB.getItem("AudioSrcId");return null!=e?e:"default"}function getAudioOutputID(){var e=localDB.getItem("AudioOutputId");return null!=e?e:"default"}function getVideoSrcID(){var e=localDB.getItem("VideoSrcId");return null!=e?e:"default"}function getRingerOutputID(){var e=localDB.getItem("RingOutputId");return null!=e?e:"default"}function formatDuration(e){var t,i=Math.floor(parseFloat(e));return i<0?i:i>=0&&i<60?i+" "+(1!=i?lang.seconds_plural:lang.second_single):i>=60&&i<3600?(t=moment.duration(i,"seconds")).minutes()+" "+(1!=t.minutes()?lang.minutes_plural:lang.minute_single)+" "+t.seconds()+" "+(1!=t.seconds()?lang.seconds_plural:lang.second_single):i>=3600&&i<86400?(t=moment.duration(i,"seconds")).hours()+" "+(1!=t.hours()?lang.hours_plural:lang.hour_single)+" "+t.minutes()+" "+(1!=t.minutes()?lang.minutes_plural:lang.minute_single)+" "+t.seconds()+" "+(1!=t.seconds()?lang.seconds_plural:lang.second_single):void 0}function formatShortDuration(e){var t,i=Math.floor(parseFloat(e));return i<0?i:i>=0&&i<60?"00:"+(i>9?i:"0"+i):i>=60&&i<3600?((t=moment.duration(i,"seconds")).minutes()>9?t.minutes():"0"+t.minutes())+":"+(t.seconds()>9?t.seconds():"0"+t.seconds()):i>=3600&&i<86400?((t=moment.duration(i,"seconds")).hours()>9?t.hours():"0"+t.hours())+":"+(t.minutes()>9?t.minutes():"0"+t.minutes())+":"+(t.seconds()>9?t.seconds():"0"+t.seconds()):void 0}function formatBytes(e,t){if(0===e)return"0 "+lang.bytes;var i=t&&t>=0?t:2,n=[lang.bytes,lang.kb,lang.mb,lang.gb,lang.tb,lang.pb,lang.eb,lang.zb,lang.yb],a=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,a)).toFixed(i))+" "+n[a]}function UserLocale(){var e=window.navigator.userLanguage||window.navigator.language;return langtag=e.split("-"),1==langtag.length?"":2==langtag.length||langtag.length>=3?langtag[1].toLowerCase():void 0}function GetAlternateLanguage(){var e=window.navigator.userLanguage||window.navigator.language;if("auto"!=Language&&(e=Language),"en"==(e=e.toLowerCase())||0==e.indexOf("en-"))return"";for(l=0;l0){localDB.setItem("externalUserConfElem",e.length);for(var t=0;t');var e="",t="",i="",n="",a="";if($.ajax({async:!1,global:!1,type:"POST",url:"get-email-info.php",dataType:"JSON",data:{username:userName,s_ajax_call:validateSToken},success:function(o){e=o.rcdomain,t=encodeURIComponent(o.rcbasicauthuser),i=encodeURIComponent(o.rcbasicauthpass),n=o.rcuser,a=o.rcpassword},error:function(e){alert("An error occurred while trying to retrieve data from the database!")}}),""!=t&&""!=i)var o="https://"+t+":"+i+"@"+e+"/";else o="https://"+e+"/";var l='
';l+='',l+='',l+='',l+='',l+='',l+='',l+="
",$("#roundcubeFrame").append(l),0==RCLoginCheck?($("#submitButton").click(),RCLoginCheck=1):$("#roundcubeFrame").attr("src",o)}else alert("Email Integration is not enabled ! You can enable Roundcube email integration by clicking on the 'Settings' wheel in the user profile section from below > 'Settings' > 'Email Integration' > 'Enable Roundcube email integration'")}function CollapseLeftPanel(){$(window).width()>=920&&($("#leftContent").hasClass("shrinkLeftContent")?($("#leftContent").removeClass("shrinkLeftContent"),$("#rightContent").removeClass("widenRightContent"),$("#aboutImg").css("margin-right","-3px")):($("#leftContent").addClass("shrinkLeftContent"),$("#rightContent").addClass("widenRightContent"),$("#aboutImg").css("margin-right","3px")))}function ShowAboutWindow(){$.jeegoopopup.close();var e="
";e+='
',e+='
',e+='
',e+='
'+lang.about_text+"
",e+="
",$.jeegoopopup.open({title:"About Roundpin",html:e,width:"640",height:"500",center:!0,scrolling:"no",skinClass:"jg_popup_basic",overlay:!0,opacity:50,draggable:!0,resizable:!1,fadeIn:0}),$("#jg_popup_b").append('");var t=$(window).width()-12,i=$(window).height()-88;t<656||i<500?($.jeegoopopup.width(t).height(i),$.jeegoopopup.center(),$("#maximizeImg").hide(),$("#minimizeImg").hide()):($.jeegoopopup.width(640).height(500),$.jeegoopopup.center(),$("#minimizeImg").hide(),$("#maximizeImg").show()),$(window).resize((function(){t=$(window).width()-12,i=$(window).height()-88,$.jeegoopopup.center(),t<656||i<500?($.jeegoopopup.width(t).height(i),$.jeegoopopup.center(),$("#maximizeImg").hide(),$("#minimizeImg").hide()):($.jeegoopopup.width(640).height(500),$.jeegoopopup.center(),$("#minimizeImg").hide(),$("#maximizeImg").show())})),$("#minimizeImg").click((function(){$.jeegoopopup.width(640).height(500),$.jeegoopopup.center(),$("#maximizeImg").show(),$("#minimizeImg").hide()})),$("#maximizeImg").click((function(){$.jeegoopopup.width(t).height(i),$.jeegoopopup.center(),$("#minimizeImg").show(),$("#maximizeImg").hide()})),$("#closeImg").click((function(){$.jeegoopopup.close(),$("#jg_popup_b").empty()})),$("#ok_button").click((function(){$.jeegoopopup.close(),$("#jg_popup_b").empty()})),$("#jg_popup_overlay").click((function(){$.jeegoopopup.close(),$("#jg_popup_b").empty()})),$(window).on("keydown",(function(e){"Escape"==e.key&&($.jeegoopopup.close(),$("#jg_popup_b").empty())}))}function incomingCallNote(){new Notification(lang.incomming_call,{icon:"../images/notification-logo.svg",body:"New incoming call !!!"}).onclick=function(e){},document.hasFocus()||setTimeout(incomingCallNote,8e3)}function changePageTitle(){"Roundpin"==$(document).attr("title")?$(document).prop("title","New call !!!"):$(document).prop("title","Roundpin"),document.hasFocus()?$(document).prop("title","Roundpin"):setTimeout(changePageTitle,460)}function UpdateUI(){$(window).outerWidth()<920?null==selectedBuddy&null==selectedLine?($("#rightContent").hide(),$("#leftContent").css("width","100%"),$("#leftContent").show()):($("#rightContent").css("margin-left","0px"),$("#rightContent").show(),$("#leftContent").hide(),null!=selectedBuddy&&updateScroll(selectedBuddy.identity)):null==selectedBuddy&null==selectedLine?($("#leftContent").css("width","320px"),$("#rightContent").css("margin-left","0px"),$("#leftContent").show(),$("#rightContent").hide()):($("#leftContent").css("width","320px"),$("#rightContent").css("margin-left","320px"),$("#leftContent").show(),$("#rightContent").show(),null!=selectedBuddy&&updateScroll(selectedBuddy.identity));for(var e=0;e",t+="
",t+="
"+lang.title_description+":
",t+="
",t+="
"+lang.internal_subscribe_extension+":
",e&&e.length>1&&e.length":t+="
",t+="
"+lang.mobile_number+":
",t+="
",t+="
"+lang.contact_number_1+":
",e&&e.length>1?t+="
":t+="
",t+="
"+lang.contact_number_2+":
",t+="
",t+="
"+lang.email+":
",t+="
",t+="",$.jeegoopopup.open({title:"Add Contact",html:t,width:"640",height:"500",center:!0,scrolling:"no",skinClass:"jg_popup_basic",contentClass:"addContactPopup",overlay:!0,opacity:50,draggable:!0,resizable:!1,fadeIn:0}),$("#jg_popup_b").append("
"),$("#save_button").click((function(){var e=$("#AddSomeone_Name").val();if(null!=e&&""!==e.trim())if(/^[A-Za-z0-9\s\-\'\[\]\(\)]+$/.test(e)){var t=$("#AddSomeone_Desc").val();if(null!=t&&""!==t.trim())if(/^[A-Za-z0-9\s\-\.\'\"\[\]\(\)\{\}\_\!\?\~\@\%\^\&\*\+\>\<\;\:\=]+$/.test(t))var i=t;else{i="";alert("The title/description that you entered is not valid!")}else i="";var n=$("#AddSomeone_Exten").val();if(null!=n&&""!==n.trim())if(/^[a-zA-Z0-9\*\#]+$/.test(n))var a=n;else{a="";alert("The extension that you entered in the 'Extension (Internal)' field is not a valid extension!")}else a="";var o=$("#AddSomeone_Mobile").val();if(null!=o&&""!==o.trim())if(/^[0-9\s\+\#]+$/.test(o))var l=o;else{l="";alert("The phone number that you entered in the 'Mobile Number' field is not valid! The only allowed characters are: digits, spaces, plus signs and pound signs.")}else l="";var s=$("#AddSomeone_Num1").val();if(null!=s&&""!==s.trim())if(/^[0-9\s\+\#]+$/.test(s))var r=s;else{r="";alert("The phone number that you entered in the 'Contact Number 1' field is not valid! The only allowed characters are: digits, spaces, plus signs and pound signs.")}else r="";var d=$("#AddSomeone_Num2").val();if(null!=d&&""!==d.trim())if(/^[0-9\s\+\#]+$/.test(d))var c=d;else{c="";alert("The phone number that you entered in the 'Contact Number 2' field is not valid! The only allowed characters are: digits, spaces, plus signs and pound signs.")}else c="";var u=$("#AddSomeone_Email").val();if(null!=u&&""!==u.trim())if(/^[A-Za-z0-9\_\.\-\~\%\+\!\?\&\*\^\=\#\$\{\}\|\/]+@[A-Za-z0-9\.\-]+\.[A-Za-z0-9\-]{2,63}$/.test(u))var p=u;else{p="";alert("The email that you entered is not a valid email address!")}else p="";var g=JSON.parse(localDB.getItem(profileUserID+"-Buddies"));if(null==g&&(g=InitUserBuddies()),""==a){var m=uID(),f=utcDateNow();g.DataCollection.push({Type:"contact",LastActivity:f,ExtensionNumber:"",MobileNumber:l,ContactNumber1:r,ContactNumber2:c,uID:null,cID:m,gID:null,DisplayName:e,Position:"",Description:i,Email:p,MemberCount:0});saveContactToSQLDB([e,i,"",l,r,c,p]),AddBuddy(new Buddy("contact",m,e,"",l,r,c,f,i,p),!1,!1,!1)}else{m=uID(),f=utcDateNow();g.DataCollection.push({Type:"extension",LastActivity:f,ExtensionNumber:a,MobileNumber:l,ContactNumber1:r,ContactNumber2:c,uID:m,cID:null,gID:null,DisplayName:e,Position:i,Description:"",Email:p,MemberCount:0});saveContactToSQLDB([e,i,a,l,r,c,p]),AddBuddy(new Buddy("extension",m,e,a,l,r,c,f,i,p),!1,!1,!0)}g.TotalRows=g.DataCollection.length,localDB.setItem(profileUserID+"-Buddies",JSON.stringify(g)),UpdateBuddyList(),$.jeegoopopup.close(),$("#jg_popup_b").empty()}else alert("The display name that you entered is not a valid display name!");else alert("'Display Name' cannot be empty!")}));var i=$(window).width()-12,n=$(window).height()-110;i<656||n<500?($.jeegoopopup.width(i).height(n),$.jeegoopopup.center(),$("#maximizeImg").hide(),$("#minimizeImg").hide()):($.jeegoopopup.width(640).height(500),$.jeegoopopup.center(),$("#minimizeImg").hide(),$("#maximizeImg").show()),$(window).resize((function(){i=$(window).width()-16,n=$(window).height()-110,$.jeegoopopup.center(),i<656||n<500?($.jeegoopopup.width(i).height(n),$.jeegoopopup.center(),$("#maximizeImg").hide(),$("#minimizeImg").hide()):($.jeegoopopup.width(640).height(500),$.jeegoopopup.center(),$("#minimizeImg").hide(),$("#maximizeImg").show())})),$("#minimizeImg").click((function(){$.jeegoopopup.width(640).height(500),$.jeegoopopup.center(),$("#maximizeImg").show(),$("#minimizeImg").hide()})),$("#maximizeImg").click((function(){$.jeegoopopup.width(i).height(n),$.jeegoopopup.center(),$("#minimizeImg").show(),$("#maximizeImg").hide()})),$("#closeImg").click((function(){$.jeegoopopup.close(),$("#jg_popup_b").empty()})),$("#cancel_button").click((function(){$.jeegoopopup.close(),$("#jg_popup_b").empty()})),$("#jg_popup_overlay").click((function(){$.jeegoopopup.close(),$("#jg_popup_b").empty()})),$(window).on("keydown",(function(e){"Escape"==e.key&&($.jeegoopopup.close(),$("#jg_popup_b").empty())}))}function CreateGroupWindow(){}function closeVideoAudio(){var e=$("#local-video-preview").get(0);try{e.srcObject.getTracks().forEach((function(e){e.stop()})),e.srcObject=null}catch(e){}try{window.SettingsMicrophoneStream.getTracks().forEach((function(e){e.stop()}))}catch(e){}window.SettingsMicrophoneStream=null;try{window.SettingsMicrophoneSoundMeter.stop()}catch(e){}window.SettingsMicrophoneSoundMeter=null;try{window.SettingsOutputAudio.pause()}catch(e){}window.SettingsOutputAudio=null;try{window.SettingsOutputStream.getTracks().forEach((function(e){e.stop()}))}catch(e){}window.SettingsOutputStream=null;try{window.SettingsOutputStreamMeter.stop()}catch(e){}return window.SettingsOutputStreamMeter=null,!0}function ConfigureExtensionWindow(){$("#settingsCMenu").hide(),$.jeegoopopup.close();var e='
';e+="
",e+='
',e+='
',e+='
',e+="
"+lang.asterisk_server_address+": *
",e+="
",e+="
"+lang.websocket_port+": *
",e+="
",e+="
"+lang.websocket_path+": *
",e+="
",e+="
"+lang.display_name+": *
";var t='value="'+getDbItem("profileName","").replace("'","'")+'"';if(e+="
",e+="
"+lang.sip_username+": *
",e+="
",e+="
"+lang.sip_password+": *
",e+="
",e+="
"+lang.stun_server+":
",e+="
",e+='

* Required field.



',e+='",e+='",e+='",e+='",e+='",e+='",e+='",e+="
";$.jeegoopopup.open({title:"Settings",html:e,width:"520",height:"500",center:!0,scrolling:"no",skinClass:"jg_popup_basic",contentClass:"configPopup",overlay:!0,opacity:50,draggable:!0,resizable:!1,fadeIn:0}),$("#jg_popup_b").append('
'),$("#jg_popup_l").append('
Connection Settings
Audio & Video
Profile Picture
Notifications
Email Integration
Change Password
Change Email
Close Account
'),1==getDbItem("useRoundcube","")?$("#emailIntegration").prop("checked",!0):$("#emailIntegration").prop("checked",!1),$("#ConnectionSettingsRow td").addClass("selectedSettingsSection"),$("#ConnectionSettingsRow").click((function(){$(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#AccountHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#ConnectionSettingsRow td").addClass("selectedSettingsSection")})),$("#ProfilePictureRow").click((function(){$(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#AppearanceHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#ProfilePictureRow td").addClass("selectedSettingsSection")})),$("#NotificationsRow").click((function(){$(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#NotificationsHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#NotificationsRow td").addClass("selectedSettingsSection")})),$("#RoundcubeEmailRow").click((function(){$(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#RoundcubeEmailHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#RoundcubeEmailRow td").addClass("selectedSettingsSection")})),$("#ChangePasswordRow").click((function(){$(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#ChangePasswordHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#ChangePasswordRow td").addClass("selectedSettingsSection")})),$("#ChangeEmailRow").click((function(){$(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#ChangeEmailHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#ChangeEmailRow td").addClass("selectedSettingsSection")})),$("#CloseAccountRow").click((function(){$(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#CloseAccountHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#CloseAccountRow td").addClass("selectedSettingsSection")}));var n=$(window).width()-192,a=$(window).height()-98;n<520||a<500?($.jeegoopopup.width(n).height(a),$.jeegoopopup.center(),$("#maximizeImg").hide(),$("#minimizeImg").hide()):($.jeegoopopup.width(520).height(500),$.jeegoopopup.center(),$("#minimizeImg").hide(),$("#maximizeImg").show()),$(window).resize((function(){n=$(window).width()-192,a=$(window).height()-98,$.jeegoopopup.center(),n<520||a<500?($.jeegoopopup.width(n).height(a),$.jeegoopopup.center(),$("#maximizeImg").hide(),$("#minimizeImg").hide()):($.jeegoopopup.width(520).height(500),$.jeegoopopup.center(),$("#minimizeImg").hide(),$("#maximizeImg").show())})),$("#minimizeImg").click((function(){$.jeegoopopup.width(520).height(500),$.jeegoopopup.center(),$("#maximizeImg").show(),$("#minimizeImg").hide()})),$("#maximizeImg").click((function(){$.jeegoopopup.width(n).height(a),$.jeegoopopup.center(),$("#minimizeImg").show(),$("#maximizeImg").hide()}));var o=$("#playbackSrc"),l=$("#preview_output_play"),s=$("#preview_ringer_play"),r=$("#preview_output_pause"),d=$("#microphoneSrc");$("#Settings_AutoGainControl").prop("checked",AutoGainControl),$("#Settings_EchoCancellation").prop("checked",EchoCancellation),$("#Settings_NoiseSuppression").prop("checked",NoiseSuppression);var c=$("#previewVideoSrc"),u=$("input[name=Settings_Oriteation]");u.each((function(){this.value==MirrorVideo&&$(this).prop("checked",!0)})),$("#local-video-preview").css("transform",MirrorVideo);var p=$("input[name=Settings_FrameRate]");p.each((function(){this.value==maxFrameRate&&$(this).prop("checked",!0)}));var g=$("input[name=Settings_Quality]");g.each((function(){this.value==videoHeight&&$(this).prop("checked",!0)}));var m=$("input[name=Settings_AspectRatio]");m.each((function(){this.value==videoAspectRatio&&$(this).prop("checked",!0)}));$("#ringTone");var f=$("#ringDevice");m.change((function(){console.log("Call to change Aspect Ratio ("+this.value+")");var e=$("#local-video-preview").get(0);e.muted=!0,e.playsinline=!0,e.autoplay=!0,e.srcObject.getTracks().forEach((function(e){e.stop()}));var t={audio:!1,video:{deviceId:"default"!=c.val()?{exact:c.val()}:"default"}};""!=$("input[name=Settings_FrameRate]:checked").val()&&(t.video.frameRate=$("input[name=Settings_FrameRate]:checked").val()),""!=$("input[name=Settings_Quality]:checked").val()&&(t.video.height=$("input[name=Settings_Quality]:checked").val()),""!=this.value&&(t.video.aspectRatio=this.value),console.log("Constraints:",t);var i=new MediaStream;navigator.mediaDevices&&navigator.mediaDevices.getUserMedia(t).then((function(t){var n=t.getVideoTracks()[0];i.addTrack(n),e.srcObject=i,e.onloadedmetadata=function(t){e.play()}})).catch((function(e){console.error(e),AlertConfigExtWindow(lang.alert_error_user_media,lang.error)}))})),g.change((function(){console.log("Call to change Video Height ("+this.value+")");var e=$("#local-video-preview").get(0);e.muted=!0,e.playsinline=!0,e.autoplay=!0,e.srcObject.getTracks().forEach((function(e){e.stop()}));var t={audio:!1,video:{deviceId:"default"!=c.val()?{exact:c.val()}:"default"}};""!=$("input[name=Settings_FrameRate]:checked").val()&&(t.video.frameRate=$("input[name=Settings_FrameRate]:checked").val()),this.value&&(t.video.height=this.value),""!=$("input[name=Settings_AspectRatio]:checked").val()&&(t.video.aspectRatio=$("input[name=Settings_AspectRatio]:checked").val()),console.log("Constraints:",t);var i=new MediaStream;navigator.mediaDevices&&navigator.mediaDevices.getUserMedia(t).then((function(t){var n=t.getVideoTracks()[0];i.addTrack(n),e.srcObject=i,e.onloadedmetadata=function(t){e.play()}})).catch((function(e){console.error(e),AlertConfigExtWindow(lang.alert_error_user_media,lang.error)}))})),p.change((function(){console.log("Call to change Frame Rate ("+this.value+")");var e=$("#local-video-preview").get(0);e.muted=!0,e.playsinline=!0,e.autoplay=!0,e.srcObject.getTracks().forEach((function(e){e.stop()}));var t={audio:!1,video:{deviceId:"default"!=c.val()?{exact:c.val()}:"default"}};""!=this.value&&(t.video.frameRate=this.value),""!=$("input[name=Settings_Quality]:checked").val()&&(t.video.height=$("input[name=Settings_Quality]:checked").val()),""!=$("input[name=Settings_AspectRatio]:checked").val()&&(t.video.aspectRatio=$("input[name=Settings_AspectRatio]:checked").val()),console.log("Constraints:",t);var i=new MediaStream;navigator.mediaDevices&&navigator.mediaDevices.getUserMedia(t).then((function(t){var n=t.getVideoTracks()[0];i.addTrack(n),e.srcObject=i,e.onloadedmetadata=function(t){e.play()}})).catch((function(e){console.error(e),AlertConfigExtWindow(lang.alert_error_user_media,lang.error)}))})),d.change((function(){console.log("Call to change Microphone ("+this.value+")");try{window.SettingsMicrophoneStream.getTracks().forEach((function(e){e.stop()})),window.SettingsMicrophoneStream=null}catch(e){}try{soundMeter=window.SettingsMicrophoneSoundMeter,soundMeter.stop(),window.SettingsMicrophoneSoundMeter=null}catch(e){}var e={audio:{deviceId:{exact:this.value}},video:!1},t=new MediaStream;navigator.mediaDevices.getUserMedia(e).then((function(e){var i=e.getAudioTracks()[0];null!=i&&(t.addTrack(i),window.SettingsMicrophoneStream=t,window.SettingsMicrophoneSoundMeter=MeterSettingsOutput(t,"Settings_MicrophoneOutput","width",50))})).catch((function(e){console.log("Failed to getUserMedia",e)}))})),o.change((function(){console.log("Call to change Speaker ("+this.value+")");var e=window.SettingsOutputAudio;null!=e&&void 0!==e.sinkId&&e.setSinkId(this.value).then((function(){console.log("sinkId applied to audioObj:",this.value)})).catch((function(e){console.warn("Failed not apply setSinkId.",e)}))})),l.click((function(){try{window.SettingsOutputAudio.pause()}catch(e){}window.SettingsOutputAudio=null;try{window.SettingsOutputStream.getTracks().forEach((function(e){e.stop()}))}catch(e){}window.SettingsOutputStream=null;try{window.SettingsOutputStreamMeter.stop()}catch(e){}window.SettingsOutputStreamMeter=null,console.log("Audio:",audioBlobs.speaker_test.url);var e=new Audio(audioBlobs.speaker_test.blob);e.preload="auto",e.onplay=function(){var t=new MediaStream;if(void 0!==e.captureStream)t=e.captureStream();else{if(void 0!==e.mozCaptureStream)return;if(void 0===e.webkitCaptureStream)return void console.warn("Cannot display Audio Levels");t=e.webkitCaptureStream()}window.SettingsOutputStream=t,window.SettingsOutputStreamMeter=MeterSettingsOutput(t,"Settings_SpeakerOutput","width",50)},e.oncanplaythrough=function(t){void 0!==e.sinkId&&e.setSinkId(o.val()).then((function(){console.log("Set sinkId to:",o.val())})).catch((function(e){console.warn("Failed not apply setSinkId.",e)})),e.play().then((function(){})).catch((function(e){console.warn("Unable to play audio file",e)})),console.log("Playing sample audio file... ")},window.SettingsOutputAudio=e})),r.click((function(){window.SettingsOutputAudio.paused?window.SettingsOutputAudio.play():window.SettingsOutputAudio.pause()})),s.click((function(){try{window.SettingsRingerAudio.pause()}catch(e){}window.SettingsRingerAudio=null;try{window.SettingsRingerStream.getTracks().forEach((function(e){e.stop()}))}catch(e){}window.SettingsRingerStream=null;try{window.SettingsRingerStreamMeter.stop()}catch(e){}window.SettingsRingerStreamMeter=null,console.log("Audio:",audioBlobs.Ringtone.url);var e=new Audio(audioBlobs.Ringtone.blob);e.preload="auto",e.onplay=function(){var t=new MediaStream;if(void 0!==e.captureStream)t=e.captureStream();else{if(void 0!==e.mozCaptureStream)return;if(void 0===e.webkitCaptureStream)return void console.warn("Cannot display Audio Levels");t=e.webkitCaptureStream()}window.SettingsRingerStream=t,window.SettingsRingerStreamMeter=MeterSettingsOutput(t,"Settings_RingerOutput","width",50)},e.oncanplaythrough=function(t){void 0!==e.sinkId&&e.setSinkId(f.val()).then((function(){console.log("Set sinkId to:",f.val())})).catch((function(e){console.warn("Failed not apply setSinkId.",e)})),e.play().then((function(){})).catch((function(e){console.warn("Unable to play audio file",e)})),console.log("Playing sample audio file... ")},window.SettingsRingerAudio=e})),u.change((function(){console.log("Call to change Orientation ("+this.value+")"),$("#local-video-preview").css("transform",this.value)})),c.change((function(){console.log("Call to change WebCam ("+this.value+")");var e=$("#local-video-preview").get(0);e.muted=!0,e.playsinline=!0,e.autoplay=!0,e.srcObject.getTracks().forEach((function(e){e.stop()}));var t={audio:!1,video:{deviceId:"default"!=this.value?{exact:this.value}:"default"}};""!=$("input[name=Settings_FrameRate]:checked").val()&&(t.video.frameRate=$("input[name=Settings_FrameRate]:checked").val()),""!=$("input[name=Settings_Quality]:checked").val()&&(t.video.height=$("input[name=Settings_Quality]:checked").val()),""!=$("input[name=Settings_AspectRatio]:checked").val()&&(t.video.aspectRatio=$("input[name=Settings_AspectRatio]:checked").val()),console.log("Constraints:",t);var i=new MediaStream;navigator.mediaDevices&&navigator.mediaDevices.getUserMedia(t).then((function(t){var n=t.getVideoTracks()[0];i.addTrack(n),e.srcObject=i,e.onloadedmetadata=function(t){e.play()}})).catch((function(e){console.error(e),AlertConfigExtWindow(lang.alert_error_user_media,lang.error)}))})),$("#AudioAndVideoRow").click((function(){if($(".settingsSubSection").each((function(){$(this).css("display","none")})),$("#AudioVideoHtml").css("display","block"),$(".SettingsSection").each((function(){$(this).removeClass("selectedSettingsSection")})),$("#AudioAndVideoRow td").addClass("selectedSettingsSection"),0==videoAudioCheck){videoAudioCheck=1;var e=$("#local-video-preview").get(0);e.muted=!0,e.playsinline=!0,e.autoplay=!0;var t=new MediaStream,i=new MediaStream;navigator.mediaDevices?navigator.mediaDevices.enumerateDevices().then((function(n){for(var a=getVideoSrcID(),l=!1,s=getAudioSrcID(),r=!1,u=!1,p=!1,g=!1,m=0;m=1?n.getVideoTracks()[0]:null;g&&null!=a?(t.addTrack(a),e.srcObject=t,e.onloadedmetadata=function(t){e.play()}):console.warn("No video / webcam devices found. Video Calling will not be possible.");var o=n.getAudioTracks().length>=1?n.getAudioTracks()[0]:null;return u&&null!=o?(i.addTrack(o),window.SettingsMicrophoneStream=i,window.SettingsMicrophoneSoundMeter=MeterSettingsOutput(i,"Settings_MicrophoneOutput","width",50)):console.warn("No microphone devices found. Calling will not be possible."),$("#Settings_SpeakerOutput").css("width","0%"),p||(console.log("No speaker devices found, make sure one is plugged in."),$("#playbackSrc").hide(),$("#RingDeviceSection").hide()),navigator.mediaDevices.enumerateDevices()})).then((function(e){for(var t=0;t0&&(a=a.substring(0,a.indexOf("("))),(l=$("