Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var loggedin=0;
- var sTransferNumber;
- var oRingTone, oRingbackTone;
- var oSipStack, oSipSessionRegister, oSipSessionCall, oSipSessionTransferCall;
- var videoRemote, videoLocal, audioRemote;
- var bFullScreen = false;
- var oNotifICall;
- var bDisableVideo = false;
- var viewLocalScreencast; // <video> (webrtc) or <div> (webrtc4all)
- var oConfigCall;
- var oReadyStateTimer;
- var divVideo, divCallOptions;
- var hangupgrowl=0;
- var answergrowl=0;
- var txtDisplayName, txtPrivateIdentity, txtPublicIdentity, txtRealm;
- var txtPhoneNumber;
- var btnCall, btnHangUp;
- var txtRegStatus, txtCallStatus;
- var btnRegister, btnUnRegister;
- var btnFullScreen, btnHoldResume, btnTransfer, btnKeyPad;
- var kstychDialer={};
- kstychDialer['mDialerState']='Paused';
- kstychDialer['mDialerSubState']='NotReady';
- kstychDialer['mDialerCampaign']='';
- kstychDialer['mdispodata']='';
- kstychDialer['mDialNextStatus']='New';
- kstychDialer['mmanualallow']='No';
- kstychDialer['pendingDataSize']=0;
- kstychDialer['phone']=kstychAppObject['user']['sipid'];
- kstychDialer['connection']={'number':'1000'+kstychAppObject['user']['sipid'],'connected':0,'mic':1,'speaker':1,'channel':'','holdext':''};
- kstychDialer["keeplocalconf"]=kstychAppObject['config']['kDialer_keeplocalconf'];
- kstychDialer['RedialLast']='';
- var kstychCall={};
- kstychCall['mCallState']='Wait'; //states : ,Wait,Call,Dispo,Close
- kstychCall['ts_Wait']=getNowTS();
- kstychCall['ts_Call']=0;
- kstychCall['ts_Talk']=0;
- kstychCall['ts_Dispo']=0;
- kstychCall['ts_Close']=0;
- kstychCall['callnumber']='';
- kstychCall['connections']={};
- kstychCall['callid']='';
- kstychCall['crmid']='';
- kstychCall['campaignid']='';
- kstychCall['listid']='';
- kstychCall['mdial_CallACK']=0;
- kstychCall['mcalldata']='';
- kstychCall['userstatus']='';
- kstychCall['usersubstatus']='';
- kstychCall['usercallback']='';
- kstychCall['userremarks']='';
- kstychCall['userdata']={};
- kstychCall['previewcrmid']='';
- kstychCall['callWrapupTime']=300;
- kstychCall['prograssiveDelay']=120;
- kstychCall['ts_now']=0;
- kstychCall['bttc_day']='';
- kstychCall['bttc_hrs']='';
- kstychCall['serv_vs_prod']='';
- kstychCall['resolution']='';
- kstychCall['satisfy']='';
- kstychCall['final_call_assess']='';
- function kGetDData(obj,key)
- {
- if(obj=="D")
- {
- if(kstychDialer[key])return kstychDialer[key];
- }
- if(obj=="C")
- {
- if(kstychCall[key])return kstychCall[key];
- }
- return false;
- }
- function kSetDData(obj,key,val)
- {
- if(obj=="D")
- {
- kstychDialer[key]=val;
- }
- if(obj=="C")
- {
- kstychCall[key]=val;
- }
- //TODO update backend user session (userlog)
- return false;
- }
- function getNowTS()
- {
- return Math.floor(Date.now());
- }
- function kcallNewConnection(number)
- {
- var clines=kGetDData('C','connections');
- if(!clines[number])
- {
- clines[number]={};
- clines[number]['connected']=0;
- clines[number]['channel']='';
- clines[number]['callid']='';
- clines[number]['ts_Call']=0;
- clines[number]['ts_Talk']=0;
- clines[number]['ts_Dispo']=0;
- clines[number]['speaker']=1;
- clines[number]['mic']=1;
- clines[number]['holdext']='';
- kSetDData('C','connections',clines);
- }
- }
- function kcallSetConnection(number,key,val)
- {
- kcallNewConnection(number);
- var clines=kGetDData('C','connections');
- clines[number][key]=val;
- kSetDData('C','connections',clines);
- }
- function kcallGetConnection(number,key)
- {
- kcallNewConnection(number);
- var clines=kGetDData('C','connections');
- return clines[number][key];
- }
- function kcallHasConnection(number)
- {
- var clines=kGetDData('C','connections');
- if(!clines[number])return false;
- return true;
- }
- function dialerQuickOpen(varid,num,state,substate,autorun)
- {
- if(kstychCall['mCallState']=="Wait")
- {
- var oldpreviewid=kstychCall['previewcrmid'];
- kstychCall['previewcrmid']='';
- kstychCall['callnumber']='';
- kstychCall['crmid']='';
- if(varid!=''&&varid>0)
- {
- if(num!=''&&num!='0')
- {
- kstychCall['callnumber']=num;
- $("#manualdialnumber_txt").val(num);
- }
- if(oldpreviewid!=varid||state!=kstychDialer['mDialerState'])
- {
- kstychCall['previewcrmid']=varid;//progressiveDelay set to 1 //TODO
- updateDialerState("dialer","mDialerState",state,"mDialerSubState",substate);
- }
- else
- {
- kstychCall['previewcrmid']=varid;
- updateDialerState();
- }
- kDialerModel();
- }
- else
- {
- if(num!='')
- {
- $("#manualdialnumber_txt").val(num);
- updateDialerState("dialer","mDialerState","Manual");
- kDialerModel();
- if(autorun==1)setTimeout(function(){$("#manualdial_btn").click()},350);
- }
- }
- }
- else
- {
- simpleNotification('error','topRight',"Already on call!");
- }
- }
- function dialerAddAlt(i,varid)
- {
- var phone=$("#dialer_altphone"+i).val();
- var desc=$("#dialer_altphone_lbl_"+i).val();
- if(!/^\d{10}$/.test(phone)&&!/^\d{11}$/.test(phone))
- {
- simpleNotification('error','topRight',"Please enter 10 or 11 neumeric digits only");
- return;
- }
- if(desc=="")
- {
- simpleNotification('error','topRight',"Please enter number description");
- return;
- }
- if(phone!="")
- {
- var data="varid="+varid;
- data+="&keys=altphone"+i+",altphone_lbl_"+i;
- data+="&altphone"+i+"="+phone;
- data+="&altphone_lbl_"+i+"="+desc;
- doAjax('record?action=addkey',data,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
- $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>');
- showRecruit(varid);
- });
- }
- }
- function dialerDelAlt(i,varid)
- {
- doAjax('record?action=delaltphone&i='+i+'&varid='+varid,'','dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
- $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>');
- showRecruit(varid);
- });
- }
- function kDialerSpy(sipid,fun)
- {
- var datastr="kstychCall="+JSON.stringify(kstychCall);
- datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
- datastr+="&sipid="+sipid;
- datastr+="&mode="+fun;
- try{sipHangUp();}catch(e){console.log(e);}
- doAjax('dialer?action=spychannel',datastr,'__fake__div__', 'ajax_spydial','singlefail','POST', function(retstr){
- });
- }
- function kCallAction(num,action)
- {
- //action : MuteSpeaker,UnMuteSpeaker,MuteMic,UnMuteMic,Hangup,Hold,UnHold
- if(num=="u")
- {
- if(action=="MuteMic")kstychDialer['connection']['mic']=sipToggleMute();
- if(action=="UnMuteMic")kstychDialer['connection']['mic']=sipToggleMute();
- if(action=="MuteSpeaker");
- if(action=="UnMuteSpeaker");
- if(action=="Hangup");
- //if(action=="Hold");
- //if(action=="UnHold");
- }
- else
- {
- if(num=="c")num=kstychCall['callnumber'];
- var channel=kcallGetConnection(num,'channel');
- if(channel!='')
- {
- if(action=="MuteMic")kcallSetConnection(num,'mic',0);
- if(action=="UnMuteMic")kcallSetConnection(num,'mic',1);
- if(action=="MuteSpeaker")kcallSetConnection(num,'speaker',0);
- if(action=="UnMuteSpeaker")kcallSetConnection(num,'speaker',1);
- if(action=="Hangup");
- //if(action=="Hold")kcallSetConnection(num,'holdext');
- //if(action=="UnHold")kcallSetConnection(num,'holdext');
- doAjax('dialer?action=kCallAction&actiontype='+action+'&conf='+kstychDialer['connection']['number']+'&channel='+channel,'','__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){
- });
- }
- else simpleNotification('error','topRight',"No Channel for ["+num+"]");
- }
- updateDialerState();
- }
- function dialerDispNumberClick()
- {
- var lastnumber=$("#spandialer_num").html();
- if(kstychCall['mCallState']=="Dispo")
- {
- saveCloseDialerCall("REDIAL");
- }
- }
- function dialerAddConfCall()
- {
- var confnumber=$("#dialerConfNumberTxt").val();
- if(confnumber==''||confnumber.length<2)
- {
- simpleNotification('error','topRight',"Empty Number");
- return;
- }
- if(!kcallHasConnection(kstychCall['callnumber'])||kstychCall['ts_Dispo']>1)
- {
- simpleNotification('error','topRight',"No call to conference");
- return;
- }
- var datastr="kstychCall="+JSON.stringify(kstychCall);
- datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
- kcallNewConnection(confnumber);
- doAjax('dialer?action=addconfcall&confnumber='+confnumber,datastr,'__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){
- if(retstr.responseText.indexOf('Error')<0)
- {
- kcallSetConnection(confnumber,'callid',retstr.responseText);
- kcallSetConnection(confnumber,'ts_Call',getNowTS());
- updateDialerState();
- }
- else
- {
- simpleNotification('error','topRight',retstr.responseText);
- }
- });
- }
- function incomingCall(calllog,crmid,number)
- {
- $("#dialersearchresults").html('<div id=divworking></div><div style="clear:both"></div>');
- kcallSetConnection(number,'callid',calllog);
- kcallSetConnection(number,'connected',1);
- kSetDData('C','callid',calllog);
- kSetDData('C','crmid',crmid);
- if(crmid>0)showRecruit(crmid);
- else
- {
- createSearchRecordDiv('dialersearchresults');
- }
- kSetDData('C','mCallState','Call');
- kSetDData('C','ts_Call',getNowTS());
- kSetDData('C','ts_Talk',getNowTS());
- kstychCall["callnumber"]=number;
- updateDialerState();
- kDialerModel();
- }
- function dialerUIUpdate(var1,var2,var3)
- {
- var3parts=var3.split("~");
- var3parts[2]=atob(var3parts[2]);
- if(var1=="dialstart")
- {
- if(var2=="c")
- {
- if(var3parts[1]&&var3parts[1]!="")
- {
- kcallSetConnection(var3parts[1],'connected',1);
- kcallSetConnection(var3parts[1],'channel',var3parts[2]);
- kcallSetConnection(var3parts[1],'ts_Call',getNowTS());
- if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Call',getNowTS());
- updateDialerState();
- }
- }
- else if(var2=="u")
- {
- var dialerConnection=kGetDData("D","connection");
- dialerConnection['channel']=var3parts[2];
- kSetDData("D","connection",dialerConnection);
- }
- }
- if(var1=="dialend")
- {
- if(var2=="c")
- {
- if(var3parts[1]&&var3parts[1]!="")
- {
- kcallSetConnection(var3parts[1],'connected',1);
- kcallSetConnection(var3parts[1],'channel',var3parts[2]);
- kcallSetConnection(var3parts[1],'ts_Talk',getNowTS());
- if(var3parts[1]==kstychCall['callnumber'])kSetDData('C','ts_Talk',getNowTS());
- updateDialerState();
- }
- }
- }
- if(var1=="hangup")
- {
- if(var2=="c")
- {
- if(var3parts[1]&&var3parts[1]!="")
- {
- kcallSetConnection(var3parts[1],'connected',0);
- if(kcallGetConnection(var3parts[1],'ts_Call')==0)kcallSetConnection(var3parts[1],'ts_Call',getNowTS());
- if(kcallGetConnection(var3parts[1],'ts_Talk')==0)kcallSetConnection(var3parts[1],'ts_Talk',getNowTS());
- kcallSetConnection(var3parts[1],'ts_Dispo',getNowTS());
- if(var3parts[1]==kstychCall['callnumber'])
- {
- if(kstychCall['ts_Call']==0)kSetDData('C','ts_Call',getNowTS());
- if(kstychCall['ts_Talk']==0)kSetDData('C','ts_Talk',getNowTS());
- kSetDData('C','ts_Dispo',getNowTS());
- hangupCall();
- }
- updateDialerState();
- }
- }
- }
- }
- function incomingPopupAlert(var1,var2,var3)
- {
- //var incomingnotify=growlSNotify(var1,var2,"top-right");
- //setTimeout(function(){$.gritter.remove(incomingnotify, {fade: true,speed: 'slow'});incomingnotify=0;},1500);
- $.titleAlert(var1+" "+var2, {
- requireBlur:true,
- stopOnFocus:true,
- duration:1500,
- interval:500
- });
- kDesktopNotification("",var1,var2,1500);
- }
- function outgoingCall()
- {
- $("#dialersearchresults").html("");
- kSetDData('C','callnumber',$("#manualdialnumber_txt").val());
- var datastr="kstychCall="+JSON.stringify(kstychCall);
- datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
- var client = $('#tcampaign_select').val();
- if(kstychDialer['mDialerState']=="Manual")
- {
- if(kstychCall['callnumber']!="")
- {
- doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
- if(kstychCall['crmid']!="")
- {
- kSetDData('C','mCallState','Call');
- kSetDData('C','ts_Call',getNowTS());
- if(kstychCall['crmid']==0)
- {
- createSearchRecordDiv('dialersearchresults');
- }
- updateDialerState();
- }
- else
- {
- kSetDData('C','previewcrmid','');
- updateDialerState("dialer","mDialerState","Manual");
- }
- });
- }
- else
- {
- simpleNotification('error','topRight',"Empty Number");
- }
- }
- if(kstychDialer['mDialerState']=="DialNext")
- {
- doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
- if(kstychCall['crmid']!="")
- {
- kSetDData('C','mCallState','Call');
- kSetDData('C','ts_Call',getNowTS());
- updateDialerState();
- }
- else
- {
- simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record");
- kSetDData('C','previewcrmid','');
- updateDialerState("dialer","mDialerState","DialNext");
- }
- });
- }
- if(kstychDialer['mDialerState']=="Progressive")
- {
- doAjax('dialer?action=newcall&client='+client,datastr,'dialersearchresults', 'ajax_manualdial','singlefail','POST', function(retstr){
- if(kstychCall['crmid']!="")
- {
- kSetDData('C','mCallState','Call');
- kSetDData('C','ts_Call',getNowTS());
- updateDialerState();
- }
- else
- {
- simpleNotification('error','topRight',"Failed to Dial Next ["+kstychDialer['mDialNextStatus']+"] Record");
- //Cleanup?
- kSetDData('C','previewcrmid','');
- updateDialerState("dialer","mDialerState","DialNext");
- }
- });
- }
- //check if current state is valid to make a call
- //prepare ajax parameters
- //call dialer controller to submit request
- //check return values for success
- //update dialer and call objects
- }
- function hangupCall()
- {
- /* Commented BY AmolG on 15 Feb 2017 */
- //kstychCall['ts_now']=getNowTS();
- var datastr="kstychCall="+JSON.stringify(kstychCall);
- datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
- doAjax('dialer?action=hangupall',datastr,'', 'ajax_manualdial','singlefail','POST',
- function(retstr){
- if(retstr.responseText.indexOf('Error')<0)
- {
- kSetDData('C','mCallState',"Dispo");
- kSetDData('C','ts_Dispo',getNowTS());
- if(kstychDialer["keeplocalconf"]==0)
- {
- try{sipHangUp();}catch(e){console.log(e);}
- var dialerConnection=kGetDData("D","connection");
- dialerConnection['connected']=0;
- dialerConnection['channel']='';
- updateDialerState("dialer","connection",dialerConnection);
- }
- else updateDialerState();
- }
- else
- {
- simpleNotification('error','topRight',retstr.responseText);
- updateDialerState();
- }
- });
- }
- function saveCloseDialerCall(flag)
- {
- kstychCall['userstatus']=$('#dialer_userstatus').val();
- kstychCall['usersubstatus']=$('#dialer_usersubstatus').val();
- kstychCall['usercallback']=$('#dialer_usercallback').val();
- kstychCall['userremarks']=$('#dialer_userremarks').val();
- kstychCall['userflag']=$('#dialer_flag').val();
- /* Commented BY AmolG on 15 Feb 2017 */
- /*kstychCall['priority']=$('#priority').val();
- kstychCall['bttc_day']=$('#bttc_day').val();
- kstychCall['bttc_hrs']=$('#bttc_hrs').val();
- kstychCall['serv_vs_prod']=$('#serv_vs_prod').val();
- kstychCall['resolution']=$('#resolution').val();
- kstychCall['satisfy']=$('#satisfy').val();
- kstychCall['final_call_assess']=$('#final_call_assess').val();*/
- if(typeof customerDispofields != 'undefined')kstychCall['userdata']=customerDispofields;
- if(flag=="AUTOWRAPUP")
- {
- kstychCall['userstatus']="AUTOWRAPUP";
- kstychCall['usersubstatus']="AUTOWRAPUP";
- $('#dialer_usercallback').val("");
- kstychCall['usercallback']="";
- kstychCall['userremarks']="";
- kstychCall['userflag']="";
- }
- else if(flag=="REDIAL")
- {
- kstychCall['userstatus']="REDIAL";
- kstychCall['usersubstatus']="REDIAL";
- $('#dialer_usercallback').val("");
- kstychCall['usercallback']="";
- kstychCall['userremarks']="";
- kstychCall['userflag']="";
- kstychDialer['RedialLast']='Yes';
- }
- else if(!$('#dialer_userstatus').length)
- {
- kstychCall['userstatus']="NORECORD";
- kstychCall['usersubstatus']="NORECORD";
- kstychCall['usercallback']="";
- kstychCall['userremarks']="";
- kstychCall['userflag']="";
- $('#dialer_usercallback').val("");
- }
- else
- {
- if(kstychCall['userstatus']==""||kstychCall['usersubstatus']=="")
- {
- simpleNotification('error','topRight',"Please Select Disposition and Subdisposition");
- return;
- }
- //For $ dropdown Condition - Changes done By Manish on 27-10-16
- /*if(kstychCall['userstatus']=="Contacted - FollowUp - Specific" || kstychCall['userstatus']=="Contacted - Follow-Up - Generic")
- {
- if(kstychCall['final_call_assess']==""&&kstychCall['serv_vs_prod']==""&&kstychCall['resolution']==""&&kstychCall['satisfy']=="")
- {
- simpleNotification('Error','topRight',"Please Select ALL(Service vs Product and Resolution and Satisfaction and Final_call_Assessment)");
- return;
- }
- }*/
- if(kstychCall['userstatus'].toLowerCase().indexOf("followup")>-1||kstychCall['userstatus'].toLowerCase().indexOf("callback")>-1)
- {
- if($('#dialer_usercallback').val()=="")
- {
- simpleNotification('error','topRight',"Please select Callback date within one month in future");
- return;
- }
- }
- else
- {
- if($('#dialer_usercallback').val()!="")
- {
- simpleNotification('error','topRight',"You Cannot input Callback date time in this Disposition");
- return;
- }
- }
- var date1 = new Date();
- var date2 = new Date($('#dialer_usercallback').val());
- var diff = date2.getTime() - date1.getTime();
- if(diff<0||diff>30*24*60*60*1000)
- {
- simpleNotification('error','topRight',"Please select Callback date within one month in future");
- return;
- }
- var hours = date2.getHours();
- var mins = date2.getMinutes();
- var fullhour=hours+(mins/60);
- if(fullhour<9||fullhour>19)
- {
- simpleNotification('error','topRight',"Please select Callback Time date within 9AM and 7PM");
- return;
- }
- }
- if($("#recruitsavedata").length)$("#recruitsavedata").click();//TODO hold div in reset, or any error will be lost
- var datastr="kstychCall="+JSON.stringify(kstychCall);
- datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
- doAjax('dialer?action=closecall',datastr,'', 'ajax_manualdial','singlefail','POST',
- function(retstr){
- kSetDData('C','mCallState',"Close");
- kSetDData('C','ts_Close',getNowTS());
- updateDialerState("action","reset","");
- });
- //Dialog box after Save & Close-Taking from KFormLib.php
- $finalCallAssess = $('#final_call_assess').val();
- if($finalCallAssess == 'Very Good Call With Customer')
- {
- /*$.gritter.add({
- title: 'type',
- text: 'text',
- class_name: 'gritter-b-center'
- });*/
- $('#goodCall').dialog({
- modal: true,
- position: ['center'],
- resizable: false,
- closeOnEscape: false,
- open: function(event, ui){
- $(".ui.dialog-titlebar-close", ui.dialog | ui).hide();
- setTimeout(function(){$('#goodCall').dialog('close');},5000);
- }
- });
- //setTimeout(function(){$('#goodCall').dialog('close');},5000);
- }
- if($finalCallAssess == 'Ok Call')
- {
- $('#okCall').dialog({
- open: function(event, ui){
- $(this).css({'max-height':500, 'overflow-y':'auto'});
- },
- modal: true,
- position: ['center'],
- resizable: false,
- closeOnEscape: false});
- setTimeout(function(){$('#okCall').dialog('close');},5000);
- }
- if($finalCallAssess == 'Not Interested Customer')
- {
- $('#notInterest').dialog({
- open: function(event, ui){
- $(this).css({'max-height':500, 'overflow-y':'auto'});
- },
- modal: true,
- position: ['center'],
- resizable: false,
- closeOnEscape: false});
- setTimeout(function(){$('#notInterest').dialog('close');},5000);
- }
- if($finalCallAssess == 'Iritated Customer')
- {
- $('#iritCust').dialog({
- open: function(event, ui){
- $(this).css({'max-height':500, 'overflow-y':'auto'});
- },
- modal: true,
- position: ['center'],
- resizable: false,
- closeOnEscape: false});
- setTimeout(function(){$('#iritCust').dialog('close');},5000);
- }
- if($finalCallAssess == 'Angry')
- {
- $('#angry').dialog({
- open: function(event, ui){
- $(this).css({'max-height':500, 'overflow-y':'auto'});
- },
- modal: true,
- position: ['center'],
- resizable: false,
- closeOnEscape: false});
- setTimeout(function(){$('#angry').dialog('close');},5000);
- }
- }
- function showWrapUp()
- {
- kstychCall['userstatus']="Paused";
- kstychCall['usersubstatus']="WRAPUP";
- $('#dialer_usercallback').val("");
- kstychCall['usercallback']="";
- kstychCall['userremarks']="";
- kstychCall['userflag']="";
- var datastr="kstychCall="+JSON.stringify(kstychCall);
- datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
- doAjax('dialer?action=wrapup',datastr,'', 'ajax_manualdial','singlefail','POST',
- function(retstr){
- dialerTimersUpdate();
- });
- }
- function resetDialer()
- {
- if(kstychDialer['RedialLast']=="Yes")
- {
- kstychDialer['RedialLast']='';
- kSetDData('C','mCallState',"Wait");
- kSetDData('C','ts_Wait',getNowTS());
- kSetDData('C','ts_Call',0);
- kSetDData('C','ts_Talk',0);
- kSetDData('C','ts_Dispo',0);
- kSetDData('C','ts_Close',0);
- updateDialerState("action","dialnext");
- return;
- }
- var dialerResetForceState=kstychDialer['mDialerState'];
- var dialerResetForceSubState=kstychDialer['mDialerSubState'];
- dialerResetForceState="Progressive";//Hardcoded TODO change to config
- dialerResetForceSubState="";
- if(kstychCall['userstatus']=="AUTOWRAPUP")
- {
- dialerResetForceState="Paused";
- dialerResetForceSubState="AUTOWRAPUP";
- }
- /* Commented BY AmolG on 15 Feb 2017 */
- if(kstychCall['userstatus']=="WRAPUP")
- {
- dialerResetForceState="Paused";
- dialerResetForceSubState="WRAPUP";
- }
- //TODO check hangup any connections?
- $("#dialersearchresults").html("");//CANNOT clear this until we have a solution of error handling in save form
- $("#manualdialnumber_txt").val("");
- resetCallArray();
- $("#dialersearchbox").html("");
- $(".dialer_conf_divs").remove();
- updateDialerState("dialer","mDialerState",dialerResetForceState,"mDialerSubState",dialerResetForceSubState);
- }
- function resetCallArray()
- {
- kSetDData('C','mCallState',"Wait");
- kSetDData('C','ts_Wait',getNowTS());
- kSetDData('C','ts_Call',0);
- kSetDData('C','ts_Talk',0);
- kSetDData('C','ts_Dispo',0);
- kSetDData('C','ts_Close',0);
- kSetDData('C','callnumber',"");
- kSetDData('C','connections',{});
- kSetDData('C','callid',"");
- kSetDData('C','crmid',"");
- kSetDData('C','campaignid',"");
- kSetDData('C','listid',"");
- kSetDData('C','mdial_CallACK',"");
- kSetDData('C','mcalldata',"");
- kSetDData('C','userstatus',"");
- kSetDData('C','usersubstatus',"");
- kSetDData('C','usercallback',"");
- kSetDData('C','userremarks',"");
- kSetDData('C','userflag',"");
- kSetDData('C','bttc_day',"");
- kSetDData('C','bttc_hrs',"");
- kSetDData('C','serv_vs_prod',"");
- kSetDData('C','resolution',"");
- kSetDData('C','satisfy',"");
- kSetDData('C','final_call_assess',"");
- kSetDData('C','userdata',{});
- if(typeof customerDispofields != 'undefined')customerDispofields={};
- kSetDData('C','previewcrmid',"");
- kSetDData('C','callWrapupTime',300);
- kSetDData('C','prograssiveDelay',120);
- }
- function updateDialerState(objstr,key,val,key2,val2)
- {
- if(objstr=="dialer")
- {
- kSetDData("D",key,val);
- kSetDData("D",key2,val2);
- if(key=='mDialerState')
- {
- if(!key2||key2=="")kSetDData("D","mDialerSubState","");
- if(val=="Paused")
- {
- resetCallArray();
- }
- $("#dialersearchresults").html("");
- kSetDData('C','ts_Wait',getNowTS());//TODO reset here?
- var datastr="kstychCall="+JSON.stringify(kstychCall);
- datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
- var client = $('#tcampaign_select').val();
- doAjax('dialer?action=dialerstate&client='+client,datastr,'', 'ajax_manualdial','singlefail','POST',
- function(retstr){
- if(val=="Progressive"||(kstychCall['previewcrmid']!=""&&kstychCall['previewcrmid']>0))
- {
- doAjax('dialer?action=previewnext&client='+client,datastr,'dialersearchresults', 'ajax_manualdial2','singlefail','POST',
- function(retstr){
- if(kstychCall['previewcrmid']!="")
- {
- updateDialerState();
- }
- else
- {
- resetCallArray();
- simpleNotification('error','topRight',"Failed to Dial Next Record");
- updateDialerState("dialer","mDialerState","DialNext");
- }
- });
- }
- updateDialerState();
- });
- }
- }
- if(objstr=="call")
- {
- kSetDData('C',key,val);
- kSetDData("C",key2,val2);
- }
- if(objstr=="action")
- {
- if(key=="dialnext")
- {
- outgoingCall();
- }
- if(key=="hangupall")
- {
- hangupCall();
- }
- if(key=="saveclose")
- {
- saveCloseDialerCall();
- }
- if(key=="reset")
- {
- resetDialer();
- }
- }
- updateDialerUI();
- //////////////////////////////////////////////////////////////
- if(objstr=="")return;
- //$("#kTopBarExtra").parent().addClass("open");
- //run this function on every state change?
- //take dialer and call objects and send to controller for update
- }
- function updateDialerUI()
- {
- $("#spandialer_num").html(kstychCall["callnumber"]);
- /* Commented BY AmolG on 15 Feb 2017 */
- //Adding default value in Text Box on Manual Call - By Manish
- $("#mobile").val(kstychCall["callnumber"]);
- //$("#status").val('New');
- $("#mainNumber").val(kstychCall["callnumber"]);
- if(kstychCall["callnumber"]!="")$("#dialertimes2").show();
- else $("#dialertimes2").hide();
- if($("#dialerManualAllowLI").length)kSetDData("D",'mmanualallow','Yes');
- //////////////////////////////////////////////////////////////
- var statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerState'];
- if(kstychDialer['mDialerState']=="Paused")statestr="<i class='fa fa-pause'></i> : "+kstychDialer['mDialerSubState'];
- if(kstychDialer['mDialerState']=="Ready")statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerSubState'];
- /* Commented BY AmolG on 15 Feb 2017 */
- /*if(kstychDialer['mDialerState']=="Ready")
- {
- //Incoming to Auto Dial - By Manish on 10-07-17
- if(kstychDialer['mDialerSubState']=='Incoming')
- kstychDialer['mDialerSubState']="AutoDial";
- statestr="<i class='fa fa-phone'></i> : "+kstychDialer['mDialerSubState'];
- }*/
- $("#dialerstate_btn").html(statestr);
- if(kstychDialer['mDialerState']=="Paused")
- {
- $("#dialerstate_div").width("150px");
- $("#manualdial_btn").hide();$("#manualdialnumber_txt").hide();
- $("#dialerstate_btn").parent().removeClass("rounded-left");
- $("#dialerstate_btn").parent().removeClass("btn-info").addClass("btn-primary");
- }
- else if(kstychDialer['mDialerState']=="Ready")
- {
- $("#dialerstate_div").width("150px");
- $("#manualdial_btn").show();$("#manualdialnumber_txt").hide();
- $("#dialerstate_btn").parent().addClass("rounded-left");
- $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info");
- }
- else if(kstychDialer['mDialerState']=="Manual")
- {
- $("#dialerstate_div").width("350px");
- $("#manualdial_btn").show();$("#manualdialnumber_txt").show();
- $("#dialerstate_btn").parent().addClass("rounded-left");
- $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info");
- }
- else if(kstychDialer['mDialerState']=="DialNext")
- {
- $("#dialerstate_div").width("150px");
- $("#manualdial_btn").show();$("#manualdialnumber_txt").hide();
- $("#dialerstate_btn").parent().addClass("rounded-left");
- $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info");
- }
- else if(kstychDialer['mDialerState']=="Progressive")
- {
- $("#dialerstate_div").width("150px");
- $("#manualdial_btn").show();$("#manualdialnumber_txt").hide();
- $("#dialerstate_btn").parent().removeClass("rounded-left");
- $("#dialerstate_btn").parent().removeClass("btn-primary").addClass("btn-info");
- }
- //////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////
- var uStateArr=[];
- uStateArr['conficon_u_a']='btn-primary';uStateArr['conficon_u_i']='fa-chain-broken';
- if(kstychDialer['connection']['connected']==1)
- {
- uStateArr['conficon_u_a']='btn-success';uStateArr['conficon_u_i']='fa-chain';
- }
- uStateArr['mic']='UnMuteMic';uStateArr['micicon']='fa-microphone-slash';
- if(kstychDialer['connection']['mic']==1)
- {
- uStateArr['mic']='MuteMic';uStateArr['micicon']='fa-microphone';
- }
- var calluhtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+uStateArr['conficon_u_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_u_a><i class='fa "+uStateArr['conficon_u_i']+"' id=conficon_u_i></i> </a>";
- calluhtml+="<ul class='dropdown-menu'>";
- calluhtml+="<li data-toggle='tooltip' data-title='My Channel' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>";
- //calluhtml+="<li data-toggle='tooltip' data-title='MuteSpeaker' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"MuteSpeaker\");return false;'><i class='fa fa-volume-off'></i></a></li>";
- calluhtml+="<li data-toggle='tooltip' data-title='"+uStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\""+uStateArr['mic']+"\");return false;'><i class='fa "+uStateArr['micicon']+"'></i></a></li>";
- //calluhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>";
- //calluhtml+="<li data-toggle='tooltip' data-title='Hold' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"u\",\"Hold\");return false;'><i class='fa fa-pause'></i></a></li>";
- calluhtml+="</ul>";
- $("#connections_div_u").html(calluhtml);
- $(".dialer_conf_divs").remove();
- var confhtml='';
- for(var key in kstychCall['connections'])
- {
- if(kstychCall['connections'].hasOwnProperty(key))
- {
- if(key==kstychCall['callnumber'])
- {
- var cStateArr=[];
- cStateArr['conficon_c0_a']='btn-primary';cStateArr['conficon_c0_i']='fa-chain-broken';
- if(kstychCall['connections'][key]['connected']==1)
- {
- cStateArr['conficon_c0_a']='btn-success';cStateArr['conficon_c0_i']='fa-chain';
- }
- cStateArr['mic']='UnMuteMic';cStateArr['micicon']='fa-microphone-slash';
- if(kstychCall['connections'][key]['mic']==1)
- {
- cStateArr['mic']='MuteMic';cStateArr['micicon']='fa-microphone';
- }
- cStateArr['speaker']='UnMuteSpeaker';cStateArr['speakericon']='fa-volume-off';
- if(kstychCall['connections'][key]['speaker']==1)
- {
- cStateArr['speaker']='MuteSpeaker';cStateArr['speakericon']='fa-volume-up';
- }
- cStateArr['holdext']='UnHold';cStateArr['holdexticon']='fa-play';
- if(kstychCall['connections'][key]['holdext']=='')
- {
- cStateArr['holdext']='Hold';cStateArr['holdexticon']='fa-pause';
- }
- var callchtml="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+cStateArr['conficon_c0_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()' id=conficon_c0_a><i class='fa "+cStateArr['conficon_c0_i']+"' id=conficon_c0_i></i> </a>";
- callchtml+="<ul class='dropdown-menu'>";
- callchtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>";
- callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['speaker']+"\");return false;'><i class='fa "+cStateArr['speakericon']+"'></i></a></li>";
- callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['mic']+"\");return false;'><i class='fa "+cStateArr['micicon']+"'></i></a></li>";
- callchtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>";
- //callchtml+="<li data-toggle='tooltip' data-title='"+cStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\"c\",\""+cStateArr['holdext']+"\");return false;'><i class='fa "+cStateArr['holdexticon']+"'></i></a></li></ul>";
- $("#connections_div_c").html(callchtml);
- }
- else
- {
- var tStateArr=[];
- tStateArr['conficon_t_a']='btn-primary';tStateArr['conficon_t_i']='fa-chain-broken';
- if(kstychCall['connections'][key]['connected']==1)
- {
- tStateArr['conficon_t_a']='btn-success';tStateArr['conficon_t_i']='fa-chain';
- }
- tStateArr['mic']='UnMuteMic';tStateArr['micicon']='fa-microphone-slash';
- if(kstychCall['connections'][key]['mic']==1)
- {
- tStateArr['mic']='MuteMic';tStateArr['micicon']='fa-microphone';
- }
- tStateArr['speaker']='UnMuteSpeaker';tStateArr['speakericon']='fa-volume-off';
- if(kstychCall['connections'][key]['speaker']==1)
- {
- tStateArr['speaker']='MuteSpeaker';tStateArr['speakericon']='fa-volume-up';
- }
- tStateArr['holdext']='UnHold';tStateArr['holdexticon']='fa-play';
- if(kstychCall['connections'][key]['holdext']=='')
- {
- tStateArr['holdext']='Hold';tStateArr['holdexticon']='fa-pause';
- }
- confhtml+="<div class='dropdown dropdown-icons dialer_conf_divs' confphonenumber='"+key+"' >";
- confhtml+="<a data-toggle='dropdown' href='#' class='btn btn-stroke "+tStateArr['conficon_t_a']+" btn-circle dropdown-toggle' onmouseout='$(this).blur()'><i class='fa "+tStateArr['conficon_t_i']+"'></i> </a>";
- confhtml+="<ul class='dropdown-menu'>";
- confhtml+="<li data-toggle='tooltip' data-title='"+key+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='return false;'><i class='fa fa-info'></i></a></li>";
- confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['speaker']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['speaker']+"\");return false;'><i class='fa "+tStateArr['speakericon']+"'></i></a></li>";
- confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['mic']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['mic']+"\");return false;'><i class='fa "+tStateArr['micicon']+"'></i></a></li>";
- confhtml+="<li data-toggle='tooltip' data-title='Hangup' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\"Hangup\");return false;'><i class='fa fa-times-circle'></i></a></li>";
- //confhtml+="<li data-toggle='tooltip' data-title='"+tStateArr['holdext']+"' data-placement='left' data-tcontainer='body'><a href='#' onclick='kCallAction(\""+key+"\",\""+tStateArr['holdext']+"\");return false;'><i class='fa "+tStateArr['holdexticon']+"'></i></a></li>";
- confhtml+="</ul></div>";
- }
- }
- }
- $(confhtml).insertAfter("#connections_div_c");
- //////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////
- if(kstychCall['mCallState']=="Wait")
- {
- $("#dialerstate_btn").parent().attr("disabled",false);
- if(kstychDialer['mmanualallow']=='Yes')$("#manualdialnumber_txt").attr("disabled",false);
- else $("#manualdialnumber_txt").attr("disabled",true);
- $("#manualdial_btn").attr("disabled",false);
- $("#manualdial_btn").attr("dialaction","dialnext");
- $("#manualdial_btn").html("<i class='fa fa-play text-default'></i>");
- if(kstychDialer['mDialerState']=="Ready")
- {
- var readyDelay=Math.ceil((getNowTS()-kstychCall['ts_Wait'])/1000);
- $("#manualdial_btn").attr("disabled",true);
- $("#manualdial_btn").attr("dialaction","");
- $("#manualdial_btn").html("Waiting");// : "+readyDelay);
- }
- }
- if(kstychCall['mCallState']=="Call")
- {
- $("#dialerstate_btn").parent().attr("disabled",true);
- $("#manualdialnumber_txt").attr("disabled",true);
- $("#manualdial_btn").attr("disabled",false);
- $("#manualdial_btn").attr("dialaction","hangupall");
- $("#manualdial_btn").html("<i class='fa fa-times text-primary'></i> Hangup");
- }
- if(kstychCall['mCallState']=="Dispo")
- {
- $("#dialerstate_btn").parent().attr("disabled",true);
- $("#manualdialnumber_txt").attr("disabled",true);
- $("#manualdial_btn").attr("disabled",false);
- $("#manualdial_btn").attr("dialaction","saveclose");
- $("#manualdial_btn").html("<i class='fa fa-save text-success'></i> Save & Close");
- }
- if(kstychCall['mCallState']=="Close")
- {
- $("#dialerstate_btn").parent().attr("disabled",true);
- $("#manualdialnumber_txt").attr("disabled",true);
- $("#manualdial_btn").attr("disabled",true);
- $("#manualdial_btn").attr("dialaction","");
- $("#manualdial_btn").html("<i class='fa fa-pause text-default'></i>");
- }
- //////////////////////////////////////////////////////////////
- }
- function dialerTimersUpdate()
- {
- var dispD="0";var dispT="0";var dispC="0";var dispW="0";
- if(kstychCall['ts_Dispo']>1)
- {
- if(Math.ceil(((kstychCall['ts_Dispo']-kstychCall['ts_Talk'])/1000))<3)
- {
- kstychCall['callWrapupTime']=90;
- if(typeof dispoClassArray!='undefined' && typeof dispoClassArray['NA'] != 'undefined')
- {
- if($('#dialer_userstatus').val()=="")
- {
- $('#dialer_userstatus').val(dispoClassArray['NA']);
- $('#dialer_userstatus').change();
- }
- }
- }
- var thiswraptime=Math.ceil(kstychCall['callWrapupTime']-((getNowTS()-kstychCall['ts_Dispo'])/1000));
- if(thiswraptime<=0)
- {
- saveCloseDialerCall('AUTOWRAPUP');
- }
- /*if(thiswraptime==90 || thiswraptime==300)
- {
- showWrapUp();
- }*/
- dispD="Wrapup : "+thiswraptime;
- $("#spandialer_ts").html(dispD);
- $("#dialertimes1").removeClass("btn-default").addClass("btn-primary");
- }
- else if(kstychCall['ts_Talk']>1)
- {
- dispT="Talk : "+Math.ceil(((getNowTS()-kstychCall['ts_Talk'])/1000));
- $("#spandialer_ts").html(dispT);
- $("#dialertimes1").removeClass("btn-primary").addClass("btn-default");
- }
- else if(kstychCall['ts_Call']>1)
- {
- dispC="Call : "+Math.ceil(((getNowTS()-kstychCall['ts_Call'])/1000));
- $("#spandialer_ts").html(dispC);
- $("#dialertimes1").removeClass("btn-primary").addClass("btn-default");
- }
- else if(kstychCall['ts_Wait']>1)
- {
- dispW="Wait : "+Math.ceil(((getNowTS()-kstychCall['ts_Wait'])/1000));
- $("#spandialer_ts").html(dispW);
- $("#dialertimes1").removeClass("btn-primary").addClass("btn-default");
- }
- if(kstychCall['mCallState']=="Wait")
- {
- if(kstychDialer['mDialerState']=="Progressive")
- {
- var progressiveDelay=Math.ceil(kstychCall['prograssiveDelay']-((getNowTS()-kstychCall['ts_Wait'])/1000));
- if(progressiveDelay<0)progressiveDelay=0;
- $("#manualdial_btn").attr("disabled",false);
- $("#manualdial_btn").attr("dialaction","dialnext");
- $("#manualdial_btn").html("<i class='fa fa-play text-default'></i> "+progressiveDelay);
- if(progressiveDelay<=0)$("#manualdial_btn").click();
- }
- }
- setTimeout(dialerTimersUpdate,1000);
- }
- function kDialerConnected()
- {
- updateDialerState();
- dialerTimersUpdate();
- $("#dialerQuickControlDiv").show();
- }
- function kDialerInit()
- {
- if(kstychAppObject['user']['id']!=0)
- {
- //simpleNotification("warning","topRight","Trying to Enable Voice Services");
- txtDisplayName = kstychAppObject['user']['sipid'];
- txtPrivateIdentity = kstychAppObject['user']['sipid'];
- txtPublicIdentity = "sip:"+kstychAppObject['user']['sipid']+"@"+kstychAppObject['user']['sipserver'];
- txtRealm = kstychAppObject['user']['sipserver'];
- //txtPhoneNumber=document.getElementById("txtphno");
- txtPhoneNumber = '1000'+kstychAppObject['user']['sipid'];
- btnCall = false;
- btnHangUp = true;
- btnFullScreen = false;
- audioRemote = document.getElementById("audio_remote");
- videoLocal = document.getElementById("video_local");
- videoRemote = document.getElementById("video_remote");
- SIPml.setDebugLevel(kstychAppObject['config']['appdebug']==0 ? "error" : "info");
- //expert stuff //siddharth
- cbVideoDisable = true;
- if(window.location.protocol == 'https:')txtWebsocketServerUrl = "wss://"+kstychAppObject['user']['sipssldomain']+":8089/ws";
- else txtWebsocketServerUrl = "ws://"+txtRealm+":8088/ws";
- txtSIPOutboundProxyUrl = "";//txtSIPOutboundProxyUrl="udp://"+txtRealm+":5060";
- var preInit = function() {
- // set default webrtc type (before initialization)
- var s_webrtc_type = null;//getPVal("wt");
- var s_fps = null;//getPVal("fps");
- var s_mvs = null;//getPVal("mvs"); // maxVideoSize
- var s_mbwu = null;//getPVal("mbwu"); // maxBandwidthUp (kbps)
- var s_mbwd = null;//getPVal("mbwd"); // maxBandwidthUp (kbps)
- var s_za = null;//getPVal("za"); // ZeroArtifacts
- var s_ndb = null;//getPVal("ndb"); // NativeDebug
- if (s_webrtc_type) SIPml.setWebRtcType(s_webrtc_type);
- // initialize SIPML5
- SIPml.init(postInit);
- // set other options after initialization
- if (s_fps) SIPml.setFps(parseFloat(s_fps));
- if (s_mvs) SIPml.setMaxVideoSize(s_mvs);
- if (s_mbwu) SIPml.setMaxBandwidthUp(parseFloat(s_mbwu));
- if (s_mbwd) SIPml.setMaxBandwidthDown(parseFloat(s_mbwd));
- if (s_za) SIPml.setZeroArtifacts(s_za === "true");
- if (s_ndb == "true") SIPml.startNativeDebug();
- //var rinningApps = SIPml.getRunningApps();
- //var _rinningApps = Base64.decode(rinningApps);
- //tsk_utils_log_info(_rinningApps);
- }
- oReadyStateTimer = setInterval(function () {
- if (document.readyState === "complete") {
- clearInterval(oReadyStateTimer);
- // initialize SIPML5
- preInit();
- }
- },
- 500);
- }
- }
- window.onload = function ()
- {
- kDialerInit();
- };
- function postInit()
- {
- // check for WebRTC support
- if (!SIPml.isWebRtcSupported())
- {
- // is it chrome?
- if (SIPml.getNavigatorFriendlyName() == 'chrome')
- {
- document.location="msie?oldchrome";
- return;
- }
- if (SIPml.getNavigatorFriendlyName() == 'ie'||SIPml.getNavigatorFriendlyName() == 'netscape')
- {
- document.location="msie";
- return;
- }
- // checks for WebSocket support
- if (!SIPml.isWebSocketSupported() && !SIPml.isWebRtc4AllSupported())
- {
- document.location="msie?nowebsockets";
- return;
- }
- }
- if (!SIPml.isWebRtc4AllSupported() && !SIPml.isWebRtcSupported())
- {
- document.location="msie?notsupported";
- return;
- }
- oConfigCall = {
- audio_remote: audioRemote,
- video_local: videoLocal,
- video_remote: videoRemote,
- screencast_window_id: 0x00000000, // entire desktop
- bandwidth: { audio:undefined, video:undefined },
- video_size: { minWidth:undefined, minHeight:undefined, maxWidth:undefined, maxHeight:undefined },
- events_listener: { events: '*', listener: onSipEventSession },
- sip_caps: [
- { name: '+g.oma.sip-im' },
- { name: 'language', value: '\"en,fr\"' }
- ]
- };
- sipRegister();
- //simpleNotification("warning","topRight","Requesting Voice Permissions");
- //navigator.getUserMedia = (navigator.getUserMedia ||navigator.webkitGetUserMedia ||navigator.mozGetUserMedia || navigator.msGetUserMedia);
- //navigator.getUserMedia({video: false, audio: true},function(localMediaStream) {},function(err) {simpleNotification("error","topRight","Your Browser doesnot support Voice. Some functions will not work.");});
- }
- // sends SIP REGISTER request to login
- function sipRegister() {
- // catch exception for IE (DOM not ready)
- try
- {
- if (!txtRealm || !txtPrivateIdentity || !txtPublicIdentity) {
- txtRegStatus = '<b>Please fill madatory fields (*)</b>';
- simpleNotification("error","topRight",txtRegStatus);
- return;
- }
- var o_impu = tsip_uri.prototype.Parse(txtPublicIdentity);
- if (!o_impu || !o_impu.s_user_name || !o_impu.s_host) {
- txtRegStatus = "<b>[" + txtPublicIdentity + "] is not a valid Public identity</b>";
- simpleNotification("error","topRight",txtRegStatus);
- return;
- }
- // enable notifications if not already done
- if (window.webkitNotifications && window.webkitNotifications.checkPermission() != 0) {
- window.webkitNotifications.requestPermission();
- }
- var iceServers=[{ url: 'stun:'+kstychAppObject['user']['sipserver']+':3478'}, { url:'turn:'+kstychAppObject['user']['sipserver'], credential:'1234',username: 'kstych'}];
- if(kstychAppObject['config']['use-ice']=='no')iceServers=[{ url: 'stun:127.0.0.1:3478'}];
- // create SIP stack
- oSipStack = new SIPml.Stack({
- realm: txtRealm,
- impi: txtPrivateIdentity,
- impu: txtPublicIdentity,
- password: kstychAppObject['user']['sipauth'],
- display_name: txtDisplayName,
- websocket_proxy_url: txtWebsocketServerUrl,
- outbound_proxy_url: txtSIPOutboundProxyUrl,
- ice_servers: iceServers,
- enable_rtcweb_breaker: false,
- events_listener: { events: '*', listener: onSipEventStack },
- enable_early_ims: true, // Must be true unless you're using a real IMS network
- enable_media_stream_cache: false,
- bandwidth: null, // could be redefined a session-level
- video_size: null, // could be redefined a session-level
- sip_headers: [
- { name: 'User-Agent', value: 'IM-client/Kstych' },
- { name: 'Organization', value: 'Kstych Pvt Ltd' }
- ]
- }
- );
- if (oSipStack.start() != 0) {
- txtRegStatus = '<b>Failed to start the SIP stack</b>';
- simpleNotification("error","topRight",txtRegStatus);
- }
- else {loggedin=1;return;}
- }
- catch (e) {
- txtRegStatus = "<b>2:" + e + "</b>";
- simpleNotification("error","topRight",txtRegStatus);
- }
- }
- // sends SIP REGISTER (expires=0) to logout
- function sipUnRegister(type)
- {
- if (oSipStack) {
- try{sipHangUp();}catch(e){console.log(e);}
- oSipStack.stop(); // shutdown all sessions
- }
- if(!type)
- {
- /* simpleNotification("warning","topRight","Retrying in 10 sec...");*/
- $("#phonetopbar").hide();
- setTimeout(sipRegister,10*1000); //Uncomment this line to resolve firefox logout issue. Commnted by YASHWANT on 10032017
- // document.location='/logout'; //Comment this line to resolve firefox logout issue. Commnted by YASHWANT on 10032017
- }
- else loggedin=0;
- }
- // makes a call (SIP INVITE)
- function sipCall(s_type,destination) {
- if(oSipStack)
- {
- if (oSipSessionCall) {
- txtCallStatus = '<i>Already in a Call...</i>';
- simpleNotification("warning","topRight",txtCallStatus);
- }
- else {
- if (!tsk_string_is_null_or_empty(destination)) {
- if(s_type == 'call-screenshare') {
- if(!SIPml.isScreenShareSupported()) {
- alert('Screen sharing not supported. Are you using chrome 26+?');
- return;
- }
- if (!location.protocol.match('https')){
- if (confirm("Screen sharing requires https://. Do you want to be redirected?")) {
- sipUnRegister();
- window.location = 'msie?httpsneeded';
- }
- return;
- }
- }
- btnCall = true;
- btnHangUp = false;
- // create call session
- oSipSessionCall = oSipStack.newSession(s_type, oConfigCall);
- // make call
- if (oSipSessionCall.call(destination) != 0) {
- oSipSessionCall = null;
- txtCallStatus = 'Failed to make call';
- simpleNotification("error","topRight",txtCallStatus);
- btnCall = false;
- btnHangUp = true;
- return;
- }
- }
- }
- }
- }
- function sipAnswer()
- {
- if(oSipStack){
- if (oSipSessionCall) {
- txtCallStatus = '<i>Connecting...</i>';
- //simpleNotification("warning","topRight",txtCallStatus);
- oSipSessionCall.accept(oConfigCall);
- }
- }
- if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'});
- }
- // Share entire desktop aor application using BFCP or WebRTC native implementation
- function sipShareScreen() {
- if (SIPml.getWebRtcType() === 'w4a') {
- // Sharing using BFCP -> requires an active session
- if (!oSipSessionCall) {
- txtCallStatus = '<i>No active session</i>';
- return;
- }
- if (oSipSessionCall.bfcpSharing) {
- if (oSipSessionCall.stopBfcpShare(oConfigCall) != 0) {
- txtCallStatus = 'Failed to stop BFCP share';
- }
- else {
- oSipSessionCall.bfcpSharing = false;
- }
- }
- else {
- oConfigCall.screencast_window_id = 0x00000000;
- if (oSipSessionCall.startBfcpShare(oConfigCall) != 0) {
- txtCallStatus = 'Failed to start BFCP share';
- }
- else {
- oSipSessionCall.bfcpSharing = true;
- }
- }
- }
- else {
- sipCall('call-screenshare',txtPhoneNumber);
- }
- }
- // transfers the call
- function sipTransfer(s_destination) {
- if (oSipSessionCall) {
- if (!tsk_string_is_null_or_empty(s_destination)) {
- btnTransfer.disabled = true;
- if (oSipSessionCall.transfer(s_destination) != 0) {
- txtCallStatus = '<i>Call transfer failed</i>';
- btnTransfer.disabled = false;
- return;
- }
- txtCallStatus = '<i>Transfering the call...</i>';
- }
- }
- }
- // holds or resumes the call
- function sipToggleHoldResume() {
- if (oSipSessionCall) {
- var i_ret;
- btnHoldResume.disabled = true;
- txtCallStatus = oSipSessionCall.bHeld ? '<i>Resuming the call...</i>' : '<i>Holding the call...</i>';
- i_ret = oSipSessionCall.bHeld ? oSipSessionCall.resume() : oSipSessionCall.hold();
- if (i_ret != 0) {
- txtCallStatus = '<i>Hold / Resume failed</i>';
- btnHoldResume.disabled = false;
- return;
- }
- }
- }
- // Mute or Unmute the call
- function sipToggleMute() {
- if (oSipSessionCall) {
- var i_ret;
- var bMute = !oSipSessionCall.bMute;
- txtCallStatus = bMute ? '<i>Mute the call...</i>' : '<i>Unmute the call...</i>';
- i_ret = oSipSessionCall.mute('audio'/*could be 'video'*/, bMute);
- if (i_ret != 0) {
- simpleNotification('error','topRight',"Mute / Unmute failed");
- return;
- }
- oSipSessionCall.bMute = bMute;
- var btnMute = bMute ? "Mute" : "Unmute";
- simpleNotification('success','topRight',"You are now ["+btnMute+"]");
- return bMute ? 0 : 1;
- }
- return 1;
- }
- // terminates the call (SIP BYE or CANCEL)
- function sipHangUp() {
- try
- {
- stopRingbackTone();
- stopRingTone();
- if (oSipSessionCall) {
- txtCallStatus = '<i>Terminating the call...</i>';
- oSipSessionCall.hangup({events_listener: { events: '*', listener: onSipEventSession }});
- //simpleNotification("warning","topRight","Call Terminated.");
- }
- //$("#phonetopbar").hide();
- }
- catch(e){console.log(e);}
- if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'});
- if(answergrowl)$.gritter.remove(answergrowl, {fade: true,speed: 'slow'});
- }
- function sipSendDTMF(c){
- if(oSipSessionCall && c){
- if(oSipSessionCall.dtmf(c) == 0){
- try { dtmfTone.play(); } catch(e){ }
- }
- }
- }
- function startRingTone() {
- try { ringtone.play(); }
- catch (e) { }
- }
- function stopRingTone() {
- try { ringtone.pause(); }
- catch (e) { }
- }
- function startRingbackTone() {
- try { ringbacktone.play(); }
- catch (e) { }
- }
- function stopRingbackTone() {
- try { ringbacktone.pause(); }
- catch (e) { }
- }
- function toggleFullScreen() {
- if (videoRemote.webkitSupportsFullscreen) {
- fullScreen(!videoRemote.webkitDisplayingFullscreen);
- }
- else {
- fullScreen(!bFullScreen);
- }
- }
- function fullScreen(b_fs) {
- return false;//TODO
- bFullScreen = b_fs;
- if (tsk_utils_have_webrtc4native() && bFullScreen && videoRemote.webkitSupportsFullscreen) {
- if (bFullScreen) {
- videoRemote.webkitEnterFullScreen();
- }
- else {
- videoRemote.webkitExitFullscreen();
- }
- }
- else {
- if (tsk_utils_have_webrtc4npapi()) {
- try { if(window.__o_display_remote) window.__o_display_remote.setFullScreen(b_fs); }
- catch (e) { /*divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen");*/ }
- }
- else {
- //divVideo.setAttribute("class", b_fs ? "full-screen" : "normal-screen");
- }
- }
- }
- function showNotifICall(s_number) {
- return false;//TODO
- // permission already asked when we registered
- if (window.webkitNotifications && window.webkitNotifications.checkPermission() == 0) {
- if (oNotifICall) {
- oNotifICall.cancel();
- }
- oNotifICall = window.webkitNotifications.createNotification('images/sipml-34x39.png', 'Incaming call', 'Incoming call from ' + s_number);
- oNotifICall.onclose = function () { oNotifICall = null; };
- oNotifICall.show();
- }
- }
- function uiOnConnectionEvent(b_connected, b_connecting) {
- // should be enum: connecting, connected, terminating, terminated
- //TODO
- btnRegister = b_connected || b_connecting;
- btnUnRegister = !b_connected && !b_connecting;
- btnCall = !(b_connected && tsk_utils_have_webrtc() && tsk_utils_have_stream());
- btnHangUp = !oSipSessionCall;
- }
- function uiVideoDisplayEvent(b_local, b_added) {
- return false;//TODO
- var o_elt_video = b_local ? videoLocal : videoRemote;
- if (b_added) {
- if (SIPml.isWebRtc4AllSupported()) {
- if (b_local) {
- if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "visible";
- if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "visible";
- //videoLocal.style.visibility = "visible";
- //viewLocalScreencast.style.visibility = "visible";
- //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = false;
- //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = false;
- }
- else {
- if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "visible";
- //videoRemote.style.visibility = "visible";
- //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = false;
- }
- }
- else {
- o_elt_video.style.opacity = 1;
- }
- uiVideoDisplayShowHide(true);
- }
- else {
- if (SIPml.isWebRtc4AllSupported()) {
- if (b_local) {
- if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().style.visibility = "hidden";
- if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().style.visibility = "hidden";
- //videoLocal.style.visibility = "hidden";
- //viewLocalScreencast.style.visibility = "hidden";
- //if (WebRtc4all_GetDisplayLocal()) WebRtc4all_GetDisplayLocal().hidden = true;
- //if (WebRtc4all_GetDisplayLocalScreencast()) WebRtc4all_GetDisplayLocalScreencast().hidden = true;
- }
- else {
- if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().style.visibility = "hidden";
- //videoRemote.style.visibility = "hidden";
- //if (WebRtc4all_GetDisplayRemote()) WebRtc4all_GetDisplayRemote().hidden = true;
- }
- }
- else{
- o_elt_video.style.opacity = 0;
- }
- fullScreen(false);
- }
- }
- function uiVideoDisplayShowHide(b_show) {
- //TODO
- if (b_show) {
- }
- else {
- }
- btnFullScreen.disabled = !b_show;
- }
- function uiCallTerminated(s_description){
- btnCall = false;
- btnHangUp = true;
- oSipSessionCall = null;
- stopRingbackTone();
- stopRingTone();
- txtCallStatus = "<i>" + s_description + "</i>";
- uiVideoDisplayShowHide(false);
- //divCallOptions.style.opacity = 0;
- if (oNotifICall) {
- oNotifICall.cancel();
- oNotifICall = null;
- }
- uiVideoDisplayEvent(true, false);
- uiVideoDisplayEvent(false, false);
- setTimeout(function () { if (!oSipSessionCall) txtCallStatus = ''; }, 2500);
- if(hangupgrowl)$.gritter.remove(hangupgrowl, {fade: true,speed: 'slow'});
- }
- // Callback function for SIP Stacks
- function onSipEventStack(e /*SIPml.Stack.Event*/) {
- tsk_utils_log_info('==stack event = ' + e.type);
- switch (e.type) {
- case 'started':
- {
- // catch exception for IE (DOM not ready)
- try {
- // LogIn (REGISTER) as soon as the stack finish starting
- oSipSessionRegister = this.newSession('register', {
- expires: 200,
- events_listener: { events: '*', listener: onSipEventSession },
- sip_caps: [
- { name: '+g.oma.sip-im', value: null },
- { name: '+audio', value: null },
- { name: 'language', value: '\"en,fr\"' }
- ]
- });
- oSipSessionRegister.register();
- }
- catch (e) {
- txtRegStatus = txtRegStatus = "<b>1:" + e + "</b>";
- simpleNotification("success","topRight",txtRegStatus);
- btnRegister = false;
- }
- break;
- }
- case 'stopping': case 'stopped': case 'failed_to_start': case 'failed_to_stop':
- {
- var bFailure = (e.type == 'failed_to_start') || (e.type == 'failed_to_stop');
- oSipStack = null;
- oSipSessionRegister = null;
- oSipSessionCall = null;
- uiOnConnectionEvent(false, false);
- stopRingbackTone();
- stopRingTone();
- uiVideoDisplayShowHide(false);
- //divCallOptions.style.opacity = 0;
- txtCallStatus = '';
- if(loggedin)
- {
- txtRegStatus = bFailure ? "<i>Disconnected: <b>" + e.description + "</b></i>" : "<i>Disconnected</i>";
- //simpleNotification("warning","topRight",txtRegStatus+", Retrying in 10 sec...");
- //setTimeout(sipRegister,10*1000);//TODO dont retry too many times, idleapp instead
- //document.location='/logout'; //Comment this line to resolve firefox logout issue. Commnted by YASHWANT on 10032017
- }
- else
- {
- //if(e.type=='stopped')doLogout(1); //Comment this line to resolve firefox logout issue. Commnted by YASHWANT on 10032017
- }
- break;
- }
- case 'i_new_call':
- {
- if (oSipSessionCall) {
- // do not accept the incoming call if we're already 'in call'
- e.newSession.hangup(); // comment this line for multi-line support
- }
- else {
- oSipSessionCall = e.newSession;
- btnCall = 'Answer';
- btnHangUp = 'Reject';
- btnCall = false;
- btnHangUp = false;
- var sRemoteNumber = (oSipSessionCall.getRemoteFriendlyName() || 'unknown');
- if(sRemoteNumber=='1000'+kstychAppObject['user']['sipid'])
- {
- //auto answer if own conf
- var dialerConnection=kGetDData("D","connection");
- dialerConnection['connected']=1;
- updateDialerState("dialer","connection",dialerConnection);
- sipAnswer();
- }
- else
- {
- startRingTone();
- txtCallStatus = "<i><a href=# onclick='sipAnswer();return false;'>Incoming call Click Here To Answer</a></i> from [<b>" + sRemoteNumber + "</b>]";
- //showNotifICall(sRemoteNumber);
- answergrowl=growlSNotify("Incoming Call",txtCallStatus,"top-right");
- hangupgrowl=growlSNotify("Incoming Call","<a href=# onclick='sipHangUp();return false;' style='color:white'>Click here to hangup</a>","top-right");
- }
- //showNotifICall(sRemoteNumber);
- }
- break;
- }
- case 'm_permission_requested':
- {
- //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner-red');
- break;
- }
- case 'm_permission_accepted':
- case 'm_permission_refused':
- {
- //document.getElementById('divNavbarInner').setAttribute('class', 'navbar-inner');
- if(e.type == 'm_permission_refused'){
- uiCallTerminated('Media stream permission denied');
- }
- break;
- }
- case 'starting': default: break;
- }
- };
- // Callback function for SIP sessions (INVITE, REGISTER, MESSAGE...)
- function onSipEventSession(e /* SIPml.Session.Event */) {
- tsk_utils_log_info('==session event = ' + e.type);
- switch (e.type) {
- case 'connecting': case 'connected':
- {
- var bConnected = (e.type == 'connected');
- if (e.session == oSipSessionRegister) {
- uiOnConnectionEvent(bConnected, !bConnected);
- txtRegStatus = "<i>" + e.description + "</i>";
- if(bConnected){/*simpleNotification("success","topRight","Connected");*//*$("#phonetopbar").show();*/kDialerConnected();}
- }
- else if (e.session == oSipSessionCall) {
- btnHangUp = 'HangUp';
- btnCall = true;
- btnHangUp = false;
- btnTransfer = false;
- if (bConnected) {
- stopRingbackTone();
- stopRingTone();
- if (oNotifICall) {
- oNotifICall.cancel();
- oNotifICall = null;
- }
- }
- txtCallStatus = "<i>" + e.description + "</i>";
- //simpleNotification("success","topRight",txtCallStatus);
- //divCallOptions.style.opacity = bConnected ? 1 : 0;
- if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback
- uiVideoDisplayEvent(true, true);
- uiVideoDisplayEvent(false, true);
- }
- }
- break;
- } // 'connecting' | 'connected'
- case 'terminating': case 'terminated':
- {
- if (e.session == oSipSessionRegister) {
- uiOnConnectionEvent(false, false);
- oSipSessionCall = null;
- oSipSessionRegister = null;
- txtRegStatus = "<i>" + e.description + "</i>";
- //simpleNotification("warning","topRight",txtRegStatus);
- }
- else if (e.session == oSipSessionCall) {
- uiCallTerminated(e.description);
- }
- break;
- } // 'terminating' | 'terminated'
- case 'm_stream_video_local_added':
- {
- if (e.session == oSipSessionCall) {
- uiVideoDisplayEvent(true, true);
- }
- break;
- }
- case 'm_stream_video_local_removed':
- {
- if (e.session == oSipSessionCall) {
- uiVideoDisplayEvent(true, false);
- }
- break;
- }
- case 'm_stream_video_remote_added':
- {
- if (e.session == oSipSessionCall) {
- uiVideoDisplayEvent(false, true);
- }
- break;
- }
- case 'm_stream_video_remote_removed':
- {
- if (e.session == oSipSessionCall) {
- uiVideoDisplayEvent(false, false);
- }
- break;
- }
- case 'm_stream_audio_local_added':
- case 'm_stream_audio_local_removed':
- case 'm_stream_audio_remote_added':
- case 'm_stream_audio_remote_removed':
- {
- break;
- }
- case 'i_ect_new_call':
- {
- oSipSessionTransferCall = e.session;
- break;
- }
- case 'i_ao_request':
- {
- if(e.session == oSipSessionCall){
- var iSipResponseCode = e.getSipResponseCode();
- if (iSipResponseCode == 180 || iSipResponseCode == 183) {
- startRingbackTone();
- txtCallStatus = '<i>Remote ringing...</i>';
- //simpleNotification("warning","topRight",txtCallStatus);
- }
- }
- break;
- }
- case 'm_early_media':
- {
- if(e.session == oSipSessionCall){
- stopRingbackTone();
- stopRingTone();
- txtCallStatus = '<i>Early media started</i>';
- //simpleNotification("warning","topRight",txtCallStatus);
- }
- break;
- }
- case 'm_local_hold_ok':
- {
- if(e.session == oSipSessionCall){
- if (oSipSessionCall.bTransfering) {
- oSipSessionCall.bTransfering = false;
- // this.AVSession.TransferCall(this.transferUri);
- }
- btnHoldResume = false;
- txtCallStatus = '<i>Call placed on hold</i>';
- oSipSessionCall.bHeld = true;
- //simpleNotification("success","topRight",txtCallStatus);
- }
- break;
- }
- case 'm_local_hold_nok':
- {
- if(e.session == oSipSessionCall){
- oSipSessionCall.bTransfering = false;
- btnHoldResume = false;
- txtCallStatus = '<i>Failed to place remote party on hold</i>';
- //simpleNotification("error","topRight",txtCallStatus);
- }
- break;
- }
- case 'm_local_resume_ok':
- {
- if(e.session == oSipSessionCall){
- oSipSessionCall.bTransfering = false;
- btnHoldResume = false;
- txtCallStatus = '<i>Call taken off hold</i>';
- oSipSessionCall.bHeld = false;
- //simpleNotification("warning","topRight",txtCallStatus);
- if (SIPml.isWebRtc4AllSupported()) { // IE don't provide stream callback yet
- uiVideoDisplayEvent(true, true);
- uiVideoDisplayEvent(false, true);
- }
- }
- break;
- }
- case 'm_local_resume_nok':
- {
- if(e.session == oSipSessionCall){
- oSipSessionCall.bTransfering = false;
- btnHoldResume = false;
- txtCallStatus = '<i>Failed to unhold call</i>';
- //simpleNotification("error","topRight",txtCallStatus);
- }
- break;
- }
- case 'm_remote_hold':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus = '<i>Placed on hold by remote party</i>';
- //simpleNotification("warning","topRight",txtCallStatus);
- }
- break;
- }
- case 'm_remote_resume':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus = '<i>Taken off hold by remote party</i>';
- //simpleNotification("warning","topRight",txtCallStatus);
- }
- break;
- }
- case 'm_bfcp_info':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus.innerHTML = 'BFCP Info: <i>'+ e.description +'</i>';
- }
- break;
- }
- case 'o_ect_trying':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus = '<i>Call transfer in progress...</i>';
- //simpleNotification("warning","topRight",txtCallStatus);
- }
- break;
- }
- case 'o_ect_accepted':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus = '<i>Call transfer accepted</i>';
- //simpleNotification("success","topRight",txtCallStatus);
- }
- break;
- }
- case 'o_ect_completed':
- case 'i_ect_completed':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus = '<i>Call transfer completed</i>';
- //simpleNotification("success","topRight",txtCallStatus);
- btnTransfer = false;
- if (oSipSessionTransferCall) {
- oSipSessionCall = oSipSessionTransferCall;
- }
- oSipSessionTransferCall = null;
- }
- break;
- }
- case 'o_ect_failed':
- case 'i_ect_failed':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus = '<i>Call transfer failed</i>';
- //simpleNotification("error","topRight",txtCallStatus);
- btnTransfer = false;
- }
- break;
- }
- case 'o_ect_notify':
- case 'i_ect_notify':
- {
- if(e.session == oSipSessionCall){
- txtCallStatus = "<i>Call Transfer: <b>" + e.getSipResponseCode() + " " + e.description + "</b></i>";
- //simpleNotification("success","topRight",txtCallStatus);
- if (e.getSipResponseCode() >= 300) {
- if (oSipSessionCall.bHeld) {
- oSipSessionCall.resume();
- }
- btnTransfer = false;
- }
- }
- break;
- }
- case 'i_ect_requested':
- {
- if(e.session == oSipSessionCall){
- var s_message = "Do you accept call transfer to [" + e.getTransferDestinationFriendlyName() + "]?";//FIXME
- if (confirm(s_message)) {
- txtCallStatus = "<i>Call transfer in progress...</i>";
- //simpleNotification("warning","topRight",txtCallStatus);
- oSipSessionCall.acceptTransfer();
- break;
- }
- oSipSessionCall.rejectTransfer();
- }
- break;
- }
- }
- }
- function dialerSipMsg(omsg)
- {
- try
- {
- if(omsg.ao_headers[6].s_name=='kstych-data')
- {
- var vparts=omsg.ao_headers[6].s_value.split("|");
- vparts[1]=atob(vparts[1]);
- vparts[2]=atob(vparts[2]);
- if(vparts[0]=="chat")incomingChat(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="presence")incomingPresense(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="wallreload")incomingwallReload(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="liveconf")incomingLiveconf(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="notify")incomingNotification(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="popupalert")incomingPopupAlert(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="incomingCall")incomingCall(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="dialerUI")dialerUIUpdate(vparts[1],vparts[2],vparts[3]);
- else if(vparts[0]=="adminCommand")adminCommand(vparts[1],vparts[2],vparts[3]);
- }
- //if(omsg.ao_headers.)
- //window.console.log(omsg.ao_headers[6]);
- }
- catch(e){}
- }
Add Comment
Please, Sign In to add comment