wsrp.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: cpscrn
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2013
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. //
  9. //
  10. // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  11. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  12. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  13. // configuration object
  14. window._F_inactiveFragments = {};
  15. window._F_libs = {};
  16. var _F_initQueue = new _F_Queue.RunQueue();
  17. var _F_WSRP =
  18. {
  19. /*
  20. * Object used to track fragments that are affected by the old portlet communication. e.g. universal viewer listening to the navigator session based portlet communication
  21. * This is needed so that wsrp portlet like the navigator is able to call the fragment to clear its state when the communicated value is updated
  22. */
  23. wsrpP2PC: {
  24. },
  25. isTransientUpdate : false,
  26. isIsolationMode : "SAP" == window.portalAgent && window.parent !== undefined,
  27. baseFragmentConstructor : window.fragment,
  28. baseCaptionConstructor : window.caption,
  29. baseAJAXRequestConstructor : window._F_Ajax.Request,
  30. baseAttach : window._F_attach,
  31. baseOnLoad: window._F_onload,
  32. baseEventExecute: window._F_Event.execute,
  33. unloaded: false,
  34. consumerModifyResource: null,
  35. unload: function(){
  36. _F_WSRP.unloaded = true;
  37. },
  38. buildResourceUrl: function(resourceTemplate, target){
  39. var begin = resourceTemplate.indexOf("_cpsresourceurl");
  40. if (begin != -1){
  41. var endMarker="cpsendmarker_";
  42. var end = resourceTemplate.indexOf(endMarker, begin);
  43. if (end != -1){
  44. var marker = resourceTemplate.substring(begin, end + endMarker.length);
  45. var decodeCount = 0;
  46. var decodedMarker = marker;
  47. while(decodedMarker != "_cpsresourceurl:cpsendmarker_" && decodeCount ++ < 10){
  48. decodedMarker = _F_Strings.urlDecode(decodedMarker);
  49. }
  50. if (decodeCount < 10){
  51. var encodedTarget = _F_Config.expandMacros(target);
  52. for (i =0; i < decodeCount ; i++){
  53. encodedTarget = _F_Strings.urlEncode(encodedTarget);
  54. }
  55. target = resourceTemplate.replace(marker, encodedTarget);
  56. }
  57. }
  58. }
  59. return target;
  60. },
  61. fixInfoTitle: function(obj){
  62. // This will fix the title in the fragment info to match the real caption title used by ther assembler.
  63. if (window.portalAgent == "cognos" && obj.isBaseFragment())
  64. {
  65. var caption = $(obj.WSRPRewritePrefix()+"caption");
  66. if (caption != null){
  67. obj.info.title = _F_Strings.normalize(_F_Document.getTextContent(caption));
  68. }
  69. }
  70. },
  71. handleTitleUpdate: function (evt){
  72. if (evt.source.id == this.id && this.isBaseFragment())
  73. {
  74. if (evt.payload != null && evt.payload.newTitle != null)
  75. {
  76. var newTitle = evt.payload.newTitle;
  77. if (newTitle != this.title)
  78. {
  79. var caption = $(this.WSRPRewritePrefix()+"caption");
  80. if (caption != null)
  81. caption.innerHTML = "&#160;" + newTitle + "&#160;";
  82. }
  83. }
  84. }
  85. },
  86. buildFragmentUri: function (fragment){
  87. var uri = "";
  88. if (fragment != null && fragment.id !== undefined){
  89. uri +="frag-id=" + _F_Strings.urlEncode(fragment.id);
  90. if (fragment.state != null){
  91. uri +="&frag-state=" + _F_Strings.urlEncode(fragment.state);
  92. }
  93. if (fragment.validator != null && fragment.validator.remote){
  94. uri +="&frag-validator=" + _F_Strings.urlEncode(fragment.validator.remote);
  95. }
  96. if (fragment.windowState != null){
  97. uri +="&frag-windowState=" + _F_Strings.urlEncode(fragment.windowState);
  98. }
  99. if (fragment.mode != null){
  100. uri +="&frag-mode=" + _F_Strings.urlEncode(fragment.mode);
  101. }
  102. if (fragment.transientState != null){
  103. for (var prop in fragment.transientState)
  104. uri+= "&" + prop + "=" + _F_Strings.urlEncode(fragment.transientState[prop]);
  105. }
  106. }
  107. return uri;
  108. },
  109. deepCopy: function(src, target){
  110. for (var prop in src){
  111. if (typeof src[prop] == 'object' ){
  112. if (target[prop] == null)
  113. target[prop] = new Object();
  114. _F_WSRP.deepCopy(src[prop], target[prop]);
  115. }else {
  116. target[prop] = src[prop];
  117. }
  118. }
  119. },
  120. cleanIsolationModeLocalFragments: function(){
  121. if (_F_WSRP.isIsolationMode)
  122. {
  123. for (var i=0; i < _F_localFragmentsIds.length; i++)
  124. if ( fragments[_F_localFragmentsIds[i]] !== undefined)
  125. delete fragments[_F_localFragmentsIds[i]];
  126. }
  127. },
  128. addLocalFragment: function(obj){
  129. if (_F_WSRP.isIsolationMode){
  130. _F_localFragmentsIds.push(obj.id);
  131. for (var fragid in fragments)
  132. if (fragments[fragid].parent != null && fragments[fragid].parent.id == obj.id)
  133. fragments[fragid].parent = obj;
  134. }
  135. },
  136. saveGlobalTransients: function(){
  137. if (_F_WSRP.isTransientUpdate)
  138. {
  139. var globalTransientValue = "";
  140. for (var prop in fragment.prototype.transientGlobal){
  141. if (globalTransientValue != "")
  142. globalTransientValue += "&";
  143. globalTransientValue += prop + "=" + _F_Strings.urlEncode(fragment.prototype.transientGlobal[prop]);
  144. }
  145. if (globalTransientValue != "")
  146. {
  147. var url = _F_Config.gateway + _F_Config.application + "?bridge-appTransients=" + _F_Strings.urlEncode(globalTransientValue);
  148. var fragRequest = new _F_Ajax.Request(url,
  149. {
  150. requestHeaders:
  151. {
  152. "Connection": "keep-alive",
  153. "Accept": "text/xml,application/xml"
  154. },
  155. asynchronous : false
  156. });
  157. }
  158. _F_WSRP.isTransientUpdate = false;
  159. }
  160. },
  161. /*Needed for CQCOGCQ00815120 */
  162. destroyTransientState: function(transientName, channel){
  163. var key = transientName + '['+channel+']';
  164. var fragList = _F_WSRP.wsrpP2PC[key];
  165. if (fragList){
  166. for (var i = 0 ; i < fragList.length; i++){
  167. fragList[i].destroyState(fragList[i].id, true, true);
  168. }
  169. }
  170. },
  171. /*Needed for CQCOGCQ00815120 */
  172. setDestroyStateForTransient: function(fragment, transientName, channel){
  173. var key = transientName + '['+channel+']';
  174. var fragList = _F_WSRP.wsrpP2PC[key];
  175. if (!fragList){
  176. fragList = [];
  177. _F_WSRP.wsrpP2PC[key] = fragList;
  178. }
  179. if (_F_Array.indexOf(fragList, fragment) == -1){
  180. fragList.push(fragment);
  181. }
  182. }
  183. }
  184. window.caption = function(fragmentID, layoutID)
  185. {
  186. var frag = fragments[fragmentID];
  187. var windowState;
  188. var mode;
  189. if (frag != null){
  190. windowState = frag.windowState;
  191. frag.windowState = "normal";
  192. mode = frag.mode;
  193. frag.mode = "view";
  194. }
  195. var obj = new _F_WSRP.baseCaptionConstructor(fragmentID, layoutID);
  196. obj.__proto__ = _F_WSRP.baseCaptionConstructor.prototype;
  197. if (frag != null){
  198. if (frag.onloadInitialized){
  199. frag.setMode(mode, "internal");
  200. frag.setWindowState(windowState, "internal");
  201. }else{
  202. _F_initQueue.add(frag, frag.setMode, [mode, "internal"]);
  203. _F_initQueue.add(frag, frag.setWindowState, [windowState, "internal"]);
  204. }
  205. }
  206. return obj;
  207. }
  208. window.caption.prototype = _F_WSRP.baseCaptionConstructor.prototype;
  209. window._F_Event.execute = function(frag, listener, evt) {
  210. if (evt.name == "fragment.load" && _F_WSRP.unloaded){
  211. return;
  212. }
  213. _F_WSRP.baseEventExecute(frag, listener, evt);
  214. }
  215. if (_F_WSRP.isIsolationMode){
  216. if (window.parent._F_isolationMode === undefined){
  217. window.parent._F_isolationMode = {
  218. transientGlobal:{},
  219. fragments:{}
  220. }
  221. }
  222. window._F_localFragmentsIds = new Array();
  223. window.fragments = window.parent._F_isolationMode.fragments;
  224. _F_Document.addEventListener(window, "beforeunload", _F_WSRP.cleanIsolationModeLocalFragments);
  225. }
  226. fragment.prototype.showbusy = function(evt)
  227. {
  228. if (window.portalAgent == "cognos" && this.isBaseFragment())
  229. {
  230. var caption = $(this.WSRPRewritePrefix()+"caption_busy");
  231. if (caption != null){
  232. var id = this.WSRPRewritePrefix()+"caption_busyicon";
  233. var busyIcon = $(id);
  234. if (busyIcon == null){
  235. busyIcon= document.createElement("IMG");
  236. busyIcon.src = _F_Config.webContent + "/fragments/portlet/images/portlet_action_refresh_ani.gif";
  237. busyIcon.id = id;
  238. xAppendChild(caption, busyIcon);
  239. }
  240. caption.style.display="";
  241. }
  242. }
  243. }
  244. fragment.prototype.hideBusy = function(evt)
  245. {
  246. if (window.portalAgent == "cognos" && this.isBaseFragment())
  247. {
  248. var busyIcon = $(this.WSRPRewritePrefix()+"caption_busy");
  249. if (busyIcon != null){
  250. busyIcon.style.display="none";
  251. }
  252. }
  253. }
  254. window.fragment = function(path, id, div)
  255. {
  256. var obj = new _F_WSRP.baseFragmentConstructor(path, id, div);
  257. obj.__proto__ = _F_WSRP.baseFragmentConstructor.prototype;
  258. obj.initialize();
  259. _F_WSRP.addLocalFragment(obj);
  260. obj.addEventListener("fragment.destroy", obj.handleDestroyEvent, false);
  261. obj.addEventListener("fragment.retrieve.before", obj.showbusy, false);
  262. obj.addEventListener("fragment.retrieve.after", obj.hideBusy, false);
  263. return obj;
  264. }
  265. window.fragment.prototype = _F_WSRP.baseFragmentConstructor.prototype;
  266. window._F_attach = function(obj)
  267. {
  268. var frag = _F_WSRP.baseAttach(obj);
  269. return frag;
  270. }
  271. fragment.prototype.initialize = function()
  272. {
  273. if (window._F_inactiveFragments[this.id] != null)
  274. _F_WSRP.deepCopy(window._F_inactiveFragments[this.id], this);
  275. }
  276. fragment.prototype.initializeBaseFragment = function(obj){
  277. for (var prop in obj)
  278. this[prop] = obj[prop];
  279. if ("cognos" == window.portalAgent)
  280. this.addEventListener("fragment.title.change", _F_WSRP.handleTitleUpdate, false);
  281. }
  282. fragment.prototype.isBaseFragment = function()
  283. {
  284. return this.instanceKeyImpl !== undefined;
  285. }
  286. fragment.prototype.baseBaseURI = fragment.prototype.baseURI;
  287. fragment.prototype.baseURI = function()
  288. {
  289. var url = this.baseBaseURI.apply(this, arguments);
  290. url += (url.indexOf("?") == -1) ? "?" : "&";
  291. url += "bridge-fid=" + this.instanceKey();
  292. url += "&bridge-gatewayURL=" + _F_Strings.urlEncode(window._F_config.WSRPGateway);
  293. if (window._F_config.WSRPWebContent != null) {
  294. url += "&bridge-webContentURL=" + _F_Strings.urlEncode(window._F_config.WSRPWebContent);
  295. }
  296. url += "&frag-portalAgent=" + _F_Strings.urlEncode(window.portalAgent);
  297. return url;
  298. }
  299. fragment.prototype.baseProcessError = fragment.prototype.processError;
  300. fragment.prototype.processError = function(code, message, details){
  301. if (code == "invalidCredentials" && window.portalAgent != "cognos")
  302. {
  303. this.performAction("");
  304. return;
  305. }
  306. return this.baseProcessError.apply(this, arguments);
  307. }
  308. fragment.prototype.handleDestroyEvent = function(evt){
  309. if (evt.eventPhase == evt.AT_TARGET ){
  310. this.destroyState(this.id);
  311. if (_F_inactiveFragments[this.id]){
  312. _F_inactiveFragments[this.id] = null;
  313. }
  314. }
  315. }
  316. fragment.prototype.destroyState = function(id, includeChildren, isSynchronous) {
  317. var url = _F_Config.gateway + _F_Config.application + "?bridge-destroy=" + _F_Strings.urlEncode(id);
  318. if(includeChildren){
  319. var appendDestroyId = function(fragment, url){
  320. var children = fragment.getChildren();
  321. for (var i =0 ; i < children.length; i++){
  322. url += "&bridge-destroy=" + _F_Strings.urlEncode(children[i].id);
  323. url = appendDestroyId(children[i], url);
  324. }
  325. return url ;
  326. }
  327. url = appendDestroyId(this, url);
  328. }
  329. url += "&bridge-fid=" + _F_Strings.urlEncode(this.instanceKey());
  330. var fragRequest = new _F_Ajax.Request(url,
  331. {
  332. requestHeaders:
  333. {
  334. "Connection": "keep-alive",
  335. "Accept": "text/xml,application/xml"
  336. },
  337. asynchronous : (isSynchronous ? false: true)
  338. });
  339. }
  340. window._F_Ajax.Request = function(url, options){
  341. _F_WSRP.unloaded = false;
  342. var resourceUrl = url;
  343. if ("cognos" != window.portalAgent)
  344. resourceUrl = _F_WSRP.buildResourceUrl(window.resourceTemplate,resourceUrl);
  345. if(window._F_WSRP.consumerModifyResource != null)
  346. {
  347. resourceUrl = window._F_WSRP.consumerModifyResource(resourceUrl);
  348. }
  349. var obj = new _F_WSRP.baseAJAXRequestConstructor(resourceUrl, options);
  350. obj.__proto__ = _F_WSRP.baseAJAXRequestConstructor.prototype;
  351. return obj;
  352. }
  353. window._F_Ajax.Request.prototype = _F_WSRP.baseAJAXRequestConstructor.prototype;
  354. fragment.prototype.getWSRPInteractionBaseParams = function()
  355. {
  356. var s = "&frag-mode=" + this.mode;
  357. if (this.mode != "view" && _F_Array.indexOf(this.modes, this.mode) == -1)
  358. s += "&frag-delegate=" + _F_Strings.urlEncode(this.mode);
  359. if (this.view != "")
  360. s += "&frag-view=" + _F_Strings.urlEncode(this.view);
  361. if (this.windowState != "")
  362. s += "&frag-windowState=" + _F_Strings.urlEncode(this.windowState);
  363. if (this.validator != null && this.validator.remote)
  364. s += "&frag-validator=" + _F_Strings.urlEncode(this.validator.remote);
  365. if (_F_config.authToken)
  366. s += "&cps-authToken=" + _F_Strings.urlEncode(_F_config.authToken);
  367. return s;
  368. }
  369. fragment.prototype.getBaseFragment = function()
  370. {
  371. var f = this;
  372. while (f != null && !(f.isBaseFragment()))
  373. f = f.parent;
  374. if (f != null && f.isBaseFragment())
  375. return f;
  376. throw "not supported";
  377. }
  378. fragment.prototype.WSRPActionUrl = function()
  379. {
  380. var f = this.getBaseFragment();
  381. if (f.WSRPActionUrlImpl !== undefined)
  382. return f.WSRPActionUrlImpl;
  383. throw "not supported";
  384. }
  385. fragment.prototype.instanceKey = function()
  386. {
  387. var f = this.getBaseFragment();
  388. if (f.instanceKeyImpl !== undefined)
  389. return f.instanceKeyImpl;
  390. throw "not supported";
  391. }
  392. fragment.prototype.WSRPRewritePrefix = function()
  393. {
  394. var f = this.getBaseFragment();
  395. if (f.WSRPRewritePrefixImpl !== undefined)
  396. return f.WSRPRewritePrefixImpl;
  397. throw "not supported";
  398. }
  399. fragment.prototype.baseSetMode = fragment.prototype.setMode;
  400. fragment.prototype.setMode = function(mode)
  401. {
  402. if (this.isBaseFragment() && (arguments[1] === undefined || arguments[1] != "internal")){
  403. if (mode != "")
  404. this.mode = mode;
  405. this.performAction("");
  406. }else{
  407. this.baseSetMode.apply(this, arguments);
  408. }
  409. }
  410. fragment.prototype.baseRetrieve = fragment.prototype.retrieve;
  411. fragment.prototype.retrieve = function(sParams, dest, asynchronous){
  412. if (sParams == null)
  413. sParams='';
  414. for (var prop in fragments)
  415. if (fragments[prop] != null && fragments[prop] != this && fragments[prop].id.indexOf(this.id) == 0){
  416. var fragment = fragments[prop];
  417. if (sParams != '')
  418. sParams += '&';
  419. sParams += "frag-sub=" + _F_Strings.urlEncode(_F_WSRP.buildFragmentUri(fragment));
  420. }
  421. for (var prop in _F_inactiveFragments)
  422. if (fragments[prop] == null && _F_inactiveFragments[prop] != null && _F_inactiveFragments[prop] != this && prop.indexOf(this.id) == 0){
  423. var fragment = _F_inactiveFragments[prop];
  424. if (sParams != '')
  425. sParams += '&';
  426. sParams += "frag-sub=" + _F_Strings.urlEncode(_F_WSRP.buildFragmentUri(fragment));
  427. }
  428. return this.baseRetrieve(sParams, dest, asynchronous);
  429. }
  430. fragment.prototype.basePerformAction = fragment.prototype.performAction;
  431. fragment.prototype.performAction = function(query)
  432. {
  433. if (this.isBaseFragment()){
  434. var wsrpActionArray = this.WSRPActionUrl();
  435. var wsrpAction = wsrpActionArray[this.mode];
  436. if (wsrpAction == null){
  437. wsrpAction = wsrpActionArray["_current"];
  438. }
  439. var form = new _F_FormWrapper.Form(this.WSRPRewritePrefix(), this.id, "perform$action", wsrpAction);
  440. var fullQuery = this.getWSRPInteractionBaseParams();
  441. if (query && query != "")
  442. fullQuery += '&' + query;
  443. form.setParams(fullQuery.split("&"));
  444. form.submit();
  445. }else{
  446. this.basePerformAction(query);
  447. }
  448. }
  449. window._F_onload = function()
  450. {
  451. if (_F_WSRP.isIsolationMode){
  452. if (window.parent._F_isolationMode !== undefined){
  453. _F_WSRP.deepCopy(fragment.prototype.transientGlobal, window.parent._F_isolationMode.transientGlobal);
  454. fragment.prototype.transientGlobal = window.parent._F_isolationMode.transientGlobal;
  455. }
  456. }
  457. for (var id in fragments)
  458. _F_WSRP.fixInfoTitle(fragments[id]);
  459. _F_WSRP.baseOnLoad();
  460. while(_F_initQueue.queue.hasNext())
  461. _F_initQueue.run();
  462. // Fix for IE to hide unwanted vertical scrollbar.
  463. if (xIE4Up && window.portalAgent == "cognos"){
  464. for (var id in fragments){
  465. var frag = fragments[id];
  466. if (frag.isBaseFragment){
  467. frag.addEventListener("fragment.load", _F_fixIEScrollbar, true);
  468. frag.addEventListener("fragment.visibility.change", _F_fixIEScrollbar, true);
  469. }
  470. }
  471. }
  472. // fire "page.load" event on the top level page
  473. var oEvent = new _F_Event.Event();
  474. oEvent.initEvent("page.load", "", null, false, false);
  475. for (var id in fragments)
  476. {
  477. if (fragments[id].parent == null)
  478. {
  479. oEvent.source = fragments[id];
  480. fragments[id].dispatchEvent(oEvent);
  481. }
  482. }
  483. _F_Document.addEventListener(window, "beforeunload", _F_WSRP.saveGlobalTransients);
  484. }
  485. function _F_fixIEScrollbar(evt){
  486. if (window._ASM_fixIEScrollbar){
  487. var frag = evt.currentTarget;
  488. _ASM_fixIEScrollbar(frag.WSRPRewritePrefix()+"_content");
  489. }
  490. }
  491. fragment.prototype.baseFragmentTransientUpdate = fragment.prototype.transientUpdate;
  492. fragment.prototype.transientUpdate= function(sName, sValue, sScope, sChannel)
  493. {
  494. _F_WSRP.isTransientUpdate = true;
  495. if (arguments.length > 2){
  496. arguments[2] = arguments[2]=="page" ? "application" : arguments[2];
  497. }
  498. return this.baseFragmentTransientUpdate.apply(this, arguments);
  499. }
  500. var _F_FormWrapper =
  501. {
  502. }
  503. _F_FormWrapper.Form = function(wsrpid, id, name, action)
  504. {
  505. this.wsrpid = wsrpid;
  506. this.id = id;
  507. this.name = name;
  508. this.action = action;
  509. }
  510. _F_FormWrapper.Form.prototype =
  511. {
  512. setParams: function(params)
  513. {
  514. this.params = params;
  515. },
  516. submit: function()
  517. {
  518. var form = this.createForm();
  519. for (var i = 0; i < this.params.length; ++i)
  520. {
  521. var param = this.params[i];
  522. if (param.length > 0)
  523. {
  524. var eq_index = param.indexOf("=");
  525. var name;
  526. var value;
  527. if (eq_index != -1)
  528. {
  529. name = decodeURIComponent(param.substring(0, eq_index));
  530. value = decodeURIComponent(param.substring(eq_index + 1));
  531. }
  532. else
  533. {
  534. name = decodeURIComponent(param);
  535. value = "";
  536. }
  537. this.addParam(form, name, value);
  538. }
  539. }
  540. if (this.action.indexOf('javascript:') == 0)
  541. eval(this.action);
  542. else
  543. form.submit();
  544. this.detach(form);
  545. },
  546. createForm: function()
  547. {
  548. var form = document.createElement("form");
  549. form.setAttribute("name", this.name);
  550. form.setAttribute("method", "POST");
  551. form.action = this.action;
  552. document.body.appendChild(form);
  553. return form;
  554. },
  555. addParam: function(form, name, value)
  556. {
  557. var param = document.createElement("input");
  558. param.setAttribute("type", "hidden");
  559. param.setAttribute("name", this.buildParamName(name));
  560. param.setAttribute("value", value);
  561. form.appendChild(param);
  562. },
  563. buildParamName: function(name)
  564. {
  565. return name;
  566. },
  567. detach: function(form)
  568. {
  569. document.body.removeChild(form);
  570. }
  571. }
  572. if ("SharePoint" == window.portalAgent) {
  573. _F_Form.find=function(name) {
  574. return document[name];
  575. }
  576. _F_Form.lookupAction=function(action) {
  577. if (window.wpforms !== undefined) {
  578. var i, l = window.wpforms.length;
  579. for (i = 0; i < l; i++)
  580. if (window.wpforms[i].action.indexOf(action) > -1)
  581. return window.wpforms[i];
  582. }
  583. document.forms[0];
  584. }
  585. _F_Form.getParamName = function(form, name)
  586. {
  587. if (form._prefix !== undefined && name.indexOf(form._prefix) == 0) {
  588. name = name.substring(form._prefix.length);
  589. }
  590. return name;
  591. }
  592. _F_FormWrapper.Form.prototype.createForm=function() {
  593. var form=document.forms[0];
  594. this.formID=form[this.wsrpid].value + '_';
  595. form[this.wsrpid].value=this.id + this.name;
  596. return form;
  597. }
  598. _F_FormWrapper.Form.prototype.buildParamName=function(name) {
  599. if (name.indexOf(this.formID) == 0)
  600. name=name.substring(this.formID.length);
  601. return this.id + this.name + '_' + name;
  602. }
  603. _F_FormWrapper.Form.prototype.detach=function() {
  604. // do nothing
  605. }
  606. }
  607. _F_Document.addEventListener(window, "beforeunload", _F_WSRP.unload);