123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454 |
- holly.phone = {
- phone_data: {},
- _phone_url: "",
- _phone_iccCount: 0,
- _phone_isWaitingEvent: false,
- _phone_isKick: true,
- _phone_unregister: 0,
- _phone_peerstate: 1,
- _phone_dialing: 2,
- _phone_innerDialing: 3,
- _phone_belling: 4,
- _phone_innerBelling: 5,
- _phone_listening: 6,
- _phone_talking: 7,
- _phone_threeWayTalking: 8,
- _phone_innerTalking: 9,
- _phone_dialTalking: 10,
- _phone_listened: 11,
- _phone_transferBelling: 12,
- _phone_transferDialing: 13,
- _phone_transfer: 14,
- _phone_dialoutTransfer: 15,
- _phone_systemBusy: 99,
- _phone_currentState: "",
- _phone_stateBeforeHold: "",
- _phone_isInvestigatting: false,
- _phone_stateDescription: ["unregister", "peerstate", "dialing", "innerDialing", "belling", "innerBelling", "listening", "talking", "threeWayTalking", "innerTalking", "dialTalking", "listened", "transferBelling", "transferDialing", "transfer", "dialTransfer"],
- _phone_peersFromSip: [],
- phone_peers: [],
- phone_peers_sip: [],
- phone_queues: [],
- phone_accountCalls: [],
- phone_serviceNos: [],
- _phone_isSettingbusy: false,
- _phone_isRelogin: false,
- phone_pbxs: [],
- _phone_callObject: {},
- _phone_sendAction: function (jsonData, onload, onerror) {
- var json = $.toJSON(jsonData);
- var timeout = 15000;
- if (jsonData.Timeout != undefined) {
- timeout = jsonData.Timeout;
- }
- $.ajax({
- type: "get",
- url: holly.phone._phone_url,
- timeout: timeout,
- cache: false,
- data: {json: json},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- },
- phone_register: function (config, phoneJson) {
- holly.phone._phone_url = config.proxy_url;
- var isMonitorPage = phoneJson.isMonitorPage;
- delete phoneJson.isMonitorPage;
- var onload = function (response) {
- var _response = response;
- if (!_response.Succeed) {
- var code = _response.Result;
- if (code) {
- if (code == 601) {
- hollyglobal.loginFailureCallback("您的账户通话座席登录数已达最大或者已经到期,通话功能将不能使用");
- } else {
- if (code == 602) {
- hollyglobal.loginFailureCallback("您的账户无通话座席登录数已达最大或者已经到期,通话功能将不能使用");
- } else if (code == 408) {
- hollyglobal.loginFailureCallback("由于您的主软电话条没有签入,不能登录软电话");
- } else {
- hollyglobal.loginFailureCallback("登录失败" + code + ",通话功能将不能使用");
- }
- }
- }
- } else if (_response.SessionID) {
- config.uniqueId = _response.SessionID;
- var date = new Date();
- var identity = date.valueOf();
- config.currentServerTime = identity - _response.Timestamp * 1000;
- config.phonebarConfig = _response.PhonebarConfig;
- config.autoBusyTime = _response.AutoBusyTime;
- config.userId = _response.UserID;
- config.pbx_in_ip = _response.PBX;
- config.accountId = _response.Account;
- config.loginName = config.user;
- config.sipNo = _response.SipNum;
- config.monitorUser = _response.MonitorUser;
- config.monitorPassword = _response.MonitorPassword;
- config.depts = $.evalJSON(_response.Departments);
- config.departmentID = (_response.DepartmentID) ? (_response.DepartmentID) : "";
- holly.session.logined = true;
- holly.softphonebar.softphonebar_init();
- holly.phone._phone_init(config);
- holly.phone._phone_waitEvent(isMonitorPage);
- if (isMonitorPage) {
- hollyglobal.isMonitorPage = true;
- var curpbx;
- if (holly.phone.phone_data.pbx_in_ip) {
- curpbx = holly.phone.phone_pbxs[holly.phone.phone_data.pbx_in_ip];
- curpbx.sessionId = _response.SessionID;
- } else {
- curpbx = holly.phone.phone_pbxs[hollyglobal.sipConfigId];
- curpbx.sessionId = _response.SessionID;
- holly.phone.phone_data.pbx_in_ip = hollyglobal.sipConfigId;
- holly.phone.phone_data.accountId = hollyglobal.accountId;
- if(hollyglobal.isMonitorJoint){
- holly.phone.phone_data.userId = window.localStorage.getItem('currentLoginAgent');
- }else {
- holly.phone.phone_data.userId = config.userId;
- }
- }
- //$("#monitor_allpbx").css("display", "block");
- holly.softphonebar.monitor_agent();
- } else {
- holly.utils.pickSoftphonebar();
- }
- hollyglobal.loginSuccessCallback(_response);
- }
- };
- var onerror = function (xhr, status, error) {
- hollyglobal.loginFailureCallback('请求超时,请检查本地网络');
- };
- holly.phone._phone_sendAction(phoneJson, onload, onerror);
- },
- _phone_init: function (config) {
- holly.session.user = {};
- holly.session.user.userId = config.userId;
- holly.session.user.loginName = config.loginName;
- holly.session.user.password = config.password;
- holly.session.user.extenType = config.extenType;
- holly.session.user.busyType = config.busyType;
- holly.session.user.sipConfigId = config.curPbx;
- holly.phone.phone_data.uniqueId = config.uniqueId;
- holly.phone.phone_data.currentServerTime = config.currentServerTime;
- holly.phone.phone_data.autoBusyTime = config.autoBusyTime;
- holly.phone.phone_data.userId = config.userId;
- holly.phone.phone_data.pbx_in_ip = config.pbx_in_ip;
- holly.phone.phone_data.accountId = config.accountId;
- holly.phone.phone_data.loginName = config.loginName;
- holly.phone.phone_data.sipNo = config.sipNo;
- holly.phone.phone_data.monitor = config.monitor;
- holly.phone.phone_data.user = config.user;
- holly.phone.phone_data.password = config.password;
- holly.phone.phone_data.extenType = config.extenType;
- holly.phone.phone_data.busyType = config.busyType;
- holly.phone.phone_data.monitorUser = config.monitorUser;
- holly.phone.phone_data.monitorPassword = config.monitorPassword;
- holly.phone.phone_data.depts = config.depts;
- holly.phone.phone_data.departmentID = config.departmentID;
- holly.phone.phone_data.phonebarConfig = new Array();
- if (config.phonebarConfig) {
- var peerstates = config.phonebarConfig.split(",");
- for (var i = 0; i < peerstates.length; i++) {
- holly.phone.phone_data.phonebarConfig[peerstates[i].split(":")[0]] = peerstates[i].split(":")[1]
- }
- }
- holly.phone._phone_currentState = holly.phone._phone_unregister;
- holly.phone.phone_publishEvent("toolbarupdate", [holly.phone._phone_stateDescription[holly.phone._phone_currentState], ""]);
- if(config.userId && hollyglobal.isMonitorJoint){
- window.localStorage.setItem('currentLoginAgent', config.userId);
- }
- },
- _phone_waitEvent: function (isMonitorPage) {
- if (holly.phone._phone_isWaitingEvent)
- return;
- holly.phone._phone_isWaitingEvent = true;
- var phoneJson = {
- Command: "Action",
- Action: "GetState",
- ActionID: "GetState" + Math.random(),
- SessionID: holly.phone.phone_data.uniqueId,
- User: holly.phone.phone_data.userId
- };
- var onload = function (response) {
- holly.phone._phone_iccCount = 0;
- if (!response)
- return;
- var datas = response;
- var _response = datas.Response;
- if (!_response)
- _response = datas;
- if (_response.Succeed && !_response.HasEvent) {
- } else if (!_response.Succeed) {
- if (_response.Expired && holly.phone._phone_isKick) {
- holly.phone._phone_relogin(isMonitorPage);
- holly.phone._phone_isWaitingEvent = false;
- return;
- }
- return;
- } else {
- if (_response.Kick) {
- var comments = "";
- if (_response.Comments)
- comments = _response.Comments;
- if (!isMonitorPage) {
- if (comments == "ukick" || comments == "ekick") {
- holly.utils.showError("您的帐号在其他地方登录了", "softphone_transfer");
- } else {
- holly.utils.showError("您已被管理员强制签出", "softphone_transfer");
- }
- holly.session.logined = false;
- holly.phone._phone_isWaitingEvent = false;
- holly.utils.kickSoftphonebar();
- holly.phone._phone_isKick = false;
- holly.softphonebar._softphonebar_barupdate('', 'unregister', '');
- return;
- }
- } else {
- var events = datas.Event;
- if (events != null && holly.phone._phone_isKick) {
- holly.phone._phone_eventHandler(events);
- if (hollyglobal.multiLogin && holly.phone._phone_currentState === holly.phone._phone_unregister) {
- holly.session.logined = false;
- holly.phone._phone_isWaitingEvent = false;
- return;
- }
- }
- }
- }
- holly.phone._phone_isWaitingEvent = false;
- //这段代码解决浏览器一直转圈的问题
- window.setTimeout(function () {
- holly.phone._phone_waitEvent(isMonitorPage);
- }, 100);
- };
- var onerror = function () {
- holly.phone._phone_isWaitingEvent = false;
- holly.phone._phone_isKick = true;
- window.setTimeout(function () {
- holly.phone._phone_iccCount++;
- if (holly.phone._phone_iccCount >= 3) {
- holly.phone._phone_iccCount = 0;
- holly.utils.unRegisterSoftphonebar();
- //alert("连接服务器超时,可能是您的网络问题,正在尝试重新连接...");
- holly.utils.showError("连接超时,尝试重新连接", "softphone_transfer");
- }
- holly.phone._phone_waitEvent(isMonitorPage);
- }, 1000);
- };
- holly.phone._phone_sendAction(phoneJson, onload, onerror);
- },
- _phone_relogin: function (isMonitorPage) {
- if (holly.phone._phone_isRelogin)
- return;
- holly.phone._phone_isRelogin = true;
- var actionName = "Login";
- if (hollyglobal.multiLogin) {
- actionName = "MultipleLogin";
- }
- var phoneJson = {
- Command: "Action",
- Action: actionName,
- ActionID: "Login" + Math.random(),
- Monitor: holly.phone.phone_data.monitor
- };
- var config = {
- monitor: false
- };
- phoneJson.ExtenType = hollyglobal.loginExtenType;
- phoneJson.Password = hollyglobal.loginPassword;
- phoneJson.BusyType = hollyglobal.loginBusyType;
- phoneJson.User = hollyglobal.loginUser;
- config.extenType = hollyglobal.loginExtenType;
- config.password = hollyglobal.loginPassword;
- config.user = hollyglobal.loginUser;
- if (isMonitorPage) {
- var phoneJson = {
- Command: "Action",
- Action: "Login",
- ActionID: "Login" + Math.random(),
- PBX: holly.session.user.sipConfigId,
- Account: hollyglobal.accountId,
- Password: hollyglobal.monitorPassword,
- UserID: hollyglobal.monitorUserID,
- MonitorUser: true
- };
- }
- var onload = function (response) {
- var _response = response;
- if (!_response.Succeed) {
- var code = _response.Result;
- if (code) {
- if (code == 601) {
- hollyglobal.loginFailureCallback("您的账户通话座席登录数已达最大或者已经到期,通话功能将不能使用");
- } else if (code == 602) {
- hollyglobal.loginFailureCallback("您的账户无通话座席登录数已达最大或者已经到期,通话功能将不能使用");
- } else if (code == 408) {
- hollyglobal.loginFailureCallback("由于您的主软电话条没有签入,不能签入软电话");
- } else {
- hollyglobal.loginFailureCallback("登录失败" + code + ",通话功能将不能使用");
- }
- } else {
- hollyglobal.loginFailureCallback("您当前的会话已经失效,通话功能将不能使用");
- }
- } else if (_response.SessionID) {
- config.uniqueId = _response.SessionID;
- var date = new Date();
- var identity = date.valueOf();
- config.currentServerTime = identity - _response.Timestamp * 1000;
- config.phonebarConfig = _response.PhonebarConfig;
- config.autoBusyTime = _response.AutoBusyTime;
- config.userId = _response.UserID;
- config.pbx_in_ip = _response.PBX;
- config.accountId = _response.Account;
- config.sipNo = _response.SipNum;
- config.monitorUser = _response.MonitorUser;
- config.monitorPassword = _response.MonitorPassword;
- config.depts = $.evalJSON(_response.Departments);
- config.departmentID = (_response.DepartmentID) ? (_response.DepartmentID) : "";
- holly.session.logined = true;
- holly.softphonebar.softphonebar_init();
- holly.phone._phone_init(config);
- if (isMonitorPage) {
- var curPbx;
- if (holly.phone.phone_data.pbx_in_ip) {
- curPbx = holly.phone.phone_pbxs[holly.phone.phone_data.pbx_in_ip];
- curPbx.sessionId = _response.SessionID;
- } else {
- curPbx = holly.phone.phone_pbxs[holly.session.user.sipConfigId];
- curPbx.sessionId = _response.SessionID;
- holly.phone.phone_data.pbx_in_ip = holly.session.user.sipConfigId;
- holly.phone.phone_data.accountId = hollyglobal.accountId;
- holly.phone.phone_data.userId = holly.session.user.userId;
- }
- } else
- holly.utils.pickSoftphonebar();
- holly.phone._phone_isWaitingEvent = false;
- holly.phone._phone_isKick = true;
- holly.phone._phone_waitEvent(isMonitorPage);
- hollyglobal.loginSuccessCallback(_response);
- }
- holly.phone._phone_isRelogin = false;
- };
- var onerror = function () {
- hollyglobal.loginFailureCallback('请求合力通话服务器超时,请检查本地网络');
- holly.phone._phone_isRelogin = false;
- holly.phone._phone_isKick = true;
- };
- holly.phone._phone_sendAction(phoneJson, onload, onerror);
- },
- _phone_eventHandler: function (evtJsons) {
- $.each(evtJsons, function (i, item) {
- holly.phone._phone_stateProcess(item);
- if (hollyglobal.isMonitorPage) {
- holly.phone._phone_monitorPeer(item);
- holly.phone._phone_monitorQueue(item);
- holly.phone._phone_monitorServiceNo(item);
- }
- if (item.Event === "UserStatus" && item.PeerStatus === "Unregistered" && holly.phone.phone_data.userId === item.UserID) {
- if (!holly.phone.phone_data.monitor)
- return false;
- }
- });
- },
- _phone_monitorAccount: function (evtJson) {
- if (evtJson.Event === "AccountStatus") {
- var account;
- if (!holly.phone.phone_accountCalls[evtJson.PBX]) {
- account = {
- account: evtJson.Account,
- inCalls: evtJson.InCalls,
- outComplete: evtJson.OutComplete,
- inComplete: evtJson.InComplete,
- outCalls: evtJson.OutCalls,
- inCallsPerHour: evtJson.InCallsPerHour,
- currentOutCalls: evtJson.CurrentOutCalls,
- pbx: evtJson.PBX,
- inCompletePerHour: evtJson.InCompletePerHour,
- outCallsPerHour: evtJson.OutCallsPerHour,
- currentInCalls: evtJson.CurrentInCalls,
- outCompletePerHour: evtJson.OutCompletePerHour
- };
- holly.phone.phone_accountCalls[evtJson.PBX] = account;
- holly.phone.phone_publishEvent("EvtAccountCalls", [account]);
- } else {
- account = holly.phone.phone_accountCalls[evtJson.PBX];
- account.account = evtJson.Account;
- account.inCalls = evtJson.InCalls;
- account.outComplete = evtJson.OutComplete;
- account.inComplete = evtJson.InComplete;
- account.outCalls = evtJson.OutCalls;
- account.inCallsPerHour = evtJson.InCallsPerHour;
- account.currentOutCalls = evtJson.CurrentOutCalls;
- account.pbx = evtJson.PBX;
- account.inCompletePerHour = evtJson.InCompletePerHour;
- account.outCallsPerHour = evtJson.OutCallsPerHour;
- account.currentInCalls = evtJson.CurrentInCalls;
- account.outCompletePerHour = evtJson.OutCompletePerHour;
- holly.phone.phone_publishEvent("EvtAccountCalls", [account]);
- }
- }
- },
- phone_pbxMonitor: function (pbx) {
- for (var i in holly.phone.phone_pbxs) {
- if (i === holly.phone.phone_data.pbx_in_ip)
- continue;
- if (i === pbx) {
- if (!holly.phone.phone_pbxs[pbx].monitor)
- holly.phone._phone_pbxMonitorResister(i);
- } else {
- if (holly.phone.phone_pbxs[i].monitor)
- holly.phone._phone_pbxMonitorLogOff(i)
- }
- }
- },
- _phone_pbxMonitorLogOff: function (pbx) {
- var phone_pbx = holly.phone.phone_pbxs[pbx];
- if (phone_pbx.isMonitorLogOff)
- return;
- phone_pbx.isMonitorLogOff = true;
- var url = phone_pbx.proxyUrl;
- var phoneJson = {
- Command: "Action",
- Action: "Logoff",
- ActionID: "Logoff" + Math.random(),
- SessionID: phone_pbx.sessionId
- };
- var onload = function (response) {
- phone_pbx.isMonitorLogOff = false;
- phone_pbx.monitor = false;
- };
- var onerror = function () {
- phone_pbx.isMonitorLogOff = false;
- phone_pbx.monitor = false;
- };
- var json = $.toJSON(phoneJson);
- var timeout = 15000;
- $.ajax({
- type: "get",
- url: url,
- timeout: timeout,
- cache: false,
- data: {json: json},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- },
- _phone_pbxMonitorResister: function (pbx) {
- var phone_pbx = holly.phone.phone_pbxs[pbx],
- url = phone_pbx.proxyUrl,
- phoneJson = {
- Command: "Action",
- Action: "Login",
- ActionID: "Login" + Math.random(),
- PBX: pbx,
- Account: holly.phone.phone_data.accountId,
- UserID: hollyglobal.monitorUserID,
- Password: hollyglobal.monitorPassword,
- MonitorUser: true
- };
- if (pbx === hollyglobal.sipConfigId)
- phoneJson.MonitorRealUserID = hollyglobal.userId;
- var onload = function (response) {
- if (response.Succeed) {
- holly.phone.phone_pbxs[pbx].sessionId = response.SessionID;
- holly.phone.phone_pbxs[pbx].isWaitingPbxEvent = false;
- holly.phone.phone_pbxs[pbx].monitor = true;
- holly.phone._phone_waitPbxEvent(pbx);
- } else {
- holly.phone.phone_pbxs[pbx].monitor = false;
- }
- };
- var onerror = function () {
- holly.phone.phone_pbxs[pbx].monitor = false;
- holly.utils.showError("请求超时,请检查本地网络", "softphone_transfer");
- };
- var json = $.toJSON(phoneJson);
- var timeout = 15000;
- $.ajax({
- type: "get",
- url: url,
- timeout: timeout,
- cache: false,
- data: {json: json},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- },
- _phone_waitPbxEvent: function (pbx) {
- var phone_pbx = holly.phone.phone_pbxs[pbx];
- if (!phone_pbx || !phone_pbx.monitor || phone_pbx.isWaitingPbxEvent)
- return;
- phone_pbx.isWaitingPbxEvent = true;
- var url = phone_pbx.proxyUrl,
- phoneJson = {
- Command: "Action",
- Action: "GetState",
- ActionID: "GetState" + Math.random(),
- SessionID: phone_pbx.sessionId,
- User: holly.phone.phone_data.monitorUser
- };
- var onload = function (response) {
- if (!response) {
- return;
- }
- var _response = response.Response;
- if (!_response.Succeed) {
- if (_response.Expired) {
- phone_pbx.isWaitingPbxEvent = false;
- holly.phone._phone_pbxMonitorResister(pbx, url);
- return;
- }
- } else if (_response.Succeed && _response.HasEvent) {
- var events = response.Event;
- if (events != null) {
- holly.phone._phone_eventHandler(events, true);
- }
- }
- phone_pbx.isWaitingPbxEvent = false;
- holly.phone._phone_waitPbxEvent(pbx);
- };
- var onerror = function () {
- phone_pbx.isWaitingPbxEvent = false;
- };
- var json = $.toJSON(phoneJson);
- var timeout = 15000;
- $.ajax({
- type: "get",
- url: url,
- timeout: timeout,
- cache: false,
- data: {json: json},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- },
- _phone_monitorServiceNo: function (evtJson) {
- if (evtJson.Event === "TrunkStatus") {
- var displayName, serviceNo;
- if (evtJson.DisplayName) {
- displayName = evtJson.DisplayName;
- if (holly.utils.startWith(displayName, "serviceno-"))
- displayName = "";
- }
- if (!holly.phone.phone_serviceNos[evtJson.ServiceNo]) {
- serviceNo = {
- serviceNo: evtJson.ServiceNo,
- inCalls: evtJson.InCalls,
- inLost: evtJson.InLost,
- inComplete: evtJson.InComplete,
- outCalls: 0,
- outComplete: 0,
- displayName: displayName,
- pbx: evtJson.PBX
- };
- holly.phone.phone_serviceNos[evtJson.ServiceNo] = serviceNo;
- } else {
- serviceNo = holly.phone.phone_serviceNos[evtJson.ServiceNo];
- serviceNo.inCalls = evtJson.InCalls,
- serviceNo.inLost = evtJson.InLost,
- serviceNo.inComplete = evtJson.InComplete,
- serviceNo.outCalls = 0,
- serviceNo.outComplete = 0,
- serviceNo.displayName = displayName
- }
- holly.phone.phone_publishEvent("EvtMonitorServiceNo", [holly.phone.phone_serviceNos[evtJson.ServiceNo]]);
- }
- },
- _phone_stateProcess: function (evtJson) {
- //console.info(evtJson.Event+':'+evtJson.PeerStatus)
- holly.phone._phone_super(evtJson);
- switch (holly.phone._phone_currentState) {
- case holly.phone._phone_unregister:
- if (evtJson.Event === "PeerStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.PeerStatus === "Registered") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- }
- }
- } else if (evtJson.Event === "UserStatus") {
- if (holly.phone.phone_data.userId === evtJson.UserID) {
- if (holly.phone.phone_data.sipNo !== evtJson.SipNum) {
- if (evtJson.PeerStatus === "Registered") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_peerstate:
- if (evtJson.Event === "UserBusy") {
- if (holly.phone.phone_data.userId === evtJson.UserID) {
- holly.phone.phone_data.busyType = evtJson.BusyType;
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- }
- } else if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Ringing") {
- if (evtJson.LinkedChannel.ChannelType === "normal") {
- holly.phone._phone_currentState = holly.phone._phone_belling;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "inner") {
- holly.phone._phone_currentState = holly.phone._phone_innerBelling;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "transfer") {
- holly.phone._phone_currentState = holly.phone._phone_transferBelling;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "dialTransfer") {
- holly.phone._phone_currentState = holly.phone._phone_transferDialing;
- holly.phone._phone_update(evtJson);
- }
- } else if (evtJson.ChannelStatus === "Ring") {
- if (evtJson.ChannelType === "dialout") {
- holly.phone._phone_currentState = holly.phone._phone_dialing;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelType === "inner") {
- holly.phone._phone_currentState = holly.phone._phone_innerDialing;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelType === "listen") {
- holly.phone._phone_currentState = holly.phone._phone_listening;
- holly.phone._phone_update(evtJson);
- }
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "normal") {
- holly.phone._phone_currentState = holly.phone._phone_talking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "threeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "inner") {
- holly.phone._phone_currentState = holly.phone._phone_innerTalking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "dialout") {
- holly.phone._phone_currentState = holly.phone._phone_dialTalking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "transfer") {
- holly.phone._phone_currentState = holly.phone._phone_transfer;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "dialTransfer") {
- holly.phone._phone_currentState = holly.phone._phone_dialoutTransfer;
- holly.phone._phone_update(evtJson);
- }
- } else if (evtJson.ChannelStatus === "Up") {
- if (evtJson.ChannelType === "listen") {
- holly.phone._phone_currentState = holly.phone._phone_listened;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- } else if (evtJson.Event === "PeerStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.PeerStatus !== "Registered") {
- holly.phone._phone_currentState = holly.phone._phone_unregister;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- break;
- case holly.phone._phone_dialing:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.ChannelType === "dialout") {
- holly.phone._phone_currentState = holly.phone._phone_dialTalking;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_innerDialing:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.ChannelType === "inner") {
- holly.phone._phone_currentState = holly.phone._phone_innerTalking;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_belling:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "normal") {
- holly.phone._phone_currentState = holly.phone._phone_talking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "threeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "transfer") {
- holly.phone._phone_currentState = holly.phone._phone_transfer;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "dialTransfer") {
- holly.phone._phone_currentState = holly.phone._phone_dialoutTransfer;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_innerBelling:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "threeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "inner") {
- holly.phone._phone_currentState = holly.phone._phone_innerTalking;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_listening:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Up") {
- if (evtJson.ChannelType === "listen") {
- holly.phone._phone_currentState = holly.phone._phone_listened;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_talking:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "ThreeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_transfer:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "ThreeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_dialoutTransfer:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "ThreeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_threeWayTalking:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- break;
- case holly.phone._phone_innerTalking:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- break;
- case holly.phone._phone_dialTalking:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "ThreeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_listened:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- break;
- case holly.phone._phone_transferBelling:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus == "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "normal") {
- holly.phone._phone_currentState = holly.phone._phone_talking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "threeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "transfer") {
- holly.phone._phone_currentState = holly.phone._phone_transfer;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "dialTransfer") {
- holly.phone._phone_currentState = holly.phone._phone_dialoutTransfer;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- case holly.phone._phone_transferDialing:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.ChannelStatus === "Link") {
- if (evtJson.LinkedChannel.ChannelType === "normal") {
- holly.phone._phone_currentState = holly.phone._phone_talking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "threeWayCall") {
- holly.phone._phone_currentState = holly.phone._phone_threeWayTalking;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "transfer") {
- holly.phone._phone_currentState = holly.phone._phone_transfer;
- holly.phone._phone_update(evtJson);
- } else if (evtJson.LinkedChannel.ChannelType === "dialTransfer") {
- holly.phone._phone_currentState = holly.phone._phone_dialoutTransfer;
- holly.phone._phone_update(evtJson);
- }
- }
- }
- }
- break;
- }
- },
- _phone_monitorPeer: function (evtJson) {
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.ChannelStatus === "Hangup" && !evtJson.UserID)
- return;
- var peer = holly.phone.phone_peers_sip[evtJson.Exten];
- if (!peer)
- return;
- if (evtJson.ChannelStatus === "Down") {
- peer.callStatus = "Down";
- peer.channel = evtJson.Channel;
- holly.phone._phone_updateQueueInfo();
- } else if (evtJson.ChannelStatus === "Ring") {
- peer.callStatus = "Ring";
- peer.called = false;
- peer.C5Status = evtJson.C5Status;
- peer.timestamp = evtJson.Timestamp;
- peer.channel = evtJson.Channel;
- peer.queueName = "";
- if (evtJson.C5Status === "OutboundCall"
- || evtJson.C5Status === "InboundCall"
- || evtJson.C5Status === "listen") {
- peer.callNo = evtJson.Data.ListenExten;
- } else if (evtJson.FromDid)
- peer.callNo = evtJson.FromDid;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- } else if (evtJson.ChannelStatus === "Ringing") {
- peer.called = true;
- peer.callStatus = "Ringing";
- peer.C5Status = evtJson.C5Status;
- peer.channel = evtJson.Channel;
- peer.linkedChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.LinkedChannel)
- peer.queueName = evtJson.LinkedChannel.QueueName;
- if (evtJson.ChannelType === "dialTransfer")
- peer.callNo = evtJson.FromDid;
- else
- peer.callNo = evtJson.FromCid;
- peer.timestamp = evtJson.Timestamp;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- } else if (evtJson.ChannelStatus === "Up") {
- if (evtJson.ChannelType === "listen") {
- peer.callNo = evtJson.Data.ListenExten;
- peer.timestamp = evtJson.Timestamp;
- peer.C5Status = evtJson.C5Status;
- peer.callStatus = evtJson.ChannelType;
- peer.linked = true;
- peer.channel = evtJson.Channel;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- }
- } else if (evtJson.ChannelStatus === "Link") {
- peer.timestamp = evtJson.Timestamp;
- peer.C5Status = evtJson.C5Status;
- peer.linked = true;
- peer.channel = evtJson.Channel;
- peer.callStatus = evtJson.ChannelType;
- if (evtJson.LinkedChannel) {
- peer.linkedChannel = evtJson.LinkedChannel.Channel;
- peer.queueName = evtJson.LinkedChannel.QueueName;
- }
- if (evtJson.ChannelType === "dialout"
- || evtJson.ChannelType === "dialTransfer")
- peer.callNo = evtJson.FromDid;
- else if (evtJson.ChannelType === "inner") {
- if (evtJson.LinkedChannel) {
- var linkExten = evtJson.LinkedChannel.Exten;
- // var linkPeer = holly.phone._phone_getUserFromSip(linkExten);
- var linkPeer = holly.phone.phone_peers_sip[linkExten];
- if (linkPeer) {
- if (linkPeer.callStatus !== "inner") {
- peer.callNo = evtJson.FromDid;
- } else {
- peer.callNo = evtJson.FromCid;
- }
- } else {
- peer.callNo = evtJson.FromCid;
- }
- } else {
- peer.callNo = evtJson.FromCid;
- }
- } else
- peer.callNo = evtJson.FromCid;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- } else if (evtJson.ChannelStatus === "Unlink") {
- } else if (evtJson.ChannelStatus === "Hangup") {
- if (evtJson.ChannelType === "listen") {
- if (holly.phone.phone_data._curChannel === evtJson.Channel) {
- holly.phone.phone_data._otherChannel = "";
- holly.phone.phone_publishEvent("EvtEndListen", []);
- }
- }
- if (peer.channel === evtJson.Channel) {
- if (holly.phone.phone_data._otherChannel === evtJson.Channel
- && (holly.phone._phone_stateDescription[holly.phone._phone_currentState] === "listening"
- || holly.phone._phone_stateDescription[holly.phone._phone_currentState] == "listened")) {
- holly.phone.phone_hangup();
- }
- }
- peer.callNo = "";
- peer.callStatus = "Idle";
- peer.timestamp = evtJson.Timestamp;
- peer.channel = "";
- peer.linkedChannel = "";
- peer.queueName = "";
- holly.phone._phone_updateQueueInfo();
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- if (evtJson.Exten && peer.sipNo === evtJson.Exten) {
- if (hollyglobal.hangupEvent && typeof hollyglobal.hangupEvent === 'function') {
- // hollyglobal.hangupEvent(peer);
- }
- }
- }
- } else if (evtJson.Event === "UserStatus") {
- var isRegistered = false;
- if (evtJson.PeerStatus === "Registered")
- isRegistered = true;
- if (!holly.phone.phone_peers[evtJson.UserID]) {
- peer = {
- exten: evtJson.Exten,
- sipNo: evtJson.SipNum,
- name: evtJson.User,
- DisplayName: evtJson.DisplayName,
- loginExten: evtJson.LoginExten,
- peerStatus: evtJson.PeerStatus,
- status: evtJson.Status,
- C5Status: evtJson.C5Status,
- busy: evtJson.Busy,
- extenType: evtJson.ExtenType,
- login: evtJson.Login,
- userId: evtJson.UserID,
- user: evtJson.User,
- localNo: evtJson.Local,
- register: isRegistered,
- InCalls: evtJson.InCalls,
- InComplete: evtJson.InComplete,
- TransferComplete: evtJson.TransferComplete,
- OutCalls: evtJson.OutCalls,
- OutComplete: evtJson.OutComplete,
- DialoutTimeLength: evtJson.DialoutTimeLength,
- linked: false,
- channel: "",
- linkedChannel: "",
- called: false,//是否是被呼
- callStatus: "Idle",
- callNo: "",
- department: evtJson.DepartmentID ? evtJson.DepartmentID : "",
- timestamp: evtJson.Login ? (evtJson.BusyTimestamp) : "",
- busyTimestamp: evtJson.BusyTimestamp,
- loginTimestamp: evtJson.LoginTimestamp,
- busyType: evtJson.BusyType,
- pinyin: cnToSpell.getSpell(evtJson.DisplayName),
- pbx: evtJson.PBX
- };
- holly.phone.phone_peers[evtJson.UserID] = peer;
- holly.phone.phone_peers_sip[evtJson.SipNum] = peer;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- } else {
- peer = holly.phone.phone_peers[evtJson.UserID];
- peer.peerStatus = evtJson.PeerStatus;
- peer.status = evtJson.Status;
- peer.exten = evtJson.Exten;
- peer.sipNo = evtJson.SipNum;
- peer.C5Status = evtJson.C5Status;
- peer.busy = evtJson.Busy;
- peer.extenType = evtJson.ExtenType;
- peer.login = evtJson.Login;
- peer.loginExten = evtJson.LoginExten;
- peer.name = evtJson.User;
- peer.DisplayName = evtJson.DisplayName;
- peer.userId = evtJson.UserID;
- peer.user = evtJson.User;
- peer.localNo = evtJson.Local;
- peer.register = isRegistered;
- peer.InCalls = evtJson.InCalls;
- peer.InComplete = evtJson.InComplete;
- peer.TransferComplete = evtJson.TransferComplete;
- peer.DialoutTimeLength = evtJson.DialoutTimeLength;
- peer.OutCalls = evtJson.OutCalls;
- peer.OutComplete = evtJson.OutComplete;
- peer.department = evtJson.DepartmentID ? evtJson.DepartmentID : "";
- peer.busyTimestamp = evtJson.BusyTimestamp;
- peer.loginTimestamp = evtJson.LoginTimestamp;
- peer.busyType = evtJson.BusyType;
- peer.timestamp = peer.login ? (peer.busyTimestamp) : "";
- if (peer.DisplayName !== evtJson.DisplayName)
- peer.pinyin = cnToSpell.getSpell(evtJson.DisplayName);
- holly.phone.phone_peers_sip[evtJson.SipNum] = peer;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- } else if (evtJson.Event === "UserBusy") {
- if (holly.phone.phone_peers[evtJson.UserID]) {
- peer = holly.phone.phone_peers[evtJson.UserID];
- peer.busy = evtJson.Busy;
- peer.busyType = evtJson.BusyType;
- peer.busyTimestamp = evtJson.BusyTimestamp;
- peer.timestamp = peer.login ? (peer.busyTimestamp) : "";
- peer.loginTimestamp = evtJson.LoginTimestamp;
- holly.phone.phone_peers_sip[peer.sipNo] = peer;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- } else if (evtJson.Event === "UserCallsUpdate") {
- if (holly.phone.phone_peers[evtJson.UserID]) {
- peer = holly.phone.phone_peers[evtJson.UserID];
- peer.InCalls = evtJson.InCalls;
- peer.InComplete = evtJson.InComplete;
- peer.TransferComplete = evtJson.TransferComplete;
- peer.DialoutTimeLength = evtJson.DialoutTimeLength;
- peer.OutCalls = evtJson.OutCalls;
- peer.OutComplete = evtJson.OutComplete;
- holly.phone.phone_peers_sip[peer.sipNo] = peer;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- } else if (evtJson.Event === "UserSignIn") {
- if (holly.phone.phone_peers[evtJson.UserID]) {
- peer = holly.phone.phone_peers[evtJson.UserID];
- peer.extenType = evtJson.ExtenType;
- peer.login = evtJson.Login;
- peer.sipNo = evtJson.SipNum;
- holly.phone.phone_peers_sip[peer.sipNo] = peer;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- } else if (evtJson.Event === "UserSignOut") {
- if (holly.phone.phone_peers[evtJson.UserID]) {
- peer = holly.phone.phone_peers[evtJson.UserID];
- peer.extenType = evtJson.ExtenType;
- peer.sipNo = evtJson.SipNum;
- peer.login = evtJson.Login;
- holly.phone.phone_peers_sip[peer.sipNo] = peer;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- } else if (evtJson.Event === "PeerStatus") {
- isRegistered = false;
- if (evtJson.PeerStatus === "Registered")
- isRegistered = true;
- // var peer = holly.phone._phone_getUserFromSip(evtJson.Exten);
- peer = holly.phone.phone_peers_sip[evtJson.Exten];
- if (peer) {
- peer.register = isRegistered;
- peer.status = evtJson.Status;
- if (evtJson.ExtenType && evtJson.ExtenType === 'Local') {
- peer.localNo = evtJson.LocalNum;
- peer.loginExten = evtJson.LocalNum;
- }
- holly.phone.phone_peers[peer.userId] = peer;
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- }
- },
- phone_registerEvent: function (eventName, method) {
- $("#icc_event").on(eventName, method);
- },
- phone_publishEvent: function (eventName, params) {
- $("#icc_event").trigger(eventName, params);
- },
- _phone_updateQueueInfo: function () {
- // if(!phone_queues || phone_queues.length<1)
- // return;
- for (var i in holly.phone.phone_queues) {
- var queue = holly.phone.phone_queues[i];
- var members = queue.members;
- queue.busyAgentCount = 0;
- queue.idleAgentCount = 0;
- for (var j in members) {
- // var peer = holly.phone._phone_getUserFromSip(members[j]);
- var peer = holly.phone.phone_peers_sip[members[j]];
- if (peer) {
- if (peer.extenType === "sip") {
- if (!peer.register
- || !peer.login
- || peer.busy
- || peer.callStatus !== "Idle") {
- queue.busyAgentCount++;
- } else {
- queue.idleAgentCount++;
- }
- } else if (peer.extenType === "gateway") {
- if (!peer.register
- || peer.busy
- || peer.callStatus !== "Idle") {
- queue.busyAgentCount++;
- } else {
- queue.idleAgentCount++;
- }
- } else if (peer.extenType === "Local") {
- if (peer.busy
- || peer.callStatus !== "Idle") {
- queue.busyAgentCount++;
- } else {
- queue.idleAgentCount++;
- }
- } else {
- queue.busyAgentCount++;
- }
- } else {
- queue.idleAgentCount++;
- }
- }
- holly.phone.phone_publishEvent("EvtMonitorQueue", [queue, "noNeedWaitCount"]);
- }
- },
- _phone_update: function (evtJson) {
- //console.info(evtJson)
- var timestamp = "";
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Timestamp)
- timestamp = evtJson.Timestamp;
- } else if (evtJson.Event === "UserStatus") {
- timestamp = (evtJson.Login ? (evtJson.BusyTimestamp) : "");
- } else if (evtJson.Event === "UserBusy") {
- timestamp = evtJson.BusyTimestamp;
- }
- if (holly.phone._phone_currentState !== holly.phone._phone_peerstate) {
- holly.utils.hideSoftphonebar();
- } else {
- holly.utils.pickSoftphonebar();
- }
- holly.phone.phone_publishEvent("toolbarupdate", [holly.phone._phone_stateDescription[holly.phone._phone_currentState], timestamp]);
- switch (holly.phone._phone_currentState) {
- case holly.phone._phone_unregister:
- break;
- case holly.phone._phone_peerstate:
- if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- holly.phone.phone_data._curChannel = evtJson.Channel;
- if (evtJson.ChannelStatus === "Hangup") {
- holly.phone.phone_publishEvent("EvtHangup", evtJson);
- }
- }
- }
- break;
- case holly.phone._phone_dialing:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- holly.phone.phone_publishEvent("EvtRing", evtJson);
- // holly.softphonebar._softphonebar_evtRing(evtJson);
- }
- break;
- case holly.phone._phone_innerDialing:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- break;
- case holly.phone._phone_belling:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Link) {
- holly.phone.phone_publishEvent("EvtRing", evtJson);
- // holly.softphonebar._softphonebar_evtRing(evtJson);
- }
- break;
- case holly.phone._phone_innerBelling:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Link) {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- // holly.phone.phone_publishEvent("EvtRing", evtJson);
- }
- }
- break;
- case holly.phone._phone_listening:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- break;
- case holly.phone._phone_talking:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Exten == holly.phone.phone_data.sipNo) {
- // holly.phone.phone_publishEvent("EvtTalking", evtJson);
- holly.softphonebar._softphonebar_evtTalking(evtJson);
- }
- break;
- case holly.phone._phone_transfer:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Link) {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- // holly.phone.phone_publishEvent("EvtTalking", evtJson);
- }
- }
- break;
- case holly.phone._phone_dialoutTransfer:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- if (evtJson.LinkedChannel) {
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- }
- break;
- case holly.phone._phone_threeWayTalking:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- break;
- case holly.phone._phone_innerTalking:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- if (evtJson.LinkedChannel)
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Link) {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- // holly.phone.phone_publishEvent("EvtTalking", evtJson);
- }
- }
- break;
- case holly.phone._phone_dialTalking:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- // holly.phone.phone_publishEvent("EvtTalking", evtJson);
- holly.softphonebar._softphonebar_evtTalking(evtJson);
- }
- break;
- case holly.phone._phone_listened:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- break;
- case holly.phone._phone_transferBelling:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Link) {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- // holly.phone.phone_publishEvent("EvtRing", evtJson);
- }
- }
- break;
- case holly.phone._phone_transferDialing:
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._otherChannel = evtJson.LinkedChannel.Channel;
- if (evtJson.Link) {
- var linkedChannel = evtJson.LinkedChannel;
- if (holly.phone._phone_callObject.callId !== linkedChannel.Uniqueid) {
- holly.phone._phone_callObject.callId = linkedChannel.Uniqueid;
- var callsheetid = "";
- if (linkedChannel.Data && linkedChannel.Data.CallSheetID)
- callsheetid = linkedChannel.Data.CallSheetID;
- holly.phone._phone_callObject = {
- callSheetId: callsheetid,
- originId: linkedChannel.Uniqueid,
- originCallNo: linkedChannel.FromDid,
- originCalledNo: linkedChannel.FromCid,
- callType: linkedChannel.ChannelType,
- callId: linkedChannel.Uniqueid,
- queue: linkedChannel.Queue,
- location: linkedChannel.Location,
- offeringTime: holly.phone._phone_dateParse(new Date(evtJson.Timestamp * 1000)),
- callerProvince: decodeURIComponent(evtJson.CallerProvince),
- callerProvinceCode: evtJson.CallerProvinceCode,
- callerCity: decodeURIComponent(evtJson.CallerCity),
- callerCityCode: evtJson.CallerCityCode,
- data: {}
- };
- if (linkedChannel.Data) {
- holly.phone._phone_callObject.data = linkedChannel.Data;
- holly.phone._phone_callObject.data.callSheetId = callsheetid;
- }
- var queue = holly.phone.phone_queues[holly.phone._phone_callObject.queue];
- if (queue) {
- holly.phone._phone_callObject.queueName = queue.queueName;
- }
- // holly.phone.phone_publishEvent("EvtRing", [holly.phone._phone_callObject]);
- }
- }
- break;
- }
- },
- _phone_getUserFromSip: function (sipNo) {
- var peer = holly.phone._phone_peersFromSip[sipNo];
- if (!peer) {
- if (!holly.phone.phone_peers)
- return null;
- for (var i in holly.phone.phone_peers) {
- if (holly.phone.phone_peers[i].sipNo === sipNo) {
- holly.phone._phone_peersFromSip[sipNo] = holly.phone.phone_peers[i];
- return holly.phone._phone_peersFromSip[sipNo];
- }
- }
- return null;
- } else {
- return peer;
- }
- },
- _phone_getUserFromExten: function (exten) {
- if (!holly.phone.phone_peers)
- return null;
- for (var i in holly.phone.phone_peers) {
- if (holly.phone.phone_peers[i].exten === exten) {
- return holly.phone.phone_peers[i];
- }
- }
- return null;
- },
- //根据工号获取坐席登录状态
- _phone_getUserStatusFromExten:function (exten) {
- var peer = holly.phone._phone_getUserFromExten(exten);
- if(peer ==null){
- return "";
- }
- var statusDesc = holly.softphonebar._softphonebar_displayStatus(peer);
- var status = "";
- if (statusDesc.indexOf("span") != -1) {
- status = statusDesc.replace(/<\/?.+?>/g,"");
- } else {
- status = statusDesc;
- }
- return status;
- },
- _phone_super: function (evtJson) {
- if (evtJson.Event === "UserStatus") {
- if (holly.phone.phone_data.userId === evtJson.UserID) {
- holly.phone.phone_data.busyType = evtJson.BusyType;
- if (holly.phone.phone_data.sipNo !== evtJson.SipNum) {
- holly.phone.phone_data.sipNo = evtJson.SipNum;
- if (evtJson.PeerStatus === "Unregistered") {
- holly.phone._phone_currentState = holly.phone._phone_unregister;
- holly.phone._phone_update(evtJson);
- if (hollyglobal.multiLogin) {
- holly.utils.kickSoftphonebar();
- }
- } else if (evtJson.PeerStatus === "Registered") {
- holly.phone._phone_currentState = holly.phone._phone_peerstate;
- holly.phone._phone_update(evtJson);
- if (hollyglobal.multiLogin) {
- holly.utils.pickSoftphonebar();
- }
- }
- }
- }
- } else if (evtJson.Event === "UserBusy") {//空闲
- if (holly.phone.phone_data.userId === evtJson.UserID){
- holly.phone.phone_data.busyType = evtJson.BusyType;
- //console.info(evtJson)
- if(holly.phone.phone_data.busyType!="99"){//通话中时状态
- hollyglobal.actionEvent('busy',evtJson.Busy);
- }
- }
- } else if (evtJson.Event === "ChannelStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (evtJson.ChannelStatus === "Unlink") {
- holly.phone.phone_data._curChannel = evtJson.Channel;
- holly.phone.phone_data._callId = "";
- }
- }
- } else if (evtJson.Event === "PeerStatus") {
- if (evtJson.Exten === holly.phone.phone_data.sipNo) {
- if (holly.phone._phone_currentState == holly.phone._phone_peerstate)
- return;
- if (holly.phone.phone_data.busyType == holly.phone._phone_systemBusy)
- return;
- // var peer = holly.phone._phone_getUserFromSip(evtJson.Exten);
- var peer = holly.phone.phone_peers_sip[evtJson.Exten];
- //console.info(peer)
- if (peer)
- holly.phone.phone_publishEvent("toolbarupdate", [holly.phone._phone_stateDescription[holly.phone._phone_currentState], ""]);
- }
- } else if (evtJson.Event === "TransferSuccess"
- || evtJson.Event === "TransferFailed") {
- evtJson.Type = "Transfer";
- if (evtJson.Investigate) {
- evtJson.Type = "Investigate";
- }
- holly.phone.phone_publishEvent("transfering", [evtJson]);
- } else if (evtJson.Event === "IvrMenuEnd") {
- holly.phone.phone_publishEvent("ivrMenuTransfering", [evtJson]);
- } else if (evtJson.Event === "DialinAgentBusyMessage") {
- holly.phone.phone_publishEvent("EvtDialinAgentBusyMessage", [evtJson]);
- }
- },
- phone_dialout: function (phoneNum, interfaceData) {
- if (/^\d+$/.test(phoneNum)) {
- var call_type = "";
- if (phoneNum.length < 5 && phoneNum.length !== 4) {
- var peer = holly.phone._phone_getUserFromExten(phoneNum);
- if (!peer) {
- phoneNum = "9" + phoneNum;
- call_type = "dialout";
- } else {
- call_type = "inner";
- }
- } else if (phoneNum.length === 4) {
- call_type = "inner";
- } else if (phoneNum.length === 5) {
- if (holly.utils.startWith(phoneNum, '1') || holly.utils.startWith(phoneNum, '0') || holly.utils.startWith(phoneNum, '9')) {
- phoneNum = "9" + phoneNum;
- call_type = "dialout";
- } else {
- call_type = "inner";
- }
- } else {
- phoneNum = "9" + phoneNum;
- call_type = "dialout";
- }
- interfaceData = {'tt': '131'};
- // var Variable = "directCallerIDNum%3d13488817474";
- hollyglobal.isPopPage = true;
- var phoneJson = {
- Command: "Action",
- Action: "Originate",
- ActionID: "Originate" + Math.random(),
- Channel: "SIP/" + holly.phone.phone_data.sipNo,
- Context: holly.phone.phone_data.accountId,
- Exten: phoneNum,
- Priority: '1',
- UserID: holly.phone.phone_data.userId,
- Timeout: 60000,
- Async: "true",
- CallType: call_type,
- // Variable:Variable,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- // if(interfaceData)
- // phoneJson.InterfaceData = interfaceData;
- var onload = function (response) {
- try {
- if (!response.Succeed) {
- if (response.Expired) {
- holly.phone._phone_relogin(false);
- }
- } else {
- // if($('#DialEnable'))
- // $('#DialEnable').removeAttr("disabled");
- }
- } catch (e) {
- //if ($('#DialEnable'))
- // $('#DialEnable').removeAttr("disabled");
- }
- }
- var onerror = function () {
- //if ($('#DialEnable'))
- //$('#DialEnable').removeAttr("disabled");
- };
- holly.phone._phone_sendAction(phoneJson, onload, onerror);
- return true;
- } else {
- hollyglobal.msgEvent("请输入正确的电话号码");
- //if ($('#DialEnable'))
- // $('#DialEnable').removeAttr("disabled");
- return false;
- }
- },
- phone_setBusy: function (isBusy, busyType) {
- if (holly.phone._phone_isSettingbusy)
- return;
- else
- holly.phone._phone_isSettingbusy = true;
- var phoneJson = {
- Command: "Action",
- Action: "Busy",
- ActionID: "Busy" + Math.random(),
- Exten: holly.phone.phone_data.userId,
- Busy: isBusy,
- BusyType: "" + busyType,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (!response.Succeed) {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- else {
- //console.info(busyType)
- hollyglobal.actionEvent('busy',busyType==0?false:true)
- //console.info(response)
- }
- holly.phone._phone_isSettingbusy = false;
- }
- var onerror = function () {
- holly.phone._phone_isSettingbusy = false;
- };
- holly.phone._phone_sendAction(phoneJson, onload, onerror);
- },
- phone_hangup: function () {
- var phoneJson = {
- Command: "Action",
- Action: "Hangup",
- ActionID: "Hangup" + Math.random(),
- Channel: holly.phone.phone_data._curChannel,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (!response.Succeed) {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- //else
- // hollyglobal.actionEvent('hangup',true);
- //console.info(response)
- }
- holly.phone._phone_sendAction(phoneJson, onload, function () {
- });
- },
- phone_hold: function () {
- var phoneJson = {
- Command: "Action",
- Action: "Hold",
- ActionID: "Hold" + Math.random(),
- Channel: holly.phone.phone_data._otherChannel,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- holly.phone._phone_stateBeforeHold = holly.phone._phone_currentState;
- hollyglobal.actionEvent('hold',true);
- //holly.phone.phone_publishEvent("barupdate", ["hold", "continueTime"]);
- } else {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- holly.phone._phone_sendAction(phoneJson, onload, function () {
- });
- },
- phone_unhold: function () {
- var phoneJson = {
- Command: "Action",
- Action: "Unhold",
- ActionID: "Unhold" + Math.random(),
- Channel: holly.phone.phone_data._otherChannel,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- hollyglobal.actionEvent('unhold',true);
- //holly.phone.phone_publishEvent("barupdate", [holly.phone._phone_stateDescription[holly.phone._phone_stateBeforeHold], "continueTime"]);
- } else {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- holly.phone._phone_sendAction(phoneJson, onload, function () {
- });
- },
- phone_consult: function (phoneNum, mode) {
- if (mode === "number") {
- if (phoneNum.length <= 6) {
- var phoneNumBak = phoneNum;
- phoneNum = phoneNum.substr(1);
- if (phoneNum.length === 5) {
- if (holly.utils.startWith(phoneNum, '1') || holly.utils.startWith(phoneNum, '0') || holly.utils.startWith(phoneNum, '9')) {
- holly.softphonebar._softphonebar_showConsult(phoneNumBak + " ");
- phoneNum = phoneNumBak;
- } else {
- holly.softphonebar._softphonebar_showConsult("工号 " + phoneNum + " ");
- }
- } else if (phoneNum.length === 4) {
- if (holly.utils.startWith(phoneNum, '0') || holly.utils.startWith(phoneNum, '9')) {
- holly.softphonebar._softphonebar_showConsult(phoneNumBak + " ");
- phoneNum = phoneNumBak;
- } else {
- holly.softphonebar._softphonebar_showConsult("工号 " + phoneNum + " ");
- }
- }
- } else
- holly.softphonebar._softphonebar_showConsult(phoneNum + " ");
- } else if (mode === "skillgroup") {
- holly.softphonebar._softphonebar_showConsult(phoneNum + " ");
- }
- var phoneJson = {
- Command: "Action",
- Action: "Consult",
- ActionID: "Consult" + Math.random(),
- FromExten: holly.phone.phone_data.sipNo,
- Exten: phoneNum,
- Timeout: 60000,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- holly.softphonebar.softphonebar_close();
- if (response.Succeed) {
- holly.utils.showTransferOrConsultSucc("咨询成功", "softphone_consult");
- holly.phone.phone_publishEvent("toolbarupdate", ["consultTalking", "continueTime"]);
- } else {
- holly.utils.showTransferOrConsultError("咨询失败", "softphone_consult");
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- holly.softphonebar.softphonebar_close();
- holly.utils.showTransferOrConsultError("咨询失败", "softphone_consult");
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_stopConsult: function () {
- var phoneJson = {
- Command: "Action",
- Action: "StopConsult",
- ActionID: "StopConsult" + Math.random(),
- FromExten: holly.phone.phone_data.sipNo,
- Timeout: 60000,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- if (response.Message != undefined) {
- if (response.Message === "Idle") {
- holly.phone.phone_publishEvent("toolbarupdate", ["peerstate", "continueTime"]);
- } else {
- holly.phone.phone_publishEvent("toolbarupdate", ["talking", "continueTime"]);
- }
- } else {
- holly.phone.phone_publishEvent("toolbarupdate", ["talking", "continueTime"]);
- }
- } else {
- holly.utils.showTransferOrConsultError("结束咨询通话失败", "softphone_consult");
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- holly.utils.showTransferOrConsultError("结束咨询通话失败", "softphone_consult");
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_toMenu: function (exten, displayName) {
- holly.softphonebar.softphonebar_closeModel();
- holly.softphonebar._softphonebar_showToMenu(displayName);
- var phoneJson = {
- Command: "Action",
- Action: "IvrMenu",
- ActionID: "IvrMenu" + Math.random(),
- Channel: holly.phone.phone_data._otherChannel,
- Context: exten,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId
- }
- var onload = function (response) {
- if (response.Succeed) {
- //holly.softphonebar.softphonebar_closeModel();
- } else {
- holly.softphonebar.softphonebar_close();
- holly.utils.showError("转IVR菜单失败", "softphone_transfer");
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- holly.softphonebar.softphonebar_close();
- holly.utils.showError("转IVR菜单失败", "softphone_transfer");
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_transfer: function (phoneNum, mode) {
- if (mode == "number") {
- if (phoneNum.length <= 6) {
- var phoneNumBak = phoneNum;
- phoneNum = phoneNum.substr(1);
- if (phoneNum.length === 5) {
- if (holly.utils.startWith(phoneNum, '1') || holly.utils.startWith(phoneNum, '0') || holly.utils.startWith(phoneNum, '9')) {
- holly.softphonebar._softphonebar_showTranster(phoneNumBak + " ");
- phoneNum = phoneNumBak;
- } else {
- holly.softphonebar._softphonebar_showTranster("工号 " + phoneNum + " ");
- }
- } else if (phoneNum.length === 4) {
- if (holly.utils.startWith(phoneNum, '0') || holly.utils.startWith(phoneNum, '9')) {
- holly.softphonebar._softphonebar_showTranster(phoneNumBak + " ");
- phoneNum = phoneNumBak;
- } else {
- holly.softphonebar._softphonebar_showTranster("工号 " + phoneNum + " ");
- }
- }
- } else
- holly.softphonebar._softphonebar_showTranster(phoneNum + " ");
- } else if (mode == "skillgroup") {
- holly.softphonebar._softphonebar_showTranster(phoneNum + " ");
- }
- var phoneJson = {
- Command: "Action",
- Action: "Transfer",
- ActionID: "Transfer" + Math.random(),
- Exten: phoneNum,
- Channel: holly.phone.phone_data._otherChannel,
- ExtraChannel: holly.phone.phone_data._curChannel,
- UserID: holly.phone.phone_data.userId,
- Context: holly.phone.phone_data.accountId,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- holly.softphonebar.softphonebar_close();
- holly.utils.showTransferOrConsultSucc("转接成功", 'softphone_transfer');
- } else {
- holly.softphonebar.softphonebar_close();
- var message = "";
- if (response.Message == "310") {
- message = "未配置外呼线路";
- } else if (response.Message == "311") {
- message = "转接的用户忙";
- } else if (response.Message == "312") {
- message = "转接的用户未签入";
- } else if (response.Message == "313") {
- message = "转接的用户正在通话";
- } else if (response.Message == "314") {
- message = "转接的用户没有以通话方式登录";
- } else if (response.Message == "315") {
- message = "无法呼通转接的用户";
- } else if (response.Message == "316") {
- message = "转接用户不存在";
- } else {
- message = "";
- }
- if (message == "") {
- holly.utils.showTransferOrConsultError("转接失败", 'softphone_transfer');
- } else {
- holly.utils.showTransferOrConsultError("转接失败:" + message, 'softphone_transfer');
- }
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- holly.softphonebar.softphonebar_close();
- holly.utils.showTransferOrConsultError("转接失败", 'softphone_transfer');
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_cancelTransfer: function () {
- if (holly.phone.phone_data._otherChannel) {
- var phoneJson = {
- Command: "Action",
- Action: "CancelTransfer",
- ActionID: "CancelTransfer" + Math.random(),
- Channel: holly.phone.phone_data._otherChannel,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- holly.softphonebar.softphonebar_close();
- if (response.Succeed) {
- holly.utils.showTransferOrConsultSucc("取消转接成功", 'softphone_transfer');
- } else {
- holly.utils.showTransferOrConsultError("取消转接失败", 'softphone_transfer');
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- holly.softphonebar.softphonebar_close();
- holly.utils.showTransferOrConsultError("取消转接失败", "softphone_transfer");
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- }
- },
- phone_threewaycall: function (phoneNum) {
- var phoneJson = {
- Command: "Action",
- Action: "ThreeWayCall",
- ActionID: "ThreeWayCall" + Math.random(),
- FromExten: holly.phone.phone_data.sipNo,
- Exten: phoneNum,
- Timeout: 60000,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- holly.softphonebar.softphonebar_close();
- if (response.Succeed) {
- holly.utils.showTransferOrConsultSucc("三方通话成功", "softphone_consult");
- holly.phone.phone_publishEvent("toolbarupdate", ["threeWayTalking", ""]);
- } else {
- holly.utils.showTransferOrConsultError("三方通话失败", "softphone_consult");
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- holly.softphonebar.softphonebar_close();
- holly.utils.showTransferOrConsultError("咨询失败", "softphone_consult");
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_kick: function (userId) {
- var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
- var phoneJson = {
- Command: "Action",
- Action: "Kick",
- ActionID: "Kick" + Math.random(),
- Exten: userId,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip || currentPeer.pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- var peer = holly.phone.phone_peers[userId];
- if (peer) {
- peer.C5Status = "";
- peer.callNo = "";
- peer.callStatus = "Idle";
- var date = new Date();
- var identity = date.valueOf();
- peer.timestamp = identity / 1000;
- peer.channel = "";
- peer.linkedChannel = "";
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- } else {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_toIVR: function () {
- if (holly.phone._phone_isToIVR)
- return;
- holly.phone._phone_isToIVR = true;
- var phoneJson = {
- Command: "Action",
- Action: "Validate",
- ActionID: "Validate" + Math.random(),
- Exten: 's',
- Channel: holly.phone.phone_data._otherChannel,
- Timeout: 60000,
- UserID: holly.phone.phone_data.userId,
- Context: holly.phone.phone_data.accountId + "-validate",
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (!response.Succeed) {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- holly.phone._phone_isToIVR = false;
- }
- var error = function () {
- holly.phone._phone_isToIVR = false;
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_kickFromPbx: function (userId, pbx) {
- var phone_pbx = holly.phone.phone_pbxs[pbx];
- var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
- var url = phone_pbx.proxyUrl;
- var phoneJson = {
- Command: "Action",
- Action: "Kick",
- ActionID: "Kick" + Math.random(),
- Exten: userId,
- UserID: holly.phone.phone_data.userId,
- PBX: pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: phone_pbx.sessionId
- };
- var onload = function (response) {
- if (response.Succeed) {
- var peer = holly.phone.phone_peers[userId];
- if (peer) {
- peer.C5Status = "";
- peer.callNo = "";
- peer.callStatus = "Idle";
- var date = new Date();
- var identity = date.valueOf();
- peer.timestamp = identity / 1000;
- peer.channel = "";
- peer.linkedChannel = "";
- holly.phone.phone_publishEvent("EvtMonitorPeer", [peer]);
- holly.phone._phone_updateQueueInfo();
- }
- } else {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- }
- var json = $.toJSON(phoneJson);
- var timeout = 15000;
- $.ajax({
- type: "get",
- url: url,
- timeout: timeout,
- cache: false,
- data: {json: json},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- },
- phone_pick: function (userId) {
- var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
- var peer = holly.phone.phone_peers[userId];
- if (peer == null || peer.localNo == null || peer.localNo == "") {
- holly.utils.showError("不能对没有直线号码的座席做签入操作", "softphone_transfer");
- return;
- }
- var phoneJson = {
- Command: "Action",
- Action: "SignIn",
- ActionID: "SignIn" + Math.random(),
- User: userId,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip || currentPeer.pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- holly.utils.showSucc("座席签入成功", "softphone_transfer");
- } else {
- holly.utils.showError("当前在线座席总数已达最大值,无法再签入", "softphone_transfer");
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_hangupChannel: function (channel) {
- var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
- var phoneJson = {
- Command: "Action",
- Action: "Hangup",
- ActionID: "ForceHangup" + Math.random(),
- Channel: channel,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip || currentPeer.pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- }
- var error = function () {
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_hangupChannelFromPbx: function (channel, pbx) {
- var phone_pbx = holly.phone.phone_pbxs[pbx];
- var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
- var url = phone_pbx.proxyUrl;
- var phoneJson = {
- Command: "Action",
- Action: "Hangup",
- ActionID: "ForceHangup" + Math.random(),
- Channel: channel,
- UserID: holly.phone.phone_data.userId,
- PBX: pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: phone_pbx.sessionId
- };
- var onload = function (response) {
- }
- var error = function () {
- }
- var json = $.toJSON(phoneJson);
- var timeout = 15000;
- $.ajax({
- type: "get",
- url: url,
- timeout: timeout,
- cache: false,
- data: {json: json},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- },
- phone_loot: function (channel) {
- var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
- if (currentPeer.busyType == "0") {
- holly.utils.showError("请先将电话置为忙碌", "softphone_transfer");
- return;
- }
- var phoneJson = {
- Command: "Action",
- Action: "Transfer",
- ActionID: "Transfer" + Math.random(),
- Exten: holly.phone.phone_data.sipNo || currentPeer.sipNo,
- Channel: channel,
- CallType: "Loot",
- Context: holly.phone.phone_data.accountId || currentPeer.accountId,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip || currentPeer.pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (!response.Succeed) {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- phone_pickFromPbx: function (userId, pbx) {
- var peer = holly.phone.phone_peers[userId];
- var currentPeer = holly.phone.phone_peers[window.localStorage.getItem('currentLoginAgent')];
- if (peer == null || peer.localNo == null || peer.localNo == "") {
- holly.utils.showError("不能对没有直线号码的座席做签入操作", "softphone_transfer");
- return;
- }
- var phone_pbx = holly.phone.phone_pbxs[pbx];
- var url = phone_pbx.proxyUrl;
- var phoneJson = {
- Command: "Action",
- Action: "SignIn",
- ActionID: "SignIn" + Math.random(),
- User: userId,
- UserID: holly.phone.phone_data.userId,
- PBX: pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: phone_pbx.sessionId
- };
- var onload = function (response) {
- if (response.Succeed) {
- holly.utils.showSucc("座席签入成功", "softphone_transfer");
- } else {
- holly.utils.showError("当前在线座席总数已达最大值,无法再签入", "softphone_transfer");
- if (response.Expired) {
- holly.phone._phone_relogin(true);
- }
- }
- }
- var error = function () {
- }
- var json = $.toJSON(phoneJson);
- var timeout = 15000;
- $.ajax({
- type: "get",
- url: url,
- timeout: timeout,
- cache: false,
- data: {json: json},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- },
- phone_investigate: function () {
- if (holly.phone._phone_isInvestigatting)
- return;
- holly.phone._phone_isInvestigatting = true;
- var phoneJson = {
- Command: "Action",
- Action: "Transfer",
- ActionID: "Transfer" + Math.random(),
- Exten: 's',
- Channel: holly.phone.phone_data._otherChannel,
- Timeout: 60000,
- CallType: 'investigate',
- UserID: holly.phone.phone_data.userId,
- Context: holly.phone.phone_data.accountId + "-investigate",
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- } else {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- holly.phone._phone_isInvestigatting = false;
- }
- var error = function () {
- holly.phone._phone_isInvestigatting = false;
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- },
- _phone_exit: function (removeQueue) {
- if (!removeQueue)
- removeQueue = false;
- if (!holly.phone.phone_data.uniqueId) {
- phone_data = {};
- holly.session.logined = false;
- window.location = './softphoneBar.html';
- return;
- }
- var actionName = "Logoff";
- if (hollyglobal.multiLogin) {
- actionName = "MultipleLogoff";
- }
- var phoneJson = {
- Command: "Action",
- Action: "Logoff",
- ActionID: "Logoff" + Math.random(),
- QueueRemove: removeQueue,
- User: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip,
- Account: holly.phone.phone_data.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- holly.utils.kickSoftphonebar();
- holly.session.logined = false;
- holly.phone._phone_isKick = false;
- holly.softphonebar._softphonebar_barupdate('', 'unregister', '');
- }
- }
- holly.phone._phone_sendAction(phoneJson, onload, function () {
- });
- },
- _phone_dateParse: function (date) {
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var hour = date.getHours();
- var minute = date.getMinutes();
- var second = date.getSeconds();
- return year + "-" + (month > 9 ? month : "0" + month) + "-" + (day > 9 ? day : "0" + day) + " "
- + (hour > 9 ? hour : "0" + hour) + ":" + (minute > 9 ? minute : "0" + minute) + ":" + (second > 9 ? second : "0" + second);
- },
- phone_isAllowDialout: function () {
- //console.info(holly.phone._phone_stateDescription[holly.phone._phone_currentState])
- return holly.phone._phone_stateDescription[holly.phone._phone_currentState] == "peerstate";
- },
- phone_closeTransfer: function () {
- var bgObj = document.getElementById("hollyc5.bgDiv");
- var msgObj = document.getElementById("hollyc5.msgDiv");
- if (msgObj != null) {
- document.getElementById("TransferEnable1").removeChild(msgObj);
- }
- if (bgObj != null) {
- document.getElementById("TransferEnable1").removeChild(bgObj);
- }
- },
- phone_openTransferOrConsult: function (objectId) {
- $("#softphone-bar-bgdiv").css({display: "block", height: $(document).height()});
- var inputElement = "<input type=\"text\" id=\"" + objectId + "_div_input\" style=\"width:160px;height:20px;color:#938c8c;float:left;padding-right: 10px;\" " +
- "value=\"请输入工号或者手机号\" onfocus=\"if(this.value=='请输入工号或者手机号'){this.value='';this.style.color='#000'}\" " +
- "onblur=\"if(this.value==''){this.value='请输入工号或者手机号';this.style.color='#938c8c'}\" autocomplete='off'/>";
- var bodyHtml = "<div class='modal-body' style='height:30px;padding:9px 0 0 2px;' >" + inputElement;
- if (objectId === 'softphone_transfer') {
- bodyHtml += "<button class='btn btn-small btn-primary' type='button' style='float:left;margin-left:5px;' onclick=\"javascript:holly.softphonebar.softphonebar_transfer($('#" + objectId + "_div_input').val())\">转 接</button>";
- // bodyHtml +="<button class='btn btn-small btn-primary' type='button' style='float:left;margin-left:5px;' onclick=\"holly.softphonebar._softphonebar_showTranster('913488817474')\">转 接</button>";
- // bodyHtml +="<button class='btn btn-small btn-primary' type='button' style='float:left;margin-left:5px;' onclick=\"holly.utils.showTransferOrConsultError('913488817474','softphone_transfer')\">转 接</button>";
- } else
- bodyHtml += "<button class='btn btn-small btn-primary' type='button' style='float:left;margin-left:5px;' onclick=\"javascript:holly.softphonebar.softphonebar_consult($('#" + objectId + "_div_input').val())\">咨 询</button>";
- // bodyHtml +="<button class='btn btn-small btn-primary' type='button' style='float:left;margin-left:5px;' onclick=\"holly.softphonebar._softphonebar_showConsult('913488817474')\">咨 询</button>";
- bodyHtml += "<button class='btn btn-small btn-primary' type='button' style='float:left;margin-left:5px;' onclick=\"javascript:holly.phone.phone_closeDiv();\">关 闭</button></div>";
- $('#' + objectId).empty();
- $('#' + objectId).html(bodyHtml);
- document.documentElement.scrollTop = 0;
- $('#' + objectId).fadeIn('fast');
- },
- phone_listen: function (curChannel,currentPeer) {
- var phoneJson = {
- Command: "Action",
- Action: "Originate",
- ActionID: "Originate" + Math.random(),
- Channel: "SIP/" + holly.phone.phone_data.sipNo,
- Application: "ChanSpy",
- Data: curChannel + "|bq",
- Callerid: holly.phone.phone_data.sipNo || currentPeer.sipNo,
- UserID: holly.phone.phone_data.userId,
- PBX: holly.phone.phone_data.pbx_in_ip || currentPeer.pbx,
- Account: holly.phone.phone_data.accountId || currentPeer.accountId,
- SessionID: holly.phone.phone_data.uniqueId
- };
- var onload = function (response) {
- if (response.Succeed) {
- holly.phone.phone_data._otherChannel = curChannel;
- } else {
- if (response.Expired) {
- holly.phone._phone_relogin();
- }
- }
- }
- var error = function () {
- }
- holly.phone._phone_sendAction(phoneJson, onload, error);
- return true;
- },
- phone_closeDiv: function () {
- var pagedir = $('#softphone-bar-bgdiv');
- var transferObj = $('#softphone_transfer');
- var consultObj = $('#softphone_consult');
- if (transferObj != null) {
- transferObj.css('display', 'none');
- }
- if (consultObj != null) {
- consultObj.css('display', 'none');
- }
- if (pagedir != null) {
- pagedir.css('display', 'none');
- }
- },
- phone_unregisterEvent: function (eventName) {
- $("#icc_event").unbind(eventName);
- },
- _phone_queryQueueItem: function (evtJson) {
- return holly.phone.phone_queues[evtJson.Queue];
- },
- _phone_monitorQueue: function (evtJson) {
- if (evtJson.Event === "QueueParams") {
- var queueItem = holly.phone._phone_queryQueueItem(evtJson);
- var member;
- if (queueItem) {
- if (evtJson.Removed) {
- queueItem.removed = true;
- }
- queueItem.queueName = evtJson.DisplayName;
- queueItem.idleAgentCount = evtJson.Members - evtJson.BusyMembers;
- queueItem.busyAgentCount = evtJson.BusyMembers;
- queueItem.totalAgentCount = evtJson.Members;
- queueItem.queueWaitCount = evtJson.Calls;
- queueItem.abadonedCalls = evtJson.Abandoned;
- queueItem.totalCalls = evtJson.TotalCalls;
- queueItem.DisplayName = evtJson.DisplayName;
- queueItem.members = [];
- for (var i in evtJson.QueueMember) {
- member = evtJson.QueueMember[i];
- queueItem.members[member] = member;
- }
- holly.phone.phone_publishEvent("EvtMonitorQueue", [queueItem, "needWaitCount"]);
- } else {
- queueItem = {
- queueName: evtJson.DisplayName,
- queueId: evtJson.Queue,
- idleAgentCount: evtJson.Members - evtJson.BusyMembers,
- busyAgentCount: evtJson.BusyMembers,
- totalAgentCount: evtJson.Members,
- queueWaitCount: evtJson.Calls,
- abadonedCalls: evtJson.Abandoned,
- DisplayName: evtJson.DisplayName,
- totalCalls: evtJson.TotalCalls,
- members: [],
- removed: false,
- pbx: evtJson.PBX
- };
- for (var i in evtJson.QueueMember) {
- member = evtJson.QueueMember[i];
- queueItem.members[member] = member;
- }
- holly.phone.phone_queues[evtJson.Queue] = queueItem;
- holly.phone.phone_publishEvent("EvtMonitorQueue", [queueItem, "needWaitCount"]);
- }
- } else if (evtJson.Event === "QueueMemberAdded") {
- var queueItem = holly.phone._phone_queryQueueItem(evtJson);
- if (queueItem) {
- if (!queueItem.members[evtJson.Exten]) {
- queueItem.members[evtJson.Exten] = evtJson.Exten; //change
- queueItem.totalAgentCount++;
- holly.phone._phone_updateQueueInfo();
- }
- }
- } else if (evtJson.Event === "QueueMemberRemoved") {
- var queueItem = holly.phone._phone_queryQueueItem(evtJson);
- if (queueItem) {
- if (queueItem.members[evtJson.Exten]) {
- delete queueItem.members[evtJson.Exten];
- queueItem.totalAgentCount--;
- holly.phone.phone_publishEvent("EvtMonitorQueue", [queueItem, "noNeedWaitCount"]);
- }
- }
- } else if (evtJson.Event === "Join") {
- var queueItem = holly.phone._phone_queryQueueItem(evtJson);
- if (queueItem) {
- queueItem.queueWaitCount++;
- holly.phone.phone_publishEvent("EvtMonitorQueue", [queueItem, "needWaitCount"]);
- }
- } else if (evtJson.Event === "Leave") {
- var queueItem = holly.phone._phone_queryQueueItem(evtJson);
- if (queueItem) {
- queueItem.totalCalls++;
- queueItem.queueWaitCount--;
- if (queueItem.queueWaitCount < 0)
- queueItem.queueWaitCount = 0;
- holly.phone.phone_publishEvent("EvtMonitorQueue", [queueItem, "needWaitCount"]);
- }
- } else if (evtJson.Event === "QueueCallerAbandon") {
- var queueItem = holly.phone._phone_queryQueueItem(evtJson);
- if (queueItem) {
- queueItem.abadonedCalls++;
- holly.phone.phone_publishEvent("EvtMonitorQueue", [queueItem, "noNeedWaitCount"]);
- }
- }
- },
- dialoutInterface: function () {
- var url = "http://127.0.0.1:7788/app?Action=Dialout&ActionID=Dialout" + Math.random() + "&Account=N000000007121&FromExten=8000&PBX=2.3.1.100&Exten=13488817474";
- var ExternalData = {
- callNum: "131313"
- };
- var json = encodeURI(ExternalData);
- var onload = function (response) {
- console.log(response);
- };
- var onerror = function (error) {
- console.log(error);
- };
- holly.phone._phone_test_sendAction(json, onload, onerror, url);
- },
- _phone_test_sendAction: function (jsonData, onload, onerror, url) {
- jsonData = $.toJSON("{'callNum' = '131313'}");
- var timeout = 15000;
- $.ajax({
- type: "get",
- url: url,
- timeout: timeout,
- cache: false,
- data: {ExternalData: jsonData},
- dataType: "jsonp",
- jsonp: "callbackName",
- success: onload,
- error: onerror
- });
- }
- }
|