/*
 InUC Web Client v8.1.8 by NEC Platforms,Ltd.
*/
var $jscomp={scope:{},checkStringArgs:function(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""}};
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};
$jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(a,c){var b=$jscomp.checkStringArgs(this,a,"startsWith");a+="";for(var e=b.length,f=a.length,h=Math.max(0,Math.min(c|0,b.length)),g=0;g<f&&h<e;)if(b[h++]!=a[g++])return!1;return g>=f}},"es6-impl","es3");
var appVer="Version 8.1.8",Server=void 0,SrvURL,SrvAddr,socketReady=!1,httpsPort="443",httpPort="80",isFirstLogin=!0,SessionID="",webPt="0",sowsPt="0",sipExt="",sipPW="",voipIp="172.16.0.10",keepAliveTimer=null,searchTimer=null,loginTimer=null,logoutTimer=null,getdataTimer=null,setdataTimer=null,getstatusTimer=null,bupTimer=null,telregTimer=null,scResTimer=null,scDiscTimer=null,sc_type="sc_loading",user_id="",user_pw="",user_phone=0,self_id=-1,tmp_mid=1,date_fmt=0,entKeyOp=0,home_sort=0,home_index=
!1,no_closedlg_flg=!0,in_chat=!1,is_bkgrnd=!1,reconn_grd_flg=!1,im_ime_enable=!1,im_ime_wait=!1,CR=String.fromCharCode(13),LF=String.fromCharCode(10),CRLF=CR+LF,CLIENT_MAX=256,CFG_JP={ST_UNKNOWN:0,DEFAULT_STATUS:5,CONF_MAX:4,CONF_MEMBER_MAX:8,statusTbl:{0:["pre_jp_offline","fa fa-times-circle","gray",131,!1],1:["pre_jp_online","fa fa-check-circle","green",1,!1],2:["pre_jp_dnd","fa fa-ban","red",65,!0],3:["pre_jp_away","fa fa-clock-o fa-flip-horizontal","orange",33,!1],4:["pre_jp_out","fa fa-sign-out",
"red",66,!0],5:["pre_jp_online","fa fa-check-square","green",2,!0],6:["pre_jp_away","fa fa-clock-o fa-flip-horizontal","gray",129,!1],7:["pre_jp_out","fa fa-sign-out","gray",130,!1]}},CFG_OTH={ST_UNKNOWN:10,DEFAULT_STATUS:1,CONF_MAX:4,CONF_MEMBER_MAX:8,statusTbl:{0:["pre_oth_none","fa fa-question","green",130,!1],1:["pre_oth_office","fa fa-desktop","green",1,!0],2:["pre_oth_vaca","fa fa-camera-retro","red",65,!0],3:["pre_oth_trvl","fa fa-plane","red",66,!0],4:["pre_oth_meet","fa fa-users","red",67,
!0],5:["pre_oth_lunch","fa fa-cutlery","red",68,!0],6:["pre_oth_sick","fa fa-ambulance","red",69,!0],7:["pre_oth_home","fa fa-home","red",70,!0],8:["pre_oth_out","fa fa-refresh","red",71,!0],9:["pre_oth_unav","fa fa-ban","red",72,!0],10:["pre_oth_unknown","fa fa-question","green",129,!1],65:["pre_oth_office","fa fa-desktop","orange",33,!1]}},SYS_TYPE_DEFAULT=0,SYS_TYPE_SL2100=1,TEL_ST_IDLE=0,TEL_ST_BUSY=1,TEL_ST_CFW=2,TEL_ST_DND=3,TS_IDLE=0,TS_INUSE=1,TS_ERROR=2,TS_NONE=3,CS_CFW_SRAM=9,CS_CFW_2406=
10,CS_CFW_2409=11,CS_DND_EXTERNAL=12,CS_DND_INTERCOM=13,CS_DND_ALL=14,CS_DND_CFW=15,SORT_TYPE_NAME=0,SORT_TYPE_GROUP=1,SORT_TYPE_STATUS=2,SORT_TYPE_INDEX=3,SORT_TYPE_IMLAST=4,SORT_TYPE_CALLLAST=5,LIST_TYPE_CONTACT=0,LIST_TYPE_TELBOOK=1,LIST_TYPE_INVCONF=2,LIST_TYPE_BRDMAIL=3,LIST_TYPE_BRDMSG=4,LIST_TYPE_COMSPD=5,LIST_TYPE_LOGIM=6,LIST_TYPE_LOGCALL=7,DATA_TYPE_USER=1,DATA_TYPE_SPD=2,DATA_TYPE_FKEY=3,DATA_TYPE_TACS=4,DATA_TYPE_HIST=5,DATA_TYPE_CPRE=6,DATA_TYPE_CFG=7,DATA_TYPE_SC=8,DATA_TYPE_LANG=9,
ACT_ADD_BUDDY=1,ACT_DEL_BUDDY=2,STATUS_TYPE_CFW=1,STATUS_TYPE_DND=2,STATUS_TYPE_MDS=3,ALERT_IM_NEW=1,ALERT_CALL_NEW=2,CHAT_TYPE_S=0,CHAT_TYPE_R=1,CHAT_ST_UNSENT=0,CHAT_ST_INVITING=1,CHAT_ST_SENDING=2,CHAT_ST_PENDING=3,CHAT_ST_SUCCESS=4,CHAT_ST_OPENED=5,CHAT_ST_ERROR=-1,CHAT_ST_RESENT=-2,CHAT_ST_HIDDEN=-3,CHAT_LOG_MAX=100,CHAT_SRVPEND_MAX_SV=100,CHAT_SRVPEND_MAX_SL=30,CHAT_SRVPEND_MAX=CHAT_SRVPEND_MAX_SV,CHAT_INPUT_MAX=512,UCSIM_INVITE="{3A16057C-50B0-4D31-8A7C-8D5E19D0A3DA}",UCSIM_END="{EB5413D6-B0D3-4A5B-A002-DC6649E9FE66}",
UCSIM_ACTIVITY="{B247B160-A4B8-422F-B212-1567AC8BB804}",UCSIM_IDLE="{6A549DB2-BF10-4775-B713-884C39268B4D}",UCSIM_ACCEPT="Accept",UCSIM_REJECT="Reject",IM_STATUS_DISC=0,IM_STATUS_WAIT=1,IM_STATUS_CONN=2,emojiArr="warai yorokobi niyari onegai dogeza ase yabai shobon naki uwaan muka kora bikkuri hatena hirameki akanbe kuchibue waru good boo ryoukai bye v-sign hakushu akushu arigatou gimon ikari kanashii komaru odoroki onegai2 owabi ok uresii".split(" "),COM_SPD_MAX=1E4,SPD_DISP_MAX=250,dlgBtnList=[],
D_BTN_LOGIN=0,D_BTN_STDALN=1,D_BTN_BDYCTRL=2,D_BTN_BDYADD=3,D_BTN_BDYRMV=4,D_BTN_CNFIM=5,D_BTN_CONNECT=6,D_BTN_UPDT_USR=7,D_BTN_UPDT_SPD=8,D_BTN_SAVE_IM=9,D_BTN_LOGOUT=10,D_BTN_OVRRIDE=11,D_BTN_SIP_RETRY=12,D_BTN_VM_DEL=13,CALL_ST_IDLE=0,CALL_ST_RINGBK=1,CALL_ST_INCOM=2,CALL_ST_SPEAK=3,CALL_ST_HOLD=4,CALL_ST_DIAL=5,CALL_ST_BUSY=6,CALL_ST_CHOLD=7,CALL_ST_CSPEAK=8,CALL_ST_INCONF=9,CALL_ST_SRVCODE=10,CALL_ST_HELD=11,CALL_ST_183=13,FKEY_COL_NONE=0,FKEY_COL_RED=1,FKEY_COL_GREEN=2,FKEY_COL_ORANGE=3,FKEY_BLINK_OFF=
0,FKEY_BLINK_SLOW=1,FKEY_BLINK_FAST=2,MODE_NONE=0,MODE_CTI=1,MODE_SMARTDEV=2,MODE_SIP=3,MODE_ST500=4,TERM_TYPE_UNKNOWN=0,TERM_TYPE_KST=1,TERM_TYPE_GT890=2,INPUT_DIAL_MAX=32,SACS_NONE=-1,SACS_DEFAULT=0,SACS_CFW=1,SACS_DND=2,SACS_MDS=3,SRVCODE_CFW=1,SRVCODE_DND=2,SRVCODE_MDS=3,SRVCODE_VMACS=4,SRVCODE_ON=0,SRVCODE_OFF=1,SRVCODE_CFW_NONE=-1,SRVCODE_CFW_ALL=0,SRVCODE_CFW_BR=1,SRVCODE_CFW_BS=2,SRVCODE_CFW_BNA=3,SRVCODE_CFW_NA=4,SRVCODE_DND_NONE=-1,SRVCODE_DND_ALL=0,SRVCODE_DND_EXT=1,SRVCODE_DND_INT=2,SRVCODE_DND_TRNS=
3,SRVCODE_MDS_NONE=-1,SRVCODE_MDS_ON=0,SRVCODE_MDS_OFF=1,SCFLAG_OFF=0,SCFLAG_ON_HIDDEN=1,SCFLAG_ON_VMACS=2,CHIST_MAX=1E3,CHIST_TYPE_ICM=0,CHIST_TYPE_OTG=1,CHIST_TYPE_HIDDEN=2,CHIST_STBIT_ABNDON=0,CHIST_STBIT_CHECKED=1,CHIST_STBIT_INTER=2,CHIST_STBIT_OTHANS=3,CHIST_STBIT_BUSY=4,CHIST_STBIT_NOCLI=5,CALL_MODE_INT=0,CALL_MODE_EXT=1,CALL_CONF_MAX=32,NOTIF_TYPE_ALL=0,NOTIF_TYPE_IM=1,NOTIF_TYPE_CALL=2,SIP_NOT_REGISTERED=0,SIP_REGISTERING=1,SIP_REGISTERED=2,TEL_SUBMIT_CALL=0,TEL_SUBMIT_DTMF=1,TEL_SUBMIT_TRANS=
2,EXPAND_NONE=0,EXPAND_SELF=1,EXPAND_OTHER=2,TYPE_VOICE_CALL=0,TYPE_VIDEO_CALL=1,TRACK_COND_KEEP=0,TRACK_COND_CHG_ON=1,TRACK_COND_CHG_OFF=2,CFG_NONE=0,CFG_MEDIA_DEVICE=1,VQ_LOW=1,VQ_MID=2,VQ_HIGH=3,DIAL_MOD_TRKACS=0,DIAL_MOD_SHARP=1,VMACS_ST_NONE=0,VMACS_ST_WT_ACS=1,VMACS_ST_START=2,VMACS_ST_SRV_ANA=3,VMACS_ST_SRV_WT=4,VMACS_ST_LIN_ANA=5,VMACS_ST_LIN_PLY=6,VMACS_ST_LIN_OPT_ANA=7,VMACS_ST_LIN_OPT_WT=8,VMACS_ST_DISC=9,VMACS_ST_UNKONWN=255,VMACS_OPR_SKIP=0,VMACS_OPR_BACK=1,VMACS_OPR_RPLY=2,VMACS_OPR_NEXT=
3,VMACS_OPR_DEL=4,VMACS_OPR_CLBK=5,VMACS_DLG_NONE=0,VMACS_DLG_LOADING=1,VMACS_DLG_PLAYING=2,VMACS_DLG_SRVCODE=3,VMACS_DLG_UNKNOWN=4,MOBCALL_IDLE=0,MOBCALL_IDLE_PUSH=1,MOBCALL_ST500=2,MOBCALL_OTHER=3,debuglog=0,l={log:function(a){0<debuglog&&console.log(a)},dir:function(a){1<debuglog&&console.dir(a)},warn:function(a){console.warn(a)},error:function(a){0<=debuglog&&console.error(a)}},ConstErrDetail="",echo_count=0;
function getDateTime(){var a=new Date;return">>> "+(a.getMonth()+1)+"/"+a.getDate()+" "+a.getHours()+":"+a.getMinutes()+":"+a.getSeconds()+" ["+echo_count+"]"}ko.bindingHandlers.fadeVisible={update:function(a,b){var c=b();1==ko.unwrap(c)?$(a).fadeIn():$(a).fadeOut()}};
$(document).ready(function(){String.prototype.startsWith||(String.prototype.startsWith=function(a,c){return this.substr(c||0,a.length)===a});try{navigator.userAgent.match(/Trident\/7/g)?(l.log("IE11"),isIE=!0):chrome&&(navigator.userAgent.match(/(iPad|iPhone|iPod|Edge\/)/g)?l.log("iOS or Edge(EdgeHtml)!"):(l.log("chrome or Edge(Chromium)"),viewModel.check_qvl(!0)))}catch(b){l.dir(b)}SrvAddr=location.hostname;SrvURL=location.protocol+"//"+SrvAddr;location.port&&(SrvURL+=":"+location.port);SrvURL=SrvURL.replace("http",
"ws");SrvURL+="/uc/ws";l.log("SrvURL="+SrvURL);Server=new FancyWebSocket(SrvURL);Server.bind("open",function(){onOpened()});Server.bind("close",function(a){onClose(a)});Server.bind("message",function(a){onMessage(a)});koInitialize();checkSipPhoneSupported();setLoginOption();setLangage();adjustStyleSheet();updtDocTitle();$(".cancelEnter").on("keydown",function(a){if(13==a.which)return $(this).blur(),!1}).on("keydown keyup keypress change input",function(){var a=$(this);text=a.val();new_text=text.replace(/\n.*/g,
"");new_text!=text&&a.val(new_text)});$(".cancelTab").on("keydown",function(a){}).on("keydown keyup keypress change input",function(){var a=$(this);text=a.val();new_text=text.replace(/\t/g," ");new_text!=text&&a.val(new_text)});$(".cancelSpace").on("keydown",function(a){if(121==a.which)return!1}).on("keydown keyup keypress change input",function(){var a=$(this);text=a.val();new_text=text.replace(/\s/g,"");new_text!=text&&a.val(new_text)});$(".onlyDial").on("keydown keyup keypress change input",function(){var a=
$(this);text=a.val();new_text=text.replace(/([^0-9\*\#])/g,"");new_text!=text&&a.val(new_text)});var a=!1;$("#search_input").on("compositionstart",function(){l.log("compositionstart");a=!0}).on("compositionend",function(){l.log("compositionend");a=!1}).on("keydown keyup keypress change input",function(){var b=this;clearTimeout(searchTimer);searchTimer=setTimeout(function(){$(b).val()?viewModel.searching(!0):viewModel.searching(!1);var c=function(){viewModel.buddyCtrlFlg()&&($(".tbk_name").css("left",
"25px"),$(".tbk_idx_str").css("left","25px"))};l.log("input - composition_flg:"+a);a||sortData(c)},400)});$("#hdr_msg_ta").focus(function(){$("#hdr_msg_ipterr_wrap").css("display","none")});$("#hdr_msg_ta").focusout(function(){new_msg=$(this).val();new_msg!==viewModel.myMsg()&&(l.log(new_msg.getByte()),255>=new_msg.getByte()?viewModel.isStandAlone()?(openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]),$(this).val(viewModel.myMsg())):($("#hdr_msg_ipterr_wrap").css("display","none"),viewModel.myMsg(new_msg),
l.log("focus out:"+new_msg),sendEvtPresenceChange()):$("#hdr_msg_ipterr_wrap").css("display","block"))});$("#hdr_msg_ta").on("keydown keyup keypress change input",function(a){new_msg=$(this).val();255>=new_msg.getByte()?$(this).removeClass("hdr_msg_ta_err"):$(this).addClass("hdr_msg_ta_err")});$("#cnfcr_iptid").on("keydown keyup keypress change input",function(a){viewModel.ipt_confid(this.value);checkConfidErr()});$("#tel_input").on("compositionstart",function(){l.log("compositionstart");a=!0}).on("keydown keyup keypress change input compositionend",
function(b){var c=this.value;"compositionend"==b.type&&(l.log("compositionend"),a=!1);a||(c!==deleteSpace(c.toHankakuDial())&&(c=deleteSpace(c.toHankakuDial()),$(this).val(c)),0==viewModel.predictList().length&&0==viewModel.ipt_dial_name().length&&0<viewModel.ipt_dial().length&&c.startsWith(viewModel.ipt_dial())?(searchTimer&&(clearTimeout(searchTimer),searchTimer=null),viewModel.ipt_dial(c)):(clearTimeout(searchTimer),searchTimer=setTimeout(function(a,b){viewModel.ipt_dial(a);viewModel.srch_dial(a);
"keydown"==b.type&&13==b.which&&submitDialer(!1)},400,c,b)))}).focus(function(){viewModel.ipt_dial_focused(!0)}).focusout(function(){viewModel.ipt_dial_focused(!1)});$(".barrageBlock").on("click",function(a){$(this).hasClass("block_clickevt")||($(".barrageBlock").addClass("block_clickevt"),setTimeout(function(){$(".barrageBlock").removeClass("block_clickevt")},1E3))});$("#im_ta_1").on("keydown keyup keypress change input",function(){imOpened(viewModel.targetUsr())});$("#im_ta_1").on("compositionstart",
function(){l.log("compositionstart");im_ime_enable=!0}).on("compositionend",function(a){"compositionend"==a.type&&(l.log("compositionend"),im_ime_enable=!1,im_ime_wait&&(sendChat(viewModel.targetUsr(),this.value),im_ime_wait=!1))});$(window).on("beforeunload",function(){if("sc_presence"==sc_type)return langTbl.d_pre_8});$(window).on("unload",function(){in_chat&&imOpened(viewModel.targetUsr());sendImEndToAll();deleteSipPhone();keepAliveTimer&&clearTimeout(keepAliveTimer);searchTimer&&clearTimeout(searchTimer);
loginTimer&&clearTimeout(loginTimer);logoutTimer&&clearTimeout(logoutTimer);getdataTimer&&clearTimeout(getdataTimer);getstatusTimer&&clearTimeout(getstatusTimer);bupTimer&&clearTimeout(bupTimer);telregTimer&&clearTimeout(telregTimer);for(var a=viewModel.comSpdDialList.removeAll(),c=0,d=a.length;c<d;c++)a[c]=null;for(c in chatRstrArr)chatRstrArr[c]=null;chatRstrArr.length=0;deleteLogs();a=viewModel.statusList.removeAll();c=0;for(d=a.length;c<d;c++)a[c]=null;destroyDialog();a=viewModel.fkeyList.removeAll();
c=0;for(d=a.length;c<d;c++)a[c]=null;deleteCallList();a=viewModel.callHistList.removeAll();c=0;for(d=a.length;c<d;c++)a[c]=null;a=viewModel.sacsList.removeAll();c=0;for(d=a.length;c<d;c++)a[c]=null;deleteDsktpNotificationAll(NOTIF_TYPE_ALL);clrCallStatusReq();c=0;for(d=memberList.length;c<d;c++)memberList[c].imSubWin&&(memberList[c].imSubWin.close(),memberList[c].imSubWin=null),memberList[c]=null;null_status=null_spd=null_chat=null_user=Server=null;ko.cleanNode(document);$(window).off();VVM=viewModel=
null});"Notification"in window||l.log("This browser does not support Notification.");$(window).on("orientationchange resize",function(a){adjustStyleSheet();adjustImWindow();adjustPageBodySize()});try{navigator.mediaDevices.ondevicechange=function(a){updtVideoConstraint()}}catch(b){}DispFirstPage()});
function startAuth(){var a=document.getElementById("inputUserId");""!==a.value&&(user_id=a.value,a.value="",a=document.getElementById("inputUserPw"),user_pw=a.value,a.value="",a=document.getElementById("inputTelMode"),l.log("login: "+a.value),user_phone=parseInt(a.value,10),a.selectedIndex=0,setLoadingMotion(function(){serverConnect()}),initToneManager())}
function serverConnect(){no_closedlg_flg=!1;viewModel.isConnecting(!0);keepAliveTimer&&(clearTimeout(keepAliveTimer),keepAliveTimer=null);keepAliveTimer=user_phone!=MODE_ST500?setTimeout("Server.disconnect()",6E4):setTimeout("Server.disconnect()",36E4);Server.connect()}function reconnect(){openDialog(langTbl.d_pre_4,dlgBtnList[D_BTN_CONNECT])}
function onOpened(){l.log(getDateTime()+"*** socket opened ***");socketReady=!0;viewModel.isConnecting(!1);reconn_grd_flg=!1;closeDialog();keepAliveTimer&&(clearTimeout(keepAliveTimer),keepAliveTimer=null);keepAliveTimer=user_phone!=MODE_ST500?setTimeout("Server.disconnect()",6E4):setTimeout("Server.disconnect()",36E4);viewModel.isStandAlone(!1);if(isFirstLogin)initUserData(function(){initSpdList(function(){setLoadingMotion(sendEvtLogin)})});else{for(var a=0,b=memberList.length;a<b;a++){var c=memberList[a];
c.imSubWin&&(c.imSubWin.close(),c.imSubWin=null)}sendEvtLogin()}}
function onClose(a){if(Server.conn!==a)l.log(getDateTime()+"## ignore old socket closed");else{l.log(getDateTime()+"onClose()");if(!socketReady&&viewModel.isConnecting())l.log(getDateTime()+"*** socket open failure ***"),viewModel.isConnecting(!1),keepAliveTimer&&(clearTimeout(keepAliveTimer),keepAliveTimer=null),no_closedlg_flg||("sc_presence"==sc_type?(telregTimer&&(clearTimeout(telregTimer),telregTimer=null),openDialog(langTbl.d_error_5+"</br>"+langTbl.d_pre_4,dlgBtnList[D_BTN_STDALN]),viewModel.phone_mode()===
MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList())):(telregTimer&&(clearTimeout(telregTimer),telregTimer=null),openDialog(langTbl.d_error_5,dlgBtnList[D_BTN_LOGIN])),viewModel.isStandAlone(!0));else{l.log(getDateTime()+"*** socket closed ***");try{viewModel.phone_mode()==MODE_ST500&&(iOS_Device()?webkit.messageHandlers.notifyLoginStateOfInUC.postMessage("0"):androidJavascriptInterface.notifyLoginStateOfInUC("0"))}catch(b){l.log("Fail to Callback notifyLoginStateOfInUC(0);")}socketReady=
!1;self_id=-1;SessionID="";keepAliveTimer&&(clearTimeout(keepAliveTimer),keepAliveTimer=null);no_closedlg_flg||("sc_presence"==sc_type?(loginTimer&&(clearTimeout(loginTimer),loginTimer=null,clrLoadingMotion()),telregTimer&&(clearTimeout(telregTimer),telregTimer=null),logoutTimer&&(clearTimeout(logoutTimer),logoutTimer=null,clrLoadingMotion()),getdataTimer&&(clearTimeout(getdataTimer),getdataTimer=null,clrLoadingOnList()),getstatusTimer&&(clearTimeout(getstatusTimer),getstatusTimer=null,clrLoadingOnList()),
bupTimer&&(clearTimeout(bupTimer),bupTimer=null),viewModel.phone_mode()!=MODE_ST500&&openDialog(langTbl.d_error_2+"</br>"+langTbl.d_pre_4,dlgBtnList[D_BTN_STDALN]),viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList()),$("#hdr_msg_ta").val(viewModel.myMsg()),$("#hdr_msg_ta").blur()):"sc_login"==sc_type?(loginTimer?(clearTimeout(loginTimer),loginTimer=null,openDialog(langTbl.d_error_5,dlgBtnList[D_BTN_LOGIN])):openDialog(langTbl.d_error_2,dlgBtnList[D_BTN_LOGIN]),
telregTimer&&(clearTimeout(telregTimer),telregTimer=null)):openDialog(langTbl.d_error_2,dlgBtnList[D_BTN_LOGIN]),viewModel.isStandAlone(!0))}no_closedlg_flg=!0}}
function onMessage(a){l.log("<<<<<< recieve data <<<<<<");l.dir({json:a});a=JSON.parse(a);if(void 0===a.type)l.log(getDateTime()+"--- !! message type is undefined !! ---");else switch(l.log("message type: "+a.type),a.type){case "event":if(void 0===a.event){l.log(getDateTime()+"--- !! event type is undefined !! ---");break}l.log("event type: "+a.event);switch(a.event){case "login":l.log(getDateTime()+"--- onLogin ---");onLogin(a);break;case "logout":l.log(getDateTime()+"--- onLogout ---");onLogout(a);
break;case "getdata":l.log(getDateTime()+"--- onGetData ---");onGetdata(a);break;case "pup":l.log(getDateTime()+"--- onPUP ---");onPreUpdate(a);break;case "bup":l.log(getDateTime()+"--- onBUP ---");onBuddyUpdate(a);break;case "pchg":l.log(getDateTime()+"--- onPCHG ---");onPreChange(a);break;case "ims":l.log(getDateTime()+"--- onIMS ---");onIMSend(a);break;case "imr":l.log(getDateTime()+"--- onIMR ---");onIMReceive(a);break;case "keep-alive":l.log(getDateTime()+"--- onKeepAlive ---");onKeepAlive(a);
break;case "conf-list":l.log(getDateTime()+"--- onConfList ---");onConfList(a);break;case "cti":l.log(getDateTime()+"--- onCTI ---");onCTI(a);break;case "telephony":l.log(getDateTime()+"--- onTelephony ---");onTelephony(a);break;case "getstatus":l.log(getDateTime()+"--- onGetstatus ---");onGetstatus(a);break;case "setdata":l.log(getDateTime()+"--- onSetdata ---");onSetdata(a);break;case "a-mute":l.log(getDateTime()+"--- onAudioMute ---");onAudioMute(a);break;case "vqchg":l.log(getDateTime()+"--- onVQChange ---");
onVQChange(a);break;case "notify":l.log(getDateTime()+"--- onNotify ---");onNotify(a);break;case "imrstr":l.log(getDateTime()+"--- onIMRSTR ---");onIMRestore(a);break;case "conf-rsReq":l.log(getDateTime()+"--- onConfRsRes ---");onConfRsRes(a);break;default:l.log(getDateTime()+"--- !! event type error !! ---"),l.log("message from: "+a.from+",type: "+a.type+",event: "+a.event)}break;default:l.log("--- !! message type error !! ---"),l.log("message from: "+a.from+",type: "+a.type+",event: "+a.event)}}
function sendJsonData(a){!0===socketReady&&(a=JSON.stringify(a),l.log(">>>>>> send data >>>>>>"),l.dir({json:a}),Server.send("message",a))}
function clearTimerAll(){keepAliveTimer&&(clearTimeout(keepAliveTimer),keepAliveTimer=null);searchTimer&&(clearTimeout(searchTimer),searchTimer=null);loginTimer&&(clearTimeout(loginTimer),loginTimer=null);logoutTimer&&(clearTimeout(logoutTimer),logoutTimer=null);getdataTimer&&(clearTimeout(getdataTimer),getdataTimer=null);getstatusTimer&&(clearTimeout(getstatusTimer),getstatusTimer=null);bupTimer&&(clearTimeout(bupTimer),bupTimer=null);telregTimer&&(clearTimeout(telregTimer),telregTimer=null);scResTimer&&
(clearTimeout(scResTimer),scResTimer=null);scDiscTimer&&(clearTimeout(scDiscTimer),scDiscTimer=null)}
function sendEvtLogin(){l.log(CR+"sendEvtLogin()");""!==user_id&&(sendEvtGetdata(DATA_TYPE_CPRE),l.log("Login ID: "+user_id),l.log("Login PW: "+user_pw),sendJsonData({type:"event",event:"login",mode:"uc",id:user_id,pw:user_pw,tel:user_phone}),loginTimer&&clearTimeout(loginTimer),loginTimer=setTimeout(function(){"sc_presence"==sc_type?(clrLoadingMotion(),openDialog(langTbl.d_error_5+"</br>"+langTbl.d_pre_4,dlgBtnList[D_BTN_STDALN]),viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),
adjustClctrlArea(),deleteCallList())):openDialog(langTbl.d_error_5,dlgBtnList[D_BTN_LOGIN]);telregTimer&&(clearTimeout(telregTimer),telregTimer=null);viewModel.isStandAlone(!0);no_closedlg_flg=!0;Server.disconnect()},6E4),user_phone!==MODE_NONE&&(telregTimer&&clearTimeout(telregTimer),telregTimer=setTimeout(function(){openDialog(langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]);user_phone=MODE_NONE},6E4)))}
function onLogin(a){if(void 0!==a.res){loginTimer&&(clearTimeout(loginTimer),loginTimer=null);var b=a.res;l.log("login-res: "+b);switch(b){case 0:void 0!==a.self&&(self_id=a.self);void 0!==a.secpt&&(httpsPort=a.secpt);void 0!==a.pt&&(httpPort=a.pt);void 0!==a.sowspt&&(sowsPt=a.sowspt);void 0!==a.sipext&&(sipExt=a.sipext);void 0!==a.sippw&&(sipPW=a.sippw);void 0!==a.ip&&(voipIp=a.ip);void 0!==a.vmbset&&a.vmbset&&viewModel.mw_count(0);SessionID=void 0!==a.sessid?a.sessid:"";void 0!==a.webpt&&(webPt=
a.webpt);checkInScheduler();recvInitData(a);deleteAllChatInfo();viewModel.phone_mode()==MODE_SIP&&setupSipPhone(sipExt,sipPW);clrLoadingMotion(function(){fadein_ScPresence();isJP()&&statusChange(viewModel.mktCfg().DEFAULT_STATUS);sendEvtGetdata(DATA_TYPE_CFG);isFirstLogin&&sendEvtGetdata(DATA_TYPE_USER);sendEvtImRestore();viewModel.phone_mode()===MODE_CTI&&sendEvtGetdata(DATA_TYPE_FKEY);viewModel.phone_mode()&&(sendEvtGetdata(DATA_TYPE_SC),sendEvtGetstatus(STATUS_TYPE_MDS));sendEvtGetdata(DATA_TYPE_SPD);
isFirstLogin=!1});break;case 1:case 2:case 3:case 4:telregTimer&&(clearTimeout(telregTimer),telregTimer=null);"sc_presence"==sc_type?(clrLoadingMotion(),openDialog(langTbl.d_login_1+"</br>"+langTbl.d_pre_10,dlgBtnList[D_BTN_LOGOUT]),viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList())):openDialog(langTbl.d_login_1,dlgBtnList[D_BTN_LOGIN]);viewModel.isStandAlone(!0);reconn_grd_flg=no_closedlg_flg=!0;break;case 7:telregTimer&&(clearTimeout(telregTimer),
telregTimer=null);"sc_presence"==sc_type?(clrLoadingMotion(),openDialog(langTbl.d_login_3+"</br>"+langTbl.d_pre_10,dlgBtnList[D_BTN_LOGOUT]),viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList())):openDialog(langTbl.d_login_3,dlgBtnList[D_BTN_LOGIN]);viewModel.isStandAlone(!0);reconn_grd_flg=no_closedlg_flg=!0;break;case 9:telregTimer&&(clearTimeout(telregTimer),telregTimer=null);"sc_presence"==sc_type?(clrLoadingMotion(),openDialog(langTbl.d_login_4+
"</br>"+langTbl.d_pre_10,dlgBtnList[D_BTN_LOGOUT]),viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList(),updtDocTitle())):openDialog(langTbl.d_login_4,dlgBtnList[D_BTN_LOGIN]);viewModel.isStandAlone(!0);reconn_grd_flg=no_closedlg_flg=!0;break;case 129:telregTimer&&(clearTimeout(telregTimer),telregTimer=null);"sc_presence"==sc_type?(clrLoadingMotion(),openDialog(langTbl.d_login_5+"</br>"+langTbl.d_pre_10,dlgBtnList[D_BTN_LOGOUT]),viewModel.phone_mode()===
MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList(),updtDocTitle())):openDialog(langTbl.d_login_5,dlgBtnList[D_BTN_LOGIN]);viewModel.isStandAlone(!0);reconn_grd_flg=no_closedlg_flg=!0;break;case 130:telregTimer&&(clearTimeout(telregTimer),telregTimer=null);"sc_presence"==sc_type?(clrLoadingMotion(),openDialog(langTbl.d_login_6+"</br>"+langTbl.d_pre_10,dlgBtnList[D_BTN_LOGOUT]),viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList(),
updtDocTitle())):openDialog(langTbl.d_login_6,dlgBtnList[D_BTN_LOGIN]);viewModel.isStandAlone(!0);reconn_grd_flg=no_closedlg_flg=!0;break;default:telregTimer&&(clearTimeout(telregTimer),telregTimer=null),"sc_presence"==sc_type?(clrLoadingMotion(),openDialog(langTbl.d_error_5+"</br>"+langTbl.d_pre_10,dlgBtnList[D_BTN_LOGOUT]),viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList(),updtDocTitle())):openDialog(langTbl.d_error_5,dlgBtnList[D_BTN_LOGIN]),
viewModel.isStandAlone(!0),reconn_grd_flg=no_closedlg_flg=!0}}}
function sendEvtLogout(){setLoadingMotion(function(){viewModel.isStandAlone()?user_phone==MODE_ST500?(openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]),clrLoadingMotion()):clrLoadingMotion(fadein_ScLogin):(sendImEndToAll(),sendJsonData({type:"event",event:"logout"}),logoutTimer&&clearTimeout(logoutTimer),reconn_grd_flg=!0,logoutTimer=setTimeout(function(){openDialog(langTbl.d_error_6,dlgBtnList[D_BTN_CNFIM]);clrLoadingMotion();reconn_grd_flg=!1},3E4))})}
function onLogout(a){try{viewModel.phone_mode()==MODE_ST500&&(iOS_Device()?webkit.messageHandlers.notifyLoginStateOfInUC.postMessage("0"):androidJavascriptInterface.notifyLoginStateOfInUC("0"))}catch(b){l.log("Fail to Callback notifyLoginStateOfInUC(0);")}if(void 0!==a.res)switch(logoutTimer&&(clearTimeout(logoutTimer),logoutTimer=null),a.res){case 0:clrLoadingMotion(fadein_ScLogin);no_closedlg_flg=!0;return;default:reconn_grd_flg=!1;openDialog(langTbl.d_error_6,dlgBtnList[D_BTN_CNFIM]);clrLoadingMotion();
return}if(void 0!==a.req)switch(a.req){case 1:isJP()?openDialog(langTbl.d_error_7_jp,dlgBtnList[D_BTN_OVRRIDE]):openDialog(langTbl.d_error_7_ot+"</br>"+langTbl.d_pre_4,dlgBtnList[D_BTN_STDALN]);viewModel.isStandAlone(!0);viewModel.phone_mode()===MODE_CTI&&(viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),deleteCallList(),updtDocTitle());reconn_grd_flg=no_closedlg_flg=!0;break;case 2:openDialog(langTbl.d_error_8,dlgBtnList[D_BTN_LOGIN]);reconn_grd_flg=no_closedlg_flg=!0;break;default:openDialog(langTbl.d_error_2,
dlgBtnList[D_BTN_LOGIN]),reconn_grd_flg=no_closedlg_flg=!0}}
function sendEvtGetdata(a){l.log(CR+"sendEvtGetdata("+a+")");var b="",c=30;switch(a){case DATA_TYPE_USER:b="usr";break;case DATA_TYPE_SPD:b="spd";c=60;break;case DATA_TYPE_FKEY:b="fkey";break;case DATA_TYPE_TACS:b="trkacs";break;case DATA_TYPE_HIST:b="hist";break;case DATA_TYPE_CPRE:b="cpre";break;case DATA_TYPE_CFG:b="cfg";break;case DATA_TYPE_SC:b="srvcode";break;default:return}sendJsonData({type:"event",event:"getdata",req:b});getdataTimer&&clearTimeout(getdataTimer);getdataTimer=setTimeout(function(){clrLoadingOnList()},
1E3*c)}function sendEvtSetdata(a){l.log(CR+"sendEvtSetdata("+a+")");var b="";switch(a){case DATA_TYPE_LANG:b={idx:viewModel.myIdx(),lang:""+viewModel.tmpLang().idx};break;default:return}sendJsonData({type:"event",event:"setdata",req:b});setdataTimer&&clearTimeout(setdataTimer);setdataTimer=setTimeout(function(){openDialog(langTbl.d_error_14,dlgBtnList[D_BTN_CNFIM]);viewModel.tmpLang(langFileList[viewModel.myLangIdx()])},3E4)}
function onGetdata(a){getdataTimer&&(clearTimeout(getdataTimer),getdataTimer=null);if(void 0!==a.res)switch(a.res){case 0:void 0!==a.data&&void 0!==a.data.usr&&recvUserDetail(a.data);void 0!==a.data&&void 0!==a.data.spd&&recvSpeedDial(a.data);void 0!==a.data&&void 0!==a.data.fkey&&recvFkeyList(a.data);void 0!==a.data&&void 0!==a.data.hist&&recvCallHistory(a.data);void 0!==a.data&&void 0!==a.data.cpre&&recvCustomPresence(a.data);void 0!==a.data&&void 0!==a.data.cfg&&recvConfig(a.data);void 0!==a.data&&
void 0!==a.data.srvcode&&recvServiceCode(a.data);break;default:clrLoadingOnList()}}function onSetdata(a){setdataTimer&&(clearTimeout(setdataTimer),setdataTimer=null);void 0!==a.res&&(a=a.res,void 0!==a.lang&&0===a.lang?(viewModel.myLangIdx(viewModel.tmpLang().idx),changeLang(langFileList[viewModel.tmpLang().idx].file)):(viewModel.tmpLang(langFileList[viewModel.myLangIdx()]),openDialog(langTbl.d_error_14,dlgBtnList[D_BTN_CNFIM])))}
function sendEvtGetstatus(a){l.log(CR+"sendEvtGetstatus("+a+")");var b="";switch(a){case STATUS_TYPE_CFW:b="cfw";break;case STATUS_TYPE_DND:b="dnd";break;case STATUS_TYPE_MDS:b="mds";break;default:return}sendJsonData({type:"event",event:"getstatus",req:b});getstatusTimer&&clearTimeout(getstatusTimer);getstatusTimer=setTimeout(function(){clrLoadingOnList()},3E4)}
function onGetstatus(a){getstatusTimer&&(clearTimeout(getstatusTimer),getstatusTimer=null);if(void 0!==a.res&&void 0!==a.data)switch(a.res){case 0:void 0!==a.data.cfw&&recvCfwStatus(a.data.cfw);void 0!==a.data.dnd&&recvDndStatus(a.data.dnd);void 0!==a.data.mds&&recvMdsStatus(a.data.mds);break;default:return}clrLoadingOnList()}
function recvCfwStatus(a){if(void 0!==a.type){switch(a.type){case 0:viewModel.sacsCfwStType(SRVCODE_CFW_NONE);break;case 1:viewModel.sacsCfwStType(SRVCODE_CFW_BR);break;case 2:viewModel.sacsCfwStType(SRVCODE_CFW_NA);break;case 3:viewModel.sacsCfwStType(SRVCODE_CFW_BS);break;case 7:viewModel.sacsCfwStType(SRVCODE_CFW_ALL);break;case 8:viewModel.sacsCfwStType(SRVCODE_CFW_BNA)}void 0!==a.dst?viewModel.sacsCfwStDst(a.dst):viewModel.sacsCfwStDst("")}clrLoadingOnList()}
function recvDndStatus(a){switch(a){case 0:viewModel.sacsDndStatus(SRVCODE_DND_NONE);break;case 4:viewModel.sacsDndStatus(SRVCODE_DND_ALL);break;case 1:viewModel.sacsDndStatus(SRVCODE_DND_EXT);break;case 2:viewModel.sacsDndStatus(SRVCODE_DND_INT);break;case 3:viewModel.sacsDndStatus(SRVCODE_DND_TRNS)}clrLoadingOnList()}
function recvMdsStatus(a){switch(a){case 0:viewModel.sacsMdsStatus(SRVCODE_MDS_NONE);break;case 1:viewModel.sacsMdsStatus(SRVCODE_MDS_ON);break;case 2:viewModel.sacsMdsStatus(SRVCODE_MDS_OFF)}initSacs();clrLoadingOnList()}function sendEvtPresenceChange(){sendJsonData({type:"event",event:"pchg",idx:viewModel.myIdx(),as:viewModel.myAs(),ts:viewModel.myTs(),cs:viewModel.myCs(),st:viewModel.myMsg()})}function onPreChange(a){}
function sendEvtBuddyUpdate(a,b){l.log(CR+"sendEvtBuddyUpdate("+a+")");switch(a){case ACT_ADD_BUDDY:case ACT_DEL_BUDDY:break;default:return}sendJsonData({type:"event",event:"bup",act:a,idxs:b});bupTimer&&clearTimeout(bupTimer);bupTimer=setTimeout(function(){resetBuddy()},3E4)}function onBuddyUpdate(a){if(void 0!==a.res)switch(a.res){case 0:void 0!==a.blist&&updtBlistInfo(a.blist);updtBuddy(a.act);break;default:resetBuddy()}}function onPreUpdate(a){void 0!==a.blist&&updtBlistInfo(a.blist)}
function onIMSend(a){if(void 0!==a.res){for(var b=memberList[a.idx],c=null,d=viewModel.chatLogArr().length,e=d-1;0<=e;e--)if(viewModel.chatLogArr()[e].mid===a.mid&&viewModel.chatLogArr()[e].user.index()===a.idx){c=viewModel.chatLogArr()[e];break}d=b.imUnsent.length;for(e=0;e<d;e++)if(b.imUnsent[e].mid===a.mid){b.imUnsent.splice(e,1);break}if(c){clearTimeout(c.timeout);switch(a.res){case 0:c.status(CHAT_ST_SUCCESS);break;case 2:c.status(CHAT_ST_PENDING);break;default:recvImSendErr(b,c)}b=0;if(2==a.res){d=
viewModel.chatLogArr().length;for(e=0;e<d;e++)viewModel.chatLogArr()[e].status()==CHAT_ST_PENDING&&b++;if(b>CHAT_SRVPEND_MAX)for(e=0;e<d;e++)if(viewModel.chatLogArr()[e].status()==CHAT_ST_PENDING){recvImSendErr(viewModel.chatLogArr()[e].user,viewModel.chatLogArr()[e]);break}}}}}
function onIMReceive(a){if(!(void 0===a.idx||0>a.idx||void 0===a.b||void 0===a.tm||void 0===a.mid)){var b=memberList[a.idx];sendJsonData({type:"event",event:"imr",res:0,idx:a.idx,mid:a.mid,tm:a.tm});recvUCSIM(b,a.b,a.tm,a.mid)||recvChat(b,a.b,a.tm,a.mid)}}function onKeepAlive(){keepAliveTimer&&clearTimeout(keepAliveTimer);keepAliveTimer=viewModel.phone_mode()!=MODE_ST500?setTimeout("Server.disconnect()",6E4):setTimeout("Server.disconnect()",36E4)}
function onConfList(a){if(void 0!==a.limit&&void 0!==a.list){var b=a.limit;a=a.list.split(",");for(var c=viewModel.confList.removeAll(),d=0,e=c.length;d<e;d++)delete c[d];for(d=0;d<b;d++){c=a[d].split(":");try{var f=decodeURIComponent(c[0])}catch(g){f=c[0]}try{var h=decodeURIComponent(c[1])}catch(g){h=c[1]}"0"!=h&&(c=confObj(f,h),viewModel.confList.push(c))}}}function onCTI(a){if(void 0!==a.data)switch(a.data.evt){case "status":CTI_onStatus(a.data);break;case "fkey":CTI_onFkey(a.data)}}
function onTelephony(a){if(void 0!==a.data&&(a=a.data,a.tel===user_phone)){telregTimer&&(clearTimeout(telregTimer),telregTimer=null);switch(a.tel){case MODE_CTI:CTI_onTelephony(a);break;case MODE_SMARTDEV:smtdev_onTelephony(a);break;case MODE_SIP:SIP_onTelephony(a);break;case MODE_ST500:ST500_onTelephony(a);break;default:none_onTelephony(a)}initSacs();deleteCallList();adjustClctrlArea();updtDocTitle()}}
function onNotify(a){void 0!==a.data&&(a=a.data,void 0!==a.sowspt&&(sowsPt=a.sowspt,setupSipPhone(sipExt,sipPW)),void 0!==a.sippw&&(sipPW=a.sippw),void 0!==a.sipext&&(sipExt=a.sipext,setupSipPhone(sipExt,sipPW)),void 0!==a.msgwt&&viewModel.mw_count(a.msgwt),void 0!==a.vmbsts&&recvVmbStatus(a.vmbsts))}function ParseAccessUrl(){var a;a=GetQueryString();null!==a&&(void 0!==a.u&&(user_id=a.u),void 0!==a.p&&(user_pw=a.p),void 0!==a.t&&"gt890"===a.t&&viewModel.term_type(TERM_TYPE_GT890))}
function GetQueryString(){if(1>=document.location.search.length)return null;var a=document.location.search.substring(1).split("&"),b={};if(null===b)return null;for(var c=0;c<a.length;c++){var d=a[c].split("="),e=decodeURIComponent(d[0]),d=decodeURIComponent(d[1]);b[e]=decodeURIComponent(d)}return b}
function DispFirstPage(){"/uc/st500"==document.location.pathname?setLoadingMotion(function(){initMemberList(function(){deleteLogs();deleteCallList();deleteSipPhone();deleteDsktpNotificationAll(NOTIF_TYPE_ALL);clearTimerAll();clrLoadingMotion();clearToneManager();clearDtmfTone();clrCallStatusReq();sipPW=sipExt="";viewModel.mw_count(-1);user_phone=MODE_NONE;viewModel.phone_mode(MODE_NONE);adjustClctrlArea();home_sort=LIST_TYPE_CONTACT;home_index=!1;viewModel.IndexHiden(!1);-1!==viewModel.myLangIdx()&&
(changeLang("lang.js"),viewModel.myLangIdx(-1));ParseAccessUrl();user_phone=MODE_ST500;viewModel.check_qvl(!1);serverConnect()})}):fadein_ScLogin()}
function fadein_ScLogin(){setLoadingMotion(function(){initMemberList(function(){deleteLogs();deleteCallList();deleteSipPhone();deleteDsktpNotificationAll(NOTIF_TYPE_ALL);clearTimerAll();clrLoadingMotion();clearToneManager();clearDtmfTone();clrCallStatusReq();sipPW=sipExt="";viewModel.mw_count(-1);for(var a in chatRstrArr)chatRstrArr[a]=null;chatRstrArr.length=0;if(user_phone==MODE_ST500)try{$(window).off("beforeunload"),iOS_Device()?webkit.messageHandlers.notifyLogoutOfInUC.postMessage(""):androidJavascriptInterface.notifyLogoutOfInUC()}catch(b){l.error("Failed to call ST500 API"),
l.dir(b)}else user_phone=MODE_NONE,viewModel.phone_mode(MODE_NONE),adjustClctrlArea(),home_sort=LIST_TYPE_CONTACT,home_index=!1,viewModel.IndexHiden(!1),-1!==viewModel.myLangIdx()&&(changeLang("lang.js"),viewModel.myLangIdx(-1)),$(".sc").css("opacity","0"),$(".sc").css("display","none"),$("#sc_loading").css("opacity","1"),$("#sc_loading").css("display","inline"),$("#sc_loading").animate({opacity:0},500),setTimeout(function(){$("#sc_login").css("display","inline");document.getElementById("inputUserId").focus();
$("#sc_login").animate({opacity:1},500);sc_type="sc_login";isFirstLogin=!0;adjustPageBodySize();updtDocTitle()},500)})})}
function fadein_ScPresence(){$(".sc").css("opacity","0");$(".sc").css("display","none");isFirstLogin?($("#sc_loading").css("opacity","1"),$("#sc_loading").css("display","inline"),$("#sc_loading").animate({opacity:0},500),setTimeout(function(){$("#sc_presence").css("display","inline");$("#sc_presence").animate({opacity:1},500);sc_type="sc_presence";updtDocTitle()},500)):($("#sc_loading").css("opacity","0"),$("#sc_loading").css("display","none"),$("#sc_presence").css("display","inline"),$("#sc_presence").css("opacity",
"1"),sc_type="sc_presence",updtDocTitle())}function adjustPageBodySize(){var a,b=document.getElementById("pagebody");!isSmartDevice()&&VVM.sup_check()&&(b.style.minWidth="380px");b.style.height="100%";var c=$("#pagebody").height();switch(sc_type){case "sc_login":a=$("#login_wrap").height(),a>c&&(b.style.height=a+40+"px")}}
function adjustStyleSheet(){var a;if(user_phone==MODE_ST500){a=viewModel.term_type()==TERM_TYPE_GT890?"main_gt":"main_st";for(i=0;link=document.getElementsByTagName("link")[i];i++)link.getAttribute("rel")&&-1!==link.getAttribute("rel").indexOf("stylesheet")&&link.getAttribute("id")&&-1!==link.getAttribute("id").indexOf("main")&&(link.getAttribute("id")&&-1!==link.getAttribute("id").indexOf(a)?link.disabled=!1:link.disabled=!0);viewModel.term_type()==TERM_TYPE_GT890&&($("#list_body").addClass("scroll"),
$("#list_lang_file").addClass("scroll"),$("#list_status").addClass("scroll"),$("#tel_ipt_predict").addClass("scroll"),$("div#im_wrap .im_body").addClass("scroll"),$("div#tel_sacslist_wrap .tel_body").addClass("scroll"))}else for(a=520>=$(window).width()?"main_t":"main_w",i=0;link=document.getElementsByTagName("link")[i];i++)link.getAttribute("rel")&&-1!==link.getAttribute("rel").indexOf("stylesheet")&&link.getAttribute("id")&&-1!==link.getAttribute("id").indexOf("main")&&(link.getAttribute("id")&&
"main"==link.getAttribute("id")?link.disabled=!1:link.getAttribute("id")&&-1!==link.getAttribute("id").indexOf(a)?link.disabled=!1:link.disabled=!0)}
function changeLang(a,b){var c="lang/"+a;l.log("get script: "+c);void 0==b&&(b=0);setLoadingMotion();$.getScript(c,function(){l.log("success to get script: "+c);void 0==langTbl?(l.log("retry: "+c),changeLang(a)):(setLangage(),initDialog(),viewModel.langJs(langTbl),resetStatusLib(),initSacs(),initVmacsOperation(),initVmInfo(),updtDocTitle(),chgSortType(viewModel.sortType(),viewModel.listType()),clrLoadingMotion())}).fail(function(d,e,f){l.error("faild to get script : "+c);l.dir(d);3>b?(l.log("retry: "+
c),changeLang(a,b+1)):clrLoadingMotion()})}
function setLangage(){loadLangTbl("login_b1","button");loadLangTbl("login_id","div");loadLangTbl("login_pw","div");loadLangTbl("login_tel","div");loadLangTbl("login_tel_0","div");loadLangTbl("login_tel_1","div");loadLangTbl("login_tel_2","div");loadLangTbl("login_tel_3","div");loadLangTbl("myprof_index","div");loadLangTbl("hdr_msg_ta","textarea");loadLangTbl("search_input","textarea");loadLangTbl("menu_userlist","div");loadLangTbl("menu_speeddial","div");loadLangTbl("menu_history","div");loadLangTbl("menu_webconf",
"div");loadLangTbl("menu_bcmsg","div");loadLangTbl("menu_bcmail","div");loadLangTbl("menu_version","div");loadLangTbl("menu_logout","div");loadLangTbl("menu_fkey","div");loadLangTbl("menu_sacs","div");loadLangTbl("alt_new_mes","div");loadLangTbl("alt_new_call","div");loadLangTbl("uinfo_isnot_buddy","div");loadLangTbl("uinfo_sbj_ext","div");loadLangTbl("uinfo_sbj_comment","div");loadLangTbl("uinfo_sbj_tel1","div");loadLangTbl("uinfo_sbj_name2","div");loadLangTbl("uinfo_sbj_tel2","div");loadLangTbl("uinfo_sbj_name3",
"div");loadLangTbl("uinfo_sbj_tel3","div");loadLangTbl("uinfo_sbj_mobile1","div");loadLangTbl("uinfo_sbj_mobile2","div");loadLangTbl("uinfo_sbj_mail1","div");loadLangTbl("uinfo_sbj_mail2","div");loadLangTbl("uinfo_sbj_company","div");loadLangTbl("uinfo_sbj_division","div");loadLangTbl("uinfo_sbj_city","div");loadLangTbl("uinfo_sbj_state","div");loadLangTbl("uinfo_sbj_zip","div");loadLangTbl("uinfo_sbj_country","div");loadLangTbl("uinfo_sbj_note","div");loadLangTbl("menu_addbuddy","div");loadLangTbl("menu_rmvbuddy",
"div");loadLangTbl2("im_btn_send","div");loadLangTbl("sort_type_name","div");loadLangTbl("sort_type_group","div");loadLangTbl("sort_type_status","div");loadLangTbl("sort_type_index","div");loadLangTbl("sort_type_logim","div");loadLangTbl("sort_type_logcall","div");loadLangTbl("sort_type_icmcall","div");loadLangTbl("sort_type_otgcall","div");loadLangTbl("cnfcr_t_id","div");loadLangTbl("cnfcr_t_user","div");loadLangTbl("cnfcr_t_conf","div");loadLangTbl("cnfcr_randamid","div");loadLangTbl2("mltsel_add_label",
"div");loadLangTbl2("label_cancel","div");loadLangTbl2("label_ok","div");loadLangTbl2("label_clear","div");loadLangTbl2("label_update","div");loadLangTbl2("label_buddy","div");loadLangTbl2("label_home","div");loadLangTbl2("label_prev","div");loadLangTbl2("label_next","div");loadLangTbl2("label_seton","div");loadLangTbl2("label_setoff","div");loadLangTbl2("label_cancel_s","div");loadLangTbl("trkacs_label","div");loadLangTbl2("label_dialpad","div");loadLangTbl2("label_ipt_dial","textarea");loadLangTbl2("label_ipt_dial_name",
"textarea");loadLangTbl2("label_call","div");loadLangTbl2("label_call_v","div");loadLangTbl2("label_close","div");loadLangTbl2("sacs_status","div");loadLangTbl2("sacs_mode","div");loadLangTbl2("sacs_type","div");loadLangTbl2("sacs_dest","div");loadLangTbl("sacs_fwd_all","div");loadLangTbl("sacs_fwd_both","div");loadLangTbl("sacs_fwd_busy","div");loadLangTbl("sacs_fwd_bna","div");loadLangTbl("sacs_fwd_na","div");loadLangTbl("sacs_dnd_all","div");loadLangTbl("sacs_dnd_ext","div");loadLangTbl("sacs_dnd_int",
"div");loadLangTbl("sacs_dnd_trans","div")}function loadLangTbl(a,b){var c=langTbl[a];c||(c=isJP()?langTbl[a+"_jp"]:langTbl[a+"_ot"]);var d=document.getElementById(a);if(d)switch(b){case "div":d.innerHTML=c;break;case "button":d.value=c;break;case "textarea":d.placeholder=c}}
function loadLangTbl2(a,b){var c=langTbl[a];c||(c=isJP()?langTbl[a+"_jp"]:langTbl[a+"_ot"]);var d=document.getElementsByClassName(a);if(d.length)for(var e in d)switch(target=d[e],b){case "div":target.innerHTML=c;break;case "button":target.value=c;break;case "textarea":target.placeholder=c}target=null}function showLangSelect(){dispMenu("#menu_lang")}function jumpToConfMode(){location.href=location.protocol+"//"+location.host+"/uc/conf"}
function updtDocTitle(){var a;a=""+viewModel.appName();viewModel.phone_mode()===MODE_CTI&&viewModel.myExt()&&(a+=" ("+viewModel.myExt()+")");document.title=a}
var chatObj=function(a,b,c,d,e,f,h){var g=this;g.user=a;g.type=b;g.ori=c;g.html=d;g.stmp=e;g.mid=f;if(e){a=new Date(1E3*e);c=a.getTime();b=a.getTimezoneOffset();a=null;a=new Date(c+6E4*b);var k=a.getFullYear(),n=a.getMonth()+1,m=a.getDate()}else a=new Date,b=a.getTimezoneOffset(),a.getTime(),k=a.getFullYear(),n=a.getMonth()+1,m=a.getDate();b=a.getHours();c=a.getMinutes();d=a.getSeconds();a=null;g.date=ko.pureComputed(function(){return convDateStr(k,n,m)});g.cmpdate=ko.pureComputed(function(){return convDateComp(k,
n,m)});g.time=convTimeStr(b,c,d);g.dFlg=ko.pureComputed(function(){if(void 0==viewModel)return!0;for(var a,b=viewModel.chatLogArr().length,c=0;c<b;c++){var d=viewModel.chatLogArr()[c];if(isSameChat(d,g)){if(a&&g.cmpdate()===a.cmpdate())return!1;break}g.user===d.user&&(a=d)}return!0});g._status=ko.observable(CHAT_ST_UNSENT);g.status=ko.pureComputed({read:function(){return g._status()},write:function(a){switch(g._status()){case CHAT_ST_OPENED:return;case CHAT_ST_SUCCESS:if(a===CHAT_ST_OPENED)break;
return;case CHAT_ST_PENDING:if(a===CHAT_ST_SUCCESS||a===CHAT_ST_ERROR)break;return;case CHAT_ST_SENDING:if(a===CHAT_ST_SUCCESS||a===CHAT_ST_PENDING||a===CHAT_ST_ERROR)break;return;case CHAT_ST_INVITING:if(a===CHAT_ST_SENDING||a===CHAT_ST_ERROR)break;return;case CHAT_ST_ERROR:if(a===CHAT_ST_RESENT||a===CHAT_ST_SUCCESS)break;return;case CHAT_ST_RESENT:if(a!==CHAT_ST_ERROR&&a!==CHAT_ST_SUCCESS)return}g._status(a)}});g.status(h);g.timeout=null;g.click=ko.observable(!1);g.subsc_sts=g.status.subscribe(function(a){g.user&&
g.user.imSubWin&&updtImSubWin(g.user,g,!1)});g.subsc_clk=g.click.subscribe(function(a){g.user&&g.user.imSubWin&&updtImSubWin(g.user,g,!1)});g.subsc_dflg=g.dFlg.subscribe(function(a){g.user&&g.user.imSubWin&&updtImSubWin(g.user,g,!1)})},usrObj=function(){var a=this;a.isVisible=ko.observable(!1);a.index=ko.observable(-1);a.ext=ko.observable("");a.name=ko.observable("");a.sort1="";a.sort2="";a.key=ko.observable(langTbl.unknown);a.keyHead=ko.observable(!1);a.telArr=ko.observableArray([]);a.mailArr=ko.observableArray([]);
a.mobArr=ko.observableArray([]);a.sipext=ko.observable("");a.mail=ko.observable("");a.name2="";a.name3="";a.comp="";a.dep="";a.city="";a.stat="";a.zip="";a.ctry="";a.note="";a.remarks=ko.observable("");a.appStOri=ko.observable(0);a.appSt=ko.pureComputed(function(){for(var b in viewModel.statusList())if(viewModel.statusList()[b].no()==a.appStOri())return a.appStOri();return viewModel.mktCfg().ST_UNKNOWN});a.telSt=ko.observable(0);a.lineSt=ko.observable(0);a.dispName=ko.pureComputed(function(){return void 0!=
viewModel&&""==a.name()?viewModel.langJs().unknown:a.name()});a.getTelName=function(b){return a.telArr()[1]&&a.telArr()[1]==b?""!==a.name2?a.name2:a.name():a.telArr()[2]&&a.telArr()[2]==b&&""!==a.name3?a.name3:a.name()};a.ocDial=ko.observable("");a.getOCDial=function(){var b;b=a.ext();if(""!==b)return b;b=a.sipext();if(""!==b)return b;b=a.telArr()[0]?a.telArr()[0]:"";if(""!==b)return b;b=a.telArr()[1]?a.telArr()[1]:"";if(""!==b)return b;b=a.telArr()[2]?a.telArr()[2]:"";if(""!==b)return b;b=a.mobArr()[0]?
a.mobArr()[0]:"";if(""!==b)return b;b=a.mobArr()[1]?a.mobArr()[1]:"";return""!==b?b:""};a.checkCallable_t1=ko.pureComputed(function(){if(1>a.telArr().length)return!1;var b=a.telArr()[0];return checkCallable(b)});a.checkCallable_t2=ko.pureComputed(function(){if(2>a.telArr().length)return!1;var b=a.telArr()[1];return checkCallable(b)});a.checkCallable_t3=ko.pureComputed(function(){if(3>a.telArr().length)return!1;var b=a.telArr()[2];return checkCallable(b)});a.checkCallable_m1=ko.pureComputed(function(){if(1>
a.mobArr().length)return!1;var b=a.mobArr()[0];return checkCallable(b)});a.checkCallable_m2=ko.pureComputed(function(){if(2>a.mobArr().length)return!1;var b=a.mobArr()[1];return checkCallable(b)});a.stObj=ko.pureComputed(function(){if(void 0!=viewModel)for(var b in viewModel.statusList()){var c=viewModel.statusList()[b];if(matchStatus(a.appSt(),a.lineSt(),c))return c}return null_status});a.subsc_stobj=a.stObj.subscribe(function(b){a.imSubWin&&a.imSubWin.viewModel.stObj(b)});a.isBuddy=ko.observable(0);
a.tmpBuddy=ko.observable(0);a.isSelect=ko.observable(!1);a.imLastIdx=ko.pureComputed(function(){if(viewModel)for(var b=viewModel.chatLogArr().length-1;0<=b;b--)if(viewModel.chatLogArr()[b].user===a)return b;return-1});a.imLastObj=ko.pureComputed(function(){if(-1===a.imLastIdx())return null_chat;var b=a.imLastIdx();return viewModel.chatLogArr()[b]});a.imLastTime=ko.pureComputed(function(){return void 0==a.imLastObj()?"":a.imLastObj().time});a.imLastMsg=ko.pureComputed(function(){return void 0==a.imLastObj()?
"":reverseHtmlTag(deleteHtmlTag(a.imLastObj().html))});a.imUnsent=[];a.imNew=ko.pureComputed(function(){if(viewModel)for(var b=viewModel.chatLogArr().length,c=0;c<b;c++){var d=viewModel.chatLogArr()[c];if(d.user===a&&d.status()!==CHAT_ST_OPENED&&d.type===CHAT_TYPE_R)return c}return-1});a.hasImAlert=ko.pureComputed(function(){if(void 0!=viewModel)for(var b in viewModel.imAlertList())if(viewModel.imAlertList()[b].user==a)return!0;return!1});a.imStatus=IM_STATUS_DISC;a.imInvId=0;a.imSesTmr=null;a.callNew=
ko.observable(!1);a.imSubWin=null};usrObj.prototype.dispose=function(){this.subsc_stobj.dispose()};
var confObj=function(a,b){this.creater=ko.observable(a);this.memberNo=ko.observable(b)},statusObj=function(a,b,c,d,e,f){this.no=ko.observable(a);this.name=ko.observable(b);this.icon=ko.observable(c);this.color=ko.observable(d);this.priority=ko.observable(e);this.selectable=ko.observable(f)},spddialObj=function(){var a=this;a.isVisible=ko.observable(!1);a.index=ko.observable(-1);a.dial=ko.observable("");a.name=ko.observable("");a.sort="";a.checkCallable=ko.pureComputed(function(){var b=a.dial();return checkCallable(b)});
a.key=ko.observable(langTbl.unknown);a.keyHead=ko.observable(!1)},alertObj=function(a,b,c,d){this.type=a;this.time=b;this.user=c;this.chat=d},fkeyObj=function(a,b,c,d,e){this.index=a;this.name=b;this.add=c;this.color=ko.observable(d);this.blink=ko.observable(e)},chistObj=function(a,b,c,d,e,f,h,g,k){this.type=a?CHIST_TYPE_OTG:CHIST_TYPE_ICM;this.dial=b;this.name=""!=c&&c!=b?c:searchCallerName(b);this.status=k;this.date=ko.pureComputed(function(){return convDateStr(d,e,f)});this.cmpdate=ko.pureComputed(function(){return convDateComp(d,
e,f)});this.time=convTimeStr(h,g,0);this.mainIcon=getCHistMainIcon(k);this.subIcon=getCHistSubIcon(a,k);this.isVisible=ko.observable(!1);this.key=ko.observable(langTbl.unknown);this.keyHead=ko.observable(!1)};function getCHistMainIcon(a){var b;b="fa fa-phone";switch(1){case getBitVal(a,CHIST_STBIT_ABNDON):case getBitVal(a,CHIST_STBIT_BUSY):b+=" color_red"}return b}
function getCHistSubIcon(a,b){var c="";switch(a){case CHIST_TYPE_OTG:c+="fa fa-arrow-right";break;default:c+="fa fa-arrow-left"}switch(1){case getBitVal(b,CHIST_STBIT_ABNDON):case getBitVal(b,CHIST_STBIT_BUSY):c+=" color_red"}return c}
var callObj=function(){var a=this;a.histType=CHIST_TYPE_HIDDEN;a.cid=0;a._dial=ko.observable("");a.dial=ko.pureComputed({read:function(){return a._dial()},write:function(b){a._dial(b)}});a._status=ko.observable(CALL_ST_IDLE);a.status=ko.pureComputed({read:function(){return a._status()},write:function(b){a._status(b);if(viewModel.primeCall()==a)switch(b){case CALL_ST_SPEAK:case CALL_ST_CSPEAK:case CALL_ST_HELD:case CALL_ST_183:startCallDrTmr();sipPhone&&getLocalVideo()&&getLocalVideo().muted(sipPhone.getMuteStatus(a.cid).audio);
break;default:stopCallDrTmr()}b!==CALL_ST_SPEAK&&a.video&&a.video.stream(null);videoSubWinManager(a);b!==CALL_ST_INCOM&&deleteDsktpNotification(NOTIF_TYPE_CALL,a);a.ansResWait(!1)}});a.ansResWait=ko.observable(!1);a.time=ko.observable(0);a.name=ko.pureComputed(function(){if(void 0===viewModel)return"";switch(a.status()){case CALL_ST_IDLE:case CALL_ST_DIAL:case CALL_ST_CHOLD:case CALL_ST_INCONF:case CALL_ST_SRVCODE:return"";case CALL_ST_CSPEAK:return viewModel.langJs().tel_cspeak}if(""!==a.dial()){if("Anonymous"==
a.dial())return langTbl.label_anonymous;var b=searchCallerName(a.dial());return""!==b?b:a.dial()}return viewModel.langJs().tel_nodial});a.icon=ko.pureComputed(function(){switch(a.status()){case CALL_ST_INCOM:return"fa fa-arrow-left";case CALL_ST_HOLD:case CALL_ST_CHOLD:case CALL_ST_HELD:return"fa fa-pause";case CALL_ST_BUSY:return"fa fa-times";case CALL_ST_RINGBK:return"fa fa-arrow-right";default:return"fa fa-volume-up"}});a.callInfo=ko.pureComputed(function(){if(void 0===viewModel)return"";switch(a.status()){case CALL_ST_RINGBK:return viewModel.langJs().tel_ringing;
case CALL_ST_INCOM:return viewModel.langJs().tel_incoming;case CALL_ST_HOLD:case CALL_ST_HELD:return viewModel.langJs().tel_holding;case CALL_ST_DIAL:return viewModel.langJs().tel_dial;case CALL_ST_BUSY:return viewModel.langJs().tel_busy;case CALL_ST_CHOLD:return viewModel.langJs().tel_chold;case CALL_ST_SPEAK:case CALL_ST_CSPEAK:case CALL_ST_183:var b=("0"+Math.floor(a.time()/60)%60).slice(-2),c=("0"+a.time()%60).slice(-2);return b+":"+c;default:return""}});a.isActive=ko.pureComputed(function(){switch(a.status()){case CALL_ST_RINGBK:case CALL_ST_SPEAK:case CALL_ST_HOLD:case CALL_ST_DIAL:case CALL_ST_BUSY:case CALL_ST_INCOM:case CALL_ST_CHOLD:case CALL_ST_CSPEAK:case CALL_ST_HELD:case CALL_ST_183:return!0;
default:return!1}});a.bTransFlag=ko.observable(!1);a.swapFlag=ko.observable(!1);a.video=null;a.callType=ko.observable(TYPE_VOICE_CALL);a.vmacs_status=ko.observable(VMACS_ST_NONE)},sacsObj=function(a,b,c,d){this.val=a;this.name=b;this.icon=c;this.func=d},langFileObj=function(a,b,c){this.idx=a;this.name=b;this.file=c},langFileList=[new langFileObj(0,"Japanese","lang_jp.js"),new langFileObj(1,"English","lang_en.js"),new langFileObj(2,"German","lang_ge.js"),new langFileObj(3,"French","lang_fr.js"),new langFileObj(4,
"Italian","lang.js"),new langFileObj(5,"Spanish","lang_sp.js"),new langFileObj(6,"Dutch","lang_du.js"),new langFileObj(7,"Portuguese","lang.js"),new langFileObj(8,"Norwegian","lang_no.js"),new langFileObj(9,"Danish","lang.js"),new langFileObj(10,"Swedish","lang.js"),new langFileObj(11,"Turkish","lang.js"),new langFileObj(12,"Romanian","lang.js"),new langFileObj(13,"Polish","lang.js"),new langFileObj(14,"Russian","lang_ru.js"),new langFileObj(15,"Simplified Chinese ","lang_si.js"),new langFileObj(16,
"Traditional Chinese","lang_tr.js"),new langFileObj(17,"Thai","lang_th.js"),new langFileObj(18,"Vietnamese","lang_vn.js"),new langFileObj(19,"Bahasa Indonesia","lang_bi.js"),new langFileObj(20,"Bahasa Malaysia","lang_ml.js"),new langFileObj(21,"Latin America Spanish","lang_ls.js"),new langFileObj(22,"Brazilian Portuguese","lang_bp.js")],VmAcsOperation=function(a,b){var c=this;c.type=a;switch(a){case VMACS_OPR_RPLY:c.icon="fa fa-step-backward";c.label=langTbl.vmbtn_replay;break;case VMACS_OPR_BACK:c.icon=
"fa fa-backward";c.label=langTbl.vmbtn_bkskip;break;case VMACS_OPR_SKIP:c.icon="fa fa-forward";c.label=langTbl.vmbtn_skip;break;case VMACS_OPR_NEXT:c.icon="fa fa-step-forward";c.label=langTbl.vmbtn_next;break;case VMACS_OPR_DEL:c.icon="fa fa-trash";c.label=langTbl.vmbtn_del;break;case VMACS_OPR_CLBK:c.icon="fa fa-phone";c.label=langTbl.vmbtn_callbk;break;default:c.icon="fa",c.label=""}c.func=function(){c.check()&&b()};c.check=ko.pureComputed(function(){if(!viewModel)return!1;var a=viewModel.primeCall();
switch(c.type){case VMACS_OPR_SKIP:case VMACS_OPR_BACK:if(a&&a.vmacs_status()==VMACS_ST_LIN_PLY)return!0;break;case VMACS_OPR_NEXT:case VMACS_OPR_RPLY:case VMACS_OPR_DEL:if(a&&a.vmacs_status()==VMACS_ST_LIN_PLY||a&&a.vmacs_status()==VMACS_ST_LIN_OPT_WT)return!0;break;case VMACS_OPR_CLBK:if(viewModel.vmDial()&&(a&&a.vmacs_status()==VMACS_ST_LIN_PLY||a&&a.vmacs_status()==VMACS_ST_LIN_OPT_WT))return!0}return!1})},null_user=new usrObj,null_chat=new chatObj(null_user,CHAT_TYPE_S,"","",0,0,CHAT_ST_UNSENT),
null_spd=new spddialObj,null_status=new statusObj(0,langTbl[CFG_OTH.statusTbl[0][0]],CFG_OTH.statusTbl[0][1],CFG_OTH.statusTbl[0][2],CFG_OTH.statusTbl[0][3],CFG_OTH.statusTbl[0][4]),memberList=[],chatRstrArr=[],kovm=function(){var a=this;a.appName=ko.pureComputed(function(){if(-1===a.myLangIdx())return a.langJs().app_name;switch(a.market()){case 1:return a.langJs().app_name_jp;default:return a.langJs().app_name_ot}});a.dispBuddyList=ko.observableArray([]);a.dispMemberList=ko.observableArray([]);a.dispImLogList=
ko.observableArray([]);a.selUserList=ko.observableArray([]);a.comSpdDialList=ko.observableArray([]);a.dispComSpdDialList=ko.observableArray([]);a.spdPageNo=ko.observable(1);a.spdPageMax=ko.observable(1);a.langJs=ko.observable(langTbl);a.market=ko.observable(0);a.mktCfg=ko.pureComputed(function(){switch(a.market()){case 1:return CFG_JP;default:return CFG_OTH}});a.myLangIdx=ko.observable(-1);a.tmpLang=ko.observable("");a.system=ko.observable(SYS_TYPE_DEFAULT);a.cstmStTbl=ko.observableArray([]);a.callHistList=
ko.observableArray([]);a.dispCallHistList=ko.observableArray([]);a.usableCallHist=ko.pureComputed(function(){switch(viewModel.phone_mode()){case MODE_CTI:case MODE_SIP:return!0}return!1});a.chatLogArr=ko.observableArray([]);a.subsc_cla=a.chatLogArr.subscribe(function(a){a.forEach(function(a){var b=a.value,c=b.user;a="deleted"==a.status?!0:!1;b&&c&&c.imSubWin&&(a&&(b=null),setTimeout(function(a){updtImSubWin(c,a,!0)},500,b))})},null,"arrayChange");a.alertList=ko.observableArray([]);a.imAlertList=ko.pureComputed(function(){for(var b=
[],c=0,d=a.alertList().length;c<d;c++){var e=a.alertList()[c];e.type===ALERT_IM_NEW&&b.push(e)}return b});a.callAlertList=ko.pureComputed(function(){for(var b=[],c=0,d=a.alertList().length;c<d;c++){var e=a.alertList()[c];e.type===ALERT_CALL_NEW&&b.push(e)}return b});a.subsc_imalt=a.imAlertList.subscribe(function(b){b=""+a.imAlertList().length;if(viewModel.phone_mode()==MODE_ST500)try{iOS_Device()?webkit.messageHandlers.notifyDisplayBadgeOfInUC.postMessage(b):androidJavascriptInterface.notifyDisplayBadgeOfInUC(b)}catch(c){l.error("Failed to call ST500 API"),
l.dir(c),l.log("IM Alert Count:"+b)}});a.ntfyMngList=ko.observableArray([]);a.mw_count=ko.observable(-1);a.confList=ko.observableArray([]);a.confResource=ko.observableArray([]);a.confMemberResource=ko.observableArray([]);a.statusList=ko.observableArray([]);a.callList=ko.observableArray([]);a.callMode=ko.observable(CALL_MODE_INT);a.fkeyList=ko.observableArray([]);a.blinkKeys=ko.observableArray([]);a.sacsList=ko.observableArray([]);a.sacsMode=ko.observable(SRVCODE_ON);a.sc_flag=ko.observable(SCFLAG_OFF);
a.scCfwList=ko.observableArray(["","","","",""]);a.scCfwTop=ko.pureComputed(function(){for(var b=0,c=a.scCfwList().length;b<c;b++)if(""!==a.scCfwList()[b])return b;return-1});a.sacsCfwStType=ko.observable(SRVCODE_CFW_NONE);a.sacsCfwStDst=ko.observable("");a.sacsCfwStLabel=ko.pureComputed(function(){var b="";switch(a.sacsCfwStType()){case SRVCODE_CFW_ALL:b+=a.langJs().sacs_fwd_all;break;case SRVCODE_CFW_BR:b+=a.langJs().sacs_fwd_both;break;case SRVCODE_CFW_BS:b+=a.langJs().sacs_fwd_busy;break;case SRVCODE_CFW_BNA:b+=
a.langJs().sacs_fwd_bna;break;case SRVCODE_CFW_NA:b+=a.langJs().sacs_fwd_na;break;default:b+=a.langJs().sacs_none}a.sacsCfwStDst()&&(b+=" ("+a.sacsCfwStDst()+")");return b});a.scDnd=ko.observable("");a.sacsDndStatus=ko.observable(SRVCODE_DND_NONE);a.sacsDndStLabel=ko.pureComputed(function(){var b="";switch(a.sacsDndStatus()){case SRVCODE_DND_ALL:b+=a.langJs().sacs_dnd_all;break;case SRVCODE_DND_EXT:b+=a.langJs().sacs_dnd_ext;break;case SRVCODE_DND_INT:b+=a.langJs().sacs_dnd_int;break;case SRVCODE_DND_TRNS:b+=
a.langJs().sacs_dnd_trans;break;default:b+=a.langJs().sacs_none}return b});a.scMdsList=ko.observableArray(["",""]);a.scMdsTop=ko.pureComputed(function(){for(var b=0,c=a.scMdsList().length;b<c;b++)if(""!==a.scMdsList()[b])return b;return-1});a.sacsMdsStatus=ko.observable(SRVCODE_MDS_NONE);a.sacsMdsStLabel=ko.pureComputed(function(){var b="";switch(a.sacsMdsStatus()){case SRVCODE_MDS_ON:b=isJP()?b+(a.langJs().sacs_mdg_jp+" : "+a.langJs().sacs_mds_on):b+(a.langJs().sacs_mdg_ot+" : "+a.langJs().sacs_mds_on);
break;case SRVCODE_MDS_OFF:b=isJP()?b+(a.langJs().sacs_mdg_jp+" : "+a.langJs().sacs_mds_off):b+(a.langJs().sacs_mdg_ot+" : "+a.langJs().sacs_mds_off);break;default:b+=a.langJs().sacs_none}return b});a.scVmacs=ko.observable("");a.scVmown=ko.observable("");a._primeCall=ko.observable(null);a.primeCall=ko.pureComputed({read:function(){return a._primeCall()},write:function(b){a._primeCall(b);if(b)switch(b.status()){case CALL_ST_SPEAK:case CALL_ST_CSPEAK:case CALL_ST_HELD:case CALL_ST_183:startCallDrTmr();
sipPhone&&getLocalVideo()&&getLocalVideo().muted(sipPhone.getMuteStatus(a.cid).audio);break;default:stopCallDrTmr()}a._primeCall()?toneManager(b.status()):toneManager(CALL_ST_IDLE);videoSubWinManager(a._primeCall())}});a.primeCallCmpt=ko.pureComputed(function(){if(1>a.callList().length)return null;for(var b=null,c=null,d=0,e=a.callList().length;d<e;d++){var f=a.callList()[d];if(f.isActive())if(f.status()===CALL_ST_INCOM)b||(b=f);else if(f.status()===CALL_ST_HOLD||f.status()===CALL_ST_CHOLD)c?c.swapFlag()&&
(c=f):c=f;else return f}return c?c:b});a.subsc_pcc=a.primeCallCmpt.subscribe(function(b){a.primeCall(b)});a.secondCall=ko.pureComputed(function(){if(2>a.callList().length)return null;for(var b=0,c=a.callList().length;b<c;b++){var d=a.callList()[b];if(d.isActive()&&d!==a.primeCall()&&d.status()!==CALL_ST_INCOM)return d}return null});a.bkgrndCalls=ko.pureComputed(function(){for(var b=[],c=0,d=a.callList().length;c<d;c++){var e=a.callList()[c];e.status()===CALL_ST_INCOM&&e!==a.primeCall()&&b.push(e)}return b});
a.confCalls=ko.pureComputed(function(){for(var b=[],c=0,d=a.callList().length;c<d;c++){var e=a.callList()[c];e.status()===CALL_ST_INCONF&&b.push(e)}return b});a.confCallObj=ko.pureComputed(function(){for(var b=0,c=a.callList().length;b<c;b++){var d=a.callList()[b];if(d.status()===CALL_ST_CHOLD||d.status()===CALL_ST_CSPEAK)return d}return null});a.ipt_dial=ko.observable("");a.srch_dial=ko.observable("");a.ipt_dial_name=ko.pureComputed(function(){return searchCallerName(a.ipt_dial())});a.ipt_dial_focused=
ko.observable(!1).extend({rateLimit:300});a.predictList=ko.pureComputed(function(){var b=[],c=a.srch_dial(),c=convEscapeChar(c),c=c.toKatakanaCase(),c=c.toHankakuCase();if((c=deleteSpace(c))&&(a.ipt_dial_focused()||viewModel.term_type()==TERM_TYPE_GT890)){for(var d=[],e=null,f=0,h=memberList.length;f<h;f++){var g=memberList[f];if(""!=g.name()){d=[];cnt=0;d[cnt++]=g.ext();d[cnt++]=g.sipext();for(var k in g.telArr())g.telArr()[k]&&(d[cnt++]=g.telArr()[k]);for(k in g.mobArr())d[cnt++]=g.mobArr()[k];
d=d.filter(function(a,b,c){return c.indexOf(a)===b});for(k in d)if(d[k]===c)return[];e=new RegExp("^"+c+".*","i");for(k in d)if(d[k].match(e)&&!b.some(function(a){return a.text==g.getTelName(d[k])+" ("+d[k]+")"})&&(b.push({text:g.getTelName(d[k])+" ("+d[k]+")",dial:d[k]}),10<=b.length))return b;e=null;e=new RegExp(".*"+c+".*","i");d=[];cnt=0;d[cnt++]=deleteSpace(g.name());isJP()&&(d[cnt++]=deleteSpace(g.sort1.toHankakuCase()+g.sort2.toHankakuCase()));for(k in d)if(d[k].match(e)){if(g.ext()&&!b.some(function(a){return a.text==
g.name()+" ("+g.ext()+")"})&&(b.push({text:g.name()+" ("+g.ext()+")",dial:g.ext()}),10<=b.length)||g.sipext()&&!b.some(function(a){return a.text==g.name()+" ("+g.sipext()+")"})&&(b.push({text:g.name()+" ("+g.sipext()+")",dial:g.sipext()}),10<=b.length))return b;for(k in g.telArr())if(g.telArr()[k]&&!b.some(function(a){return a.text==g.getTelName(g.telArr()[k])+" ("+g.telArr()[k]+")"})&&(b.push({text:g.getTelName(g.telArr()[k])+" ("+g.telArr()[k]+")",dial:g.telArr()[k]}),10<=b.length))return b;for(k in g.mobArr())if(g.mobArr()[k]&&
!b.some(function(a){return a.text==g.name()+" ("+g.mobArr()[k]+")"})&&(b.push({text:g.name()+" ("+g.mobArr()[k]+")",dial:g.mobArr()[k]}),10<=b.length))return b}if(g.name2.match(e)&&g.telArr()[1]&&g.name2.match(e)&&!b.some(function(a){return a.text==g.name2+" ("+g.telArr()[1]+")"})&&(b.push({text:g.name2+" ("+g.telArr()[1]+")",dial:g.telArr()[1]}),10<=b.length)||g.name3.match(e)&&g.telArr()[2]&&g.name3.match(e)&&!b.some(function(a){return a.text==g.name3+" ("+g.telArr()[2]+")"})&&(b.push({text:g.name3+
" ("+g.telArr()[2]+")",dial:g.telArr()[2]}),10<=b.length))return b;e=null}}f=0;for(h=viewModel.comSpdDialList().length;f<h;f++){g=viewModel.comSpdDialList()[f];d=[];cnt=0;d[cnt++]=g.dial();for(k in d)if(d[k]===c)return b;e=new RegExp("^"+c+".*","i");for(k in d)if(d[k].match(e)&&!b.some(function(a){return a.text==g.name()+" ("+d[k]+")"})&&(b.push({text:g.name()+" ("+d[k]+")",dial:d[k]}),10<=b.length))return b;e=null;e=new RegExp(".*"+c+".*","i");d=[];cnt=0;d[cnt++]=g.name();d[cnt++]=g.sort.toHankakuCase();
for(k in d)if(d[k].match(e)&&!b.some(function(a){return a.text==g.name()+" ("+g.dial()+")"})){b.push({text:g.name()+" ("+g.dial()+")",dial:g.dial()});if(10<=b.length)return b;break}e=null}}return b});a.telSubmitType=ko.pureComputed(function(){if(isTel_CTI()){if(a.primeCall()&&a.secondCall()&&a.secondCall().bTransFlag())return TEL_SUBMIT_TRANS;if(a.primeCall()){if(a.primeCall().vmacs_status()!==VMACS_ST_NONE)return TEL_SUBMIT_CALL;if(a.primeCall().status()===CALL_ST_SPEAK)return TEL_SUBMIT_DTMF}}else if(isTel_SIP()){if(a.primeCall()&&
!a.secondCall()&&a.primeCall().bTransFlag())return TEL_SUBMIT_TRANS;if(a.primeCall()){if(a.primeCall().vmacs_status()!==VMACS_ST_NONE)return TEL_SUBMIT_CALL;if(a.primeCall().status()===CALL_ST_SPEAK||a.primeCall().status()===CALL_ST_183)return TEL_SUBMIT_DTMF}}return TEL_SUBMIT_CALL});a.telSubmitIcon=ko.pureComputed(function(){switch(a.telSubmitType()){case TEL_SUBMIT_DTMF:return"fa fa-th";case TEL_SUBMIT_TRANS:return"fa fa-share";default:return"fa fa-phone"}});a.telSubmitLabel=ko.pureComputed(function(){switch(a.telSubmitType()){case TEL_SUBMIT_DTMF:return a.langJs().label_dtmf;
case TEL_SUBMIT_TRANS:return a.langJs().label_trans;default:return a.langJs().label_call}});a.chkMakeCall=ko.pureComputed(function(){if(!a.phone_mode()||viewModel.isSipInactive()||""===a.ipt_dial()||!checkCallable(a.ipt_dial()))return!1;if(!a.primeCall()&&!a.secondCall())return!0;if(a.primeCall()&&!a.secondCall())switch(a.primeCall().status()){case CALL_ST_DIAL:return!0;case CALL_ST_SPEAK:case CALL_ST_183:if(viewModel.phone_mode()===MODE_CTI&&viewModel.term_type()===TERM_TYPE_UNKNOWN)break;return!0;
case CALL_ST_HOLD:if(viewModel.phone_mode()===MODE_SIP)return!0}else if(a.primeCall()&&a.secondCall())switch(a.primeCall().status()){case CALL_ST_DIAL:return!0;case CALL_ST_SPEAK:case CALL_ST_183:if(viewModel.phone_mode()!==MODE_CTI||viewModel.term_type()!==TERM_TYPE_UNKNOWN)return!0}return!1});a.chkEndCall=ko.pureComputed(function(){if((a.phone_mode()!=MODE_CTI||a.term_type()!=TERM_TYPE_KST)&&a.phone_mode()!=MODE_SIP)return!1;if(a.primeCall()||a.secondCall())if(a.primeCall()&&!a.secondCall())switch(a.primeCall().status()){case CALL_ST_RINGBK:case CALL_ST_SPEAK:case CALL_ST_DIAL:case CALL_ST_BUSY:case CALL_ST_CHOLD:case CALL_ST_CSPEAK:case CALL_ST_HELD:case CALL_ST_183:return!0;
case CALL_ST_INCOM:if(isTel_SIP())return!0}else if(a.primeCall()&&a.secondCall())switch(a.primeCall().status()){case CALL_ST_SPEAK:case CALL_ST_RINGBK:case CALL_ST_DIAL:case CALL_ST_BUSY:case CALL_ST_CHOLD:case CALL_ST_CSPEAK:case CALL_ST_HELD:case CALL_ST_183:return!0;case CALL_ST_INCOM:if(isTel_SIP())return!0}return!1});a.chkAnsCall=ko.pureComputed(function(){if((a.phone_mode()!=MODE_CTI||a.term_type()!=TERM_TYPE_KST)&&a.phone_mode()!=MODE_SIP||!a.primeCall()&&!a.secondCall()||a.secondCall()&&a.secondCall().swapFlag())return!1;
if(a.phone_mode()==MODE_CTI)if(a.primeCall()&&!a.secondCall())switch(a.primeCall().status()){case CALL_ST_INCOM:case CALL_ST_HOLD:if(!a.primeCall().ansResWait())return!0}else a.primeCall()&&a.secondCall();else if(a.phone_mode()==MODE_SIP)switch(a.primeCall().status()){case CALL_ST_INCOM:case CALL_ST_HOLD:if(!a.primeCall().ansResWait())return!0}return!1});a.chkHoldCall=ko.pureComputed(function(){if((a.phone_mode()!=MODE_CTI||a.term_type()!=TERM_TYPE_KST)&&a.phone_mode()!=MODE_SIP)return!1;if(a.primeCall()||
a.secondCall())if(a.primeCall()&&!a.secondCall()){if(a.primeCall().status()===CALL_ST_SPEAK)return a.primeCall().vmacs_status()!==VMACS_ST_NONE?!1:!0}else a.primeCall()&&a.secondCall();return!1});a.chkTransCall=ko.pureComputed(function(){if((a.phone_mode()!=MODE_CTI||a.term_type()!=TERM_TYPE_KST)&&a.phone_mode()!=MODE_SIP)return!1;if((a.primeCall()||a.secondCall())&&(!a.primeCall()||a.secondCall())&&a.primeCall()&&a.secondCall())switch(a.primeCall().status()){case CALL_ST_RINGBK:case CALL_ST_SPEAK:if(a.secondCall().status()===
CALL_ST_HOLD)return!0}return!1});a.chkConfHold=ko.pureComputed(function(){if(a.phone_mode()!==MODE_CTI||a.term_type()!==TERM_TYPE_KST)return!1;if(a.primeCall()||a.secondCall())if(a.primeCall()&&!a.secondCall())switch(a.primeCall().status()){case CALL_ST_SPEAK:case CALL_ST_CSPEAK:if(a.primeCall().vmacs_status()===VMACS_ST_NONE&&a.confCalls.length<CALL_CONF_MAX-1)return!0}else a.primeCall()&&a.secondCall();return!1});a.chkConfAdd=ko.pureComputed(function(){return a.phone_mode()!==MODE_CTI||a.term_type()!==
TERM_TYPE_KST?!1:(a.primeCall()||a.secondCall())&&(!a.primeCall()||a.secondCall())&&a.primeCall()&&a.secondCall()&&a.primeCall().status()===CALL_ST_SPEAK&&a.secondCall().status()===CALL_ST_CHOLD?!0:!1});a.chkPickupCall=ko.pureComputed(function(){if(a.phone_mode()!==MODE_CTI||a.term_type()!==TERM_TYPE_KST)return!1;if(a.primeCall()||a.secondCall())if(a.primeCall()&&!a.secondCall()){if(a.primeCall().status()===CALL_ST_INCOM&&a.bkgrndCalls().length)return!0}else a.primeCall()&&a.secondCall();return!1});
a.chkMakeScCall=ko.pureComputed(function(){return!a.phone_mode()||viewModel.isSipInactive()?!1:a.primeCall()||a.secondCall()?!1:!0});a.chkSendDTMF=ko.pureComputed(function(){return(a.phone_mode()==MODE_CTI&&a.term_type()==TERM_TYPE_KST||a.phone_mode()==MODE_SIP)&&a.primeCall()&&a.primeCall().vmacs_status()===VMACS_ST_NONE?a.primeCall().status()===CALL_ST_SPEAK||a.primeCall().status()===CALL_ST_183?!0:!1:!1});a.chkBlindTrans=ko.pureComputed(function(){return(a.phone_mode()==MODE_CTI&&a.term_type()==
TERM_TYPE_KST||a.phone_mode()==MODE_SIP)&&a.primeCall()&&a.primeCall().vmacs_status()===VMACS_ST_NONE?a.primeCall()&&!a.secondCall()&&a.primeCall().status()===CALL_ST_SPEAK?!0:!1:!1});a.chkSwapCall=ko.pureComputed(function(){return a.isSipActive()&&a.primeCall()&&a.secondCall()?a.primeCall().status()===CALL_ST_SPEAK?!0:!1:!1});a.chkMakeSip=ko.pureComputed(function(){return a.isSipActive()?a.chkMakeCall():!1});a.chkAnsVideo=ko.pureComputed(function(){return a.isSipActive()&&a.primeCall()&&a.primeCall().callType()===
TYPE_VIDEO_CALL&&a.primeCall().status()===CALL_ST_INCOM?a.chkAnsCall():!1});a.chkSwitchVideo=ko.pureComputed(function(){return a.isSipActive()&&!viewModel.videoSubWin()&&a.primeCall()&&a.primeCall().vmacs_status()===VMACS_ST_NONE?a.primeCall().status()===CALL_ST_SPEAK?!0:!1:!1});a.chkSwitchToVoice=ko.pureComputed(function(){return a.isSipActive()&&viewModel.videoSubWin()&&a.primeCall()?a.primeCall().callType()==TYPE_VIDEO_CALL?!0:!1:!1});a.chkSipSpeaking=ko.pureComputed(function(){return a.isSipActive()&&
a.primeCall()?a.primeCall().status()===CALL_ST_SPEAK?!0:!1:!1});a.chkMediaCfg=ko.pureComputed(function(){return!a.isSipActive()||a.primeCall()?!1:!0});a.trkacsDial=ko.observable("");a.trkacsDialDisp=ko.pureComputed(function(){return"+"+a.trkacsDial()});a.sacsPage=ko.observable(SACS_NONE);a.subsc_sp=a.sacsPage.subscribe(function(b){b!==SACS_NONE&&a.cfgPage(CFG_NONE)});a.sacsHdr=ko.pureComputed(function(){switch(a.sacsPage()){case SACS_CFW:return a.langJs().sacs_fwd;case SACS_DND:return a.langJs().sacs_dnd;
case SACS_MDS:return isJP()?a.langJs().sacs_mds_jp:a.langJs().sacs_mds_ot;default:return a.langJs().tel_sacs}});a.IndexHiden=ko.observable(!1);a.check_qvl=ko.observable(!1);a.phone_mode=ko.observable(MODE_NONE);a.term_type=ko.observable(TERM_TYPE_UNKNOWN);a.chk_insche=ko.observable(!1);a.searching=ko.observable(!1);a.ipt_confid=ko.observable("");a.myIdx=ko.observable(-1).extend({notify:"always"});a.myName=ko.observable(langTbl.unknown);a.myAs=ko.observable(0);a.myLs=ko.observable(0);a.myTs=ko.observable(0);
a.myCs=ko.observable(0);a.myMsg=ko.observable("");a.myExt=ko.observable("");a.myObj=ko.pureComputed(function(){return-1===a.myIdx()?null_user:memberList[a.myIdx()]});a._targetUsr=ko.observable(null_user);a.targetUsr=ko.pureComputed({read:function(){return a._targetUsr()},write:function(b){b&&a._targetUsr(b)}});a.mltSlMode=ko.observable(!1);a.buddyCtrlFlg=ko.observable(!1);a.listType=ko.observable(LIST_TYPE_CONTACT);a.sortType=ko.observable(SORT_TYPE_NAME);a.dialogMsg=ko.observable("");a.dialogBtns=
ko.observableArray([]);a._isStandAlone=ko.observable(!0);a.isStandAlone=ko.pureComputed({read:function(){return a._isStandAlone()},write:function(b){a._isStandAlone(b);1==b&&deleteSipPhone()}});a.isConnecting=ko.observable(!1);a.videoSubWin=ko.observable(null);a.sipRegStatus=ko.observable(SIP_NOT_REGISTERED);a.subsc_srs=a.sipRegStatus.subscribe(function(b){b!==SIP_NOT_REGISTERED&&a.sipRegErrStr("")});a.sipRegErrStr=ko.observable("");a.hasSipRegError=ko.pureComputed(function(){if(a.phone_mode()===
MODE_SIP)switch(a.sipRegStatus()){case SIP_NOT_REGISTERED:return!0}return!1});a.isSipActive=ko.pureComputed(function(){if(a.phone_mode()===MODE_SIP)switch(a.sipRegStatus()){case SIP_REGISTERED:return!0}return!1});a.isSipInactive=ko.pureComputed(function(){if(a.phone_mode()===MODE_SIP)switch(a.sipRegStatus()){case SIP_NOT_REGISTERED:case SIP_REGISTERING:return!0}return!1});a.isDialerExpand=ko.pureComputed(function(){return a.isSipActive()&&a.telSubmitType()==TEL_SUBMIT_CALL?!0:!1});a.cfgPage=ko.observable(CFG_NONE);
a.subsc_cp=a.cfgPage.subscribe(function(b){b!==CFG_NONE&&a.sacsPage(SACS_NONE)});a.cfgHdr=ko.pureComputed(function(){switch(a.cfgPage()){case CFG_MEDIA_DEVICE:return a.langJs().cfg_mediadev;default:return""}});a.isAudioDevAttached=ko.observable(!0).extend({rateLimit:500});a.isVideoDevAttached=ko.observable(!0).extend({rateLimit:500});a.audioDevice=ko.observable({label:"No Device",deviceId:"default"});a.videoDevice=ko.observable({label:"No Device",deviceId:"default"});a.tmpAudioDevice=ko.observable(null);
a.tmpVideoDevice=ko.observable(null);a.audioDeviceList=ko.observable([]);a.audioDeviceViewList=ko.pureComputed(function(){var b=a.audioDeviceList();0==b.length&&b.push({label:a.langJs().no_device,deviceId:"default"});setTimeout(function(){reloadMediaCfg()},100);return b}).extend({rateLimit:500});a.videoDeviceList=ko.observable([]);a.videoDeviceViewList=ko.pureComputed(function(){var b=a.videoDeviceList();0==b.length&&b.push({label:a.langJs().no_device,deviceId:"default"});setTimeout(function(){reloadMediaCfg()},
100);return b}).extend({rateLimit:500});a.audioDeviceId=ko.pureComputed(function(){return null==a.audioDevice()?"default":a.audioDevice().deviceId});a.videoDeviceId=ko.pureComputed(function(){return null==a.videoDevice()?"default":a.videoDevice().deviceId});a.getVmbacsDialog=ko.pureComputed(function(){if(isTel_Mobile())return VMACS_DLG_NONE;var b=a.primeCall();if(!b)return VMACS_DLG_NONE;switch(b.vmacs_status()){case VMACS_ST_NONE:case VMACS_ST_DISC:return VMACS_DLG_NONE;case VMACS_ST_WT_ACS:case VMACS_ST_START:return VMACS_DLG_LOADING;
case VMACS_ST_SRV_WT:case VMACS_ST_SRV_ANA:return VMACS_DLG_SRVCODE;case VMACS_ST_LIN_PLY:case VMACS_ST_LIN_ANA:case VMACS_ST_LIN_OPT_WT:case VMACS_ST_LIN_OPT_ANA:return VMACS_DLG_PLAYING;default:return VMACS_DLG_UNKNOWN}});a.vmTime=ko.observable("");a.vmDial=ko.observable("");a.vmName=ko.pureComputed(function(){return searchCallerName(a.vmDial())});a.vmacsOpeArr=ko.observableArray([])};
kovm.prototype.dispose=function(){this.subsc_sts.dispose();this.subsc_clk.dispose();this.subsc_dflg.dispose();this.subsc_cla.dispose();this.subsc_imalt.dispose();this.subsc_pcc.dispose();this.subsc_sp.dispose();this.subsc_srs.dispose();this.subsc_cp.dispose()};
var videovm=function(){var a=this;a.localStreams=ko.observableArray([]);a.modStreams=ko.observableArray([]);a.ScShareStream=ko.observable(null);a.hasAudio=ko.pureComputed(function(){try{if(0<a.localVideo().stream().getAudioTracks().length)return!0}catch(b){}return!1});a.hasVideo=ko.pureComputed(function(){try{if(0<a.localVideo().stream().getVideoTracks()[0].enabled)return!0}catch(b){}return!1});a.localMuted=ko.pureComputed(function(){try{if(a.localVideo().muted())return!0}catch(b){}return!1});a.cameraEnabled=
ko.pureComputed(function(){return viewModel.primeCall()?viewModel.primeCall().callType()==TYPE_VIDEO_CALL:!1});a.isVideoDevAttached=ko.pureComputed(function(){return viewModel.isVideoDevAttached()});a.sup_check=ko.observable(!1);a.dvc_ready=ko.observable(!1);a.cap_check=ko.observable(!1);a.active=ko.pureComputed(function(){var b;b=1&a.sup_check();return b&=a.dvc_ready()});a.subsc_act=a.active.subscribe(function(a){l.log("video activity: "+a)});a.videoList=ko.observableArray([]);a.viewVideoList=ko.pureComputed(function(){var b=
[];if(!viewModel.primeCall()||viewModel.primeCall().status()!==CALL_ST_SPEAK&&viewModel.primeCall().status()!==CALL_ST_183)return b;for(var c=0,d=a.videoList().length;c<d;c++){var e=a.videoList()[c];e.visible()&&(e==a.localVideo()&&b.push(e),viewModel.primeCall()&&e==viewModel.primeCall().video&&b.push(e))}return b});a.subsc_vvl=a.viewVideoList.subscribe(function(a){viewModel.videoSubWin()&&adjustFrames();muteVideoElements()});a.localVideo=ko.pureComputed(function(){for(var b=0,c=a.videoList().length;b<
c;b++){var d=a.videoList()[b];if(!0===d.islocal())return d}return null});a.visibleLocal=ko.pureComputed(function(){return a.localVideo()&&a.localVideo().visible()?!0:!1});a.vqstr_h=ko.observable("");a.vqstr_l=ko.observable("");a.vqtmp=ko.observable(VQ_MID);a.videoObj=function(a,c,d){var b=this;b.width=0;b.height=0;b.top=0;b.left=0;b.fontSz=0;b.name=ko.observable(a);b._stream=ko.observable(c);b.stream=ko.pureComputed({read:function(){return b._stream()},write:function(a){b._stream(a);viewModel.videoSubWin()&&
adjustFrames();try{viewModel.chkSipSpeaking()&&0<a.getVideoTracks()[0].enabled&&openVideoSubWin()}catch(h){}}});b.expand=ko.observable(EXPAND_NONE);b.muted=ko.observable(!1);b.vqval=ko.observable(VQ_MID);b.audioflg=function(){return!b.muted()};b.videoflg=function(){try{if(0<b.stream().getVideoTracks()[0].enabled)return!0}catch(f){}return!1};b.islocal=ko.observable(d);b.zindex=ko.pureComputed(function(){return b.expand()});b.visible=ko.observable(!0);b.visibleNameFlag=ko.observable(!1);b.visibleName=
ko.pureComputed(function(){return b.expand()==EXPAND_OTHER?!1:b.visibleNameFlag()});b.fadeinName=function(a){a.visibleNameFlag(!0)};b.fadeoutName=function(a){a.visibleNameFlag(!1)}}};videovm.prototype.dispose=function(){this.subsc_sact.dispose();this.subsc_vvl.dispose()};var dBtnObj=function(a,b){this.label=a;this.func=b},ntfyMngObj=function(a,b,c){this.type=a;this.obj=b;this.ntfy=c},viewModel=new kovm,VVM=new videovm;
function koInitialize(){ko.applyBindings(viewModel,document.getElementById("sc_loading"));ko.applyBindings(viewModel,document.getElementById("sc_login"));ko.applyBindings(viewModel,document.getElementById("sc_presence"));ko.applyBindings(viewModel,document.getElementById("dialg_mask"));ko.applyBindings(VVM,document.getElementById("video_mask"));for(i=0;i<viewModel.mktCfg().CONF_MAX;i++)viewModel.confResource.push(!0);for(i=0;i<viewModel.mktCfg().CONF_MEMBER_MAX-1;i++)viewModel.confMemberResource.push(!0);
resetStatusLib();initDialog()}
function resetStatusLib(){for(var a=viewModel.statusList.removeAll(),b=0,c=a.length;b<c;b++)delete a[b];for(var d in viewModel.mktCfg().statusTbl)a=readStatusTbl(d),viewModel.statusList.push(new statusObj(parseInt(d,10),langTbl[a[0]],a[1],a[2],a[3],a[4]));for(d in viewModel.cstmStTbl())a=viewModel.cstmStTbl()[d],viewModel.statusList.push(new statusObj(parseInt(d,10),a[0],a[1],a[2],a[3],a[4]));viewModel.statusList.sort(function(a,b){return a.priority()===b.priority()?0:a.priority()>b.priority()?1:
-1})}function readStatusTbl(a){return viewModel.mktCfg().statusTbl[a]?viewModel.mktCfg().statusTbl[a]:viewModel.mktCfg().statusTbl[0]}
function initMemberList(a){if(memberList.length)for(var b=0,c=memberList.length;b<c;b++)memberList[b].imSubWin&&(memberList[b].imSubWin.close(),memberList[b].imSubWin=null),delete memberList[b];viewModel.dispBuddyList().length&&viewModel.dispBuddyList.removeAll();viewModel.dispMemberList().length&&viewModel.dispMemberList.removeAll();viewModel.dispImLogList().length&&viewModel.dispImLogList.removeAll();for(b=0;b<CLIENT_MAX;b++)memberList[b]=new usrObj,memberList[b].index(b);c=[viewModel.dispBuddyList(),
viewModel.dispMemberList(),viewModel.dispImLogList()];for(b=0;b<CLIENT_MAX;b++)c[0].push(null_user),c[1].push(null_user),c[2].push(null_user);a&&a()}function initSpdList(a){if(viewModel.comSpdDialList().length){objs=viewModel.comSpdDialList.removeAll();for(var b=0,c=objs.length;b<c;b++)delete objs[b]}viewModel.dispComSpdDialList().length&&viewModel.dispComSpdDialList.removeAll();c=viewModel.dispComSpdDialList();for(b=0;b<SPD_DISP_MAX;b++)c.push(null_spd);a&&a()}
function deleteLogs(){for(var a=0,b=memberList.length;a<b;a++);objs=viewModel.chatLogArr.removeAll();a=0;for(b=objs.length;a<b;a++)delete objs[a];objs=viewModel.alertList.removeAll();a=0;for(b=objs.length;a<b;a++)delete objs[a];objs=viewModel.callHistList.removeAll();a=0;for(b=objs.length;a<b;a++)delete objs[a]}function dispContactList(a){chgSortType(home_sort,LIST_TYPE_CONTACT,null,function(){viewModel.targetUsr(null_user);clrSelectAllUser();viewModel.mltSlMode(!1);a&&a()})}
function statusChange(a){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):(viewModel.myAs(a),sendEvtPresenceChange())}var target_blocking=!1;function dispUserInfo(a){viewModel.targetUsr(a);$("#uinfo_wrap").css("display","block");document.getElementById("uinfo_body").scrollTop=0;$("#uinfo_wrap").stop();$("#uinfo_wrap").animate({opacity:1},300);viewModel.term_type()==TERM_TYPE_GT890&&$("#uinfo_body").addClass("scroll");target_blocking=!0}
function closeUserInfo(){-1!==viewModel.myLangIdx()&&viewModel.tmpLang().idx!==viewModel.myLangIdx()&&(viewModel.isStandAlone()?(openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]),viewModel.tmpLang(langFileList[viewModel.myLangIdx()])):sendEvtSetdata(DATA_TYPE_LANG));$("#uinfo_wrap").stop();$("#uinfo_wrap").animate({opacity:0},250);setTimeout(function(){$("#uinfo_wrap").css("display","none");viewModel.targetUsr(null_user)},250);target_blocking=!1}
function opnAddBdyDlg(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):isJP()?openDialog(langTbl.d_pre_2_jp,dlgBtnList[D_BTN_BDYADD]):openDialog(langTbl.d_pre_2_ot,dlgBtnList[D_BTN_BDYADD])}function opnRmvBdyDlg(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):isJP()?openDialog(langTbl.d_pre_3_jp+langTbl.d_pre_7_jp,dlgBtnList[D_BTN_BDYRMV]):openDialog(langTbl.d_pre_3_ot+langTbl.d_pre_7_ot,dlgBtnList[D_BTN_BDYRMV])}
function addBuddy(){-1!==viewModel.targetUsr().index()&&(viewModel.targetUsr().tmpBuddy(1),updtBuddyListReq())}function removeBuddy(){-1!==viewModel.targetUsr().index()&&(viewModel.targetUsr().tmpBuddy(0),updtBuddyListReq())}function selectUser(a){viewModel.mltSlMode()&&(a.isSelect()?(a.isSelect(!1),viewModel.selUserList.remove(a)):(a.isSelect(!0),viewModel.selUserList.push(a)))}
function selectUsers(a,b){if(viewModel.mltSlMode()){var c=[];i=0;for(len=memberList.length;i<len;i++){var d=memberList[i];""!=d.name()&&d.index()!==viewModel.myIdx()&&(b&&!d.isBuddy()||d.key()!==a||c.push(d))}var e=1;i=0;for(len=c.length;i<len;i++)d=c[i],e*=!0===d.isSelect();if(e)for(i=0,len=c.length;i<len;i++)d=c[i],d.isSelect()&&(d.isSelect(!1),viewModel.selUserList.remove(d));else{e=[];i=0;for(len=c.length;i<len;i++)d=c[i],d.isSelect()||(d.isSelect(!0),e.push(d));viewModel.selUserList.push.apply(viewModel.selUserList,
e)}}}function clrSelectAllUser(){for(var a=0,b=memberList.length;a<b;a++)memberList[a].isSelect(!1);viewModel.selUserList.removeAll()}
function dispTextChat(a){viewModel.targetUsr(a);isJP()||(viewModel.targetUsr().imStatus=IM_STATUS_DISC);deleteImAlert(a);deleteDsktpNotification(NOTIF_TYPE_IM,a);if(!in_chat)try{viewModel.phone_mode()==MODE_ST500&&(iOS_Device()?webkit.messageHandlers.notifyOpenImOfInUC.postMessage(""+a.index()):androidJavascriptInterface.notifyOpenImOfInUC(""+a.index()))}catch(d){l.error("Failed to call ST500 API"),l.dir(d)}in_chat=!0;if(isSmartDevice()){$("#im_wrap").css("display","block");a=document.getElementsByClassName("newmes_block");
var b=null,c=a.length;if(c)for(i=0;i<c;i++)if("none"!=$(a[i]).css("display")){b=a[i];break}b?document.getElementById("im_msgline").scrollTop=b.offsetTop-5:document.getElementById("im_msgline").scrollTop=document.getElementById("im_msgline").scrollHeight;adjustImWindow();$("#im_window").stop();$("#im_window").animate({right:"0"},300)}else!a.imSubWin||a.imSubWin.closed?(a.imSubWin=null,b=(screen.width-380)/2,c=(screen.height-600)/2,window.open("sub_im.htm?id="+a.index(),""," width=380,height=600,left="+
b+",top="+c+",resizable")):a.imSubWin.focus(),target_blocking||viewModel.targetUsr(null_user)}function closeTextChat(){closeSelEmoji();$("#im_ta_1").val("");isJP()||(viewModel.targetUsr().imStatus=IM_STATUS_DISC);$("#im_window").stop();$("#im_window").animate({right:"-100%"},250);setTimeout(function(){$("#im_wrap").css("display","none")},250);imOpened(viewModel.targetUsr());target_blocking||viewModel.targetUsr(null_user);in_chat=!1;viewModel.listType()===LIST_TYPE_LOGIM&&sortUsrData()}
function isChattingWith(a){return in_chat&&viewModel.targetUsr()===a&&!is_bkgrnd}function adjustImWindow(){var a=document.getElementById("im_window");460>$(window).width()?$(a).css("maxWidth","none"):viewModel.term_type()==TERM_TYPE_GT890?$(a).css("maxWidth","600px"):$(a).css("maxWidth","400px")}function dispSelEmoji(){$(".im_input_normal").css("display","none");$(".im_input_emoji").css("display","block")}
function closeSelEmoji(){$(".im_input_emoji").css("display","none");$(".im_input_normal").css("display","block")}function dispDiagSaveLog(){-1!==viewModel.targetUsr().imLastIdx()&&openDialog(langTbl.d_pre_9,dlgBtnList[D_BTN_SAVE_IM])}
function saveLogAsText(a){if(-1!==a.index()){var b;b=""+(a.name()+CRLF);i=0;for(len=viewModel.chatLogArr().length;i<len;i++)if(log=viewModel.chatLogArr()[i],log.user===a){log.dFlg()&&(b+=CRLF,b+="============= << "+log.date()+" >> ============="+CRLF,b+=CRLF);if(log.type==CHAT_TYPE_S)switch(b+="----------------------------------------"+CRLF,b+=log.time,b+=" ["+viewModel.myName()+"]",log.status()){case CHAT_ST_UNSENT:b+=" : "+langTbl.unsent+CRLF;break;case CHAT_ST_PENDING:b+=" : "+langTbl.pending+
CRLF;break;case CHAT_ST_INVITING:case CHAT_ST_SENDING:b+=" : "+langTbl.sending+CRLF;break;case CHAT_ST_ERROR:b+=" : "+langTbl.error+CRLF;break;case CHAT_ST_RESENT:b+=" : "+langTbl.resent+CRLF;break;default:b+=CRLF}else b+="----------------------------------------"+CRLF,b+=log.time,b+=" ["+log.user.name()+"]"+CRLF;b+=replaceCRLF(reverseHtmlTag(deleteHtmlTag(log.html)))+CRLF;b+=CRLF}a=new Blob([b],{type:"text/plain"});b="log";var c=new Date,d=c.getFullYear(),e=c.getMonth()+1,f=c.getDate(),h=c.getHours(),
g=c.getMinutes();c.getSeconds();b=b+d+("0"+e).slice(-2);b+=("0"+f).slice(-2);b+=("0"+h).slice(-2);b+=("0"+g).slice(-2);b+=".txt";window.navigator.msSaveBlob?window.navigator.msSaveBlob(a,b):(c=document.createElement("a"),c.href=URL.createObjectURL(a),c.target="_blank",c.download=b,c.click())}}
function sendChat(a,b){if(-1!==a.index()&&b)if(1==im_ime_enable)im_ime_wait=!0;else{im_ime_wait=!1;if(viewModel.isStandAlone()){for(var c=0,d=viewModel.chatLogArr().length,e=0;e<d;e++)viewModel.chatLogArr()[e].status()==CHAT_ST_UNSENT&&c++;if(c>=CHAT_SRVPEND_MAX){openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]);return}}html=b;html=replaceHtmlTag(html);isJP()&&(html=replaceCallBack(html),html=replaceEmoji(html));html=replaceConfURL(html);html=setAutoLink(html);b=replaceCRLF(b);var c=getUuid(),
f=getTimeStamp(),c=new chatObj(a,CHAT_TYPE_S,b,html,f,c,CHAT_ST_UNSENT);!1!==pushChatLogArry(c)&&(a.imUnsent.push(c),viewModel.isStandAlone()?!a.imSubWin||a.imSubWin.closed?openDialog(langTbl.d_pre_5,dlgBtnList[D_BTN_CNFIM]):(c=a.imSubWin,c.openDialog(langTbl.d_pre_5,c.dlgBtnList[c.D_BTN_CNFIM])):a.imStatus!==IM_STATUS_CONN?(c.status(CHAT_ST_INVITING),a.imStatus===IM_STATUS_DISC&&(sendImInvite(a),a.imStatus=IM_STATUS_WAIT,a.imSesTmr=setTimeout(function(a){var b=[];e=0;for(d=a.imUnsent.length;e<d;e++)b.push(a.imUnsent[e]);
e=0;for(d=b.length;e<d;e++)recvImSendErr(a,b[e]);a.imStatus=IM_STATUS_DISC},3E4,a))):(c.status(CHAT_ST_SENDING),sendJsonData({type:"event",event:"ims",idx:a.index(),mid:c.mid,tm:c.stmp,b:b}),c.timeout=setTimeout(function(a,b){recvImSendErr(a,b)},3E4,a,c)),document.getElementById("im_msgline").scrollTop=document.getElementById("im_msgline").scrollHeight,$("#im_ta_1").val(""))}}function dispResend(a){a.click(!0);setTimeout(function(a){a.click(!1)},3E3,a)}
function resendChatManu(a){a.click(!1);a.status(CHAT_ST_RESENT);sendChat(a.user,a.ori)}
function sendChatSelAll(a){if(!viewModel.selUserList().length)return!1;if(!isJP()&&viewModel.selUserList().length>CHAT_SRVPEND_MAX)return openDialog(langTbl.d_create_4_2,dlgBtnList[D_BTN_CNFIM]),!1;if(viewModel.isStandAlone())return openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]),!1;if(!a)return!1;html=a;html=replaceHtmlTag(html);isJP()&&(html=replaceCallBack(html),html=replaceEmoji(html));html=replaceConfURL(html);html=setAutoLink(html);a=replaceCRLF(a);var b=[],c=[],d=getUuid(),e=getUuid(),
f=getTimeStamp();i=0;for(len=memberList.length;i<len;i++){var h=memberList[i];if(-1!==h.index()&&h.isSelect()){var g=new chatObj(h,CHAT_TYPE_S,a,html,f,e,CHAT_ST_UNSENT);!1!==pushChatLogArry(g)&&(h.imUnsent.push(g),viewModel.isStandAlone()?openDialog(langTbl.d_pre_5,dlgBtnList[D_BTN_CNFIM]):h.imStatus!==IM_STATUS_CONN?(g.status(CHAT_ST_INVITING),h.imStatus===IM_STATUS_DISC&&(b.push(h.index()),h.imInvId=d,h.imStatus=IM_STATUS_WAIT,h.imSesTmr=setTimeout(function(a){var b=[];i=0;for(len=a.imUnsent.length;i<
len;i++)b.push(a.imUnsent[i]);i=0;for(len=b.length;i<len;i++)recvImSendErr(a,b[i]);a.imStatus=IM_STATUS_DISC},3E4,h))):(c.push(h.index()),g.status(CHAT_ST_SENDING),g.timeout=setTimeout(function(a,b){recvImSendErr(a,b)},3E4,h,g)))}}b.length&&sendJsonData({type:"event",event:"ims",idxs:b,mid:d,tm:f,b:UCSIM_INVITE});c.length&&sendJsonData({type:"event",event:"ims",idxs:c,mid:e,tm:f,b:a});$("#im_ta_2").val("");return!0}
function recvChat(a,b,c,d){b=replaceConfURL(b);var e;e=replaceHtmlTag(b);isJP()&&(e=replaceCallBack(e),e=replaceEmoji(e));e=setAutoLink(e);e=new chatObj(a,CHAT_TYPE_R,b,e,c,d,CHAT_ST_SUCCESS);if(!1!==pushChatLogArry(e)&&(isChattingWith(a)?document.getElementById("im_msgline").scrollTop=document.getElementById("im_msgline").scrollHeight:(obj=new alertObj(ALERT_IM_NEW,c,a,e),setAlert(obj),updateImNew(a,e),viewModel.listType()===LIST_TYPE_LOGIM&&sortUsrData()),setNotification(NOTIF_TYPE_IM,a,b),viewModel.phone_mode()==
MODE_ST500)){a=JSON.stringify({id:""+d,from:a.name(),message:b,index:""+a.index(),isChatting:in_chat&&viewModel.targetUsr()==a?!0:!1});try{iOS_Device()?webkit.messageHandlers.notifyIncomingImOfInUC.postMessage(a):androidJavascriptInterface.notifyIncomingImOfInUC(a)}catch(f){l.error("Failed to call ST500 API"),l.dir(f)}}}
function recvImSendErr(a,b){for(var c=0,d=a.imUnsent.length;c<d;c++)if(a.imUnsent[c]===b){a.imUnsent.splice(c,1);break}for(var e=!1,d=viewModel.chatLogArr().length,c=0;c<d;c++)if(b===viewModel.chatLogArr()[c]){e=!0;break}!1!==e&&(b.status(CHAT_ST_ERROR),isChattingWith(a)||(c=new alertObj(ALERT_IM_NEW,b.stmp,a,b),setAlert(c),updateImNew(a,b),viewModel.listType()===LIST_TYPE_LOGIM&&sortUsrData()))}
function pushChatLogArry(a){for(var b=viewModel.chatLogArr().length,c=0;c<b;c++)if(isSameChat(viewModel.chatLogArr()[c],a))return viewModel.chatLogArr()[c].type===CHAT_TYPE_S?viewModel.chatLogArr()[c].status(a.status()):viewModel.chatLogArr()[c].status()===CHAT_ST_OPENED&&a.status()!==CHAT_ST_OPENED&&(l.log(">>> re-opend from id:"+a.user.index()+",mid:"+a.mid+",tm:"+a.stmp),sendJsonData({type:"event",event:"imopnd",data:[{idx:a.user.index(),mid:a.mid,tm:a.stmp}]})),!1;if(viewModel.chatLogArr().length>=
CHAT_LOG_MAX){for(var d=viewModel.chatLogArr.shift(),c=0,b=d.user.imUnsent.length;c<b;c++)if(d.user.imUnsent[c]===d){d.user.imUnsent.splice(c,1);break}deleteOneImAlert(d)}viewModel.chatLogArr.push(a);viewModel.listType()===LIST_TYPE_LOGIM&&sortUsrData();return!0}function updateImNew(a,b){updtSubWinImNew(a,b)}
function updtImSubWin(a,b,c){if(a&&a.imSubWin){var d=a.imSubWin;a=getChatArrByUser(a).slice();var e=d.viewModel.chatLogArr(),f=!1;if(b)for(var h=0,g=e.length;h<g;h++)if(e[h]==b){e[h]=$.extend(!0,{},b);d.viewModel.chatLogArr.valueHasMutated();f=!0;break}f||d.viewModel.chatLogArr(a);c&&d.scrollToNewMessage()}}function updtSubWinImNew(a,b){a&&a.imSubWin&&updtImSubWin(a,b,!0)}
function getChatArrByUser(a){var b=[],c;if(!viewModel)return b;for(var d=0,e=viewModel.chatLogArr().length;d<e;d++)c=viewModel.chatLogArr()[d],c.user===a?b.push(c):b.push(null_chat);return b}function sendImInvite(a){if(-1!==a.index()&&!isJP()){var b=getUuid(),c=getTimeStamp();a.imInvId=b;sendJsonData({type:"event",event:"ims",idx:a.index(),mid:b,tm:c,b:UCSIM_INVITE})}}
function recvUCSIM(a,b,c,d){if(isJP())return!1;switch(b){case UCSIM_INVITE:return recvImInvite(a,b,c,d),!0;case UCSIM_ACCEPT:case UCSIM_REJECT:if(65536<=d)return recvImInvRes(a,b,c,d),!0;break;case UCSIM_END:return a.imStatus=IM_STATUS_DISC,!0;case UCSIM_ACTIVITY:case UCSIM_IDLE:return!0}return!1}
function recvImInvite(a,b,c,d){-1===a.index()||isJP()||b!=UCSIM_INVITE||(c=getTimeStamp(),a.imStatus=IM_STATUS_CONN,a.imInvId=d,b=""+(parseInt(d,10)+65536),sendJsonData({type:"event",event:"ims",idx:a.index(),mid:b,tm:c,b:UCSIM_ACCEPT}),sendChatAftAccept(a))}
function recvImInvRes(a,b,c,d){isJP()||b!=UCSIM_ACCEPT||parseInt(d,10)!==parseInt(a.imInvId,10)+65536?isJP()||b!=UCSIM_REJECT||parseInt(d,10)!==parseInt(a.imInvId,10)+65536||(a.imStatus=IM_STATUS_DISC,a.imInvId=0,clearTimeout(a.imSesTmr),setIMErrAftReject(a)):(a.imStatus=IM_STATUS_CONN,a.imInvId=0,clearTimeout(a.imSesTmr),sendChatAftAccept(a))}
function sendChatAftAccept(a){if(-1!==a.index())for(i=0,len=a.imUnsent.length;i<len;i++)chat=a.imUnsent[i],chat.status()===CHAT_ST_INVITING&&(chat.status(CHAT_ST_SENDING),sendJsonData({type:"event",event:"ims",idx:a.index(),mid:chat.mid,tm:chat.stmp,b:chat.ori}),chat.timeout=setTimeout(function(a,c){recvImSendErr(a,c)},3E4,a,chat))}
function setIMErrAftReject(a){i=0;for(len=a.imUnsent.length;i<len;i++)chat=a.imUnsent[i],chat.status()===CHAT_ST_INVITING&&(clearTimeout(chat.timeout),recvImSendErr(a,chat))}function sendImEndToAll(){if(!isJP()){var a=[],b=getUuid(),c=getTimeStamp();i=0;for(len=memberList.length;i<len;i++){var d=memberList[i];-1!==d.index()&&d.imStatus!==IM_STATUS_DISC&&(d.imStatus=IM_STATUS_DISC,d.imInvId=0,a.push(d.index()))}a.length&&sendJsonData({type:"event",event:"ims",idxs:a,mid:b,tm:c,b:UCSIM_END})}}
function convDateStr(a,b,c){if(!viewModel)return"";b=("0"+b).slice(-2);c=("0"+c).slice(-2);var d=a+"/"+b+"/"+c,e=(new Date(d)).getDay();switch(date_fmt){case 0:d=b+"/"+c+"/"+a;break;case 2:d=c+"/"+b+"/"+a}void 0!==viewModel.langJs().weekTbl[e]&&(d+=" ("+viewModel.langJs().weekTbl[e]+")");return d}function convDateComp(a,b,c){b=("0"+b).slice(-2);c=("0"+c).slice(-2);return a+b+c}function convTimeStr(a,b,c){a=("0"+a).slice(-2);b=("0"+b).slice(-2);("0"+c).slice(-2);return a+":"+b}
function getUuid(){if(isJP())return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"==a?b:b&3|8).toString(16)});65535<=tmp_mid?tmp_mid=1:tmp_mid++;return""+tmp_mid}function getTimeStamp(){var a=new Date,b=a.getTimezoneOffset(),a=a.getTime();return Math.floor((a-6E4*b)/1E3)}function convEmjGif(a){return"emj_"+("0"+(a+1)).slice(-2)+".gif"}
function setCallBack(a){if(viewModel.myExt()){var b=a.val(),b=b+"<t"+viewModel.myExt()+"/>";b.length<=CHAT_INPUT_MAX&&a.val(b)}}function setEmoji(a,b){var c=a.val(),c=c+"(_"+emojiArr[b]+"_)";c.length<=CHAT_INPUT_MAX&&a.val(c);closeSelEmoji()}function replaceCRLF(a){return a=a.replace(/\n/g,"\r\n").replace(/\r\r/g,"\r")}function replaceHtmlTag(a){return a=a.replace(RegExp("<","g"),"&lt;")}function reverseHtmlTag(a){return a=a.replace(RegExp("&lt;","g"),"<")}
function replaceCallBack(a){var b=a.match(/&lt;t[0-9]+\/>/g);if(b)for(var c=0,d=b.length;c<d;c++){var e=b[c],e=e.replace("&lt;t",""),e=e.replace("/>","");a=a.replace(b[c],"<span class='im_callback' onClick=openDialer('"+e+"') data-bind=\"style:{cursor:$root.phone_mode()?'pointer':'default'}\">"+e+"</span>")}return a}
function replaceEmoji(a){i=0;for(len=emojiArr.length;i<len;i++){key="\\(_"+emojiArr[i]+"_\\)";var b=new RegExp(key,"g");switch(!0){case 25<=i&&34>=i:a=a.replace(b,"<img class='im_emoji_l' src=\"./img/"+convEmjGif(i)+'">');break;default:a=a.replace(b,"<img class='im_emoji' src=\"./img/"+convEmjGif(i)+'">')}}return a}
function replaceConfURL(a){return a="0"==httpsPort?"80"==httpPort?a.replace(/(http|https):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>)\/uc\/conf\?id=([A-Za-z0-9]+)/g,"http://"+SrvAddr+"/uc/conf?id=$2"):a.replace(/(http|https):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>)\/uc\/conf\?id=([A-Za-z0-9]+)/g,"http://"+SrvAddr+":"+httpPort+"/uc/conf?id=$2"):"443"==httpsPort?a.replace(/(http|https):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>)\/uc\/conf\?id=([A-Za-z0-9]+)/g,"https://"+SrvAddr+"/uc/conf?id=$2"):
a.replace(/(http|https):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>)\/uc\/conf\?id=([A-Za-z0-9]+)/g,"https://"+SrvAddr+":"+httpsPort+"/uc/conf?id=$2")}
function setAutoLink(a){var b,c;if(b=a.match(/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g))for(var d=0,e=b.length;d<e;d++)c=b[d],null!==c.match(/https:\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>)\/uc\/conf\?id=([A-Za-z0-9]+)/g)?viewModel.term_type()!==TERM_TYPE_GT890&&(c=viewModel.phone_mode()===MODE_ST500?"<span class='im_link'><a onClick=\"openConfURL('"+c+"&u="+user_id+"&m=st500')\">"+c+"</a></span>":"<span class='im_link'><a onClick=\"openConfURL('"+c+"&u="+user_id+"')\">"+
c+"</a></span>",a=a.replace(b[d],c)):(c="<span class='im_link'><a onClick=\"window.open('"+c+"')\">"+c+"</a></span>",a=a.replace(b[d],c));if(b=a.match(/[\w-]@[\w\.-]+\.\w{2,}/g))if(b=a.match(/[\w-]+@[\w\.-]+\.\w{2,}/g))for(d=0,e=b.length;d<e;d++)c=b[d],c="<span class='im_link' onClick=\"sendMail('"+c+"')\">"+c+"</span>",a=a.replace(b[d],c);return a}function deleteHtmlTag(a){return a=a.replace(/<("[^"]*"|'[^']*'|[^'">])*>/g,"")}function deleteSpace(a){return a=a.replace(/\s/g,"")}
function convEscapeChar(a){return a=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function dispMenu(a){$("#menu_mask").css("opacity","0");$("#menu_mask").css("display","block");$(a).css("display","block");$("#menu_mask").stop();$("#menu_mask").animate({opacity:1},200)}function closeMenu(a){$("#menu_mask").stop();$("#menu_mask").animate({opacity:"0"},250);setTimeout(function(){$(".menu_body").css("display","none");$("#menu_mask").css("display","none");$("#menu_mask").css("opacity","1");a&&a()},250)}
function dispUserList(){chgSortType(SORT_TYPE_NAME,LIST_TYPE_TELBOOK);viewModel.targetUsr(null_user);clrSelectAllUser();viewModel.mltSlMode(!1)}function updateMemberList(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):openDialog(langTbl.d_pre_6,dlgBtnList[D_BTN_UPDT_USR])}function sendUpdateUser(){setLoadingOnList(function(){clrDisplayUsrList();initUserData(function(){sendEvtGetdata(DATA_TYPE_USER)})})}
function chgBuddy(a){viewModel.buddyCtrlFlg()&&a.tmpBuddy(1-a.tmpBuddy())}function chgBuddys(a){if(viewModel.buddyCtrlFlg()){var b=[];i=0;for(len=memberList.length;i<len;i++){var c=memberList[i];""!=c.name()&&c.index()!==viewModel.myIdx()&&c.index()!==viewModel.myIdx()&&c.key()===a&&b.push(c)}a=1;i=0;for(len=b.length;i<len;i++)c=b[i],a*=c.tmpBuddy();if(a)for(i=0,len=b.length;i<len;i++)c=b[i],c.tmpBuddy(0);else for(i=0,len=b.length;i<len;i++)c=b[i],c.tmpBuddy(1)}}
function resetBuddy(){for(var a=0,b=memberList.length;a<b;a++){var c=memberList[a];-1!==c.index()&&c.tmpBuddy(c.isBuddy())}}function updtBuddy(a){for(var b=0,c=memberList.length;b<c;b++){var d=memberList[b];-1!==d.index()&&(a==ACT_ADD_BUDDY&&d.isBuddy()<d.tmpBuddy()||a==ACT_DEL_BUDDY&&d.isBuddy()>d.tmpBuddy())&&d.isBuddy(d.tmpBuddy())}sortData()}
function startBdyCtrl(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):viewModel.buddyCtrlFlg()?cancelBdyCtrl():($(".tbk_name").animate({left:"25px"},300),$(".tbk_idx_str").animate({left:"25px"},300),viewModel.buddyCtrlFlg(!0))}
function endBdyCtrl(){viewModel.buddyCtrlFlg()&&(viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):isBdyChged()?isJP()?openDialog(langTbl.d_pre_1_jp+langTbl.d_pre_7_jp,dlgBtnList[D_BTN_BDYCTRL]):openDialog(langTbl.d_pre_1_ot+langTbl.d_pre_7_ot,dlgBtnList[D_BTN_BDYCTRL]):cancelBdyCtrl())}
function cancelBdyCtrl(){viewModel.buddyCtrlFlg()&&(resetBuddy(),$(".tbk_name").animate({left:"0px"},300),$(".tbk_idx_str").animate({left:"0px"},300),setTimeout(function(){viewModel.buddyCtrlFlg(!1)},300))}function isBdyChged(){for(var a=0,b=memberList.length;a<b;a++){var c=memberList[a];if(-1!==c.index()&&c.tmpBuddy()!==c.isBuddy())return!0}return!1}
function updtBuddyListReq(){if(viewModel.isStandAlone())openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]);else{for(var a=[],b=[],c=0,d=memberList.length;c<d;c++){var e=memberList[c];-1!==e.index()&&e.tmpBuddy()!==e.isBuddy()&&(e.tmpBuddy()?a.push(e.index()):b.push(e.index()))}0<b.length&&sendEvtBuddyUpdate(ACT_DEL_BUDDY,b);0<a.length&&sendEvtBuddyUpdate(ACT_ADD_BUDDY,a)}}
function dispComSpdDial(){chgSortType(SORT_TYPE_NAME,LIST_TYPE_COMSPD,null,function(){viewModel.comSpdDialList().length||sendUpdateSpd()});viewModel.targetUsr(null_user);clrSelectAllUser();viewModel.mltSlMode(!1)}function updateSpeedDial(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):openDialog(langTbl.d_pre_6,dlgBtnList[D_BTN_UPDT_SPD])}
function sendUpdateSpd(){setLoadingOnList(function(){clrDisplaySpdList();initSpdList(function(){viewModel.spdPageNo(1);viewModel.spdPageMax(1);sendEvtGetdata(DATA_TYPE_SPD)})})}function loadSpeedDial(a){l.log(a+"/"+viewModel.spdPageMax());if(1>a||a>viewModel.spdPageMax())return 0;document.getElementById("list_body").scrollTop=0;setLoadingOnList(function(){sortSpdData(a,function(){clrLoadingOnList()})})}
function dispConfCreate(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):chkCallStatus(function(){clrSelectAllUser();viewModel.mltSlMode(!0);setRandomId();chgSortType(SORT_TYPE_NAME,LIST_TYPE_INVCONF,function(){$("#cnfcr_wrap").css("display","block");$("#cnfcr_wrap").css("opacity","1")})})}function closeConfCreate(){dispContactList(function(){$("#cnfcr_wrap").css("opacity","0");$("#cnfcr_wrap").css("display","none")})}
function dispInviteConf(){$("#cnfcr_wrap").stop();$("#cnfcr_wrap").animate({opacity:"0"},200);setTimeout(function(){$("#cnfcr_wrap").css("display","none")},200)}function closeInviteConf(){$("#cnfcr_wrap").stop();$("#cnfcr_wrap").css("display","block");$("#cnfcr_wrap").animate({opacity:"1"},200)}
function rsrvConf(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):viewModel.ipt_confid()&&checkConfidErr()?viewModel.confList().length>=viewModel.mktCfg().CONF_MAX?openDialog(langTbl.d_create_2,dlgBtnList[D_BTN_CNFIM]):viewModel.selUserList().length>viewModel.mktCfg().CONF_MEMBER_MAX-1?openDialog(langTbl.d_create_4,dlgBtnList[D_BTN_CNFIM]):chkCallStatus(function(){sendJsonData({type:"event",event:"conf-rsReq",confId:viewModel.ipt_confid()})}):openDialog(langTbl.d_create_5,
dlgBtnList[D_BTN_CNFIM])}function onConfRsRes(a){var b=a.res;l.log("reserve-res: "+b+",self:"+a.self);switch(b){case "success":startConf();return;case "duplicate":a=langTbl.d_create_1;break;case "non-capacity":a=langTbl.d_create_2;break;case "error":a=langTbl.d_error;break;case "no-license":a=langTbl.d_create_2;break;default:return}openDialog(a,dlgBtnList[D_BTN_CNFIM])}
function startConf(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):viewModel.selUserList().length>viewModel.mktCfg().CONF_MEMBER_MAX-1?openDialog(langTbl.d_create_4,dlgBtnList[D_BTN_CNFIM]):chkCallStatus(function(){var a,b;b="0"==httpsPort?"80"==httpPort?"http://"+SrvAddr:"http://"+SrvAddr+":"+httpPort:"443"==httpsPort?"https://"+SrvAddr:"https://"+SrvAddr+":"+httpsPort;b+="/uc/conf?id="+viewModel.ipt_confid();a=isJP()?"https://WebRTCIP/uc/conf?id="+viewModel.ipt_confid():
b;b+="&u="+user_id;b+="&p="+user_pw;viewModel.phone_mode()==MODE_ST500&&(b+="&m=st500");subWin=window.open(b);b=""+(langTbl.invite_im1+"\n");b=b+(a+"\n")+langTbl.invite_im2;sendChatSelAll(b);closeConfCreate()})}function checkConfidErr(){text=$("#cnfcr_iptid").val();new_text=text.replace(/[^0-9A-Za-z]/g,"");if(new_text!=text)return $("#cnfcr_ipterr_wrap").css("display","block"),!1;$("#cnfcr_ipterr_wrap").css("display","none");return!0}
function clearConfId(){viewModel.ipt_confid("");$("#cnfcr_iptid").val("");checkConfidErr()}function setRandomId(){var a=("00"+viewModel.myIdx()).slice(-3),b="xxaxxbxxcxxxxxxx".replace(/[abcx]/g,function(b){switch(b){case "a":return a[0];case "b":return a[1];case "c":return a[2];default:return(36*Math.random()|0).toString(36)}});viewModel.ipt_confid(b);$("#cnfcr_iptid").val(b);checkConfidErr()}
function openInScheduler(){if(0==viewModel.chk_insche())l.log("TCP port number for web programming has not been set.");else{var a;a=SrvAddr?SrvAddr:location.host;"0"===webPt?(a="http://"+a,"80"!==httpPort&&(a+=":"+httpPort)):(a="https://"+a,"443"!==webPt&&(a+=":"+webPt));a+="/html/apps/InScheduler/conference.cgi?relatedSession="+SessionID;window.open(a)}}
function checkInScheduler(){"0"===webPt&&"0"===httpPort?viewModel.chk_insche(!1):""===SessionID?viewModel.chk_insche(!1):viewModel.chk_insche(!0)}
function dispBroadcastMsg(){viewModel.isStandAlone()?openDialog(langTbl.d_error_9,dlgBtnList[D_BTN_CNFIM]):(clrSelectAllUser(),viewModel.mltSlMode(!0),chgSortType(SORT_TYPE_NAME,LIST_TYPE_BRDMSG,function(){$("#brdmsg_wrap").css("display","block");$("#brdmsg_wrap").css("opacity","1")}),viewModel.term_type()==TERM_TYPE_GT890&&$("div#brdmsg_wrap .im_body").addClass("scroll"))}
function closeBroadcastMsg(){closeSelEmoji();$("#im_ta_2").val("");dispContactList(function(){$("#brdmsg_wrap").css("opacity","0");$("#brdmsg_wrap").css("display","none")})}function dispInviteBrdMsg(){$("#brdmsg_wrap").stop();$("#brdmsg_wrap").animate({opacity:"0"},200);setTimeout(function(){$("#brdmsg_wrap").css("display","none")},250)}function closeInviteBrdMsg(){$("#brdmsg_wrap").stop();$("#brdmsg_wrap").css("display","block");$("#brdmsg_wrap").animate({opacity:"1"},200)}
function dispBroadcastMail(){clrSelectAllUser();viewModel.mltSlMode(!0);chgSortType(SORT_TYPE_NAME,LIST_TYPE_BRDMAIL,function(){$("#brdmail_wrap").css("display","block");$("#brdmail_wrap").css("opacity","1")});viewModel.term_type()==TERM_TYPE_GT890&&$("div#brdmail_wrap .win_body").addClass("scroll")}function closeBroadcastMail(){dispContactList(function(){$("#brdmail_wrap").css("opacity","0");$("#brdmail_wrap").css("display","none")})}
function dispInviteBrdMail(){$("#brdmail_wrap").stop();$("#brdmail_wrap").animate({opacity:"0"},200);setTimeout(function(){$("#brdmail_wrap").css("display","none")},200)}function closeInviteBrdMail(){$("#brdmail_wrap").stop();$("#brdmail_wrap").css("display","block");$("#brdmail_wrap").animate({opacity:"1"},200)}
function showMailList(a){a=$(a.parentElement).children(".brdmail_list");"none"===$(a).css("display")?(closeMailList(),$(a).css("display","block"),$(a).css("opacity","1")):closeMailList()}function selectMail(a,b){a.mail(b)}function closeMailList(a){$(".brdmail_list").css("display","none");$(".brdmail_list").css("opacity","0")}function dispVerInfo(){document.getElementById("ver_val").innerHTML=appVer;$("#ver_mask").css("display","block")}
function closeVerInfo(){$("#ver_mask").css("display","none")}function logout(){openDialog(langTbl.d_pre_8+langTbl.d_pre_10,dlgBtnList[D_BTN_LOGOUT])}function isJP(){if(!viewModel)return!1;switch(viewModel.market()){case 1:return!0;default:return!1}}function matchStatus(a,b,c){switch(viewModel.market()){case 1:return 0<b?c.no()===a:0===c.no();default:return c.no()===a}}
function getPreBgcolor(a,b){switch(viewModel.market()){case 1:return"color_"+a.color()+"_rv";default:return 0<b?"color_"+a.color()+"_rv":"color_gray_rv"}}function checkOffline(a){if(-1===a.index()||void 0===a.lineSt()||void 0===a.appSt()||!a.lineSt())return!0;switch(viewModel.market()){case 1:if(6===a.appSt()||7===a.appSt())return!0}return!1}function enaSortName(){return isLogList()?!1:!0}function enaSortGroup(){return isLogList()?!1:getDataType(viewModel.listType())===DATA_TYPE_USER?!0:!1}
function enaSortStatus(){return isLogList()?!1:isBuddyListType(viewModel.listType())?!0:!1}function enaSortIndex(){return isLogList()?!1:getDataType(viewModel.listType())===DATA_TYPE_SPD?!0:!1}function isLogList(){switch(viewModel.listType()){case LIST_TYPE_LOGIM:case LIST_TYPE_LOGCALL:return!0;default:return!1}}function getDataType(a){switch(a){case LIST_TYPE_COMSPD:return DATA_TYPE_SPD;case LIST_TYPE_LOGCALL:return DATA_TYPE_HIST;default:return DATA_TYPE_USER}}
function isVisibleIndex(){var a=viewModel.listType(),b=viewModel.sortType();if(viewModel.IndexHiden())return!1;switch(a){case LIST_TYPE_COMSPD:if(b===SORT_TYPE_INDEX)return!1}return!0}function chgIndexHide(){!0===this.IndexHiden()?this.IndexHiden(!1):this.IndexHiden(!0)}
function setNotification(a,b,c){var d=null;"getAttention"in window&&window.getAttention();if("focus"in window){for(var e=!1,f=0,h=memberList.length;f<h;f++)if(memberList[f].imSubWin&&memberList[f].imSubWin.document.hasFocus()){e=!0;break}e||(window.blur(),setTimeout(window.focus,0))}switch(a){case NOTIF_TYPE_IM:d=function(){dispTextChat(b)};d=makeDsktpNotification(b.name(),c,d);break;case NOTIF_TYPE_CALL:d=function(){window.open().close();window.focus()},d=makeDsktpNotification(b.name(),c,d)}d&&(deleteDsktpNotification(a,
b),a=new ntfyMngObj(a,b,d),viewModel.ntfyMngList.push(a))}function checkDsktpNotification(){if(!("Notification"in window))return!1;if("granted"===Notification.permission)return l.log("granted"),!0;"denied"!==Notification.permission&&(l.log("denied"),Notification.requestPermission(function(a){if("granted"===a)return!0}));return!1}
function makeDsktpNotification(a,b,c){if(!checkDsktpNotification())return null;b={body:b,icon:"./img/nec_b_sq.png",requireInteraction:!0};try{var d=new Notification(a,b);d.onclick=function(){c();this.close()};$(d).on("show",function(a){a=0;for(var b=viewModel.ntfyMngList().length;a<b;a++)if(viewModel.ntfyMngList()[a].ntfy==this)return;$(this).off("show");this.close()});$(d).on("close",function(a){l.log("** notification has closed.");l.dir(this);$(this).off()});l.log("** notification has created");
l.dir(d);return d}catch(e){l.log("Error in setNotification()")}return null}function deleteDsktpNotification(a,b){switch(a){case NOTIF_TYPE_IM:case NOTIF_TYPE_CALL:break;default:return}var c=viewModel.ntfyMngList.remove(function(c){return c.type==a&&c.obj==b?!0:!1}),d;for(d in c)c[d].ntfy&&setTimeout(function(a){a.close()},1E3,c[d].ntfy)}
function deleteDsktpNotificationAll(a){var b=[],b=a==NOTIF_TYPE_ALL?viewModel.ntfyMngList.removeAll():viewModel.ntfyMngList.remove(function(b){return b.type==a?!0:!1}),c;for(c in b)b[c].ntfy&&b[c].ntfy.close()}var now_loading=!1;
function setLoadingMotion(a){l.log(">> set loading motion");now_loading=!0;$("#sc_loading").css("display","inline");$(".sc").css("visibility","hidden");$("#sc_loading").css("visibility","visible");$("#sc_loading").stop();$("#sc_loading").animate({opacity:"1"},300);setTimeout(function(a){a&&a()},300,a)}
function clrLoadingMotion(a){now_loading?(l.log(">> clear loading motion"),now_loading=!1,$("#sc_loading").stop(),$("#sc_loading").css("opacity","1"),$("#sc_loading").animate({opacity:"0"},300),setTimeout(function(a){$("#sc_loading").css("display","none");$(".sc").css("visibility","visible");a&&a()},300,a)):a&&a()}function setLoadingOnList(a){l.log(">> set loading motion 2");$("#list_loading").css("display","block");a&&setTimeout(function(a){a()},100,a)}
function clrLoadingOnList(a){l.log(">> clear loading motion 2");$("#list_loading").css("display","none");a&&setTimeout(function(a){a()},100,a)}String.prototype.toKatakanaCase=function(){var a,b,c=[];for(a=this.length-1;0<=a;a--)b=this.charCodeAt(a),c[a]=12353<=b&&12438>=b?b+96:b;return String.fromCharCode.apply(null,c)};String.prototype.toHirakanaCase=function(){var a,b,c=[];for(a=this.length-1;0<=a;a--)b=this.charCodeAt(a),c[a]=12449<=b&&12534>=b?b-96:b;return String.fromCharCode.apply(null,c)};
String.prototype.toHankakuCase=function(){var a,b,c,d,e=[];d={12449:65383,12451:65384,12453:65385,12455:65386,12457:65387,12515:65388,12517:65389,12519:65390,12483:65391,12540:65392,12450:65393,12452:65394,12454:65395,12456:65396,12458:65397,12459:65398,12461:65399,12463:65400,12465:65401,12467:65402,12469:65403,12471:65404,12473:65405,12475:65406,12477:65407,12479:65408,12481:65409,12484:65410,12486:65411,12488:65412,12490:65413,12491:65414,12492:65415,12493:65416,12494:65417,12495:65418,12498:65419,
12501:65420,12504:65421,12507:65422,12510:65423,12511:65424,12512:65425,12513:65426,12514:65427,12516:65428,12518:65429,12520:65430,12521:65431,12522:65432,12523:65433,12524:65434,12525:65435,12527:65436,12530:65382,12531:65437,12288:32};a=0;for(b=this.length;a<b;a++)switch(c=this.charCodeAt(a),!0){case c in d:e.push(d[c]);break;case 65313<=c&&65374>=c:e.push(c-65248);break;case 12459<=c&&12489>=c:e.push(d[c-1],65438);break;case 12495<=c&&12509>=c:e.push(d[c-c%3],[65438,65439][c%3-1]);break;default:e.push(c)}return String.fromCharCode.apply(null,
e)};String.prototype.getByte=function(){var a=0;for(i=0;i<this.length;i++)switch(!0){case " "<=this.charAt(i)&&"~">=this.charAt(i):case "\uff61"<=this.charAt(i)&&"\uff9f">=this.charAt(i):a+=1;break;default:a+=2}return a};String.prototype.toHankakuDial=function(){var a="";for(i=0;i<this.length;i++){for(j=0;16>j;j++)if(this.charAt(i)=="\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\uff10\uff0a\uff03\uff08\uff09\uff0d\u3000"[j]){a+="1234567890*#()- "[j];break}16==j&&(a+=this.charAt(i))}return a};
function getInitialIndex(a){a=a.charAt(0).toHankakuCase();var b=a.charCodeAt(0);switch(!0){case 65393<=b&&65397>=b:case 65383<=b&&65387>=b:return"\u3042";case 65398<=b&&65402>=b:return"\u304b";case 65403<=b&&65407>=b:return"\u3055";case 65408<=b&&65412>=b:case 65391==b:return"\u305f";case 65413<=b&&65417>=b:return"\u306a";case 65418<=b&&65422>=b:return"\u306f";case 65423<=b&&65427>=b:return"\u307e";case 65428<=b&&65430>=b:case 65388<=b&&65390>=b:return"\u3084";case 65431<=b&&65435>=b:return"\u3089";
case 65436<=b&&65437>=b||65382==b:return"\u308f"}return a}
function recvInitData(a){if(void 0!==a.data&&void 0!==a.blist){var b=a.blist,c=a.data;void 0!==a.sys&&(l.log("system: "+a.sys),viewModel.system(a.sys),CHAT_SRVPEND_MAX=a.sys==SYS_TYPE_SL2100?CHAT_SRVPEND_MAX_SL:CHAT_SRVPEND_MAX_SV);if(void 0!==a.mkt&&(l.log("market: "+a.mkt),viewModel.market(a.mkt),resetStatusLib(),initSacs(),initVmacsOperation(),initVmInfo(),isJP()))for(var d=0,e=memberList.length;d<e;d++){var f=memberList[d];f.imStatus=IM_STATUS_CONN}void 0!==a.lang&&-1!==a.lang?0<=a.lang&&a.lang<
langFileList.length?viewModel.myLangIdx()!=a.lang&&(viewModel.myLangIdx(a.lang),viewModel.tmpLang(langFileList[a.lang]),changeLang(viewModel.tmpLang().file),updtDocTitle()):(isJP()?(viewModel.myLangIdx(0),viewModel.tmpLang(langFileList[0])):(viewModel.myLangIdx(1),viewModel.tmpLang(langFileList[1])),changeLang(viewModel.tmpLang().file),updtDocTitle()):viewModel.myLangIdx(-1);void 0!==a.dfmt&&(date_fmt=a.dfmt);if(void 0===b.buddy)l.log("blist.buddy is undefined.");else{for(d=0;d<memberList.length;d++)if(f=
memberList[d])getBitVal(b.buddy[Math.floor(d/32)],d%32)?(f.isBuddy(1),f.tmpBuddy(1)):(f.isBuddy(0),f.tmpBuddy(0));recvUserDetail(c);void 0!==b.info&&updtBlistInfo(b);isFirstLogin&&chgSortType(home_sort,LIST_TYPE_CONTACT)}}}
function updtBlistInfo(a){var b=1,c=1;if(void 0!==a.now&&void 0!==a.end&&(b=a.now,c=a.end,b>c))return;var d=viewModel.myIdx();void 0!==a.myidx&&0<=a.myidx&&a.myidx<CLIENT_MAX&&(d=a.myidx);if(void 0!==a.info)for(var e=0,f=a.info.length;e<f;e++){var h=a.info[e].idx;if(!(0>h||h>=CLIENT_MAX)){var g=memberList[h];tmp_en="";tmp_cs=tmp_ts=tmp_ls=tmp_as=0;tmp_st="";void 0!==a.info[e].en&&(tmp_en=a.info[e].en);void 0!==a.info[e].as&&(tmp_as=a.info[e].as);void 0!==a.info[e].ls&&(tmp_ls=a.info[e].ls);void 0!==
a.info[e].ts&&(tmp_ts=a.info[e].ts);void 0!==a.info[e].cs&&(tmp_cs=a.info[e].cs);void 0!==a.info[e].st&&(tmp_st=a.info[e].st);g.ext(tmp_en);isJP()?tmp_ls?g.appStOri(tmp_as):g.appStOri(0):(g.appStOri(tmp_as),tmp_ls||(g.imStatus=IM_STATUS_DISC));g.lineSt(tmp_ls);g.telSt(setTelStatus(tmp_ts,tmp_cs));g.remarks(tmp_st);h===d&&(viewModel.myExt(tmp_en),viewModel.myLs(tmp_ls),viewModel.myTs(tmp_ts),viewModel.myCs(tmp_cs),void 0!==a.myidx&&(viewModel.myAs(tmp_as),viewModel.myMsg(tmp_st),$("#hdr_msg_ta").val(tmp_st)),
g.isBuddy(1),g.tmpBuddy(1),updtDocTitle())}}viewModel.myIdx(d);if(void 0!==a.fls)for(e=0,f=a.fls.length;e<f;e++)h=a.fls[e].idx,0>h||h>=CLIENT_MAX||(g=memberList[h],g.tmpBuddy(g.isBuddy()));b===c&&viewModel.sortType()===SORT_TYPE_STATUS&&sortUsrData()}function getBitVal(a,b){return a>>>b&1}function setBitVal(a,b){return a|1<<b}
function setTelStatus(a,b){switch(a){case TS_INUSE:case TS_ERROR:return TEL_ST_BUSY;default:if(!isJP()){if(getBitVal(b,CS_DND_EXTERNAL-1)||getBitVal(b,CS_DND_INTERCOM-1)||getBitVal(b,CS_DND_ALL-1)||getBitVal(b,CS_DND_CFW-1))return TEL_ST_DND;if(getBitVal(b,CS_CFW_SRAM-1)||getBitVal(b,CS_CFW_2406-1)||getBitVal(b,CS_CFW_2409-1))return TEL_ST_CFW}}return TEL_ST_IDLE}
function initUserData(a){i=0;for(len=memberList.length;i<len;i++){var b=memberList[i];b.index(i);b.name("");b.sort1="";b.sort2="";b.key(langTbl.unknown);b.keyHead(!1);b.telArr([]);b.mailArr([]);b.mobArr([]);b.mail("");b.name2="";b.name3="";b.comp="";b.dep="";b.city="";b.stat="";b.zip="";b.ctry="";b.note="";b.imSubWin&&(b.imSubWin.close(),b.imSubWin=null);b.ocDial(b.getOCDial())}a&&a()}
function recvUserDetail(a){var b=1,c=1;if(void 0!==a.now&&void 0!==a.end&&(b=a.now,c=a.end,b>c))return;if(void 0!==a.usr)for(var d=0,e=a.usr.length;d<e;d++)if(void 0!==a.usr[d].idx){var f=a.usr[d],h=f.idx;if(!(0>h||h>=CLIENT_MAX)){var g=memberList[h];if(g){g.index(h);var k=f.en;k&&checkCallable(k)&&g.ext(k);void 0!==f.nm&&(""!==f.nm?(g.name(f.nm),void 0!==f.ks&&(g.sort1=f.ks),void 0!==f.km&&(g.sort2=f.km)):g.ext()&&g.name(langTbl.ext_user+" "+g.ext()));if(void 0!=f.t1||void 0!=f.t2||void 0!=f.t3)g.telArr([]),
void 0!==f.t1&&""!==f.t1?g.telArr.push(f.t1):g.telArr.push(""),void 0!==f.t2&&""!==f.t2?g.telArr.push(f.t2):g.telArr.push(""),void 0!==f.t3&&""!==f.t3?g.telArr.push(f.t3):g.telArr.push("");if(void 0!=f.e1||void 0!=f.e2)g.mailArr([]),void 0!==f.e1&&""!==f.e1&&g.mailArr.push(f.e1),void 0!==f.e2&&""!==f.e2&&g.mailArr.push(f.e2),g.mailArr()[0]&&g.mail(g.mailArr()[0]);if(void 0!=f.m1||void 0!=f.m2)g.mobArr([]),void 0!==f.m1&&""!==f.m1&&g.mobArr.push(f.m1),void 0!==f.m2&&""!==f.m2&&g.mobArr.push(f.m2);
void 0!==f.n2&&(g.name2=f.n2);void 0!==f.n3&&(g.name3=f.n3);void 0!==f.cm&&(g.comp=f.cm);void 0!==f.dv&&(g.dep=f.dv);void 0!==f.ct&&(g.city=f.ct);void 0!==f.sp&&(g.stat=f.sp);void 0!==f.zp&&(g.zip=f.zp);void 0!==f.cn&&(g.ctry=f.cn);void 0!==f.nt&&(g.note=f.nt);void 0!==f.sen&&g.sipext(f.sen);g.ocDial(g.getOCDial());h===viewModel.myIdx()&&(""!==g.name()?viewModel.myName(g.name()):viewModel.myName(langTbl.unknown))}}}b===c?getDataType(viewModel.listType())===DATA_TYPE_USER&&setLoadingOnList(function(){sortUsrData(function(){clrLoadingOnList()})}):
(getdataTimer&&clearTimeout(getdataTimer),getdataTimer=setTimeout(function(){clrLoadingOnList()},3E4))}
function recvSpeedDial(a){if(void 0!==a.now&&void 0!==a.end){var b=a.now,c=a.end;if(!(b>c)){if(void 0!==a.spd)for(var d=0,e=a.spd.length;d<e;d++){var f=a.spd[d];if(void 0!==f.idx&&void 0!==f.dd&&void 0!==f.nm){var h="";void 0!==f.kn&&(h=f.kn);var g=new spddialObj;g.index(f.idx);g.dial(f.dd);g.name(f.nm);g.sort=h;viewModel.comSpdDialList()[viewModel.comSpdDialList().length]=g}}b===c?getDataType(viewModel.listType())===DATA_TYPE_SPD&&setLoadingOnList(function(){sortSpdData(viewModel.spdPageNo(),function(){clrLoadingOnList()})}):
(getdataTimer&&clearTimeout(getdataTimer),getdataTimer=setTimeout(function(){clrLoadingOnList()},6E4))}}}function clrDisplayList(){switch(getDataType(viewModel.listType())){case DATA_TYPE_USER:clrDisplayUsrList();break;case DATA_TYPE_SPD:clrDisplaySpdList();break;case DATA_TYPE_HIST:clrDisplayHistList()}}
function clrDisplayUsrList(){dispList=isBuddyListType(viewModel.listType())?viewModel.dispBuddyList:viewModel.listType()===LIST_TYPE_LOGIM?viewModel.dispImLogList:viewModel.dispMemberList;idx=0;for(len=dispList().length;idx<len;idx++)data=dispList()[idx],data.isVisible(!1),data.keyHead(!1)}function clrDisplaySpdList(){dispList=viewModel.dispComSpdDialList;idx=0;for(len=dispList().length;idx<len;idx++)data=dispList()[idx],data.isVisible(!1),data.keyHead(!1)}
function clrDisplayHistList(){dispList=viewModel.dispCallHistList;idx=0;for(len=dispList().length;idx<len;idx++)data=dispList()[idx],data.isVisible(!1),data.keyHead(!1)}
function chgSortType(a,b,c,d){l.log(getDateTime()+"*** chgSortType() start ***");b===LIST_TYPE_LOGCALL&&(deleteCallAlert(),viewModel.phone_mode()===MODE_CTI&&updtCallHistory());setLoadingOnList(function(){$("#search_input").val("");viewModel.searching(!1);viewModel.listType()===LIST_TYPE_CONTACT&&(home_sort=viewModel.sortType(),home_index=viewModel.IndexHiden());b===LIST_TYPE_CONTACT?viewModel.IndexHiden(home_index):viewModel.IndexHiden(!1);viewModel.listType(b);viewModel.sortType(a);l.log(getDateTime()+
"*** chgSortType() del start ***");clrDisplayList();l.log(getDateTime()+"*** chgSortType() del end ***");c&&c();b===LIST_TYPE_LOGCALL&&viewModel.phone_mode()===MODE_CTI||setTimeout(function(a){sortData(function(){viewModel.buddyCtrlFlg()&&($(".tbk_name").css("left","25px"),$(".tbk_idx_str").css("left","25px"));clrLoadingOnList(function(){a&&a();l.log(getDateTime()+"*** chgSortType() end ***")})})},100,d)})}
function sortData(a){switch(getDataType(viewModel.listType())){case DATA_TYPE_USER:sortUsrData(a);break;case DATA_TYPE_SPD:sortSpdData(1,a);break;case DATA_TYPE_HIST:sortCallHistData(a)}}var _search_init=!1;
function sortUsrData(a){l.log(getDateTime()+"*** sortUsrData() start ***");dispList=isBuddyListType(viewModel.listType())?viewModel.dispBuddyList():viewModel.listType()===LIST_TYPE_LOGIM?viewModel.dispImLogList():viewModel.dispMemberList();var b=$("#search_input").val(),b=convEscapeChar(b),b=b.toKatakanaCase(),b=b.toHankakuCase(),b=deleteSpace(b);l.log("input: "+b);if(0==_search_init)_search_init=!0,a&&a(),l.log(getDateTime()+"*** sortUsrData() abort ***");else{var c=new RegExp(".*"+b+".*","i");l.log(getDateTime()+
"*** sortUsrData() key set ***");idx=0;for(len=memberList.length;idx<len;idx++)if(data=memberList[idx],dispList[idx]=data,data.key(langTbl.unknown),data.isVisible(!1),!(0>data.index()||""==data.name()&&viewModel.listType()!==LIST_TYPE_LOGIM||data.index()===viewModel.myIdx()||isBuddyListType(viewModel.listType())&&!data.isBuddy()||viewModel.listType()===LIST_TYPE_LOGIM&&viewModel.sortType()===SORT_TYPE_IMLAST&&-1===data.imLastIdx()||viewModel.listType()===LIST_TYPE_BRDMAIL&&0===data.mailArr().length)){if(b){var d=
[],e=!1;cnt=0;d[cnt++]=deleteSpace(data.name());d[cnt++]=deleteSpace(data.sort1.toHankakuCase()+data.sort2.toHankakuCase());d[cnt++]=data.ext();d[cnt++]=data.sipext();for(var f in data.telArr())data.telArr()[f]&&(d[cnt++]=data.telArr()[f]);for(f in data.mailArr())d[cnt++]=data.mailArr()[f];for(f in data.mobArr())d[cnt++]=data.mobArr()[f];for(f in d)if(d[f].match(c)){e=!0;break}if(!1===e)continue}switch(viewModel.sortType()){case SORT_TYPE_NAME:data.sort1&&data.key(getInitialIndex(data.sort1));break;
case SORT_TYPE_GROUP:data.dep&&data.key(data.dep);break;case SORT_TYPE_STATUS:data.key(data.stObj().name());break;case SORT_TYPE_IMLAST:-1!==data.imLastIdx()&&data.key(data.imLastObj().cmpdate())}data.isVisible(!0)}var c=null,h=function(a,b){switch(viewModel.sortType()){case SORT_TYPE_IMLAST:return-1===a.imLastIdx()?1:-1===b.imLastIdx()?-1:a.imLastIdx()===b.imLastIdx()?0:a.imLastIdx()<b.imLastIdx()?1:-1;default:return a.sort1?b.sort1?a.sort1==b.sort1?a.sort2?b.sort2?a.sort2===b.sort2?0:a.sort2>b.sort2?
1:-1:-1:1:a.sort1>b.sort1?1:-1:-1:1}};l.log(getDateTime()+"*** sortUsrData() sort start ***");switch(viewModel.sortType()){case SORT_TYPE_NAME:case SORT_TYPE_GROUP:dispList.sort(function(a,b){return a.key()===langTbl.unknown?b.key()===langTbl.unknown?h(a,b):1:b.key()===langTbl.unknown?-1:a.key()===b.key()?h(a,b):a.key()>b.key()?1:-1});break;case SORT_TYPE_STATUS:dispList.sort(function(a,b){var c=a.stObj(),d=b.stObj();return c.priority()===d.priority()?h(a,b):c.priority()>d.priority()?1:-1});break;
case SORT_TYPE_IMLAST:dispList.sort(function(a,b){return a.imLastObj()?b.imLastObj()?a.imLastObj().stmp===b.imLastObj().stmp?h(a,b):a.imLastObj().stmp<b.imLastObj().stmp?1:-1:-1:1})}l.log(getDateTime()+"*** sortUsrData() sort end ***");before=null_user;f=cnt=0;for(len=dispList.length;f<len;f++)b=dispList[f],b.keyHead(!1),-1!==b.index()&&b.index()!==viewModel.myIdx()&&b.isVisible()&&(0===cnt?b.keyHead(!0):(b=dispList[f],b.key()!==before.key()&&b.keyHead(!0)),before=dispList[f],cnt++);l.log(getDateTime()+
"*** sortUsrData() notify ***");isBuddyListType(viewModel.listType())?viewModel.dispBuddyList.valueHasMutated():viewModel.listType()===LIST_TYPE_LOGIM?viewModel.dispImLogList.valueHasMutated():viewModel.dispMemberList.valueHasMutated();l.log(getDateTime()+"*** sortUsrData() end ***");a&&a()}}
function sortSpdData(a,b){viewModel.spdPageNo(a);copyList=viewModel.comSpdDialList().concat();dispList=viewModel.dispComSpdDialList();var c=$("#search_input").val(),c=convEscapeChar(c),c=c.toKatakanaCase(),c=c.toHankakuCase();if(0==_search_init)_search_init=!0;else{var d=new RegExp(".*"+c+".*","i");l.log(getDateTime()+"*** sortSpdData() key set ***");len1=copyList.length;len2=dispList.length;start=(a-1)*SPD_DISP_MAX;l.log("len1:"+len1);l.log("len2:"+len2);l.log("start:"+start);var e=function(a,b){return a.sort?
b.sort?a.sort==b.sort?0:a.sort>b.sort?1:-1:-1:1};switch(viewModel.sortType()){case SORT_TYPE_INDEX:copyList.sort(function(a,b){return a.index()===b.index()?0:a.index()>b.index()?1:-1});break;default:copyList.sort(function(a,b){return a.key()===langTbl.unknown?1:b.key()===langTbl.unknown?-1:a.key()===b.key()?e(a,b):a.key()>b.key()?1:-1})}for(idx=0;idx<len2;idx++)dispList[idx]=null_spd;for(idx=num=0;idx<len1;idx++)if(data=copyList[idx],data.key(langTbl.unknown),data.isVisible(!1),!(0>data.index())){if(c){var f=
[],h=!1;cnt=0;f[cnt++]=data.name();f[cnt++]=data.sort.toHankakuCase();f[cnt++]=data.dial();for(var g in f)if(f[g].match(d)){h=!0;break}if(!1===h)continue}switch(viewModel.sortType()){case SORT_TYPE_NAME:data.sort&&data.key(getInitialIndex(data.sort))}idx>=start&&0<=num-start&&num-start<len2&&(dispList[num-start]=data,data.isVisible(!0));num++}d=null;0<num?viewModel.spdPageMax(Math.floor((num-1)/SPD_DISP_MAX)+1):viewModel.spdPageMax(1);l.log(getDateTime()+"*** sortSpdData() sort start ***");switch(viewModel.sortType()){case SORT_TYPE_INDEX:dispList.sort(function(a,
b){return a.index()===b.index()?0:a.index()>b.index()?1:-1});break;default:dispList.sort(function(a,b){return a.key()===langTbl.unknown?1:b.key()===langTbl.unknown?-1:a.key()===b.key()?e(a,b):a.key()>b.key()?1:-1})}l.log(getDateTime()+"*** sortSpdData() sort end ***");before=null_spd;g=cnt=0;for(len=dispList.length;g<len;g++)data=dispList[g],data.keyHead(!1),-1!==data.index()&&data.isVisible()&&(0===cnt?data.keyHead(!0):(data=dispList[g],data.key()!==before.key()&&data.keyHead(!0)),before=dispList[g],
cnt++);l.log(getDateTime()+"*** sortSpdData() notify ***");viewModel.dispComSpdDialList.valueHasMutated();l.log(getDateTime()+"*** sortSpdData() end ***")}b&&b()}
function sortCallHistData(a){l.log(getDateTime()+"*** sortCallHistData() start ***");dispList=viewModel.dispCallHistList();var b=$("#search_input").val(),b=convEscapeChar(b),b=b.toKatakanaCase(),b=b.toHankakuCase(),b=deleteSpace(b);l.log("input: "+b);if(0==_search_init)_search_init=!0,a&&a(),l.log(getDateTime()+"*** sortCallHistData() abort ***");else{var c=new RegExp(".*"+b+".*","i");l.log(getDateTime()+"*** sortCallHistData() key set ***");idx=0;for(len=viewModel.callHistList().length;idx<len;idx++)if(data=
viewModel.callHistList()[idx],dispList[idx]=data,data.key(langTbl.unknown),data.isVisible(!1),""!==data.dial){if(b){var d=[],e=!1;cnt=0;d[cnt++]=deleteSpace(data.name);d[cnt++]=deleteSpace(data.dial);for(var f in d)if(d[f].match(c)){e=!0;break}if(!1===e)continue}data.key(data.cmpdate());data.isVisible(!0)}c=null;l.log(getDateTime()+"*** sortCallHistData() sort start ***");dispList.sort(function(a,b){if(a.key()===langTbl.unknown)return b.key()===langTbl.unknown?0:1;if(b.key()===langTbl.unknown)return-1;
if(a.key()===b.key()){var c;c=a.time==b.time?1:a.time<b.time?1:-1;return c}return a.key()<b.key()?1:-1});l.log(getDateTime()+"*** sortCallHistData() sort end ***");before=null;f=cnt=0;for(len=dispList.length;f<len;f++)hist=dispList[f],hist.keyHead(!1),""!==hist.dial&&hist.isVisible()&&(0===cnt?hist.keyHead(!0):(hist=dispList[f],before&&hist.key()===before.key()||hist.keyHead(!0)),before=dispList[f],cnt++);l.log(getDateTime()+"*** sortCallHistData() notify ***");viewModel.dispCallHistList.valueHasMutated();
l.log(getDateTime()+"*** sortCallHistData() end ***");a&&a()}}
function makeCallHist(a){var b=searchCall(a);if(b&&b.histType!=CHIST_TYPE_HIDDEN){a=b.histType;var c=b.dial(),d=b.name(),e=new Date,f=e.getFullYear(),h=e.getMonth()+1,g=e.getDate(),k=e.getHours(),e=e.getMinutes(),b=getCallHistStatus(b),n=viewModel.callHistList(),m;for(m in n)n[m].dial==c&&n[m].cmpdate()==convDateComp(f,h,g)&&n[m].time==convTimeStr(k,e,0)&&viewModel.callHistList.remove(n[m]);m=new chistObj(a,c,d,f,h,g,k,e,b);viewModel.callHistList().length>=CHIST_MAX&&viewModel.callHistList.shift();
viewModel.callHistList.push(m);sortCallHistData()}}function getCallHistStatus(a){var b=0;a.status()==CALL_ST_INCOM&&(b=setBitVal(b,CHIST_STBIT_ABNDON));return b}function clearSearch(){$("#search_input").val("");viewModel.searching(!1);sortData(function(){viewModel.buddyCtrlFlg()&&($(".tbk_name").css("left","25px"),$(".tbk_idx_str").css("left","25px"))})}function isBuddyListType(a){switch(a){case LIST_TYPE_CONTACT:case LIST_TYPE_INVCONF:case LIST_TYPE_BRDMSG:return!0;default:return!1}}
function isHistListType(a){switch(a){case LIST_TYPE_LOGIM:case LIST_TYPE_LOGCALL:return!0;default:return!1}}function sendMail(a){a="mailto:"+(a+";%20");var b=document.createElement("iframe");b.src=a;document.body.appendChild(b);setTimeout(function(a){a.parentNode.removeChild(a)},500,b)}function sendMltMail(){var a="";i=0;for(len=memberList.length;i<len;i++){var b=memberList[i];-1!==b.index()&&b.isSelect()&&b.mail()&&(a+=b.mail()+";%20")}a&&sendMail(a)}
function sendBroadcastMail(){viewModel.selUserList().length&&(sendMltMail(),closeBroadcastMail())}
function initDialog(){destroyDialog();btns=[];label=langTbl.d_ok;btn=new dBtnObj(label,function(){closeDialog();clrLoadingMotion();fadein_ScLogin()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();viewModel.myLs(0);no_closedlg_flg=!1;viewModel.isConnecting(!0);keepAliveTimer&&(clearTimeout(keepAliveTimer),keepAliveTimer=null);keepAliveTimer=viewModel.phone_mode()!=MODE_ST500?setTimeout("Server.disconnect()",6E4):setTimeout("Server.disconnect()",
36E4);Server.connect()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog();viewModel.myLs(0)});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();$(".tbk_name").animate({left:"0px"},300);$(".tbk_idx_str").animate({left:"0px"},300);setTimeout(function(){viewModel.buddyCtrlFlg(!1);updtBuddyListReq()},300)});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);
btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();addBuddy()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();removeBuddy()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_ok;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);
dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();serverConnect()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();sendUpdateUser()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();
sendUpdateSpd()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();saveLogAsText(viewModel.targetUsr())});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){sendEvtLogout();closeDialog()});btns.push(btn);label=langTbl.d_no;btn=
new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){closeDialog();viewModel.myLs(0)});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog();viewModel.myLs(0);serverConnect()});btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){setupSipPhone(sipExt,sipPW);closeDialog()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});
btns.push(btn);dlgBtnList.push(btns);btns=[];label=langTbl.d_yes;btn=new dBtnObj(label,function(){sendDTMF_VmDelete();closeDialog()});btns.push(btn);label=langTbl.d_no;btn=new dBtnObj(label,function(){closeDialog()});btns.push(btn);dlgBtnList.push(btns)}function destroyDialog(){for(var a=0,b=dlgBtnList.length;a<b;a++)delete dlgBtnList[a];dlgBtnList.length=0}
function openDialog(a,b){var c=0;closeDialog();viewModel.dialogMsg(a);for(var d=0,e=b.length;d<e;d++)viewModel.dialogBtns.push(b[d]),c++;$("#dialg_mask").css("display","block");$(".dialog_btn").css("display","none");$(".dialog_btn_"+c).css("display","block")}function closeDialog(){$("#dialg_mask").css("display","none");$(".dialog_btn").css("display","none");viewModel.dialogMsg("");viewModel.dialogBtns.removeAll()}
function setAlert(a){for(var b=viewModel.alertList().length,c=0;c<b;c++)if(viewModel.alertList()[c].type===ALERT_IM_NEW&&isSameChat(a.chat,viewModel.alertList()[c].chat))return;viewModel.alertList.push(a);switch(a.type){case ALERT_IM_NEW:$("#alt_new_mes_wrap").css("display","block");break;case ALERT_CALL_NEW:$("#alt_new_call_wrap").css("display","block")}}
function closeAlert(a){$(a).css("display","none");a=document.getElementsByClassName("alt_wrap");for(var b=!1,c=0,d=a.length;c<d;c++)if("none"!==$(a[c]).css("display")){b=!0;break}!1===b&&$("#alert_box").css("display","none")}function deleteImAlert(a){if(-1!==a.index)for(var b=viewModel.alertList.remove(function(b){return b.type===ALERT_IM_NEW&&b.user===a?!0:!1}),c=0,d=b.length;c<d;c++)delete b[idx]}
function deleteOneImAlert(a){for(var b=viewModel.alertList.remove(function(b){return b.chat===a?!0:!1}),c=b.length,d=0;d<c;d++)b[d]=null}function deleteCallAlert(){for(var a=viewModel.alertList.remove(function(a){return a.type===ALERT_CALL_NEW?!0:!1}),b=0,c=a.length;b<c;b++)delete a[idx]}var callTimer=null;function deleteCallList(){stopCallDrTmr();for(var a=viewModel.callList.removeAll(),b=0,c=a.length;b<c;b++)delete a[b];adjustClctrlArea();closeVideoSubWin();dettachScreenShare()}
function setLoginOption(){var a=document.getElementById("inputTelMode"),b;b=document.createElement("option");b.setAttribute("id","login_tel_0");b.setAttribute("value",MODE_NONE);a.appendChild(b);b=document.createElement("option");b.setAttribute("id","login_tel_1");b.setAttribute("value",MODE_CTI);a.appendChild(b);isSmartDevice()&&(b=document.createElement("option"),b.setAttribute("id","login_tel_2"),b.setAttribute("value",MODE_SMARTDEV),a.appendChild(b));!isSmartDevice()&&VVM.sup_check()&&(b=document.createElement("option"),
b.setAttribute("id","login_tel_3"),b.setAttribute("value",MODE_SIP),a.appendChild(b))}function isChrome(){return chrome?!0:!1}function iOS_Device(){return null!==navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?!0:!1}function Android_Device(){return null!==navigator.userAgent.match(/Android/g)?!0:!1}function isSmartDevice(){return iOS_Device()||Android_Device()?!0:!1}
function acsST450(a){l.log("st450://"+a);subWin=window.open("st450://"+a);setTimeout(function(){subWin.close()},100);closeAppSelect()}function acsTelTag(a){l.log("tel:"+a);subWin=window.open("tel:"+a);setTimeout(function(){subWin.close()},100);closeAppSelect()}function openAppSelect(a){$("#app_select_mask").css("display","block");$("#app_select_hide").val(a)}function closeAppSelect(){$("#app_select_mask").css("display","none");$("#app_select_hide").val("")}
function openDialer(a){if(viewModel.phone_mode()&&!viewModel.isSipInactive()){clearDial();initCallMode();if(a){if(!checkCallable(a))return;inputDial(a)}$("#tel_ipt_wrap").css("display","block");$("#tel_mask").css("display","block");$("#tel_mask").stop();$("#tel_mask").animate({opacity:1},300,"",function(){a||$("#tel_input").focus()})}}function openDialerSpd(a){a&&(openDialer(a.dial()),isJP()&&chgCallMode())}
function closeDialer(){$("#tel_mask").stop();$("#tel_mask").animate({opacity:0},250);setTimeout(function(){$("#tel_mask").css("display","none");$("#tel_ipt_wrap").css("display","none");$("#tel_ipt_wrap2").css("display","none");clearDial();initCallMode()},250)}function openDialer2(){$("#tel_ipt_wrap2").css("display","block");$("#tel_mask").css("display","block");$("#tel_mask").stop();$("#tel_mask").animate({opacity:1},300)}
function sendDTMF(a){setDial(a);if(viewModel.chkMakeCall())switch(clearDial(),viewModel.phone_mode()){case MODE_CTI:viewModel.primeCall()&&CTI_dialCall(a);break;case MODE_SIP:SIP_sendDTMF(viewModel.primeCall().cid,a)}}var CtiVmShiftWait=VMACS_ST_NONE;
function recvVmbStatus(a){var b=viewModel.primeCall();if(b&&b.vmacs_status()!=VMACS_ST_NONE){switch(a.st){case "vm_ans":b.vmacs_status(VMACS_ST_START);break;case "srv_wt":b.vmacs_status(VMACS_ST_SRV_WT);break;case "srv_ana":b.vmacs_status(VMACS_ST_SRV_ANA);break;case "lsn_ply":b.vmacs_status(VMACS_ST_LIN_PLY);break;case "lsn_ana":b.vmacs_status(VMACS_ST_LIN_ANA);break;case "lsn_opt_wt":b.vmacs_status(VMACS_ST_LIN_OPT_WT);break;case "lsn_opt_ana":b.vmacs_status(VMACS_ST_LIN_OPT_ANA);break;case "vm_disc":b.vmacs_status(VMACS_ST_DISC);
break;default:b.vmacs_status(VMACS_ST_UNKONWN)}void 0!==a.tm?(b=a.tm,viewModel.vmTime(convDateStr(b[0],b[1],b[2])+" "+convTimeStr(b[3],b[4],0))):viewModel.vmTime(langTbl.unknown);void 0!==a.dd?viewModel.vmDial(a.dd):viewModel.vmDial(langTbl.label_anonymous)}}function initVmInfo(){viewModel.vmTime(langTbl.unknown);viewModel.vmDial(langTbl.label_anonymous)}
function initVmacsOperation(){var a=null,a=viewModel.vmacsOpeArr.removeAll(),b;for(b in a)a[b]=null;a=new VmAcsOperation(VMACS_OPR_RPLY,function(){sendDTMF_VmReplay()});viewModel.vmacsOpeArr.push(a);a=new VmAcsOperation(VMACS_OPR_BACK,function(){sendDTMF_VmBackskip()});viewModel.vmacsOpeArr.push(a);a=new VmAcsOperation(VMACS_OPR_SKIP,function(){sendDTMF_VmSkip()});viewModel.vmacsOpeArr.push(a);a=new VmAcsOperation(VMACS_OPR_NEXT,function(){sendDTMF_VmNext()});viewModel.vmacsOpeArr.push(a);a=new VmAcsOperation(VMACS_OPR_DEL,
function(){openDialog(langTbl.vmdlg_delete,dlgBtnList[D_BTN_VM_DEL])});viewModel.vmacsOpeArr.push(a);a=new VmAcsOperation(VMACS_OPR_CLBK,function(){openDialer(viewModel.vmDial())});viewModel.vmacsOpeArr.push(a)}function sendDTMF_VmBoxAcs(){isJP()&&sendDTMF("#")}function sendDTMF_VmHearMode(){isJP()?sendDTMF("1#"):sendDTMF("5")}function sendDTMF_VmSkip(){isJP()?sendDTMF("3#"):sendDTMF("4")}function sendDTMF_VmBackskip(){isJP()?sendDTMF("6#"):sendDTMF("2")}
function sendDTMF_VmReplay(){isJP()?sendDTMF("1#"):sendDTMF("22")}function sendDTMF_VmDelete(){isJP()?sendDTMF("7#"):sendDTMF("3")}function sendDTMF_VmNext(){isJP()?sendDTMF("9#"):sendDTMF("5")}
function checkCallable(a){if(!a)return!1;a=a.replace(/([\-])/g,"");var b=a.replace(/([^0-9\*\#])/g,"");return b===a?(viewModel.trkacsDial()&&viewModel.callMode()===CALL_MODE_EXT&&(b=viewModel.trkacsDial()+b),isTel_SIP()&&(b=appendSharpDial(b),b=b.replace(/\*/g,"%2a").replace(/#/g,"%23")),b.length<=INPUT_DIAL_MAX?!0:!1):!1}function startCallDrTmr(){clearInterval(callTimer);callTimer=setInterval(function(){viewModel.primeCall()&&viewModel.primeCall().time(viewModel.primeCall().time()+1)},1E3)}
function stopCallDrTmr(){clearInterval(callTimer);callTimer=null}function addCall(a,b,c){var d=new callObj;d.cid=a;d.histType=c;b===CALL_ST_INCOM?viewModel.callList.push(d):viewModel.callList.unshift(d);d.status(b);return d}
function rmvCall(a){objs=viewModel.callList.remove(function(b){return b.cid==a});for(var b in objs)objs[b].video&&rmvVideo(objs[b].video),deleteDsktpNotification(NOTIF_TYPE_CALL,objs[b]),delete objs[b];0==viewModel.callList().length&&(stopCallDrTmr(),stopVideo(),deleteDsktpNotificationAll(NOTIF_TYPE_CALL),initVmInfo())}function swapCall(){viewModel.chkSwapCall()&&isTel_SIP()&&(SIP_holdCall(viewModel.primeCall().cid),viewModel.secondCall().swapFlag(!0))}
function searchCall(a){if(null===a)return null;for(var b=0,c=viewModel.callList().length;b<c;b++){var d=viewModel.callList()[b];if(d.cid===a)return d}return null}function searchCallByDial(a){if(0==a.length)return null;for(var b=0,c=viewModel.callList().length;b<c;b++){var d=viewModel.callList()[b];if(d.dial()===a)return d}return null}
function onDialTone(a){if(viewModel.sc_flag()==SCFLAG_ON_HIDDEN)onDialToneSc(a);else{var b=searchCall(a);if(b)b.status(CALL_ST_DIAL);else if(b=addCall(a,CALL_ST_DIAL,CHIST_TYPE_OTG),!b)return;adjustClctrlArea();viewModel.secondCall()&&viewModel.secondCall().bTransFlag()&&openDialer();viewModel.sc_flag()==SCFLAG_ON_VMACS&&(viewModel.sc_flag(SCFLAG_OFF),stopScResTimer(),b.vmacs_status(VMACS_ST_WT_ACS))}}
function onDialToneSc(a){viewModel.sc_flag(SCFLAG_OFF);stopScResTimer();var b=searchCall(a);if(b)b.status(CALL_ST_SRVCODE);else if(b=addCall(a,CALL_ST_SRVCODE,CHIST_TYPE_HIDDEN),!b)return;setScDiscTimer(a)}function onRingBack(a,b){var c=searchCall(a);if(c)c.status(CALL_ST_RINGBK);else if(c=addCall(a,CALL_ST_RINGBK,CHIST_TYPE_OTG),!c)return;c.dial(b);adjustClctrlArea();viewModel.secondCall()&&viewModel.secondCall().bTransFlag()&&setTimeout(function(){clickTransBtn()},1E3)}
function onEarlyMedia(a){(a=searchCall(a))&&a.status()!=CALL_ST_SRVCODE&&a.status(CALL_ST_183)}function onBusyCall(a){(a=searchCall(a))&&a.status(CALL_ST_BUSY)}function onHold(a){if(a=searchCall(a)){a.status(CALL_ST_HOLD);var b=viewModel.secondCall();b&&b.swapFlag()?clickAnsBtn(b,b.callType()):isTel_SIP()&&a.bTransFlag()&&openDialer()}}
function onCall(a,b,c){if(c=searchCall(a))c.status(CALL_ST_INCOM);else if(c=addCall(a,CALL_ST_INCOM,CHIST_TYPE_ICM),!c)return;c.dial(b);setNotification(NOTIF_TYPE_CALL,c,langTbl.tel_incoming);adjustClctrlArea()}function onAnsCall(a,b){var c=searchCall(a);c&&(c.swapFlag()&&(viewModel.callList.remove(c),viewModel.callList.unshift(c),c.swapFlag(!1)),c.status(CALL_ST_SPEAK),b&&c.dial(b),c.bTransFlag(!1),adjustClctrlArea())}
function onEndCall(a){var b=searchCall(a);if(b){stopScDiscTimer();if(b.status()===CALL_ST_INCONF&&1===viewModel.confCalls().length&&viewModel.confCalls()[0]===b){var c=viewModel.confCallObj();c&&onEndCall(c.cid)}isTel_CTI()&&b.vmacs_status()!==VMACS_ST_NONE&&(CtiVmShiftWait=b.vmacs_status(),setTimeout(function(){CtiVmShiftWait=VMACS_ST_NONE},1E3));b.status()===CALL_ST_INCOM&&(c=new alertObj(ALERT_CALL_NEW,getTimeStamp(),null_user,null_chat),setAlert(c));b==viewModel.primeCall()&&b.status()!==CALL_ST_INCOM&&
closeDialer();rmvCall(a);adjustClctrlArea()}}function onTransCall(a,b){var c=searchCall(a);if(c)c.status(CALL_ST_SPEAK);else if(c=addCall(a,CALL_ST_SPEAK,CHIST_TYPE_ICM),!c)return;c.dial(b);isTel_CTI()&&CtiVmShiftWait!==VMACS_ST_NONE&&(c.vmacs_status(CtiVmShiftWait),CtiVmShiftWait=VMACS_ST_NONE);adjustClctrlArea()}function onConferenced(a){if(a=searchCall(a))a.status(CALL_ST_INCONF),adjustClctrlArea()}
function onConfHold(a){var b=searchCall(a);if(b)b.status(CALL_ST_CHOLD);else if(b=addCall(a,CALL_ST_CHOLD,CHIST_TYPE_HIDDEN),!b)return;b.status(CALL_ST_CHOLD)}function onConfStart(a){(a=searchCall(a))&&a.status(CALL_ST_CSPEAK)}function onHeld(a){(a=searchCall(a))&&a.status(CALL_ST_HELD)}function onUnHoldCall(a){(a=searchCall(a))&&a.status(CALL_ST_SPEAK)}
function submitDialer(a){switch(viewModel.telSubmitType()){case TEL_SUBMIT_TRANS:bTransCall(a);break;case TEL_SUBMIT_CALL:case TEL_SUBMIT_DTMF:makeCall(a)}}
function makeCall(a){if(viewModel.chkMakeCall()){var b="";viewModel.trkacsDial()&&viewModel.callMode()===CALL_MODE_EXT&&(b+=viewModel.trkacsDial());if(b+=viewModel.ipt_dial())switch(closeDialer(),clearDial(),viewModel.primeCall()&&viewModel.primeCall().vmacs_status()!==VMACS_ST_NONE&&endCall(viewModel.primeCall().cid),viewModel.phone_mode()){case MODE_CTI:viewModel.primeCall()?CTI_dialCall(b):CTI_makeCall(b);break;case MODE_SMARTDEV:iOS_Device()?openAppSelect(b):Android_Device()&&acsTelTag(b);break;
case MODE_ST500:ST500_makeCall(b);break;case MODE_SIP:!viewModel.primeCall()||viewModel.primeCall()&&viewModel.primeCall().status()==CALL_ST_HOLD?SIP_makeCall(b,a):SIP_sendDTMF(viewModel.primeCall().cid,b)}}}function clickAnsBtn(a,b){a.ansResWait(!0);isTel_CTI()?a.status()==CALL_ST_HOLD?CTI_unholdCall(a.cid):CTI_ansCall(a.cid):isTel_SIP()&&(a.status()===CALL_ST_HOLD?SIP_unholdCall(a.cid):SIP_ansCall(a.cid,b))}
function pickupCall(a){viewModel.callList.remove(a);viewModel.callList.unshift(a);clickAnsBtn(a,!1);closeBkgrndCalls()}function endCall(a){var b=parseInt(a,10);viewModel.phone_mode()===MODE_CTI?CTI_endCall(b):SIP_endCall(a);onEndCall(a)}function clickHoldBtn(a){viewModel.chkHoldCall()&&(isTel_CTI()?CTI_holdCall(a.cid):isTel_SIP()&&SIP_holdCall(a.cid))}
function clickTransBtn(){if(viewModel.chkTransCall()){var a=viewModel.primeCall(),b=viewModel.secondCall();a&&b&&(isTel_CTI()?CTI_transCall(a.cid):isTel_SIP()&&(a.status()==CALL_ST_RINGBK?SIP_TransCall(b.cid,a.cid,a.dial(),sipExt):SIP_TransCall(b.cid,a.cid,a.dial(),b.dial())))}}function cHoldCall(a){if(viewModel.chkConfHold()&&viewModel.phone_mode()===MODE_CTI){var b=parseInt(a,10);viewModel.primeCall().status()===CALL_ST_CSPEAK?CTI_cReHoldCall(b):CTI_cHoldCall(a)}}
function cAddCall(a){viewModel.chkConfAdd()&&viewModel.phone_mode()===MODE_CTI&&(a=parseInt(a,10),CTI_cAddCall(a))}function clickBTransBtn(){viewModel.chkBlindTrans()&&(viewModel.phone_mode()===MODE_CTI?(CTI_holdCall(viewModel.primeCall().cid),viewModel.primeCall().bTransFlag(!0)):viewModel.phone_mode()===MODE_SIP&&(SIP_holdCall(viewModel.primeCall().cid),viewModel.primeCall().bTransFlag(!0)))}function bTransCall(a){isTel_CTI()?makeCall(a):isTel_SIP()&&makeCall(a)}
function adjustClctrlArea(a){viewModel.phone_mode()&&viewModel.phone_mode()!=MODE_ST500?viewModel.primeCall()||viewModel.secondCall()?viewModel.primeCall()&&!viewModel.secondCall()?($("#callctrl_wrap").stop(),$("#callctrl_wrap").css("display","block"),$("#main_wrap").css("height","calc(100% - 30px)"),$("#callctrl_wrap").animate({height:"60px"},500,"",function(){$("#main_wrap").css("height","calc(100% - 90px)");a&&a()})):($("#callctrl_wrap").stop(),$("#callctrl_wrap").css("display","block"),$("#main_wrap").css("height",
"calc(100% - 90px)"),$("#callctrl_wrap").animate({height:"90px"},500,"",function(){$("#main_wrap").css("height","calc(100% - 120px)");a&&a()})):($("#callctrl_wrap").stop(),$("#main_wrap").css("height","100%"),$("#callctrl_wrap").animate({height:"0"},500,"",function(){$("#main_wrap").css("height","calc(100% - 30px)");$("#callctrl_wrap").css("display","none");a&&a()})):($("#callctrl_wrap").stop(),$("#main_wrap").css("height","100%"),$("#callctrl_wrap").css("height","0"),$("#callctrl_wrap").css("display",
"none"),a&&a());0===viewModel.bkgrndCalls().length&&closeBkgrndCalls()}function inputDial(a){$("#tel_input").val($("#tel_input").val()+a);searchTimer&&(clearTimeout(searchTimer),searchTimer=null);viewModel.ipt_dial($("#tel_input").val());viewModel.srch_dial($("#tel_input").val())}function clearDial(){$("#tel_input").val("");searchTimer&&(clearTimeout(searchTimer),searchTimer=null);viewModel.ipt_dial("");viewModel.srch_dial("")}function setDial(a){clearDial();inputDial(a)}
function chgCallMode(){if(viewModel.trkacsDial())if(viewModel.callMode()===CALL_MODE_INT){viewModel.callMode(CALL_MODE_EXT);var a=$("#tel_trkacs").outerWidth()+1;$("#tel_input").css("width","calc(100% - "+a+"px)");$("#tel_trkacs").css("display","block");$("#tel_input").focus()}else initCallMode()}function initCallMode(){viewModel.callMode(CALL_MODE_INT);$("#tel_input").css("width","100%");$("#tel_trkacs").css("display","none");$("#tel_input").focus()}
function searchCallerName(a,b){if(!a)return"";void 0==b&&(b=0);for(var c=0,d=memberList.length;c<d;c++){var e=memberList[c];if(-1!==e.index){var f=[];e.ext()&&f.push(e.ext());e.sipext()&&f.push(e.sipext());e.telArr()[0]&&f.push(e.telArr()[0]);for(var h in e.mobArr())e.mobArr()[h]&&f.push(e.mobArr()[h]);for(h in f)if(f[h]==a)return e.name();if(2<=e.telArr().length&&a===e.telArr()[1])return""!==e.name2?e.name2:e.name();if(3<=e.telArr().length&&a===e.telArr()[2])return""!==e.name3?e.name3:e.name()}}c=
0;for(d=viewModel.comSpdDialList().length;c<d;c++)if(e=viewModel.comSpdDialList()[c],!(0>e.index)&&e.dial()==a)return e.name();if(0==(b>>DIAL_MOD_TRKACS&1)&&viewModel.trkacsDial()&&a.startsWith(viewModel.trkacsDial()))return b|=1<<DIAL_MOD_TRKACS,a=a.slice(viewModel.trkacsDial().length),searchCallerName(a,b);if(0==(b>>DIAL_MOD_SHARP&1)&&"#"==a.charAt(a.length-1))return b|=1<<DIAL_MOD_SHARP,a=a.slice(0,-1),searchCallerName(a,b);if(0==(b>>DIAL_MOD_TRKACS&1)){switch(a){case viewModel.scMdsList()[SRVCODE_MDS_OFF]:case viewModel.scMdsList()[SRVCODE_MDS_ON]:return isJP()?
langTbl.sacs_mds_jp:langTbl.sacs_mds_ot;case viewModel.scVmacs():case viewModel.scVmown():return langTbl.sacs_vm}d=0;c="^(";for(h in viewModel.scCfwList())viewModel.scCfwList()[h]&&(c+=viewModel.scCfwList()[h],c+="|",d++);if(0<d&&(c=convEscapeChar(c),c=c.slice(0,-1),h=new RegExp(c+")[0-9*#]*"),a.match(h)))return langTbl.sacs_fwd;if(viewModel.scDnd()&&(c="^"+viewModel.scDnd(),c=convEscapeChar(c),h=new RegExp(c+"[0-9*#]*"),a.match(h)))return langTbl.sacs_dnd}return""}
function recvFkeyList(a){var b=1,c=1;if(void 0!==a.now&&void 0!==a.end&&(b=a.now,c=a.end,b>c))return;if(1===b)for(var d=viewModel.fkeyList.removeAll(),e=0,f=d.length;e<f;e++)delete d[e];if(void 0!==a.fkey)for(e=0,f=a.fkey.length;e<f;e++)if(d=a.fkey[e],void 0!==d.idx&&void 0!==d.nm){var h="";void 0!==d.ad&&(h=d.ad);d=new fkeyObj(d.idx,d.nm,h,FKEY_COL_NONE,FKEY_BLINK_OFF);viewModel.fkeyList.push(d)}b===c?viewModel.fkeyList.sort(function(a,b){return a.index===b.index?0:a.index>b.index?1:-1}):(getdataTimer&&
clearTimeout(getdataTimer),getdataTimer=setTimeout(function(){clrLoadingOnList()},3E4))}function dispHistory(){viewModel.imAlertList().length?chgSortType(SORT_TYPE_IMLAST,LIST_TYPE_LOGIM):viewModel.callAlertList().length?chgSortType(SORT_TYPE_CALLLAST,LIST_TYPE_LOGCALL):chgSortType(SORT_TYPE_IMLAST,LIST_TYPE_LOGIM)}function recvTrkacsDial(a){void 0!==a.cfg.trkacs&&viewModel.trkacsDial(a.cfg.trkacs)}
function recvCallHistory(a){var b=1,c=1;if(void 0!==a.now&&void 0!==a.end&&(b=a.now,c=a.end,b>c))return;if(1===b)for(var d=viewModel.callHistList.removeAll(),e=0,f=d.length;e<f;e++)delete d[e];if(void 0!==a.hist)for(e=0,f=a.hist.length;e<f;e++)d=a.hist[e],void 0!==d.dd&&""!==d.dd&&(d=new chistObj(d.type,d.dd,d.nm,d.yr,d.mnt,d.dy,d.hr,d.min,d.st),viewModel.callHistList.push(d));b===c?viewModel.callHistList.sort(function(a,b){return a.cmpdate()===b.cmpdate()?a.time===b.time?0:a.time<b.time?1:-1:a.cmpdate()<
b.cmpdate()?1:-1}):(getdataTimer&&clearTimeout(getdataTimer),getdataTimer=setTimeout(function(){clrLoadingOnList()},3E4));b===c?getDataType(viewModel.listType())===DATA_TYPE_HIST&&setLoadingOnList(function(){sortCallHistData(function(){clrLoadingOnList()})}):(getdataTimer&&clearTimeout(getdataTimer),getdataTimer=setTimeout(function(){clrLoadingOnList()},3E4))}function updtCallHistory(){setLoadingOnList(function(){sendEvtGetdata(DATA_TYPE_HIST)})}
function recvCustomPresence(a){if(void 0!==a.cpre){for(var b="location-arrow asterisk at bed coffee book building lock mobile subway".split(" "),c=["green","orange","red"],d=viewModel.cstmStTbl().length=0,e=a.cpre.length;d<e;d++){var f=a.cpre[d];if(void 0!=f.idx&&0<=f.idx&&4>=f.idx&&void 0!=f.i&&0<=f.i&&9>=f.c&&void 0!=f.c&&0<=f.c&&2>=f.c&&void 0!=f.t&&""!=f.t){var h=129+f.idx,g;switch(f.c){case 0:g=3;break;case 1:g=34;break;default:g=73}g+=f.idx;viewModel.cstmStTbl()[h]=[f.t,"fa fa-"+b[f.i],c[f.c],
g,!0]}else l.log("invalid param: ["+f.idx+","+f.i+","+f.c+","+f.t+"]")}l.log("CustomPresence apply:");l.dir(viewModel.cstmStTbl());resetStatusLib()}}
function recvImEnterMode(a){entKeyOp=a.cfg.iment;l.log("enterKeyOperation apply:"+entKeyOp);$(".im_ta").off("keydown.enter");$(".im_ta").on("keydown.enter",function(a){if(13==a.which){if(a.ctrlKey&&0==entKeyOp||!a.ctrlKey&&1==entKeyOp)return sendChat(viewModel.targetUsr(),$(this).val()),!1;if(a.ctrlKey&&1==entKeyOp){a=$(this).val();var b=(a.match(/\n/g)||[]).length;if(512<a.length+b+2)return!1;var b=this.selectionStart,d=b+1;this.value=a.substr(0,b)+"\n"+a.substr(b);this.setSelectionRange(d,d);return!1}}})}
function recvConfig(a){void 0!==a.cfg.trkacs&&recvTrkacsDial(a);void 0!==a.cfg.iment&&recvImEnterMode(a)}
function recvServiceCode(a){void 0!==a.srvcode&&(a=a.srvcode,void 0!==a.cfw_all&&(viewModel.scCfwList()[SRVCODE_CFW_ALL]=a.cfw_all),void 0!==a.cfw_br&&(viewModel.scCfwList()[SRVCODE_CFW_BR]=a.cfw_br),void 0!==a.cfw_bs&&(viewModel.scCfwList()[SRVCODE_CFW_BS]=a.cfw_bs),void 0!==a.cfw_bsna&&(viewModel.scCfwList()[SRVCODE_CFW_BNA]=a.cfw_bsna),void 0!==a.cfw_na&&(viewModel.scCfwList()[SRVCODE_CFW_NA]=a.cfw_na),viewModel.scCfwList.valueHasMutated(),void 0!==a.dnd&&viewModel.scDnd(a.dnd),void 0!==a.mds_on&&
(viewModel.scMdsList()[SRVCODE_MDS_ON]=a.mds_on),void 0!==a.mds_off&&(viewModel.scMdsList()[SRVCODE_MDS_OFF]=a.mds_off),viewModel.scMdsList.valueHasMutated(),void 0!==a.vm_acs&&viewModel.scVmacs(a.vm_acs),void 0!==a.vm_own&&viewModel.scVmown(a.vm_own))}var blink_timer=null,blinking=0;
function fkeyBlinkStart(){blink_timer||(blink_timer=setInterval(function(){i=0;for(len=viewModel.fkeyList().length;i<len;i++)switch(key=viewModel.fkeyList()[i],!0){case key.blink()===FKEY_BLINK_FAST&&1===blinking:case key.blink()===FKEY_BLINK_FAST&&3===blinking:case key.blink()===FKEY_BLINK_SLOW&&2===blinking:case key.blink()===FKEY_BLINK_SLOW&&3===blinking:$("#fkey_"+i).addClass("color_light_gray");break;default:$("#fkey_"+i).removeClass("color_light_gray")}blinking=(blinking+1)%4},200))}
function fkeyBlinkStop(){clearInterval(blink_timer);blink_timer=null;blinking=0}function clickFkey(a){sendJsonData({type:"event",event:"cti",data:{evt:"fkey",idx:viewModel.fkeyList()[a].index}})}function CTI_makeCall(a){a&&sendJsonData({type:"event",event:"cti",data:{evt:"make",dd:a}})}function CTI_dialCall(a){a&&sendJsonData({type:"event",event:"cti",data:{evt:"dial",dd:a}})}function CTI_ansCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"ans",cid:a}})}
function CTI_endCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"end",cid:a}})}function CTI_holdCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"hold",cid:a}})}function CTI_unholdCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"unhold",cid:a}})}function CTI_transCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"trans",cid:a}})}
function CTI_cHoldCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"c-hold",cid:a}})}function CTI_cAddCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"c-add",cid:a}})}function CTI_cReHoldCall(a){a=parseInt(a,10);sendJsonData({type:"event",event:"cti",data:{evt:"c-rehold",cid:a}})}
function CTI_onStatus(a){if(void 0!==a.cid){a.cid=""+a.cid;l.dir(viewModel.callList());var b=searchCall(a.cid);if(b)switch(b.status()){case CALL_ST_IDLE:l.log("now status: IDLE");CTI_idle_handler(a);break;case CALL_ST_RINGBK:l.log("now status: RINGBK");CTI_ring_handler(a);break;case CALL_ST_INCOM:l.log("now status: INCOM");CTI_incom_handler(a);break;case CALL_ST_SPEAK:l.log("now status: SPEAK");CTI_speak_handler(a);break;case CALL_ST_HOLD:l.log("now status: HOLD");CTI_hold_handler(a);break;case CALL_ST_DIAL:l.log("now status: DIAL");
CTI_dial_handler(a);break;case CALL_ST_BUSY:l.log("now status: BUSY");CTI_busy_handler(a);break;case CALL_ST_CHOLD:l.log("now status: CHOLD");CTI_chold_handler(a);break;case CALL_ST_CSPEAK:l.log("now status: CSPEAK");CTI_cspeak_handler(a);break;case CALL_ST_INCONF:l.log("now status: INCONF");CTI_inconf_handler(a);break;case CALL_ST_SRVCODE:l.log("now status: SRVCODE");CTI_srvcode_handler(a);break;default:l.log("now status: UNKNOWN")}else l.log("now status: IDLE( not_exist )"),CTI_idle_handler(a)}}
function CTI_idle_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");onCall(a.cid,a.dd);break;case 3:l.log("status event: DIAL");onDialTone(a.cid);break;case 5:l.log("status event: RINGBACK");onRingBack(a.cid,a.dd);break;case 6:l.log("status event: BUSY");break;case 8:l.log("status event: CONNECTED");onTransCall(a.cid,a.dd);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");onConfHold(a.cid);
break;case 13:l.log("status event: HOLD-TRANS");break;case 14:l.log("status event: DISCONNECTED");break;case 15:l.log("status event: UNKNOWN");break;default:l.log("status event: undefined")}}
function CTI_ring_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");break;case 6:l.log("status event: BUSY");onBusyCall(a.cid);break;case 8:l.log("status event: CONNECTED");onAnsCall(a.cid,a.dd);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");break;case 14:l.log("status event: DISCONNECTED");
onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_incom_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");onRingBack(a.cid,a.dd);break;case 6:l.log("status event: BUSY");break;case 8:l.log("status event: CONNECTED");onAnsCall(a.cid,a.dd);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");break;
case 14:l.log("status event: DISCONNECTED");onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_speak_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");break;case 6:l.log("status event: BUSY");onBusyCall(a.cid);break;case 8:l.log("status event: CONNECTED");break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");onConferenced(a.cid);break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");onHold(a.cid);
break;case 14:l.log("status event: DISCONNECTED");onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_hold_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");onCall(a.cid,a.dd);break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");break;case 6:l.log("status event: BUSY");break;case 8:l.log("status event: CONNECTED");onAnsCall(a.cid,a.dd);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");onConferenced(a.cid);break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");
break;case 14:l.log("status event: DISCONNECTED");onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_dial_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");onRingBack(a.cid,a.dd);break;case 6:l.log("status event: BUSY");onBusyCall(a.cid);break;case 8:l.log("status event: CONNECTED");onAnsCall(a.cid,a.dd);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");onConfHold(a.cid);break;case 13:l.log("status event: HOLD-TRANS");
break;case 14:l.log("status event: DISCONNECTED");onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_busy_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");onRingBack(a.cid,a.dd);break;case 6:l.log("status event: BUSY");break;case 8:l.log("status event: CONNECTED");onAnsCall(a.cid,a.dd);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");break;
case 14:l.log("status event: DISCONNECTED");onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_chold_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");onDialTone(a.cid);break;case 5:l.log("status event: RINGBACK");break;case 6:l.log("status event: BUSY");break;case 8:l.log("status event: CONNECTED");onConfStart(a.cid);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");break;case 14:l.log("status event: DISCONNECTED");
onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_cspeak_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");break;case 6:l.log("status event: BUSY");onBusyCall(a.cid);break;case 8:l.log("status event: CONNECTED");break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");onConfHold(a.cid);break;case 13:l.log("status event: HOLD-TRANS");break;case 14:l.log("status event: DISCONNECTED");
onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_inconf_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");break;case 6:l.log("status event: BUSY");break;case 8:l.log("status event: CONNECTED");onAnsCall(a.cid,a.dd);break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");break;case 14:l.log("status event: DISCONNECTED");
onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}
function CTI_srvcode_handler(a){if(void 0!==a.sts)switch(a.sts){case 2:l.log("status event: OFFERING");break;case 3:l.log("status event: DIAL");break;case 5:l.log("status event: RINGBACK");break;case 6:l.log("status event: BUSY");break;case 8:l.log("status event: CONNECTED");break;case 10:l.log("status event: HOLD");break;case 11:l.log("status event: CONF");break;case 12:l.log("status event: HOLD-CONF");break;case 13:l.log("status event: HOLD-TRANS");break;case 14:l.log("status event: DISCONNECTED");
onEndCall(a.cid);break;case 15:l.log("status event: UNKNOWN");onEndCall(a.cid);break;default:l.log("status event: undefined")}}function CTI_onFkey(a){if(viewModel.phone_mode()===MODE_CTI)for(i=0,len=viewModel.fkeyList().length;i<len;i++)if(fkey=viewModel.fkeyList()[i],fkey.index===a.idx){fkey.color(a.col);switch(a.blk){case 1:case 2:case 5:case 6:fkey.blink(FKEY_BLINK_SLOW);break;case 3:case 4:fkey.blink(FKEY_BLINK_FAST);break;default:fkey.blink(FKEY_BLINK_OFF)}break}}
function showBkgrndCalls(){"none"==$("#tel_bkgrnd_mask").css("display")?$("#tel_bkgrnd_mask").css("display","block"):$("#tel_bkgrnd_mask").css("display","none")}function closeBkgrndCalls(){$("#tel_bkgrnd_mask").css("display","none")}function dispFkeyList(){"none"!==$("#tel_fkeylist_wrap").css("display")?closeFkeyList():(closeSrvAcs(),fkeyBlinkStart(),$(".inner_window").css("display","none"),$("#tel_fkeylist_wrap").css("display","block"))}
function closeFkeyList(){$("#tel_fkeylist_wrap").css("display","none");fkeyBlinkStop()}function isTel_CTI(){try{return viewModel.phone_mode()===MODE_CTI}catch(a){return!1}}function isTel_SIP(){try{return viewModel.phone_mode()===MODE_SIP}catch(a){return!1}}function isTel_Mobile(){try{return viewModel.phone_mode()===MODE_SMARTDEV}catch(a){return!1}}
function CTI_onTelephony(a){if(0===a.sts){switch(a.type){case 1:viewModel.term_type(TERM_TYPE_KST);break;default:viewModel.term_type(TERM_TYPE_UNKNOWN)}viewModel.phone_mode(MODE_CTI)}else{switch(a.sts){case 1:openDialog(langTbl.d_error_13+"</br>"+langTbl.d_error_12+"[code=0417]",dlgBtnList[D_BTN_CNFIM]);break;case 2:openDialog(langTbl.d_login_4+"</br>"+langTbl.d_error_12+"[code=0082]",dlgBtnList[D_BTN_CNFIM]);break;case 3:openDialog(langTbl.d_error_10+"</br>"+langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]);
break;case 4:openDialog(langTbl.d_error_11+"</br>"+langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]);break;default:openDialog(langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM])}user_phone=MODE_NONE;viewModel.phone_mode(MODE_NONE)}}
function smtdev_onTelephony(a){if(0===a.sts)viewModel.phone_mode(MODE_SMARTDEV);else{switch(a.sts){case 1:openDialog(langTbl.d_error_13+"</br>"+langTbl.d_error_12+"[code=0417]",dlgBtnList[D_BTN_CNFIM]);break;default:openDialog(langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM])}user_phone=MODE_NONE;viewModel.phone_mode(MODE_NONE)}}
function SIP_onTelephony(a){if(0===a.sts)viewModel.phone_mode(MODE_SIP),viewModel.phone_mode()===MODE_SIP&&sipExt&&setupSipPhone(sipExt,sipPW);else{switch(a.sts){case 1:openDialog(langTbl.d_error_13+"</br>"+langTbl.d_error_12+"[code=0417]",dlgBtnList[D_BTN_CNFIM]);break;case 5:openDialog(langTbl.d_login_4+"</br>"+langTbl.d_error_12+"[code=0084]",dlgBtnList[D_BTN_CNFIM]);break;case 6:openDialog(langTbl.d_error_15+"</br>"+langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]);break;case 7:openDialog(langTbl.d_error_13+
"</br>"+langTbl.d_error_12+"[code=0030]",dlgBtnList[D_BTN_CNFIM]);break;case 8:openDialog(langTbl.d_error_17+"</br>"+langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]);break;case 9:openDialog(langTbl.d_error_13+"</br>"+langTbl.d_error_12+"[code=0419]",dlgBtnList[D_BTN_CNFIM]);break;case 10:openDialog(langTbl.d_error_18+"</br>"+langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]);break;case 11:openDialog(langTbl.d_error_19+"</br>"+langTbl.d_error_12+"[code=842615]",dlgBtnList[D_BTN_CNFIM]);break;case 12:openDialog(langTbl.d_error_19+
"</br>"+langTbl.d_error_12+"[code=205743]",dlgBtnList[D_BTN_CNFIM]);break;case 13:openDialog(langTbl.d_error_19+"</br>"+langTbl.d_error_12+"[code=150516]",dlgBtnList[D_BTN_CNFIM]);break;case 14:openDialog(langTbl.d_error_19+"</br>"+langTbl.d_error_12+"[code=206406]",dlgBtnList[D_BTN_CNFIM]);break;case 15:openDialog(langTbl.d_error_19+"</br>"+langTbl.d_error_12+"[code=206407]",dlgBtnList[D_BTN_CNFIM]);break;case 16:openDialog(langTbl.d_error_19+"</br>"+langTbl.d_error_12+"[code=206408]",dlgBtnList[D_BTN_CNFIM]);
break;case 17:openDialog(langTbl.d_error_19+"</br>"+langTbl.d_error_12+"[code=842703]",dlgBtnList[D_BTN_CNFIM]);break;default:openDialog(langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM])}user_phone=MODE_NONE;viewModel.phone_mode(MODE_NONE)}}
function ST500_onTelephony(a){if(0===a.sts){try{iOS_Device()?webkit.messageHandlers.notifyLoginStateOfInUC.postMessage("1"):androidJavascriptInterface.notifyLoginStateOfInUC("1")}catch(b){l.log("Fail to Callback notifyLoginStateOfInUC(1);")}viewModel.phone_mode(MODE_ST500);viewModel.term_type()==TERM_TYPE_GT890?viewModel.check_qvl(!1):viewModel.check_qvl(!0);adjustStyleSheet()}else{switch(a.sts){case 18:openDialog(langTbl.d_error_12+"[code=0420]",dlgBtnList[D_BTN_LOGOUT]);break;default:openDialog(langTbl.d_error_12,
dlgBtnList[D_BTN_LOGOUT])}viewModel.phone_mode(MODE_ST500)}}function none_onTelephony(a){openDialog(langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]);user_phone=MODE_NONE;viewModel.phone_mode(MODE_NONE)}
function dispSrvAcs(a){if(viewModel.sacsPage()===SACS_NONE||a!==SACS_DEFAULT&&viewModel.sacsPage()!==a){closeFkeyList();switch(a){case SACS_CFW:dispSacsCFW();break;case SACS_DND:dispSacsDND();break;case SACS_MDS:dispSacsMDS();break;default:dispSacsMain()}$(".inner_window").css("display","none")}else closeSrvAcs()}function closeSrvAcs(){viewModel.sacsPage(SACS_NONE)}
function initSacs(){for(var a=viewModel.sacsList.removeAll(),b=0,c=a.length;b<c;b++)delete a[b];viewModel.phone_mode()&&(a=[],a.push(new sacsObj(SACS_CFW,langTbl.sacs_fwd,"fa fa-share",dispSacsCFW,"")),a.push(new sacsObj(SACS_DND,langTbl.sacs_dnd,"fa fa-ban",dispSacsDND,"")),viewModel.phone_mode()!==MODE_CTI&&viewModel.sacsMdsStatus()!==SRVCODE_MDS_NONE&&(isJP()?a.push(new sacsObj(SACS_MDS,langTbl.sacs_mds_jp,"fa fa-link",dispSacsMDS,"")):a.push(new sacsObj(SACS_MDS,langTbl.sacs_mds_ot,"fa fa-link",
dispSacsMDS,""))),isJP()||viewModel.system()==SYS_TYPE_SL2100&&viewModel.phone_mode()==MODE_ST500||"0"===webPt&&"0"===httpPort||a.push(new sacsObj(SACS_DEFAULT,langTbl.sacs_webpro,"fa fa-laptop",openWebPro,"")),isTel_SIP()&&a.push(new sacsObj(SACS_NONE,langTbl.cfg_mediadev,"fa fa-cog",openMediaCfg,"")),viewModel.sacsList.push.apply(viewModel.sacsList,a))}
function clickRadioBtn(a,b){if(!(0>b))for(var c=a.match(/.*_mode/),d=document.getElementsByClassName(a),e=0,f=d.length;e<f;e++){var h=$(d[e]).children(".faol")[0],h=$(h).children(".fa")[0];e===b?(c&&viewModel.sacsMode(SRVCODE_ON),$(h).removeClass("fa-circle-o"),$(h).addClass("fa-circle")):(c&&viewModel.sacsMode(SRVCODE_OFF),$(h).removeClass("fa-circle"),$(h).addClass("fa-circle-o"))}}
function isSelectedRadio(a){a=$(a).children(".faol")[0];a=$(a).children(".fa")[0];return $(a).hasClass("fa-circle")}function dispSacsMain(){viewModel.sacsPage(SACS_DEFAULT)}function dispSacsCFW(){viewModel.sacsPage(SACS_CFW);clickRadioBtn("cfw_mode",0);clickRadioBtn("cfw_type",viewModel.scCfwTop());$("#cfw_input").val("");sendEvtGetstatus(STATUS_TYPE_CFW)}function dispSacsDND(){viewModel.sacsPage(SACS_DND);clickRadioBtn("dnd_mode",0);clickRadioBtn("dnd_type",0);sendEvtGetstatus(STATUS_TYPE_DND)}
function dispSacsMDS(){viewModel.sacsPage(SACS_MDS);clickRadioBtn("mds_mode",viewModel.scMdsTop());sendEvtGetstatus(STATUS_TYPE_MDS)}function openWebPro(){if("0"===webPt&&"0"===httpPort)l.log("TCP port number for web programming has not been set.");else{var a;a=SrvAddr?SrvAddr:location.host;"0"===webPt?(a="http://"+a,"80"!==httpPort&&(a+=":"+httpPort)):(a="https://"+a,"443"!==webPt&&(a+=":"+webPt));subWin=window.open(a)}}
function makeScCall(a){if(viewModel.chkMakeScCall()){var b=makeScDial(a);if(b){switch(a){case SRVCODE_CFW:case SRVCODE_DND:case SRVCODE_MDS:viewModel.sc_flag(SCFLAG_ON_HIDDEN);break;case SRVCODE_VMACS:viewModel.sc_flag(SCFLAG_ON_VMACS);break;default:return}setScResTimer();switch(viewModel.phone_mode()){case MODE_CTI:CTI_makeCall(b);switch(a){case SRVCODE_CFW:setLoadingOnList();setTimeout(function(){dispSacsCFW()},3E3);break;case SRVCODE_DND:setLoadingOnList();setTimeout(function(){dispSacsDND()},
3E3);break;case SRVCODE_MDS:setLoadingOnList(),setTimeout(function(){dispSacsMDS()},3E3)}break;case MODE_SMARTDEV:iOS_Device()?openAppSelect(b):Android_Device()&&acsTelTag(b);switch(a){case SRVCODE_CFW:case SRVCODE_DND:case SRVCODE_MDS:dispSacsMain()}break;case MODE_ST500:ST500_makeCall(b);break;case MODE_SIP:switch(SIP_makeCall(b,!1),a){case SRVCODE_CFW:setLoadingOnList();setTimeout(function(){dispSacsCFW()},3E3);break;case SRVCODE_DND:setLoadingOnList();setTimeout(function(){dispSacsDND()},3E3);
break;case SRVCODE_MDS:setLoadingOnList(),setTimeout(function(){dispSacsMDS()},3E3)}}}}}function makeScDial(a){var b="";switch(a){case SRVCODE_CFW:b=makeScDial_cfw();break;case SRVCODE_DND:b=makeScDial_dnd();break;case SRVCODE_MDS:b=makeScDial_mds();break;case SRVCODE_VMACS:b=makeScDial_vmacs()}return b}
function makeScDial_cfw(){for(var a="",b=document.getElementsByClassName("cfw_type"),c=void 0,d=0,e=b.length;d<e;d++)if(isSelectedRadio(b[d])){c=d;break}if(void 0===c)return"";switch(c){case SRVCODE_CFW_ALL:a+=viewModel.scCfwList()[SRVCODE_CFW_ALL];break;case SRVCODE_CFW_BR:a+=viewModel.scCfwList()[SRVCODE_CFW_BR];break;case SRVCODE_CFW_BS:a+=viewModel.scCfwList()[SRVCODE_CFW_BS];break;case SRVCODE_CFW_BNA:a+=viewModel.scCfwList()[SRVCODE_CFW_BNA];break;case SRVCODE_CFW_NA:a+=viewModel.scCfwList()[SRVCODE_CFW_NA];
break;default:return""}if(!a)return"";b=document.getElementsByClassName("cfw_mode");c=SRVCODE_OFF;d=0;for(e=b.length;d<e;d++)isSelectedRadio(b[d])&&(c=d);switch(c){case SRVCODE_OFF:a+=0;break;case SRVCODE_ON:a+=1;break;default:return""}if(c===SRVCODE_ON)if($("#cfw_input").val())a+=$("#cfw_input").val();else return"";return a}
function makeScDial_dnd(){var a=viewModel.scDnd();if(!a)return"";for(var b=SRVCODE_OFF,c=-1,d=document.getElementsByClassName("dnd_mode"),e=0,f=d.length;e<f;e++)isSelectedRadio(d[e])&&(b=e);switch(b){case SRVCODE_OFF:a+=0;break;case SRVCODE_ON:d=document.getElementsByClassName("dnd_type");e=0;for(f=d.length;e<f;e++)if(isSelectedRadio(d[e])){c=e;break}if(-1===c)return"";switch(c){case SRVCODE_DND_ALL:a+=3;break;case SRVCODE_DND_EXT:a+=1;break;case SRVCODE_DND_INT:a+=2;break;case SRVCODE_DND_TRNS:a+=
4;break;default:return""}break;default:return""}return a}function makeScDial_mds(){for(var a="",b=document.getElementsByClassName("mds_mode"),c=SRVCODE_OFF,d=0,e=b.length;d<e;d++)isSelectedRadio(b[d])&&(c=d);switch(c){case SRVCODE_OFF:a+=viewModel.scMdsList()[SRVCODE_MDS_OFF];break;case SRVCODE_ON:a+=viewModel.scMdsList()[SRVCODE_MDS_ON];break;default:return""}return a}function makeScDial_vmacs(){return viewModel.scVmown()}
function setScResTimer(){scResTimer&&clearTimeout(scResTimer);scResTimer=setTimeout(function(){viewModel.sc_flag(SCFLAG_OFF)},1E4)}function stopScResTimer(){scResTimer&&(clearTimeout(scResTimer),scResTimer=null)}function setScDiscTimer(a){scDiscTimer&&clearTimeout(scDiscTimer);scResTimer=setTimeout(function(a){endCall(a)},1E3,a)}function stopScDiscTimer(){scDiscTimer&&(clearTimeout(scDiscTimer),scDiscTimer=null)}
var ToneArr=[],TONE_NONE=0,TONE_RINGBACK=1,TONE_MUSIC=2,TONE_RINGING=3,DtmfTone=[],DTMF_0=0,DTMF_1=1,DTMF_2=2,DTMF_3=3,DTMF_4=4,DTMF_5=5,DTMF_6=6,DTMF_7=7,DTMF_8=8,DTMF_9=9,DTMF_AST=10,DTMF_SHP=11,AudioContext=window.AudioContext||window.webkitAudioContext,a_ctx=null,a_src=null;function initToneManager(){void 0!==AudioContext&&null==a_ctx&&(a_ctx=new AudioContext)}
function setupToneManager(){var a=[],b=function(){l.log("...  setupToneManagerRetry ");setTimeout(function(){setupToneManager()},3E3)};void 0===ToneArr[TONE_RINGBACK]&&(a[TONE_RINGBACK]=new XMLHttpRequest,a[TONE_RINGBACK].open("GET","mp3/rbt.mp3",!0),a[TONE_RINGBACK].responseType="arraybuffer",a[TONE_RINGBACK].onload=function(){4===a[TONE_RINGBACK].readyState&&(200===a[TONE_RINGBACK].status?(a[TONE_RINGBACK].onload=null,a[TONE_RINGBACK].onerror=null,a_ctx.decodeAudioData(a[TONE_RINGBACK].response).then(function(a){ToneArr[TONE_RINGBACK]=
a;viewModel.primeCall()?toneManager(viewModel.primeCall().status()):toneManager(CALL_ST_IDLE)},function(a){console.dir(a);delete ToneArr[TONE_RINGBACK];l.log("-----------------\x3e  Error! Delete TONE_RINGBACK!");b()})):l.log("-----------------\x3e  Error! state="+a[TONE_RINGBACK].status+" TONE_RINGBACK!"))},a[TONE_RINGBACK].onerror=function(c){l.log("request TONE_RINGBACK onerror!");l.dir(c);a[TONE_RINGBACK].onload=null;a[TONE_RINGBACK].onerror=null;b()},a[TONE_RINGBACK].send());void 0===ToneArr[TONE_MUSIC]&&
(a[TONE_MUSIC]=new XMLHttpRequest,a[TONE_MUSIC].open("GET","mp3/music.mp3",!0),a[TONE_MUSIC].responseType="arraybuffer",a[TONE_MUSIC].onload=function(){4===a[TONE_MUSIC].readyState&&(200===a[TONE_MUSIC].status?(a[TONE_MUSIC].onload=null,a[TONE_MUSIC].onerror=null,a_ctx.decodeAudioData(a[TONE_MUSIC].response).then(function(a){ToneArr[TONE_MUSIC]=a;viewModel.primeCall()?toneManager(viewModel.primeCall().status()):toneManager(CALL_ST_IDLE)},function(a){console.dir(a);delete ToneArr[TONE_MUSIC];l.log("-----------------\x3e  Error! Delete TONE_MUSIC!");
b()})):l.log("-----------------\x3e  Error! state="+a[TONE_MUSIC].status+" TONE_MUSIC!"))},a[TONE_MUSIC].onerror=function(c){l.log("request TONE_MUSIC onerror!");l.dir(c);a[TONE_MUSIC].onload=null;a[TONE_MUSIC].onerror=null;b()},a[TONE_MUSIC].send());void 0===ToneArr[TONE_RINGING]&&(a[TONE_RINGING]=new XMLHttpRequest,a[TONE_RINGING].open("GET","mp3/ring.mp3",!0),a[TONE_RINGING].responseType="arraybuffer",a[TONE_RINGING].onload=function(){4===a[TONE_RINGING].readyState&&(200===a[TONE_RINGING].status?
(a[TONE_RINGING].onload=null,a[TONE_RINGING].onerror=null,a_ctx.decodeAudioData(a[TONE_RINGING].response).then(function(a){ToneArr[TONE_RINGING]=a;viewModel.primeCall()?toneManager(viewModel.primeCall().status()):toneManager(CALL_ST_IDLE)},function(a){console.dir(a);delete ToneArr[TONE_RINGING];l.log("-----------------\x3e  Error! Delete TONE_RINGING!");b()})):l.log("-----------------\x3e  Error! state="+a[TONE_RINGING].status+" TONE_RINGING!"))},a[TONE_RINGING].onerror=function(c){l.log("request TONE_RINGING onerror!");
l.dir(c);a[TONE_RINGING].onload=null;a[TONE_RINGING].onerror=null;b()},a[TONE_RINGING].send())}
function toneManager(a){var b=TONE_NONE;if(viewModel.phone_mode()==MODE_SIP){switch(a){case CALL_ST_RINGBK:b=TONE_RINGBACK;break;case CALL_ST_HELD:b=TONE_MUSIC;break;case CALL_ST_INCOM:b=TONE_RINGING}if(a_src)if(a_src.tone!=b)a_src.stop(),a_src=null;else return;b!=TONE_NONE&&(ToneArr[b]?(a_src=a_ctx.createBufferSource(),a_src.buffer=ToneArr[b],a_src.tone=b,a_src.loop=!0,a_src.connect(a_ctx.destination),a_src.start(0)):(l.log("toneplay not ready."),setupToneManager()))}}
function clearToneManager(){for(var a in ToneArr)delete ToneArr[a];a_src&&(a_src.stop(),a_src=null)}
function dtmfToneLoader(a){var b=function(){l.log("...  dtmfToneLoaderRetry["+a+"]");setTimeout(function(){dtmfToneLoader(a)},3E3)},c=new XMLHttpRequest;c.open("GET","mp3/d_"+a+".mp3",!0);c.responseType="arraybuffer";c.onload=function(){4===c.readyState&&(c.onload=null,c.onerror=null,200===c.status?a_ctx.decodeAudioData(c.response).then(function(b){DtmfTone[a]=b},function(c){console.dir(c);DtmfTone[a]&&(delete DtmfTone[a],l.log("-----------------\x3e  Error! Delete DTMF tone["+a+"]!"));b()}):l.log("-----------------\x3e  Error! state="+
c.status+" DTMF["+a+"]!"))};c.onerror=function(a){l.log("request onerror!");l.dir(a);c.onload=null;c.onerror=null;b()};c.send();return c}function setupDtmfTone(a){for(var b=DTMF_0;b<=DTMF_SHP;b++)void 0===DtmfTone[b]&&dtmfToneLoader(b);a&&playDtmfTone(a)}
function playDtmfTone(a){if(viewModel.phone_mode()==MODE_SIP){var b=null,c=null;1<a.length&&(setTimeout(function(a){playDtmfTone(a.slice(1))},200,a),a=a.charAt(0));switch(a){case "0":case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":b=DtmfTone[parseInt(a,10)];break;case "*":b=DtmfTone[DTMF_AST];break;case "#":b=DtmfTone[DTMF_SHP];break;default:return}b?(c=a_ctx.createBufferSource(),c.buffer=b,c.connect(a_ctx.destination),c.start(0)):setupDtmfTone(a)}}
function clearDtmfTone(){for(var a in DtmfTone)delete DtmfTone[a]}var sipPhone=null,reRegTimer=null;
function setupSipPhone(a,b){l.log("setup SIP : "+a+" / "+b);1<debuglog?JsSIP.debug.enable("JsSIP:*"):JsSIP.debug.disable("JsSIP:*");reRegTimer&&(clearTimeout(reRegTimer),reRegTimer=null);sipPhone?(deleteSipPhone(),reRegTimer=setTimeout(function(a,b){setupSipPhone(a,b);reRegTimer=null},300,a,b)):a&&(setupToneManager(),setupDtmfTone(),sipPhone=new sipUaObj(SrvAddr,sowsPt,voipIp),sipPhone.register(a,b),viewModel.sipRegStatus(SIP_REGISTERING),sipPhone.bind("connection",function(a){l.log("<<<<<< recieve sip event <<<<<<");
a.info&&l.log("connection event: "+a.info);l.dir(a);switch(a.info){case "connected":onSipConnected(a);break;case "disconnected":onSipDisconnected(a)}}),sipPhone.bind("registration",function(a){l.log("<<<<<< recieve sip event <<<<<<");a.info&&l.log("registration event: "+a.info);l.dir(a);switch(a.info){case "registered":onSipRegistered(a);break;case "unregistered":onSipUnRegistered(a);break;case "failed":onSipUnRegistered(a)}}),sipPhone.bind("session",function(a){l.log("<<<<<< recieve sip event <<<<<<");
a.info&&l.log("session event: "+a.info);l.dir(a);switch(a.info){case "incoming":onSipIncoming(a);break;case "ringback":onSipRingBack(a);break;case "progress":onSipProgress(a);break;case "confirmed":onSipConfirmed(a);break;case "ended":onSipEnded(a);break;case "failed":onSipCallFailed(a);break;case "update":onSipUpdate(a);break;case "muted":onSipMuted(a);break;case "unmuted":onSipUnmuted(a);break;case "hold":onSipHold(a);break;case "unhold":onSipUnhold(a);break;case "refer":onSipReferSuccess(a);break;
case "replaces":onSipReplaces(a)}}),sipPhone.bind("error",function(a){l.log("<<<<<< recieve sip event <<<<<<");a.info&&l.log("error event: "+a.info);l.dir(a);onSipError(a)}),sipPhone.bind("modStream",function(a){onSipModStream(a)}))}function deleteSipPhone(){deleteCallList();sipPhone&&(sipPhone.destroy(),sipPhone=null,viewModel.sipRegErrStr(viewModel.langJs().d_error_2),viewModel.sipRegStatus(SIP_NOT_REGISTERED))}
function dispSipRegError(){viewModel.sipRegStatus()==SIP_NOT_REGISTERED&&(""==viewModel.sipRegErrStr()?openDialog(langTbl.d_error_16,dlgBtnList[D_BTN_CNFIM]):viewModel.isStandAlone()?openDialog(viewModel.sipRegErrStr(),dlgBtnList[D_BTN_CNFIM]):openDialog(viewModel.sipRegErrStr()+"</br>"+langTbl.d_pre_4,dlgBtnList[D_BTN_SIP_RETRY]))}function getRemoteStreamAll(){for(var a=0,b=viewModel.callList().length;a<b;a++){var c=viewModel.callList()[a];sipPhone.getStream(c.cid)}}var makeCallType=TYPE_VOICE_CALL;
function SIP_makeCall(a,b){a&&(sipPhone?(a=appendSharpDial(a),makeCallType=b?TYPE_VIDEO_CALL:TYPE_VOICE_CALL,startVideo(function(){if(constraints.audio)if(b&&!constraints.video)openDialog(viewModel.langJs().alt_no_video,dlgBtnList[D_BTN_CNFIM]);else{var c={audio:0!=constraints.audio?!0:!1,video:0!=constraints.video&b?!0:!1},c=makeModifiedStream(VVM.localStreams()[VVM.localStreams().length-1],c);sipPhone.call(a,c)}else openDialog(viewModel.langJs().alt_no_audio,dlgBtnList[D_BTN_CNFIM])},null)):l.log("SIP Phone Object is not exist!"))}
function appendSharpDial(a){return a}
function SIP_ansCall(a,b){if(a)if(sipPhone){var c=searchCall(a);c&&(c.callType(b?TYPE_VIDEO_CALL:TYPE_VOICE_CALL),startVideo(function(){if(constraints.audio)if(b&&!constraints.video)openDialog(viewModel.langJs().alt_no_video,dlgBtnList[D_BTN_CNFIM]);else{var c={audio:0!=constraints.audio?!0:!1,video:0!=constraints.video&b?!0:!1},c=makeModifiedStream(VVM.localStreams()[VVM.localStreams().length-1],c);sipPhone.answer(a,c)}else openDialog(viewModel.langJs().alt_no_audio,dlgBtnList[D_BTN_CNFIM])},null))}else l.log("SIP Phone Object is not exist!")}
function SIP_endCall(a){a&&(sipPhone?sipPhone.end(a):l.log("SIP Phone Object is not exist!"))}function SIP_holdCall(a){if(a)if(sipPhone){var b=searchCall(a);b&&(unmuteAudio(b),sipPhone.hold(a,function(){onHold(a)}))}else l.log("SIP Phone Object is not exist!")}
function SIP_unholdCall(a){if(a)if(sipPhone){var b=searchCall(a);b&&(b={audio:!0,video:b.callType()==TYPE_VIDEO_CALL?!0:!1},b=makeModifiedStream(VVM.localStreams()[VVM.localStreams().length-1],b),sipPhone.changeStream(a,b,{audio:!0,video:!0}),sipPhone.unhold(a,function(){sipPhone.getStream(a);onAnsCall(a,null)}))}else l.log("SIP Phone Object is not exist!")}function SIP_sendDTMF(a,b){a&&b&&(sipPhone?(playDtmfTone(b),sipPhone.dtmf(a,b)):l.log("SIP Phone Object is not exist!"))}
function SIP_TransCall(a,b,c,d){sipPhone?sipPhone.refer(a,b,c,d):l.log("SIP Phone Object is not exist!")}
function SIP_bTransCall(){if(sipPhone){var a="";viewModel.trkacsDial()&&viewModel.callMode()===CALL_MODE_EXT&&(a+=viewModel.trkacsDial());a+=viewModel.ipt_dial();if(a=appendSharpDial(a))closeDialer(),clearDial(),viewModel.primeCall().status()==CALL_ST_HOLD?sipPhone.refer(viewModel.primeCall().cid,null,a,viewModel.myExt()):sipPhone.hold(viewModel.primeCall().cid,function(){onHold(viewModel.primeCall().cid);sipPhone.refer(viewModel.primeCall().cid,null,a,viewModel.myExt())})}else l.log("SIP Phone Object is not exist!")}
function SIP_getStream(a){a&&sipPhone.getStream(a)}function onSipConnected(a){}function onSipDisconnected(a){"sc_presence"==sc_type&&viewModel.sipRegStatus()!==SIP_NOT_REGISTERED&&(openDialog(langTbl.d_error_12,dlgBtnList[D_BTN_CNFIM]),viewModel.sipRegStatus(SIP_NOT_REGISTERED),deleteSipPhone())}function onSipRegistered(a){viewModel.sipRegStatus(SIP_REGISTERED);updtVideoConstraint()}
function onSipUnRegistered(a){l.log("Registration failed : "+a.cause);a.code?viewModel.sipRegErrStr(a.code+": "+a.cause):viewModel.sipRegErrStr(a.cause);viewModel.sipRegStatus(SIP_NOT_REGISTERED)}function onSipIncoming(a){var b=a.cid,c=a.v_flg;onCall(b,a.caller,c);(a=searchCall(b))&&a.callType(c?TYPE_VIDEO_CALL:TYPE_VOICE_CALL)}
function onSipRingBack(a){var b=a.cid,c=a.caller;void 0!==a.v_flg&&(makeCallType=a.v_flg?TYPE_VIDEO_CALL:TYPE_VOICE_CALL);if(viewModel.sc_flag()==SCFLAG_ON_HIDDEN)onDialToneSc(a.cid);else if(onRingBack(b,c),a=searchCall(b))a.callType(makeCallType),viewModel.sc_flag()==SCFLAG_ON_VMACS&&(viewModel.sc_flag(SCFLAG_OFF),stopScResTimer(),a.vmacs_status(VMACS_ST_WT_ACS))}function onSipError(a){}function onSipEnded(a){makeCallHist(a.cid);onEndCall(a.cid)}
function onSipCallFailed(a){a.code&&openDialog(a.cause+"("+a.code+")",dlgBtnList[D_BTN_CNFIM]);onSipEnded(a)}function onSipUpdate(a){viewModel.primeCall()&&a.cid==viewModel.primeCall().cid&&viewModel.primeCall().status()==CALL_ST_SPEAK&&setTimeout(function(){sipPhone.getStream(a.cid)},500)}function onSipProgress(a){if(183==a.code){sipPhone.getStream(a.cid);onEarlyMedia(a.cid);var b=searchCall(a.cid);b&&(b.video||addVideo(b.name(),null,!1,b));sipPhone.getStream(a.cid)}}
function onSipConfirmed(a){sipPhone.getStream(a.cid);onAnsCall(a.cid,"");getLocalVideo()||addVideo(viewModel.myName(),null,!0,null);var b=searchCall(a.cid);b&&(b.video||addVideo(b.name(),null,!1,b));sipPhone.getStream(a.cid)}
function onSipModStream(a){var b,c,d,e,f,h,g;g=h=!0;if(b=getLocalVideo())c=b.stream()?b.stream().getAudioTracks():[],d=b.stream()?b.stream().getVideoTracks():[],e=a.local?a.local.getAudioTracks():[],f=a.local?a.local.getVideoTracks():[],0<c.length&&0<e.length&&c[0].id===e[0].id&&(h=!1),0<d.length&&0<f.length&&d[0].id===f[0].id&&(g=!1),(h||g)&&b.stream(a.local);g=h=!0;var k=searchCall(a.cid);k&&(b=k.video)&&(c=b.stream()?b.stream().getAudioTracks():[],d=b.stream()?b.stream().getVideoTracks():[],e=
a.remote?a.remote.getAudioTracks():[],f=a.remote?a.remote.getVideoTracks():[],0<c.length&&0<e.length&&c[0].id===e[0].id&&(h=!1),0<d.length&&0<f.length&&d[0].id===f[0].id&&(g=!1),(h||g)&&b.stream(a.remote));k.callType()==TYPE_VIDEO_CALL&&a.local&&0==a.local.getVideoTracks().length&&(l.log("callType change to VOICE"),k.callType(TYPE_VOICE_CALL));a.local&&0!==a.local.getVideoTracks().length||a.remote&&0!==a.remote.getVideoTracks().length?viewModel.chkSipSpeaking()&&openVideoSubWin():closeVideoSubWin();
muteVideoElements()}function onSipMuted(a){try{VVM.localVideo().muted(!0)}catch(b){}}function onSipUnmuted(a){try{VVM.localVideo().muted(!1)}catch(b){}}function onSipHold(a){onHeld(a.cid);(a=searchCall(a.cid))&&unmuteAudio(a)}
function onSipUnhold(a){var b=a.cid,c=searchCall(b);if(c){var d=c.callType();sipPhone.getStream(a.cid);onUnHoldCall(b);c.callType(VVM.hasVideo()?TYPE_VIDEO_CALL:TYPE_VOICE_CALL);d==TYPE_VIDEO_CALL&&c.callType()==TYPE_VOICE_CALL&&-1!=a.v_flg&&setTimeout(function(a){switchToVideo(a)},1E3,c)}}function onSipReferSuccess(a){var b=a.rep_cid;endCall(a.ref_cid);endCall(b)}function onSipReplaces(a){onSipIncoming(a);SIP_ansCall(a.cid,a.v_flg)}
function addVideo(a,b,c,d){a=new VVM.videoObj(a,b,c);d&&(d.video=a);VVM.videoList.push(a);return a}function rmvVideo(a){VVM.videoList.remove(a);if(a.stream()){var b;b=a.stream().getVideoTracks();for(var c in b)b[c].stop();b=a.stream().getAudioTracks();for(c in b)b[c].stop();a.stream(null)}0==VVM.videoList().length&&(closeVideoSubWin(),dettachScreenShare())}function getLocalVideo(){for(var a=0,b=VVM.videoList().length;a<b;a++){var c=VVM.videoList()[a];if(!0===c.islocal())return c}return null}
function initExpandVideo(){for(var a=0,b=VVM.videoList().length;a<b;a++)VVM.videoList()[a].expand(EXPAND_NONE)}function expandVideo(a){if(a.expand()==EXPAND_SELF)for(var b=0,c=VVM.videoList().length;b<c;b++){var d=VVM.videoList()[b];d.expand(EXPAND_NONE)}else for(b=0,c=VVM.videoList().length;b<c;b++)d=VVM.videoList()[b],d===a?d.expand(EXPAND_SELF):d.expand(EXPAND_OTHER);adjustFrames()}
function getExpandIdx(){for(var a=0,b=VVM.viewVideoList().length;a<b;a++)if(VVM.viewVideoList()[a].expand()==EXPAND_SELF)return a;return-1}function getLocalVideoIdxStr(){if(!VVM)return null;for(var a=0,b=VVM.viewVideoList().length;a<b;a++)if(VVM.viewVideoList()[a].islocal())return".video#vid"+a;return null}var vmute_timer=null;
function muteVideoElements(){null!=vmute_timer&&(clearTimeout(vmute_timer),vmute_timer=null);vmute_timer=setTimeout(function(){for(var a=0,b=VVM.viewVideoList().length;a<b;a++){var c=VVM.viewVideoList()[a],d=".video#vid"+a;c.islocal()?$(d)[0].muted=!0:($(d)[0].muted=!0,$(d)[0].muted=!1)}viewModel.videoSubWin()&&void 0!==viewModel.videoSubWin().muteAllVideoElements&&viewModel.videoSubWin().muteAllVideoElements();vmute_timer=null},50)}var vadd_timer=[];
function addSrcVideoElement(a){vadd_timer[a]&&(clearTimeout(vadd_timer[a]),delete vadd_timer[a]);vadd_timer[a]=setTimeout(addSrcVideoElement,100,a);l.log("addSrcVideoElement["+a+"]");if(void 0===VVM.viewVideoList()[a])return l.warn("addSrcVideoElement no list ["+a+"]"),clearTimeout(vadd_timer[a]),delete vadd_timer[a],null;var b=VVM.viewVideoList()[a].stream();if(void 0==b||null==b)return l.warn("not ready stream["+a+"]"),null;var c=$(".video#vid"+a)[0];if(void 0===c||null==c)return l.warn("not ready videoElement["+
a+"]"),null;if(void 0===c.srcObject)return l.warn("not support srcObject["+a+"]"),clearTimeout(vadd_timer[a]),delete vadd_timer[a],window.URL.createObjectURL(b);if(viewModel.videoSubWin())if(void 0!==viewModel.videoSubWin().addSrcVideoElement)viewModel.videoSubWin().addSrcVideoElement(a);else return l.log("addSrcVideoElement wait videoSubWin ["+a+"]"),null;setTimeout(function(b){c.srcObject=b;l.log("set srcObject["+a+"]");l.dir(b)},100,b);clearTimeout(vadd_timer[a]);delete vadd_timer[a];return null}
function adjustFrames(){if(viewModel.videoSubWin())try{viewModel.videoSubWin().adjustFrames()}catch(a){}}
function openVideoSubWin(){if(viewModel.videoSubWin())if(viewModel.videoSubWin().closed)viewModel.videoSubWin(null);else{viewModel.videoSubWin().focus();return}initExpandVideo();var a=window.open("sub_vid.htm",""," width=640,height=560,left="+(screen.width-640)/2+",top="+(screen.height-560)/2+",resizable");viewModel.videoSubWin(a);setTimeout(function(a){if(a&&a.closed&&a==viewModel.videoSubWin()){closeVideoSubWin();try{switchToVoice(viewModel.primeCall()),dettachScreenShare()}catch(c){}}},1E4,a)}
function closeVideoSubWin(){if(viewModel.videoSubWin()){try{ko.cleanNode(viewModel.videoSubWin().document)}catch(a){}viewModel.videoSubWin().closed?viewModel.videoSubWin(null):viewModel.videoSubWin().close()}}
function videoSubWinManager(a){if(a&&a.status()==CALL_ST_SPEAK){try{VVM.localVideo().stream().getVideoTracks()[0].enabled&&openVideoSubWin()}catch(b){}try{a.video.stream().getVideoTracks()[0].enabled&&openVideoSubWin()}catch(b){}}else viewModel.chkSipSpeaking()||(VVM.ScShareStream()&&dettachScreenShare(),sendEvtVQChange(VQ_MID),closeVideoSubWin())}
function checkVideoCall(){var a=0,b=0;try{var c=getLocalVideo().stream().getVideoTracks(),d;for(d in c)1==c[d].enabled&&a++}catch(e){}try{for(d in c=viewModel.primeCall().video.stream().getVideoTracks(),c)1==c[d].enabled&&b++}catch(e){}return a||b?!0:!1}function getLocalVideoTrack(){var a=0;try{a=getLocalVideo().stream().getVideoTracks().length}catch(b){}return a}var constraints={video:!1,audio:!1},dvc_ready=!1;
function checkSipPhoneSupported(){try{navigator.userAgent.match(/Trident\/7/g)?l.log("IE11"):chrome&&(navigator.userAgent.match(/(iPad|iPhone|iPod|Edge\/|Edg\/)/g)?l.log("iOS or Edge!"):(l.log("chrome"),"https:"===location.protocol&&VVM.sup_check(!0)))}catch(a){l.dir(a)}try{chrome?-1===navigator.userAgent.indexOf("Android")&&"https:"===location.protocol&&(navigator.mediaDevices&&"getDisplayMedia"in navigator.mediaDevices?(l.log("capture enable!"),VVM.cap_check(!0)):(l.log("getDisplayMedia is not defined."),
VVM.cap_check(!1))):l.log("not chrome! capture disable!")}catch(a){l.log("not chrome! capture disable!"),l.dir(a)}}
function updtVideoConstraint(){VVM.dvc_ready(!1);constraints.video=!1;constraints.audio=!1;viewModel.isAudioDevAttached(!1);viewModel.isVideoDevAttached(!1);viewModel.audioDeviceList([]);viewModel.videoDeviceList([]);if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices)navigator.mediaDevices.enumerateDevices().then(function(a){var b=[],c=[];a.forEach(function(a){l.log(a.kind+": "+a.label+" id = "+a.deviceId);"videoinput"==a.kind&&(viewModel.isVideoDevAttached(!0),constraints.video={optional:[{sourceId:viewModel.videoDeviceId()}]},
c.push(a));"audioinput"==a.kind&&(viewModel.isAudioDevAttached(!0),constraints.audio={optional:[{sourceId:viewModel.audioDeviceId()}]},b.push(a))});l.dir({constraints:constraints});VVM.dvc_ready(!0);viewModel.audioDeviceList(b);viewModel.videoDeviceList(c)})["catch"](function(a){l.error(a.name+": "+a.message);ConstErrDetail=a.name+": "+a.message;VVM.dvc_ready(!0)});else{l.log("Legacy getSources");try{MediaStreamTrack&&MediaStreamTrack.getSources?MediaStreamTrack.getSources(function(a){l.dir({sourceInfos:a});
for(var b=[],c=[],d=0;d<a.length;d++)"video"==a[d].kind?(viewModel.isVideoDevAttached(!0),constraints.video={optional:[{sourceId:viewModel.videoDeviceId()}]},c.push(a[d])):"audio"==a[d].kind&&(viewModel.isAudioDevAttached(!0),constraints.audio={optional:[{sourceId:viewModel.audioDeviceId()}]},b.push(a[d]));l.dir({constraints:constraints});VVM.dvc_ready(!0);viewModel.audioDeviceList(b);viewModel.videoDeviceList(c)}):VVM.dvc_ready(!0)}catch(a){l.dir(a),l.error("WebRTC Plugin not installed."),openDialog(langTbl.d_error_3,
dlgBtnList[D_BTN_CLOSED]),VVM.dvc_ready(!0)}}}function startVideo(a,b){if(VVM.sup_check()){updtVideoConstraint();var c=setInterval(function(a,b){VVM.dvc_ready()&&(_startVideo(a,b),clearInterval(c))},100,a,b);setTimeout(function(a){clearInterval(a);VVM.dvc_ready()||(openDialog(viewModel.langJs().vmsg_error_3+"[SourceUnavailableError]"+ConstErrDetail,dlgBtnList[D_BTN_CNFIM]),ConstErrDetail="")},5E3,c)}else b&&b()}
function _startVideo(a,b){l.log(CR+"startVideo()");l.dir({constraints:constraints});if(constraints.video||constraints.audio){var c=function(b){l.log("[OK] Media is ready");VVM.localStreams.push(b);a&&a()},d=function(a){l.dir({"[NG] Media is failed":a});b&&b();try{chrome&&"http:"===location.protocol?openDialog(viewModel.langJs().vmsg_error_1,dlgBtnList[D_BTN_CNFIM]):openDialog(viewModel.langJs().vmsg_error_3+"["+a.name+"] "+a.message,dlgBtnList[D_BTN_CNFIM])}catch(h){openDialog(viewModel.langJs().vmsg_error_3+
"["+a.name+"] "+a.message,dlgBtnList[D_BTN_CNFIM])}},e=getDeviceStream(constraints);e?e.then(c)["catch"](d):console.log("Not Support Browser")}else{l.log("[--] No Media exists");b&&b();try{chrome&&"http:"===location.protocol?openDialog(viewModel.langJs().vmsg_error_1,dlgBtnList[D_BTN_CNFIM]):(openDialog(viewModel.langJs().vmsg_error_3+"[SourceUnavailableError]"+ConstErrDetail,dlgBtnList[D_BTN_CNFIM]),ConstErrDetail="")}catch(f){openDialog(viewModel.langJs().vmsg_error_3+"[SourceUnavailableError]"+
ConstErrDetail,dlgBtnList[D_BTN_CNFIM]),ConstErrDetail=""}}}function getDeviceStream(a){if(navigator.mediaDevices&&"getUserMedia"in navigator.mediaDevices)return l.log("navigator.mediaDevices.getUserMadia"),navigator.mediaDevices.getUserMedia(a);l.log("navigator.getUserMadia with No Promise");return null}
function stopVideo(){l.log("-- stop video --");var a=$(".video"),b;for(b in a)a[b].srcObject=null;var a=VVM.localStreams.removeAll(),c;for(c in a){var d=a[c],e;e=d.getVideoTracks();for(b in e)d.removeTrack(e[b]),e[b].stop();e=d.getAudioTracks();for(b in e)d.removeTrack(e[b]),e[b].stop();a[c]=null}a=VVM.modStreams.removeAll();for(c in a){d=a[c];e=d.getVideoTracks();for(b in e)e[b].stop();e=d.getAudioTracks();for(b in e)e[b].stop();a[c]=null}getLocalVideo()&&rmvVideo(getLocalVideo())}
function makeModifiedStream(a,b){var c=a.clone();if(0==b.audio){var d=c.getAudioTracks(),e;for(e in d)c.removeTrack(d[e]),d[e].stop()}if(0==b.video)for(e in d=c.getVideoTracks(),d)c.removeTrack(d[e]),d[e].stop();VVM.modStreams.push(c);return c}function attachScreenShare(a){var b=viewModel.primeCall();VVM.hasAudio();VVM.hasVideo();a.getVideoTracks()[0].onended=function(){dettachScreenShare()};VVM.ScShareStream(a);sipPhone.update(b.cid,a,{audio:!1,video:!0},function(){sipPhone.getStream(b.cid)})}
function dettachScreenShare(){if(VVM.ScShareStream()){var a;a=VVM.ScShareStream().getVideoTracks();for(var b in a)a[b].onended=null,a[b].stop();VVM.ScShareStream(null);var c=viewModel.primeCall();c&&(a=VVM.hasAudio(),b=c.callType()==TYPE_VIDEO_CALL?!0:!1,a={audio:a,video:b},a=makeModifiedStream(VVM.localStreams()[VVM.localStreams().length-1],a),b={audio:!1,video:!0},viewModel.chkSipSpeaking()?sipPhone.update(c.cid,a,b,function(){sipPhone.getStream(c.cid)}):sipPhone.changeStream(c.cid,a,b))}}
function switchToVideo(a){(a=a?a:viewModel.primeCall())&&a.status()===CALL_ST_SPEAK&&a.callType()!=TYPE_VIDEO_CALL&&(a.callType(TYPE_VIDEO_CALL),VVM.ScShareStream()||SIP_renegotiateCall(a,TRACK_COND_KEEP,TRACK_COND_CHG_ON))}function switchToVoice(a){a=a?a:viewModel.primeCall();if(!a||a.status()!==CALL_ST_SPEAK||a.callType()==TYPE_VOICE_CALL)return!1;a.callType(TYPE_VOICE_CALL);VVM.ScShareStream()||SIP_renegotiateCall(a,TRACK_COND_KEEP,TRACK_COND_CHG_OFF);return!0}
function muteAudio(a){if(a=a?a:viewModel.primeCall())sipPhone?(sendJsonData({type:"event",event:"a-mute",val:1,en:[a.dial()]}),sipPhone.mute(a.cid,!0,!1)):l.log("SIP Phone Object is not exist!")}function unmuteAudio(a){if(a=a?a:viewModel.primeCall())sipPhone?(sendJsonData({type:"event",event:"a-mute",val:0,en:[a.dial()]}),sipPhone.unmute(a.cid,!0,!1)):l.log("SIP Phone Object is not exist!")}function onAudioMute(a){var b=searchCallByDial(a.en);if(b)try{b.video.muted(a.val?!0:!1)}catch(c){}}
function SIP_renegotiateCall(a,b,c){if((a=a?a:viewModel.primeCall())&&a.status()===CALL_ST_SPEAK){var d=VVM.localStreams()[VVM.localStreams().length-1],e={audio:!1,video:!1};b==TRACK_COND_CHG_ON&&(d&&0<d.getAudioTracks().length?e.audio=!0:b=TRACK_COND_KEEP);c==TRACK_COND_CHG_ON&&(d&&0<d.getVideoTracks().length?e.video=!0:c=TRACK_COND_KEEP);d=makeModifiedStream(d,e);sipPhone.update(a.cid,d,{audio:b!==TRACK_COND_KEEP?!0:!1,video:c!==TRACK_COND_KEEP?!0:!1},function(){sipPhone.getStream(a.cid)})}}
function openCfgPage(a){viewModel.cfgPage()!==CFG_NONE&&viewModel.cfgPage()===a?closeCfgPage():viewModel.cfgPage(a)}function closeCfgPage(){switch(viewModel.cfgPage()){case CFG_MEDIA_DEVICE:reloadMediaCfg()}viewModel.cfgPage(CFG_NONE)}function openMediaCfg(){openCfgPage(CFG_MEDIA_DEVICE)}
function reloadMediaCfg(){for(var a in viewModel.audioDeviceViewList()){var b=viewModel.audioDeviceViewList()[a];b.deviceId==viewModel.audioDevice().deviceId&&viewModel.tmpAudioDevice(b)}for(a in viewModel.videoDeviceViewList())b=viewModel.videoDeviceViewList()[a],b.deviceId==viewModel.videoDevice().deviceId&&viewModel.tmpVideoDevice(b)}
function changeMediaDevice(){var a=!1;if(viewModel.chkMediaCfg()){try{viewModel.tmpAudioDevice().deviceId!==viewModel.audioDevice().deviceId&&(viewModel.audioDevice(viewModel.tmpAudioDevice()),VVM.hasAudio()&&(a=!0))}catch(b){}try{viewModel.tmpVideoDevice().deviceId!==viewModel.videoDevice().deviceId&&(viewModel.videoDevice(viewModel.tmpVideoDevice()),VVM.hasVideo()&&(a=!0))}catch(b){}a&&startVideo(function(){constraints.audio?constraints.video?SIP_renegotiateCall(null,TRACK_COND_CHG_ON,TRACK_COND_CHG_ON):
SIP_renegotiateCall(null,TRACK_COND_CHG_ON,TRACK_COND_CHG_OFF):openDialog(viewModel.langJs().alt_no_audio,dlgBtnList[D_BTN_CNFIM])},null);closeCfgPage()}}function sendEvtVQChange(a,b){if(isTel_SIP()&&(!VVM.localVideo()||VVM.localVideo().vqval()!=a))try{b=b?b:viewModel.primeCall(),sendJsonData({type:"event",event:"vqchg",req:a,en:[b.dial()]}),VVM.vqtmp(a)}catch(c){}}
function onVQChange(a){if(isTel_SIP())if(void 0!==a.res)try{switch(a.res){case 0:VVM.localVideo()&&VVM.localVideo().vqval()!=VVM.vqtmp()&&(VVM.localVideo().vqval(VVM.vqtmp()),SIP_renegotiateCall(null,TRACK_COND_KEEP,TRACK_COND_KEEP));break;default:VVM.vqtmp(VVM.localVideo().vqval())}}catch(c){}else if(void 0!==a.req)try{var b=searchCallByDial(a.en);b&&b.video.vqval(a.req)}catch(c){}}
function ST500_makeCall(a){l.log("st500:"+a);var b=encodeURI(searchCallerName(a));iOS_Device()&&(b=b.replace("#","%23"),b=b.replace("?","%3F"),b=b.replace(";","%3B"));a="st500://"+a+"?name="+b;b=document.createElement("iframe");b.src=a;document.body.appendChild(b);setTimeout(function(a){a.parentNode.removeChild(a)},500,b)}function dispSearchZone(){$("#search_zone_wrap").css("display","flex")}
function closeSearchZone(){viewModel.phone_mode()==MODE_ST500&&$("#search_zone_wrap").css("display","none")}
function mobApi_reconnect(a,b,c,d){if(!Server)return 1;l.log("Call mobApi_reconnect("+a+","+b+","+c+","+d+");");if(c==user_id&&d==user_pw){if(a){if(reconn_grd_flg)return 0;c=a;b&&(c=c+":"+b);c=c.replace("http","ws");c+="/uc/ws";b=a.split("//")[1];if(!b)return l.log("Address Format Error."),1;if(c!=SrvURL){a=new FancyWebSocket(c);if(!a)return l.log("wsServer Connection Error."),1;Server.unbind("open");Server.unbind("close");Server.unbind("message");Server.conn&&Server.disconnect();Server=null;deleteSipPhone();
try{viewModel.phone_mode()==MODE_ST500&&(iOS_Device()?webkit.messageHandlers.notifyLoginStateOfInUC.postMessage("0"):androidJavascriptInterface.notifyLoginStateOfInUC("0"))}catch(e){l.log("Fail to Callback notifyLoginStateOfInUC(0);")}Server=a;SrvURL=c;SrvAddr=b;Server.bind("open",function(){onOpened()});Server.bind("close",function(a){onClose(a)});Server.bind("message",function(a){onMessage(a)});serverConnect();return 0}}if(viewModel.isStandAlone()){if(reconn_grd_flg)return 0;serverConnect()}}else return 1;
return 0}function mobApi_imopen(a){a>=memberList.length||(viewModel.isStandAlone()&&serverConnect(),in_chat&&viewModel.targetUsr()!=memberList[a]&&imOpened(viewModel.targetUsr()),dispTextChat(memberList[a]))}function mobApi_isBackground(a){a?(in_chat&&imOpened(viewModel.targetUsr()),is_bkgrnd=!0):(in_chat&&dispTextChat(viewModel.targetUsr()),is_bkgrnd=!1)}
function mobApi_disconnect(){if(Server&&Server.conn){var a;a=new FancyWebSocket(SrvURL);Server.unbind("open");Server.unbind("close");Server.unbind("message");Server.disconnect();onClose(Server.conn);Server=a;Server.bind("open",function(){onOpened()});Server.bind("close",function(a){onClose(a)});Server.bind("message",function(a){onMessage(a)})}}
function sendConfRejectReq(){if(""!==user_id){var a={type:"event",event:"conf-rjReq",id:user_id};viewModel.phone_mode()===MODE_ST500&&(a.tel=viewModel.phone_mode());sendJsonData(a)}}function sendEvtImRestore(){l.log(CR+"sendEvtImRestore");sendJsonData({type:"event",event:"imrstr"});resendChatAutoAtRestore()}
function onIMRestore(a){if(1===a.now){for(var b in chatRstrArr)chatRstrArr[b]=null;chatRstrArr.length=0}var c=a.data.length;for(b=0;b<c;b++){var d=a.data[b];if(!(void 0===d||void 0===d.idx||0>d.idx||void 0===d.type||void 0===d.b||void 0===d.tm||void 0===d.mid||void 0===d.sts)&&d.sts!==CHAT_ST_HIDDEN){var e=memberList[d.idx],f=replaceConfURL(d.b),h=f,h=replaceHtmlTag(h);isJP()&&(h=replaceCallBack(h),h=replaceEmoji(h));h=setAutoLink(h);h=new chatObj(e,d.type,f,h,d.tm,d.mid,d.sts);pushChatRstrArry(h);
d.sts===CHAT_ST_PENDING&&d.type===CHAT_TYPE_R&&recvChat(e,f,d.tm,d.mid)}}if(a.now===a.end){c=viewModel.chatLogArr().length;for(b=0;b<c;b++)pushChatRstrArry(viewModel.chatLogArr()[b]);viewModel.chatLogArr(chatRstrArr.slice());viewModel.listType()===LIST_TYPE_LOGIM&&sortUsrData();for(b in memberList)memberList[b].imSubWin&&memberList[b].imSubWin.viewModel.chatLogArr(viewModel.chatLogArr());restoreNewArrivalNotification();for(b in chatRstrArr)chatRstrArr[b]=null;chatRstrArr.length=0}}
function imOpened(a){for(var b=viewModel.chatLogArr(),c=b.length,d,e=[],f=0;f<c;f++)a===b[f].user&&b[f].status()!==CHAT_ST_OPENED&&b[f].type===CHAT_TYPE_R&&(d={idx:a.index(),mid:b[f].mid,tm:b[f].stmp},e.push(d),b[f].status(CHAT_ST_OPENED));e.length&&sendJsonData({type:"event",event:"imopnd",data:e})}
function pushChatRstrArry(a){for(var b=chatRstrArr.length,c=b-1;0<=c;c--)if(isSameChat(a,chatRstrArr[c])){chatRstrArr[c].status(a.status());return}if(chatRstrArr.length>=CHAT_LOG_MAX){for(var d=chatRstrArr.shift(),c=0,b=d.user.imUnsent.length;c<b;c++)if(d.user.imUnsent[c]===d){d.user.imUnsent.splice(c,1);break}deleteOneImAlert(d)}chatRstrArr.push(a)}
function resendChatAutoAtRestore(){for(var a=memberList.length,b=0;b<a;b++){var c=memberList[b];if(-1!==c.index)for(var d=c.imUnsent.length,e=0;e<d;e++){var f=c.imUnsent.shift();f.status()===CHAT_ST_UNSENT&&sendChat(f.user,f.ori)}}}function deleteAllChatInfo(){for(var a=viewModel.chatLogArr.removeAll(),b=a.length,c=0;c<b;c++)deleteImAlert(a[c].user),deleteDsktpNotification(NOTIF_TYPE_IM,a[c].user),a[c]=null}
function isSameChat(a,b){return a.mid===b.mid&&a.stmp===b.stmp&&a.type===b.type&&a.user===b.user?!0:!1}
function restoreNewArrivalNotification(){for(var a=viewModel.chatLogArr().length,b=0;b<a;b++)if(viewModel.chatLogArr()[b].status()!==CHAT_ST_OPENED&&viewModel.chatLogArr()[b].type===CHAT_TYPE_R)if(isChattingWith(viewModel.chatLogArr()[b].user))document.getElementById("im_msgline").scrollTop=document.getElementById("im_msgline").scrollHeight;else{var c=new alertObj(ALERT_IM_NEW,viewModel.chatLogArr()[b].stmp,viewModel.chatLogArr()[b].user,viewModel.chatLogArr()[b]);setAlert(c);updateImNew(viewModel.chatLogArr()[b].user,
viewModel.chatLogArr()[b]);viewModel.listType()===LIST_TYPE_LOGIM&&sortUsrData()}}var CallStatusReq=[];
function chkCallStatus(a){if(viewModel.phone_mode()==MODE_ST500){var b=function(){openDialog(langTbl.d_error_20,dlgBtnList[D_BTN_CNFIM])},c="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"==a?b:b&3|8).toString(16)}),d=setTimeout(function(a,b){a();delete CallStatusReq[b]},5E3,b,c);CallStatusReq[c]={s_func:a,f_func:b,timer:d};try{iOS_Device()?webkit.messageHandlers.requestCallingStatus.postMessage(c):androidJavascriptInterface.requestCallingStatus(c)}catch(e){l.log("Fail to Callback requestCallingStatus();")}}else a()}
function clrCallStatusReq(){for(var a=0,b=CallStatusReq.length;a<b;a++)delete CallStatusReq[a];CallStatusReq.length=0}function mobApi_isInCalling(a,b){a==MOBCALL_IDLE_PUSH&&(a=Android_Device()?MOBCALL_ST500:MOBCALL_IDLE);""===b?a!=MOBCALL_IDLE&&sendConfRejectReq():CallStatusReq[b]&&(clearTimeout(CallStatusReq[b].timer),a==MOBCALL_IDLE?CallStatusReq[b].s_func():CallStatusReq[b].f_func(),delete CallStatusReq[b])}
function openConfURL(a){0==viewModel.check_qvl()?openDialog(langTbl.d_error_3,dlgBtnList[D_BTN_CNFIM]):chkCallStatus(function(){window.open(a)})};
