(function(global) { "use strict"; var C3TConnector = function(oApplet) { if ( C3TConnector.prototype._singletonInstance ) { return C3TConnector.prototype._singletonInstance; } if (oApplet === undefined) { //console.error("You must give the reference to the java applet (Ie : applet ID)"); return undefined; } else { //console.log("creating instance"); this.applet = oApplet; $(document).trigger("C3TConnector_loaded"); } C3TConnector.prototype._singletonInstance = this; this.getSessionId = function() { return this.applet.getCurrentSessionId(); }; this.isConnected = function() { return this.applet.isConnected(); }; this.connect = function(login, password) { return this.applet.connect(login, password); }; this.disconnect = function() { return this.applet.disconnect(); }; this.getContextValue = function(key, sessionId) { return this.applet.getContextValue(key, sessionId); }; this.setContextValue = function(key, value, sessionId) { return this.applet.setContextValue(key, value, sessionId); }; this.makeCall = function(recipient) { return this.applet.makeCall(recipient); }; this.answerCall = function() { return this.applet.answerCall(); }; this.toggleHold = function() { return this.applet.toggleHold(); }; this.dropCall = function() { return this.applet.dropCall(); }; this.initiateTransfer = function(recipient) { return this.applet.initiateTransfer(recipient); }; this.completeTransfer = function() { return this.applet.completeTransfer(); }; }; global.C3TConnector = C3TConnector; }(window)); //declare general closure function doCall(pPhone, pObj, PID) { C3TConnector().makeCall(pPhone); }; function doTransferCTI(pRef, pPhone){ C3TConnector().initiateTransfer(pPhone); }; function completeTransferCTI(){ C3TConnector().completeTransfer(); }; //Listener function sessionCreated(sessionId, campaignName, remoteParty, incoming) { C3TConnector().setContextValue("phoneNumber", remoteParty, sessionId); openCallWindow(); }; function openCallWindow() { var phoneNumber = C3TConnector().getContextValue("phoneNumber", C3TConnector().getSessionId()); if (phoneNumber) { var win = window.open('receive_call_C3T.fl?phone=' + phoneNumber, 'Dring', 'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=800,height=600'); } else { alert("Aucun appel n'est en cours."); } } function callTransferCompleted(sessionId) { setTimeout(openObjectFromContext,2000); }; function openObjectFromContext() { var tempsession = "" + C3TConnector().getSessionId(); var objId = C3TConnector().getContextValue("objId", tempsession); var objType = C3TConnector().getContextValue("objType", tempsession); if (objId && objType) { var win = window.open('read_' + objType + '.fl?id=' + objId, 'Transfered_Object', 'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=800,height=600'); win.focus(); } } function callTransferInitiated(sessionId) { }; function sessionDestroyed(sessionId) { }; function setContextForTransfer() { return true; };