123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 |
- /*
- IBM Confidential
- OCO Source Materials
- IBM Cognos Products: rs
- (C) Copyright IBM Corp. 2018, 2020
- The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
- */
- define( ['bi/authoring/utils/pat/rsLaunchParameters',
- 'bi/authoring/utils/U_Blocker',
- 'bi/authoring/utils/U_Object',
- 'bi/authoring/utils/U_ClearableTimeout'],
- function(rsLaunchParameters, U_Blocker, U_Object, U_ClearableTimeout) {
- var rsPromptHandler = {};
- //
- ///**
- // * @private
- // */
- rsPromptHandler.k_iPollPromptWindow = 1000;
- ///**
- // * @private
- // */
- //G_BusServer.m_aLogonListeners = [];
- ///**
- // * @private
- // */
- rsPromptHandler.m_oPromptListeners = {};
- ///**
- // * @private
- // */
- rsPromptHandler.m_oPromptWindows = {};
- /**
- * @private
- */
- rsPromptHandler.m_iPromptId = 0;
- //G_BusServer.M_bUseReportServiceConsumerMode = false;
- //
- ///**
- // * @private
- // */
- //G_BusServer.f_setParameterValues = function(v_sParameterValues)
- //{
- // this.m_sParameterValues = v_sParameterValues;
- // this.m_docParameterValues = null;
- //};
- //
- //G_BusServer.F_GetParameterValuesNode = function()
- //{
- // if (!this.m_docParameterValues)
- // {
- // this.m_docParameterValues = this.f_parseParameterValues(this.m_sParameterValues);
- // }
- //
- // return this.m_docParameterValues.documentElement;
- //};
- //
- ///**
- // * convert parameters from xml to json
- // *
- // * <bus:parameterValues>
- // * <item xsi:type="bus:parameterValue">
- // * <bus:name xsi:type="xs:string">Parameter1</bus:name>
- // * <bus:value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:parmValueItem[1]">
- // * <item xsi:type="bus:simpleParmValueItem">
- // * <bus:inclusive xsi:type="xs:boolean">true</bus:inclusive>
- // * <bus:display xsi:type="xs:string">BugShield Lotion</bus:display>
- // * <bus:use xsi:type="xs:string">BugShield Lotion</bus:use>
- // * </item>
- // * </bus:value>
- // * </item>
- // * </bus:parameterValues>
- // *
- // * [
- // * {
- // * "name": "Parameter1",
- // * "value": [
- // * {
- // * "inclusive": true,
- // * "use": "BugShield Lotion",
- // * "display": "BugShield Lotion",
- // * "type": "simpleParmValueItem"
- // * }
- // * ]
- // * }
- // * ]
- // *
- // */
- //G_BusServer.F_GetParameterValuesJson = function()
- //{
- // var v_nParameters = G_BusServer.F_GetParameterValuesNode();
- // var v_nlParamItems = v_nParameters.selectNodes("./item"), v_nParamItem;
- // var v_nlValues, v_nValue, v_nValueItem;
- // var v_aParams = [], v_oParam, v_oValue, v_oItem, v_sDisplay;
- //
- // for (var v_iIdx = 0; v_iIdx < v_nlParamItems.length; v_iIdx++)
- // {
- // v_nParamItem = v_nlParamItems.item(v_iIdx);
- //
- // v_oParam = {
- // name: U_Node.F_GetText(v_nParamItem.selectSingleNode("./bus:name")),
- // value: []
- // };
- //
- // v_nValue = v_nParamItem.selectSingleNode("./bus:value");
- // v_nlValues = v_nValue.selectNodes("./item");
- // var v_aItems = [];
- //
- // for (var v_iValue = 0; v_iValue < v_nlValues.length; v_iValue++)
- // {
- // v_nValueItem = v_nlValues.item(v_iValue);
- //
- // v_oValue = {
- // type: v_nValueItem.getAttribute("xsi:type").split(":").pop(),
- // inclusive: v_nValueItem.selectSingleNode("./bus:inclusive[text()='true']") ? true : false
- // };
- //
- // switch (v_oValue.type)
- // {
- // case "simpleParmValueItem":
- // v_aItems.push({
- // xmlNode: v_nValueItem,
- // jsonObj: v_oValue
- // });
- // break;
- //
- // case "boundRangeParmValueItem":
- // v_oValue.start = {};
- // v_aItems.push({
- // xmlNode: v_nValueItem.selectSingleNode("./bus:start"),
- // jsonObj: v_oValue.start
- // });
- //
- // v_oValue.end = {};
- // v_aItems.push({
- // xmlNode: v_nValueItem.selectSingleNode("./bus:end"),
- // jsonObj: v_oValue.end
- // });
- // break;
- //
- // case "unboundedStartRangeParmValueItem":
- // v_oValue.end = {};
- // v_aItems.push({
- // xmlNode: v_nValueItem.selectSingleNode("./bus:end"),
- // jsonObj: v_oValue.end
- // });
- // break;
- //
- // case "unboundedEndRangeParmValueItem":
- // v_oValue.start = {};
- // v_aItems.push({
- // xmlNode: v_nValueItem.selectSingleNode("./bus:start"),
- // jsonObj: v_oValue.start
- // });
- // break;
- //
- // case "hierarchicalParmValueItem":
- // // The spec is invalid, but we need to render it anyway
- // G_Debug.F_Print("'hierarchicalParmValueItem' type is not handled.");
- // break;
- // }
- //
- // for (var v_iItem = 0; v_iItem < v_aItems.length; v_iItem++)
- // {
- // v_oItem = v_aItems[v_iItem];
- //
- // v_oItem.jsonObj.type = v_oItem.xmlNode.getAttribute("xsi:type").split(":").pop();
- // v_oItem.jsonObj.inclusive = v_oItem.xmlNode.selectSingleNode("./bus:inclusive[text()='true']") ? true : false;
- // v_oItem.jsonObj.use = U_Node.F_GetText(v_oItem.xmlNode.selectSingleNode("bus:use"));
- //
- // v_sDisplay = U_Node.F_GetText(v_oItem.xmlNode.selectSingleNode("./bus:display"));
- // if (v_sDisplay)
- // {
- // v_oItem.jsonObj.display = v_sDisplay;
- // }
- // }
- //
- // v_oParam.value.push(v_oValue);
- // }
- //
- // v_aParams.push(v_oParam);
- // }
- //
- // return v_aParams;
- //};
- //
- ///**
- // * @private
- // */
- //G_BusServer.f_setNoParameterValues = function()
- //{
- // /**
- // * @private
- // */
- // this.f_setParameterValues(
- // '<bus:parameterValues ' + C_BusRequest.k_sBIBusNamespaceDecl + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:arrayType="bus:parameterValue[]" xsi:type="SOAP-ENC:Array">' +
- // '</bus:parameterValues>');
- //};
- //
- //G_BusServer.f_setNoParameterValues();
- //
- //
- ///**
- // * @private
- // */
- //G_BusServer.m_aParametersListeners = [];
- //
- ///**
- // * @param {I_ServerParametersListener} v_oListener
- // * @type void
- // */
- //G_BusServer.F_AddParametersListener = function( v_oListener )
- //{
- // this.m_aParametersListeners.push( v_oListener );
- //};
- //
- ///**
- // * @private
- // */
- rsPromptHandler.f_getPromptId = function()
- {
- return ++this.m_iPromptId;
- };
- ///**
- // * Sets the CAF context id for the server.
- // * @param {String} v_sCafContextId CAF context id
- // * @type void
- // */
- //G_BusServer.F_SetCafContextId = function(v_sCafContextId)
- //{
- // this.m_sCafContextId = v_sCafContextId;
- //};
- //
- ///**
- // * @returns The CAF context id for the server.
- // * @type String
- // */
- //G_BusServer.F_GetCafContextId = function()
- //{
- // return this.m_sCafContextId;
- //};
- //
- ///**
- // * @private
- // */
- //G_BusServer.m_sRoutingServerGroup = "";
- //
- ///**
- // * This identifies the routing server group that the requests will be sent to.
- // * @param {String} v_sRoutingServerGroup Routing server group to use for the request.
- // * @type void
- // */
- //G_BusServer.F_SetCurrentReportRoutingServerGroup = function(v_sRoutingServerGroup)
- //{
- // this.m_sRoutingServerGroup = v_sRoutingServerGroup || "";
- //};
- //
- ///**
- // * @returns The router server group.
- // * @type String
- // */
- //G_BusServer.F_GetCurrentReportRoutingServerGroup = function()
- //{
- // return this.m_sRoutingServerGroup;
- //};
- //
- ///**
- // * @private
- // */
- //G_BusServer.f_onUserProfileAcountOK = function(v_oAccount)
- //{
- // G_BusServer.f_onLogonComplete(true);
- //};
- //
- ///**
- // * @private
- // */
- //G_BusServer.f_onUserProfileAcountFailed = function(v_oDfd, v_oXHRError, v_sTextStatus, v_sErrorThrown)
- //{
- // G_BusServer.f_onLogonComplete(false);
- //};
- //
- ///**
- // * Launches the server dialog window for logon to the bus. The application will be blocked until the window closes.
- // * @param {I_ServerLogonListener} v_oListener The listener for the logon.
- // * @returns False if the logon process could not be started.
- // * @type Boolean
- // */
- //G_BusServer.F_Logon = function(v_oListener, v_docResponse)
- //{
- // // Call the Glass login perspective
- // U_GlassUtils.F_UserProfileAcountRequest(this.f_onUserProfileAcountOK.bind(this), this.f_onUserProfileAcountFailed.bind(this));
- //
- // // After login the failing SOAP request must be done again
- // this.m_aLogonListeners.push(v_oListener);
- //
- // // Because the user session could have timed out, we need to clear the authenticity token so that it is renewed when next needed
- // this.m_sAuthenticityToken = "";
- //
- // return true;
- //};
- //
- ///**
- // * @private
- // * Called by portal services when logon is complete
- // */
- //function ccModalCallBack( v_sStatus )
- //{
- // G_BusServer.f_onLogonComplete( v_sStatus == "ok" );
- //};
- //
- ///**
- // * @private
- // */
- //G_BusServer.f_onLogonComplete = function(v_bSuccess)
- //{
- // //Cant send a new request on a callback from another window.
- // //Bugzilla Bug 249843
- // setTimeout(this.f_onAfterLogonComplete.bind(this, v_bSuccess), 0);
- //};
- //
- ///**
- // * @private
- // */
- //G_BusServer.f_onAfterLogonComplete = function(v_bSuccess)
- //{
- // U_Array.F_CallEach( this.m_aLogonListeners, "F_OnServerLogonComplete", v_bSuccess );
- // this.m_aLogonListeners.length = 0;
- //};
- //
- ///**
- // * @type void
- // */
- //G_BusServer.F_Logoff = function()
- //{
- // var v_oBusRequest = new C_BusRequest( null, C_BusRequest.K_sSOAPAction_contentManagerService, "<bus:logoff/>" );
- // v_oBusRequest.F_Send();
- // // need to clear out the authenticityToken on logoff so next request can generate the new and correct one.
- // this.m_sAuthenticityToken = "";
- //};
- //
- ///**
- // * @param {XMLDocument} v_docSOAPResponse
- // * @type Boolean
- // */
- //G_BusServer.F_AuthenticationRequired = function( v_docSOAPResponse )
- //{
- // var v_nBIBusHeader = v_docSOAPResponse.selectSingleNode( "/SOAP-ENV:Envelope/SOAP-ENV:Header/bus:biBusHeader" );
- //
- // if (v_nBIBusHeader && v_nBIBusHeader.selectSingleNode(".//*[local-name() = 'errorCodeString' and text() = 'camAuthUserRecoverable']" ) )
- // {
- // return v_nBIBusHeader.selectSingleNode( ".//bus:promptInfo | .//promptInfo" ) != null;
- // }
- // return false;
- //};
- //
- ///**
- // * @param {XMLDocument} v_docSOAPResponse
- // * @type Boolean
- // */
- //G_BusServer.F_RequiresServerPrompting = function( v_docSOAPResponse )
- //{
- // return Boolean( v_docSOAPResponse && v_docSOAPResponse.selectSingleNode( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result/bus:details/item[bus:status='prompting']" ) );
- //};
-
- rsPromptHandler.f_createSoapPromptLaunchParameters = function(v_docSOAPResponse, v_fnOkCallback)
- {
- return this.f_createPromptLaunchParameters(v_docSOAPResponse, null, v_fnOkCallback);
- };
-
- /**
- * Launches the interactive viewer for response prompting, then passes the final response to callback function.
- * @param {XMLDocument} v_docSOAPResponse
- * @param {Function} v_fnOkCallback
- */
- rsPromptHandler.f_createPromptLaunchParameters = function(v_docSOAPResponse, v_oRequest, v_fnOkCallback)
- {
- var v_oLaunchParameters = {
- promptFnOkCallback: v_fnOkCallback,
- reportXML: null
- };
- if (v_docSOAPResponse)
- {
- v_oLaunchParameters.promptSOAPResponse = ( new XMLSerializer() ).serializeToString( v_docSOAPResponse );
- }
- if (v_oRequest)
- {
- v_oLaunchParameters.promptRequest = v_oRequest;
- }
-
- return v_oLaunchParameters;
- };
- rsPromptHandler.f_createRestPromptLaunchParameters = function(v_oRequest, v_fnOkCallback)
- {
- return this.f_createPromptLaunchParameters(null, v_oRequest, v_fnOkCallback);
- };
-
- /**
- * @private
- See WO 2397
- The pdsState object will contains these properties:
- ccs_cbdata the callback client state sent to promptDataSource.xts.
- clientContext the parameter sent to promptDataSource.xts. (Formerly the 4th parameter 'clientContext' of the callback function)
- conversation the conversation used in promptDataSource.xts's SOAP request. (Formerly the 3rd parameter of the callback function)
- parameters contains the paremeter values collected by the promptDataSource.xts. (Formerly the 1st parameter of the callback function)
- state the state of response returned promptDataSource.xts's SOAP request (OK, Cancel, Error). (Formerly the 2nd parameter 'response' of the callback function)
- tracking the tracking info used in prompDataSource.xts's SOAP request. (Formerly the 5th parameter of the callback function)
- */
- rsPromptHandler.f_prompting_OkCallback = function(v_sPromptId, v_oResponse, v_oAttachments, v_sParameters, v_oOpener)
- {
- var pdsState =
- {
- "v_sClientContext": v_sPromptId,
- "response": v_oResponse,
- "attachments": v_oAttachments,
- "parameters": v_sParameters,
- "opener": v_oOpener
- };
-
- var v_oOpener = null;
- if ( pdsState.state != "Cancel" )
- {
- if (pdsState.parameters)
- {
- // Save parameter values used to generate the response.
- //G_BusServer.F_AddParameterValues( pdsState.parameters );
- }
- if (this.m_oPromptListeners[pdsState.v_sClientContext].F_SetPromptCallbackResponse)
- {
- this.m_oPromptListeners[pdsState.v_sClientContext].F_SetPromptCallbackResponse( pdsState.response, pdsState.attachments );
- }
- v_oOpener = pdsState.opener;
- }
-
- var v_sClientContext = pdsState.v_sClientContext;
- if ( !v_sClientContext )
- {
- //G_Debug.F_Print("Error: Prompting returned with no client context. Will attempt to inform any listener that can be found");
- for ( var s in this.m_oPromptWindows )
- {
- v_sClientContext = s;
- }
- }
- if ( this.m_iLastPromptTimeoutId )
- {
- U_ClearableTimeout.F_Clear( this.m_iLastPromptTimeoutId );
- this.m_iLastPromptTimeoutId = null;
- }
- //Cant send a new request on a callback from another window.
- //Bugzilla Bug 249843
- setTimeout( function(v_sClientContext) {
- this.f_fireOnPromptingComplete(v_sClientContext);
- // Close opener after the call above to ensure parameters
- // are still defined while they are being processed during the callback.
- if (v_oOpener)
- {
- v_oOpener.close();
- }
- }.bind(rsPromptHandler, v_sClientContext), 0);
- delete this.m_oPromptWindows[v_sClientContext];
-
- if ( U_Object.F_IsEmpty(this.m_oPromptWindows) )
- {
- U_Blocker.F_HideEventBlocker();
- }
- else
- {
- //set the focus to another prompt window.
- for ( var s in this.m_oPromptWindows )
- {
- this.m_oPromptWindows[s].focus();
- break;
- }
- }
- };
- //G_BusServer.F_ProcessPromptContext = function( v_oPromptContext, v_oRequest )
- //{
- // // If the prompt was cancelled (using a prompt button) then v_oRequest will be null
- // var v_docSOAPResponse = v_oRequest ? v_oRequest.F_GetResponse() : null;;
- //
- // var v_sParameters = null;
- // if (v_docSOAPResponse && !v_oPromptContext.requestType)
- // {
- // // Extract parameters from response so that they can be added to current parameter values.
- // var v_nParameters = v_docSOAPResponse.selectSingleNode("/SOAP-ENV:Envelope/SOAP-ENV:Body//bus:details/*[@xsi:type='bus:asynchDetailParameterValues']/bus:parameters");
- // v_sParameters = this.f_responseParametersToParameterValues( v_nParameters );
- // }
- //
- // if (v_oPromptContext.promptRequest && v_docSOAPResponse)
- // {
- // var v_sOrigUrl = v_oPromptContext.promptRequest.url;
- // // Make REST call to transform SOAP response into REST JSON response
- // v_oPromptContext.promptRequest.type = "POST";
- // v_oPromptContext.promptRequest.url += "/promptResults";
- // v_oPromptContext.promptRequest.data = U_Node.F_GetXml( v_docSOAPResponse );
- // v_oPromptContext.promptRequest.contentType = "text/xml";
- // Application.GlassContext.services.ajax.ajax(v_oPromptContext.promptRequest)
- // .done( function( v_oResponseData, v_sStatus, v_oXHR )
- // {
- // // Restore URL so we can call delete on it latter.
- // v_oPromptContext.promptRequest.url = v_sOrigUrl;
- // this.f_processPromptContextResponse( v_oPromptContext, v_oResponseData, null, v_sParameters );
- // }.bind(this)
- // )
- // //.fail(??)
- // ;
- // }
- // else
- // {
- // var v_oAttachments = v_oRequest ? v_oRequest.F_GetAttachments() : null;
- // this.f_processPromptContextResponse( v_oPromptContext, v_docSOAPResponse, v_oAttachments, v_sParameters );
- // }
- //};
- //
- //G_BusServer.f_processPromptContextResponse = function( v_oPromptContext, v_oResponse, v_oAttachments, v_sParameters )
- //{
- // if (v_oPromptContext.requestType == "collectParameterValues")
- // {
- // if (v_oResponse)
- // {
- // v_oPromptContext.promptFnOkCallback(G_BusServer.F_GetParameterValuesJson());
- // }
- // Application.F_CloseCurrentPerspective(undefined, function() {
- // try
- // {
- // v_oPromptContext.promptOpener.close();
- // }
- // catch(e)
- // {
- // // do nothing
- // }
- // });
- // }
- // else
- // {
- // // Closing opener is done in callback AFTER values are processed.
- // v_oPromptContext.promptFnOkCallback(v_oResponse, v_oAttachments, v_sParameters, v_oPromptContext.promptOpener);
- // }
- //};
- //
- //G_BusServer.F_ReleasePromptContext = function( v_oPromptContext )
- //{
- // if (v_oPromptContext && v_oPromptContext.promptRequest)
- // {
- // v_oPromptContext.promptRequest.type = "DELETE";
- // if (v_oPromptContext.promptRequest.data)
- // {
- // delete v_oPromptContext.promptRequest.data;
- // }
- // Application.GlassContext.services.ajax.ajax(v_oPromptContext.promptRequest);
- //
- // // Clear main report conversation so we don't release it since the delete above will handle it on the server.
- // // ensures that this conversation doesn't get released in our shutdown code that releases all shared conversations.
- // C_BusConversation.F_UnShareConversation( C_BusRequest.K_sMainReportConversation );
- // }
- //};
-
- /**
- * Launches the server dialog window for prompting. The application will be blocked until the window closes.
- * @param {I_ServerPromptingListener} v_oListener The listener for the prompting.
- * @param {XMLDocument} v_docSOAPResponse
- * @param {Object} v_oGlassContext The Glass context instance
- * @returns False if the prompting process could not be started.
- * @type Boolean
- */
- rsPromptHandler.F_DoPrompting = function(v_oListener, v_docSOAPResponse, v_oGlassContext)
- {
- var v_sPromptId = this.f_getPromptId();
- var v_frmPrompting, v_sUrl, v_oLaunchParameters;
-
- v_oLaunchParameters = this.f_createSoapPromptLaunchParameters(v_docSOAPResponse, this.f_prompting_OkCallback.bind(this, v_sPromptId));
- v_oLaunchParameters.promptOutputPages = v_oListener.getOutputPages(v_docSOAPResponse);
-
- var v_oContext = {
- urlMap: {
- perspective: "authoring",
- isViewer: true,
- UIProfile: "Titan",
- promptResponse: "promptPage",
- ui_appbar: false,
- ui_navbar: false,
- launchParametersKey: rsLaunchParameters.Store(v_oLaunchParameters)
- }
- };
-
- v_sUrl = v_oGlassContext.getUrl(v_oContext);
-
- return this.f_launchPrompt( v_oListener, v_sUrl, v_frmPrompting, v_oLaunchParameters, v_sPromptId );
- };
-
- rsPromptHandler.f_onPromptBlockerMouseDown = function()
- {
- for ( var s in this.m_oPromptWindows )
- {
- this.m_oPromptWindows[s].focus();
- return;
- }
- //Shouldn't get here, but just in case.
- U_Blocker.F_HideEventBlocker();
- // ? G_Debug.F_Print("f_onPromptBlockerMouseDown: blocker was up, yet no prompt window");
- };
- rsPromptHandler.f_launchPrompt = function( v_oListener, v_sUrl, v_frmPrompting, v_oLaunchParameters, v_sPromptId )
- {
- // ? this.f_setNoParameterValues();
-
- //show blocker above dialogs
- var v_elBlocker = U_Blocker.F_ShowEventBlocker( 1000000 );
- v_elBlocker.onmousedown = this.f_onPromptBlockerMouseDown.bind(this);
-
- this.m_oPromptListeners[v_sPromptId] = v_oListener;
- this.m_oPromptWindows[v_sPromptId] = window.open( v_sUrl, (v_frmPrompting ? v_frmPrompting.target : "_blank"), "directories=no,location=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,top=100,left=100,height=600,width=1000" );
- if ( !Boolean( this.m_oPromptWindows[v_sPromptId] ) )
- {
- U_Blocker.F_HideEventBlocker();
- return false;
- }
- this.m_oPromptWindows[v_sPromptId].focus();
-
- if (v_frmPrompting)
- {
- v_frmPrompting.submit();
- }
-
- if (v_oLaunchParameters)
- {
- v_oLaunchParameters.promptOpener = this.m_oPromptWindows[v_sPromptId];
- }
-
- // when window closes call I_ServerPromptingListener.protype.F_OnServerPromptingComplete = function()
- this.m_iLastPromptTimeoutId = U_ClearableTimeout.F_Create( this.f_checkPromptingWindowState.bind(this, v_sPromptId), this.k_iPollPromptWindow );
-
- return true;
- };
- ///**
- // * @private
- // */
- ///**
- // * @private
- // */
- rsPromptHandler.f_checkPromptingWindowState = function( v_sPromptId )
- {
- this.m_iLastPromptTimeoutId = null;
-
- if ( this.m_oPromptWindows[v_sPromptId] )
- {
- // Permission denied error occurs intermittently on IE 6 if window is closed (Bug 550790)
- var v_bWindowClosed = false;
- try
- {
- v_bWindowClosed = this.m_oPromptWindows[v_sPromptId].closed;
- }
- catch ( e )
- {
- v_bWindowClosed = true;
- }
-
- if ( v_bWindowClosed )
- {
- delete this.m_oPromptWindows[v_sPromptId];
- if ( U_Object.F_IsEmpty(this.m_oPromptWindows) )
- {
- U_Blocker.F_HideEventBlocker();
- }
- else
- {
- //set the focus to another prompt window.
- for ( var s in this.m_oPromptWindows )
- {
- this.m_oPromptWindows[s].focus();
- break;
- }
- }
- //Cant send a new request on a callback from another window.
- //Bugzilla Bug 249843
- setTimeout(this.f_fireOnPromptingComplete.bind(this, v_sPromptId), 0);
- }
- else
- {
- this.m_iLastPromptTimeoutId = U_ClearableTimeout.F_Create( this.f_checkPromptingWindowState.bind(this, v_sPromptId), this.k_iPollPromptWindow );
- }
- }
- //else the callback was fired
- };
- /**
- * The window that loaded this module is closing.
- * Close any currently open prompt windows.
- */
- rsPromptHandler.f_OnUnLoad = function( v_fOnUnLoad )
- {
- for (var v_sPromptId in this.m_oPromptWindows)
- {
- // Permission denied error occurs intermittently on IE 6 if window is closed (Bug 550790)
- var v_bWindowClosed = false;
- try
- {
- v_bWindowClosed = this.m_oPromptWindows[v_sPromptId].closed;
- }
- catch ( e )
- {
- v_bWindowClosed = true;
- }
-
- if (!v_bWindowClosed)
- {
- try {
- this.m_oPromptWindows[v_sPromptId].close();
- }
- catch(e) {}
- }
- delete this.m_oPromptWindows[v_sPromptId];
- }
-
- if (v_fOnUnLoad)
- {
- v_fOnUnLoad();
- }
- };
- //
- ///**
- // * @type Array
- // */
- //G_BusServer.F_GetScriptableParameter = function( v_sParameter )
- //{
- // var v_aParameters = [];
- // var d = this.f_parseParameterValues( this.m_sParameterValues );
- // if ( d )
- // {
- // var nl = d.documentElement.selectNodes( v_sParameter ? "item[bus:name=" + U_String.F_ToXPathString( v_sParameter ) + "]" : "item" );
- // var v_iLength = nl.length;
- // for ( var i = 0; i < v_iLength; i++ )
- // {
- // var v_nParameter = nl.item( i );
- // var v_aValues = [];
- // var v_oParameter = { "parameter" : v_nParameter.selectSingleNode( "bus:name" ).text, "values" : v_aValues };
- // v_aParameters.push( v_oParameter );
- // var v_nlValues = v_nParameter.selectNodes( "bus:value/item" );
- // var v_iValuesLength = v_nlValues.length;
- // for ( var j = 0; j < v_iValuesLength; j++ )
- // {
- // var v_nValueItem = v_nlValues.item( j );
- // if ( v_nValueItem.selectSingleNode( "bus:start | bus:end" ) )
- // {
- // var v_nStarUse = v_nValueItem.selectSingleNode( "bus:start/bus:use" );
- // var v_nStartDisplay = v_nValueItem.selectSingleNode( "bus:start/bus:display" );
- // var v_nEndUse = v_nValueItem.selectSingleNode( "bus:end/bus:use" );
- // var v_nEndDisplay = v_nValueItem.selectSingleNode( "bus:end/bus:display" );
- // v_aValues.push( new C_ScriptableParameterRangeValue( v_nStarUse ? v_nStarUse.text : null, v_nStartDisplay ? v_nStartDisplay.text : null, v_nEndUse ? v_nEndUse.text : null, v_nEndDisplay ? v_nEndDisplay.text : null ) );
- // }
- // else
- // {
- // var v_nUse = v_nValueItem.selectSingleNode( "bus:use" );
- // var v_nDisplay = v_nValueItem.selectSingleNode( "bus:display" );
- // v_aValues.push( new C_ScriptableParameterValue( v_nUse ? v_nUse.text : null, v_nDisplay ? v_nDisplay.text : null ) );
- // }
- // }
- // }
- // }
- // return v_aParameters;
- //};
- //
- ///**
- // * @type String
- // */
- //G_BusServer.F_GetParameterValues = function()
- //{
- // return this.m_sParameterValues;
- //};
- //
- ///**
- // * @type void
- // * @param {String} v_sParameterValues XML for the parameters element
- // * @returns True if the parameter values were updated, False otherwise
- // * @type Boolean
- // */
- //G_BusServer.F_SetParameterValues = function(v_sParameterValues)
- //{
- // var v_sNewParams = v_sParameterValues.replace(/bus:parameters(\W)/g, "bus:parameterValues$1");
- // var v_docNewParams = this.f_parseParameterValues( v_sNewParams );
- // var v_docOldParams = this.f_parseParameterValues( this.m_sParameterValues );
- //
- // if ( v_docNewParams && v_docOldParams && U_Node.F_GetXml( v_docNewParams.documentElement ) != U_Node.F_GetXml( v_docOldParams.documentElement ) )
- // {
- // this.f_setParameterValues(v_sNewParams);
- // this.F_fireOnParametersChange();
- // return true;
- // }
- // return false;
- //};
- //
- //G_BusServer.f_responseParametersToParameterValues = function( v_nParameters )
- //{
- // var v_sParameterValues = U_Node.F_GetXml( v_nParameters );
- // // v_nParameters is the <bus:parameters> node from asynchDetailParameterValues in the SOAP response.
- // // However, m_sParameterValues is used as the SOAP representation of the parameterValues parameter in SOAP requests
- // // e.g. run( object, parameterValues, options )
- // // We must therefore rename the root element from parameters to parameterValues
- // var v_sNewParams = v_sParameterValues.replace(/bus:parameters(\W)/g, "bus:parameterValues$1");
- // return v_sNewParams;
- //};
- //
- //G_BusServer.F_SetSOAPParameterValues = function(v_nParameters)
- //{
- // if (v_nParameters)
- // {
- // this.f_setParameterValues(this.f_responseParametersToParameterValues( v_nParameters ));
- // }
- //};
- //
- //G_BusServer.f_parseParameterValues = function( v_sParameterValues )
- //{
- // var d = U_XML.F_LoadValidXML( v_sParameterValues );
- // U_XML.F_SetSelectionNamespaces( d, 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + C_BusRequest.k_sBIBusNamespaceDecl );
- // return d;
- //};
- //
- ///**
- // * @type void
- // * @param {String} v_sParameterValues XML to add to the parameters element
- // * @returns True if the parameter values were updated, False otherwise
- // * @type Boolean
- // */
- //G_BusServer.F_AddParameterValues = function( v_sParameterValues )
- //{
- // var v_docNewParams = this.f_parseParameterValues( v_sParameterValues );
- // var v_docCurrentParams = this.f_parseParameterValues( this.m_sParameterValues );
- //
- // if ( v_docNewParams && v_docCurrentParams )
- // {
- // var v_nRoot = v_docCurrentParams.documentElement;
- // var nl = v_docNewParams.documentElement.selectNodes( "item" );
- // var v_iLength = nl.length;
- // for ( var i = 0; i < v_iLength; i++ )
- // {
- // var v_nNewParameter = nl.item( i );
- // var v_sName = v_nNewParameter.selectSingleNode( "bus:name" ).text;
- // var v_nRemovedParamter = U_XML.F_RemoveNode( v_nRoot, "item[bus:name=" + U_String.F_ToXPathString( v_sName ) + "]" );
- // // Credential parameters must be merged
- // if ( v_nRemovedParamter && ( v_sName.indexOf( "credential:" ) == 0 ) )
- // {
- // var v_nRemovedCredential = U_XML.F_LoadString( null, v_nRemovedParamter.selectSingleNode( "bus:value/item/bus:use" ).text ).documentElement;
- // var v_docNewCredential = U_XML.F_LoadString( null, v_nNewParameter.selectSingleNode( "bus:value/item/bus:use" ).text );
- // var v_nNewCredential = v_docNewCredential.documentElement;
- // var v_nlRemovedCredential = v_nRemovedCredential.selectNodes( "*" );
- // for ( var j = 0; j < v_nlRemovedCredential.length; j++ )
- // {
- // var v_nOld = v_nlRemovedCredential.item( j );
- // if ( !v_nNewCredential.selectSingleNode( v_nOld.nodeName ) )
- // {
- // v_nNewCredential.appendChild( U_XML.F_ImportNode( v_docNewCredential, v_nOld ) );
- // }
- // }
- // var v_sNewCredential = U_Node.F_GetXml( v_nNewCredential );
- // v_nNewParameter.selectSingleNode( "bus:value/item/bus:use" ).text = v_sNewCredential;
- // v_nNewParameter.selectSingleNode( "bus:value/item/bus:display" ).text = v_sNewCredential;
- // }
- // v_nRoot.appendChild( v_nNewParameter );
- // }
- // return this.F_SetParameterValues( U_Node.F_GetXml( v_docCurrentParams ) );
- // }
- // return false;
- //};
- //
- ///**
- // * @type void
- // * @param {String} v_sParameterValues XML for the parameters element
- // * @returns True if the parameter values were updated, False otherwise
- // * @type Boolean
- // */
- //G_BusServer.F_SetInitialParameterValues = function( v_sParameterValues )
- //{
- // this.m_sInitialParameterValues = v_sParameterValues;
- // return this.F_SetParameterValues( v_sParameterValues );
- //};
- //
- ///**
- // * @type void
- // */
- //G_BusServer.F_RestoreToInitialParameterValues = function()
- //{
- // if ( this.m_sInitialParameterValues )
- // {
- // this.F_SetParameterValues( this.m_sInitialParameterValues );
- // }
- // else
- // {
- // this.F_ClearParameterValues();
- // }
- //};
- //
- ///**
- // * @type Boolean
- // */
- //G_BusServer.F_HasParameterValues = function()
- //{
- // var v_nParams = this.F_GetParameterValuesNode();
- // return ( v_nParams.childNodes.length > 0 );
- //};
- //
- ///**
- // * @type void
- // */
- //G_BusServer.F_ClearParameterValues = function(v_bFireChange)
- //{
- // this.f_setNoParameterValues();
- //
- // if (v_bFireChange !== false)
- // {
- // this.F_fireOnParametersChange();
- // }
- //};
- //
- ///**
- // * @private
- // */
- //G_BusServer.F_fireOnParametersChange = function()
- //{
- // U_Array.F_CallEach( this.m_aParametersListeners, "F_OnServerParametersChange" );
- //};
- //
- ///**
- // * @private
- // */
- rsPromptHandler.f_fireOnPromptingComplete = function(v_sClientContext)
- {
- if ( this.m_oPromptListeners[v_sClientContext] && this.m_oPromptListeners[v_sClientContext].F_OnServerPromptingComplete )
- {
- this.m_oPromptListeners[v_sClientContext].F_OnServerPromptingComplete();
- }
- delete this.m_oPromptListeners[v_sClientContext];
- };
- //
- //G_BusServer.F_GetAuthenticityToken = function()
- //{
- // if ( !this.m_sAuthenticityToken )
- // {
- // try
- // {
- // this.m_sAuthenticityToken = ( new CAMAuthenticityTokenSession() ).generate();
- // }
- // catch ( e )
- // {
- // alert( "Exception thrown by CAMAuthenticityTokenSession" +
- // "\n\n Make sure you've included the camcrypto javascript files:" +
- // "\n camcrypto/base64.js" +
- // "\n camcrypto/camcryptoutil.js" +
- // "\n camcrypto/sha1.js" +
- // "\n camcrypto/authtoken1.js"
- // );
- // }
- // }
- // return this.m_sAuthenticityToken;
- //};
- //
- //G_BusServer.F_GetCredentialParameters = function()
- //{
- // var v_nParametersNode = G_BusServer.F_GetParameterValuesNode();
- // var v_nlParamItems = v_nParametersNode.selectNodes("item[starts-with(./bus:name,'credential:')]");
- // var v_aParams = [];
- //
- // for (var i = 0; i < v_nlParamItems.length; ++i)
- // {
- // var v_nItem = v_nlParamItems.item(i);
- // var v_oParam = {
- // name : U_Node.F_GetText(v_nItem.selectSingleNode("bus:name")),
- // type : U_Node.F_GetText(v_nItem.selectSingleNode("bus:value/item/@xsi:type")),
- // inclusive : v_nItem.selectSingleNode("bus:value/item/bus:inclusive[text()='true']") ? true : false,
- // values : [{
- // use : U_Node.F_GetText(v_nItem.selectSingleNode("bus:value/item/bus:use")),
- // display : U_Node.F_GetText(v_nItem.selectSingleNode("bus:value/item/bus:display"))
- // }]
- // };
- //
- // v_aParams.push(v_oParam);
- // }
- //
- // return v_aParams;
- //};
- /**
- * Launches the server dialog window for prompting. The application will be blocked until the window closes.
- * @param {Object} v_oListener The C_RestRequest object which prompted
- * @param {Object} v_oRequest The ajax request object to retrieve prompt page
- * @param {Object} v_oGlassContext The Glass context instance
- * @returns False if the prompting process could not be started.
- * @type Boolean
- */
- rsPromptHandler.F_DoRestPrompting = function(v_oListener, v_oRequest, v_oGlassContext)
- {
- var v_iPromptId = this.f_getPromptId();
- var v_oLaunchParameters = this.f_createRestPromptLaunchParameters( v_oRequest, this.f_prompting_OkCallback.bind(this, v_iPromptId) );
-
- var v_oContext = {
- urlMap: {
- perspective: "authoring",
- isViewer: true,
- UIProfile: "Titan",
- promptResponse: "url",
- ui_appbar: false,
- ui_navbar: false,
- // Uncomment following to enable debugging glass code in prompting window
- //debugBundles: true,
- launchParametersKey: rsLaunchParameters.Store(v_oLaunchParameters, true)
- }
- };
-
- var v_sUrl = v_oGlassContext.getUrl(v_oContext);
- return this.f_launchPrompt( v_oListener, v_sUrl, null, v_oLaunchParameters, v_iPromptId );
- };
- window.onunload = rsPromptHandler.f_OnUnLoad.bind(rsPromptHandler, window.onunload);
- return rsPromptHandler;
- });
|