123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- (function($) {
- $.extend({
- QYProxy: {
- m_bLoging: false,
- o_LoginParam: '',
- m_CurrentState: 0,
- Internal_trim: function(str) {
- str = str.replace(/^(\s|\u00A0)+/, '')
- for (var i = str.length - 1; i >= 0; i--) {
- if (/\S/.test(str.charAt(i))) {
- str = str.substring(0, i + 1)
- break
- }
- }
- return str
- },
-
- GetFunctionJsonParamInfo: function(funcobj, funcobjname, newName) {
-
- var text = ''
- if (newName) {
- text = newName.toString()
- } else {
- text = ''
- }
-
-
-
- console.log(text, 'text.......')
- var paramnames = text.split(',')
- console.log(paramnames, 'paramnamesparamnamesparamnames')
-
- var numargs = funcobj.arguments.length
- var expargs = funcobj.length
-
- var ss = { opcode: funcobjname }
- if (paramnames.length != 0) {
- ss[this.Internal_trim(paramnames[0])] = funcobj.arguments[0]
- for (let i = 1; i < paramnames.length; i++) {
- ss[this.Internal_trim(paramnames[i])] = funcobj.arguments[i]
- }
- }
-
- console.log(ss, funcobj.arguments, 'sssssss')
- return (ss)
- },
- dateFormatter: function(value) {
- var date
- if (value) {
- date = new Date(value)
- } else {
- date = new Date()
- }
- return date.getFullYear() + '-' +
- parseInt(date.getMonth() + 1) + '-' +
- parseInt(date.getDate()) + ' ' +
- parseInt(date.getHours()) + ':' +
- parseInt(date.getMinutes()) + ':' +
- parseInt(date.getSeconds()) + ':' +
- parseInt(date.getMilliseconds())
- },
- Internal_postMessage: function(funcobj, funcobjname, newName) {
-
- var s = this.GetFunctionJsonParamInfo(funcobj, funcobjname, newName)
- try {
-
-
-
- $.QYAgent[funcobjname](s)
-
- } catch (e) {
- }
- },
- on: function(eventname, handler) {
- try {
-
-
- eventTarget.on(eventname, handler)
- } catch (e) {
- }
- },
- un: function(eventname, handler) {
- eventTarget.un(eventname, handler)
- },
-
- UpdateCurrentState: function() {
- this.Internal_postMessage(this.UpdateCurrentState, 'UpdateCurrentState')
- },
-
- GetCurrentState: function() {
- return this.m_CurrentState
- },
-
- DoLogin: function(LoginParam) {
- this.Internal_postMessage(this.DoLogin, 'DoLogin', 'LoginParam')
- },
-
-
- DoSALogin: function(Ip, Port, CId, Code) {
- this.Internal_postMessage(this.DoSALogin, 'DoSALogin', 'Ip, Port, CId, Code')
- },
-
- SALogout: function() {
- this.Internal_postMessage(this.SALogout, 'SALogout')
- },
-
- DoMoLogin: function(ip_mo, port_mo, user, password) {
- this.Internal_postMessage(this.DoMoLogin, 'DoMoLogin', 'ip_mo, port_mo, user, password')
- },
-
- MoLogout: function() {
- this.Internal_postMessage(this.MoLogout, 'MoLogout')
- },
-
- MoGetPageHead: function(module_name, page_index) {
- this.Internal_postMessage(this.MoGetPageHead, 'MoGetPageHead', 'module_name, page_index')
- },
-
- MoPageSwitch: function(module_name, page_index, search_value, switch_flag) {
- this.Internal_postMessage(this.MoPageSwitch, 'MoPageSwitch', 'module_name, page_index, search_value, switch_flag')
- },
- MoCommand: function(module_name, command, param) {
- this.Internal_postMessage(this.MoCommand, 'MoCommand', 'module_name, command, param')
- },
-
-
- SendChat: function(MessageID, Receiver) {
- this.Internal_postMessage(this.SendChat, 'SendChat', 'MessageID, Receiver')
- },
-
- NotifyCodeList: function() {
- this.Internal_postMessage(this.NotifycodeList, 'NotifycodeList')
- },
- SetDebug: function(bDebug) {
- this.Internal_postMessage(this.SetDebug, 'SetDebug', 'bDebug')
- },
- Logout: function() {
- this.Internal_postMessage(this.Logout, 'Logout')
- this.m_CurrentState = 0
- },
-
- SetBusy: function() {
- this.Internal_postMessage(this.SetBusy, 'SetBusy')
- },
-
- SetFree: function() {
- this.Internal_postMessage(this.SetFree, 'SetFree')
- },
-
- SetRest: function(CustomName) {
- this.Internal_postMessage(this.SetRest, 'SetRest', 'CustomName')
- },
-
- Snatch: function(nType, FormatStr) {
- this.Internal_postMessage(this.Snatch, 'Snatch', 'nType, FormatStr')
- },
-
- GetAgentInfo: function(nType, nFlag, CodeList) {
- this.Internal_postMessage(this.GetAgentInfo, 'GetAgentInfo', 'nType, nFlag, CodeList')
- },
-
- GetChannelQueueSize: function(Gid, nFlag) {
- this.Internal_postMessage(this.GetChannelQueueSize, 'GetChannelQueueSize', 'Gid, nFlag')
- },
-
- GetChannelQueueInfo: function(Gid, nFlag) {
- this.Internal_postMessage(this.GetChannelQueueInfo, 'GetChannelQueueInfo', 'Gid, nFlag')
- },
-
- ClientAnswer: function(nType) {
- this.Internal_postMessage(this.ClientAnswer, 'ClientAnswer', 'nType')
- },
-
- Hangup: function() {
- this.Internal_postMessage(this.Hangup, 'Hangup')
- },
-
- EndProcessing: function() {
- this.Internal_postMessage(this.EndProcessing, 'EndProcessing')
- },
-
- Keep: function() {
- this.Internal_postMessage(this.Keep, 'Keep')
- },
-
-
- Silence: function() {
- this.Internal_postMessage(this.Silence, 'Silence')
- },
-
- Restore: function() {
- this.Internal_postMessage(this.Restore, 'Restore')
- },
-
- MakeCallOut: function(CallerNo, CalledNo, BusinessCode, Reserved) {
- this.Internal_postMessage(this.MakeCallOut, 'MakeCallOut', 'CallerNo, CalledNo, BusinessCode, Reserved')
- },
-
- MakeCallOutCancel: function() {
- this.Internal_postMessage(this.MakeCallOutCancel, 'MakeCallOutCancel')
- },
-
- TransTel: function(CallerNo, CalledNo, BusinessCode, Reserved) {
- this.Internal_postMessage(this.TransTel, 'TransTel', 'CallerNo, CalledNo, BusinessCode, Reserved')
- },
-
- TransAgent: function(nType, FormatStr) {
- this.Internal_postMessage(this.TransAgent, 'TransAgent', 'nType, FormatStr')
- },
-
- TransIVR: function(BusinessCode) {
- this.Internal_postMessage(this.TransIVR, 'TransIVR', 'BusinessCode')
- },
-
- TransCancel: function() {
- this.Internal_postMessage(this.TransCancel, 'TransCancel')
- },
-
- ConfStart: function(CallerNo, CalledNo, BusinessCode) {
- this.Internal_postMessage(this.ConfStart, 'ConfStart', 'CallerNo, CalledNo, BusinessCode')
- },
-
- ConfStartCancel: function() {
- this.Internal_postMessage(this.ConfStartCancel, 'ConfStartCancel')
- },
-
- TransConfirm: function(Response) {
- this.Internal_postMessage(this.TransConfirm, 'TransConfirm', 'Response')
- },
-
- ConfConfirm: function(Response) {
- this.Internal_postMessage(this.ConfConfirm, 'ConfConfirm', 'Response')
- },
-
- InManager: function() {
- this.Internal_postMessage(this.InManager, 'InManager')
- },
-
- OutManager: function() {
- this.Internal_postMessage(this.OutManager, 'OutManager')
- },
-
- Listen: function(Code) {
- this.Internal_postMessage(this.Listen, 'Listen', 'Code')
- },
-
- ExitListen: function() {
- this.Internal_postMessage(this.ExitListen, 'ExitListen')
- },
-
- ForceInsert: function(Code) {
- this.Internal_postMessage(this.ForceInsert, 'ForceInsert', 'Code')
- },
-
- ExitForceInsert: function() {
- this.Internal_postMessage(this.ExitForceInsert, 'ExitForceInsert')
- },
-
- ForceRelease: function(Code) {
- this.Internal_postMessage(this.ForceRelease, 'ForceRelease', 'Code')
- },
-
- ForceSetBusy: function(Code) {
- this.Internal_postMessage(this.ForceSetBusy, 'ForceSetBusy', 'Code')
- },
-
- ForceSetFree: function(Code) {
- this.Internal_postMessage(this.ForceSetFree, 'ForceSetFree', 'Code')
- },
-
- ForceLogout: function(Code) {
- this.Internal_postMessage(this.ForceLogout, 'ForceLogout', 'Code')
- },
-
- MeetingStart: function() {
- this.Internal_postMessage(this.MeetingStart, 'MeetingStart')
- },
-
- MeetingAdd: function(CalledList) {
- this.Internal_postMessage(this.MeetingAdd, 'MeetingAdd', 'CalledList')
- },
-
- MeetingUpdateMode: function(MeetingNumber, nMode) {
- this.Internal_postMessage(this.MeetingUpdateMode, 'MeetingUpdateMode', 'MeetingNumber, nMode')
- },
-
- MeetingHangup: function(MeetingNumber) {
- this.Internal_postMessage(this.MeetingHangup, 'MeetingHangup', 'MeetingNumber')
- },
-
- MeetingEnd: function() {
- this.Internal_postMessage(this.MeetingEnd, 'MeetingEnd')
- },
-
- SendDTMF: function(Keys) {
- this.Internal_postMessage(this.SendDTMF, 'SendDTMF', 'Keys')
- },
-
- CustomCommand: function(nType, sData) {
- this.Internal_postMessage(this.CustomCommand, 'CustomCommand', 'Type, sData')
- },
-
-
- GetFreeAgentCount: function(gid) {
- this.Internal_postMessage(this.GetFreeAgentCount, 'GetFreeAgentCount', 'gid')
- },
-
-
- ApplyTelLogin: function(Channel) {
- this.Internal_postMessage(this.ApplyTelLogin, 'ApplyTelLogin', 'Channel')
- },
-
-
- SetBusyState: function(bBusy) {
- this.Internal_postMessage(this.SetBusyState, 'SetBusyState', 'bBusy')
- },
-
-
- PlayAudio: function(Command, Param1, Param2, Param3) {
- this.Internal_postMessage(this.PlayAudio, 'PlayAudio', 'Command, Param1, Param2, Param3')
- },
-
-
-
- SetUnloadState: function(unloadState) {
- this.Internal_postMessage(this.SetUnloadState, 'SetUnloadState', 'unloadState')
- },
-
-
- GetPredialInfo: function(cid, ids) {
- this.Internal_postMessage(this.GetPredialInfo, 'GetPredialInfo', 'cid, ids')
- },
-
-
-
- SetPredialTaskInfo: function(taskid, taskname, operate) {
- this.Internal_postMessage(this.GetPredialInfo, 'SetPredialTaskInfo', 'taskid, taskname, operate')
- }
- }
- })
-
- window.addEventListener('message', function(event) {
- if (event.source != window) { return }
- if (event.data.type && (event.data.type == 'FROM_BK')) {
-
-
- if (event.data.handler == 'S_AgentState') {
-
- $.QYProxy.m_CurrentState = event.data.bkdata.args.State
- }
- setTimeout($.acooly.agent[event.data.handler](event.data.bkdata.args), 0)
- }
- }, false)
- })(jQuery)
|