config.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** BI and PM: qs
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2015
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *****************************************************************/
  11. // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
  12. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  13. var cfgValues = new Array();
  14. function showMeTheValues(event) {
  15. if (typeof event != "undefined")
  16. {
  17. if (goApplicationManager.get("debugDumpAllowed") == true && event.shiftKey && event.ctrlKey) {
  18. switch (event.keyCode) {
  19. case 67:
  20. if (typeof showConfigValues == "function")
  21. showConfigValues(false);
  22. break;
  23. case 68:
  24. if (typeof showDialogValues == "function")
  25. showDialogValues();
  26. break;
  27. case 69:
  28. if (typeof showConfigValues == "function")
  29. showConfigValues(true);
  30. break;
  31. case 82:
  32. if (typeof recordCommandsToggle == "function")
  33. recordCommandsToggle();
  34. break;
  35. case 81:
  36. if (typeof pushCommandsToggle == "function")
  37. pushCommandsToggle();
  38. break;
  39. }
  40. }
  41. else
  42. keydown(event);
  43. }
  44. };
  45. function updateReportHasChanged(bChanged)
  46. {
  47. if (bChanged == null)
  48. {
  49. bChanged = false;
  50. }
  51. if (bChanged && typeof leavingQS === "function")
  52. {
  53. window.onbeforeunload = leavingQS;
  54. }
  55. else
  56. {
  57. window.onbeforeunload = null;
  58. }
  59. goApplicationManager.add("reportHasChanged", bChanged);
  60. };
  61. function cfgSet(n, v) { cfgValues[n] = v; }
  62. function cfgGet(n) { return cfgValues[n]; }
  63. function cfgRemove(n) { delete cfgValues[n]; }
  64. function cfgIsArray(a) {
  65. return isArray(cfgValues[a]);
  66. };
  67. function cfgIsValid(n) {
  68. return ( !(typeof cfgValues[n] == "undefined" || cfgValues[n] == null) );
  69. };
  70. function cfgPush(a, v) {
  71. if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
  72. addToArray(cfgValues[a], v);
  73. };
  74. function cfgSetDefaultAt(i) {
  75. cfgSetAt("ColFormat", i, new Array("none"));
  76. };
  77. function cfgSetAt(a, i, v) {
  78. if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
  79. insertInArrayAt(cfgValues[a], i, v);
  80. };
  81. function cfgGetAt(a, i) {
  82. if (!cfgIsArray(a)) return null;
  83. return cfgValues[a][i];
  84. };
  85. function cfgPop(a, v) {
  86. if (!cfgIsArray(a)) return;
  87. var bRemoved=false;
  88. var size=cfgValues[a].length;
  89. for (var i=0;i<size;i++) {
  90. if (!bRemoved && cfgValues[a][i]==v) bRemoved=true;
  91. if (bRemoved && i+1<size) cfgValues[a][i]=cfgValues[a][i+1];
  92. }
  93. if (bRemoved) cfgValues[a].length=size-1;
  94. };
  95. function cfgSize(a) {
  96. if (cfgIsArray(a)) return cfgValues[a].length;
  97. return 0;
  98. };
  99. function cfgIndexOf(a, v) {
  100. if (!cfgIsArray(a)) return -1;
  101. for (var i=0; i<cfgValues[a].length; i++)
  102. if (cfgValues[a][i]==v) return i;
  103. return -1;
  104. };
  105. function cfgMakeArray(a) {
  106. return makeArray(cfgValues[a]);
  107. };
  108. function cfgBackup(p) {
  109. cfgSet(p + ".backup", cloneObject(cfgGet(p)));
  110. };
  111. function cfgRestore(p) {
  112. cfgSet(p, cloneObject(cfgGet(p + ".backup")));
  113. };
  114. function addToArray(a, v) { if (!contains(a, v)) a[a.length] = v;}
  115. function insertInArrayAt(a, i, v) { a[i] = v; }
  116. function makeArray(a) {
  117. if (a == null || typeof a == "undefined")
  118. a = new Array();
  119. else if (typeof a != "object") {
  120. var tmp = a; a = new Array(); a[0] = tmp;
  121. }
  122. return a;
  123. };
  124. function containsByIndice(a, v) {
  125. for (var i in a)
  126. if (i == v) return true;
  127. return false;
  128. };
  129. function contains(a, v) {
  130. for (var i in a)
  131. if (a[i] == v) return true;
  132. return false;
  133. };
  134. function isArray(a) {
  135. if (a != null && typeof a == "object") return true;
  136. return false;
  137. };
  138. function cloneArray(a) {
  139. var n = new Array();
  140. for (var i in a){
  141. n[i] = cloneObject(a[i]);
  142. }
  143. return n;
  144. };
  145. function cloneObject(o) {
  146. if (o != null && typeof o == "object" && typeof o.clone == "function") {
  147. return o.clone();
  148. }
  149. else if (o instanceof Array) {
  150. return cloneArray(o);
  151. }
  152. else {
  153. return o;
  154. }
  155. };
  156. function qsDefaults() {
  157. cfgSet("StartRow", 1);
  158. cfgRemove("SelColumns");
  159. cfgRemove("CutColumns");
  160. cfgRemove("DialogSize");
  161. cfgRemove("DialogExecFunc");
  162. cfgRemove("DialogSelCols");
  163. cfgRemove("FormatType");
  164. cfgRemove("FormatDecimals");
  165. cfgRemove("FormatScale");
  166. cfgRemove("FormatThousandSep");
  167. cfgRemove("FormatNegSign");
  168. cfgRemove("FormatCurrencySymbol");
  169. cfgRemove("ExpFilter");
  170. cfgRemove("ColFilterIdx");
  171. cfgRemove("FilterStrings");
  172. cfgRemove("ColFormat");
  173. cfgRemove("combinedFilters");
  174. cfgRemove("combinedFilters_default");
  175. };
  176. function plusEnc(val)
  177. {
  178. if (typeof val == "string")
  179. {
  180. var tempVal = "";
  181. for (var i = 0; i < val.length; i++)
  182. {
  183. if (val.charAt(i) == "+")
  184. tempVal += "%2b";
  185. else
  186. tempVal += val.charAt(i);
  187. }
  188. return tempVal;
  189. }
  190. else
  191. return val;
  192. };
  193. function cEscape(strVal)
  194. {
  195. if (strVal == "")
  196. return false;
  197. return encodeURIComponent(strVal);
  198. };
  199. function setQSCookie(type, name, value)
  200. {
  201. if (type === null || name === null) {
  202. return;
  203. }
  204. var cookies = loadQSCookies();
  205. if (typeof cookies[type] == "undefined" || cookies[type] === null) {
  206. cookies[type] = new Array();
  207. }
  208. cookies[type][name] = value;
  209. var aCookieValueArray = new Array();
  210. for (var n in cookies[type]) {
  211. if (cookies[type][n] !== null) {
  212. aCookieValueArray.push(n + ':' + cookies[type][n]);
  213. }
  214. }
  215. var sCookieString = aCookieValueArray.join("|");
  216. if (navigator.cookieEnabled) {
  217. var str = type + "=" + sCookieString;
  218. if (sCookiePath) {
  219. str += ";path=" + sCookiePath;
  220. }
  221. if (bPersistentCookie) {
  222. var exp = new Date();
  223. if (sCookieString.length == 0) {
  224. exp.setTime(exp.getTime() - 1);
  225. }
  226. else {
  227. exp.setTime(exp.getTime() + 2592000000);
  228. }
  229. str += ";expires=" + exp.toGMTString();
  230. }
  231. document.cookie = str;
  232. }
  233. };
  234. function getQSCookie(type, name)
  235. {
  236. if (type == null) {
  237. return null;
  238. }
  239. var cookies = loadQSCookies();
  240. if (cookies[type] === null
  241. || typeof cookies[type] === "undefined"
  242. || typeof cookies[type][name] === "undefined")
  243. {
  244. return null;
  245. }
  246. return cookies[type][name];
  247. };
  248. function loadQSCookies()
  249. {
  250. if (document.cookie == null) {
  251. return (new Array());
  252. }
  253. var retval = new Array();
  254. var aFullCookies = document.cookie.split(';');
  255. for (var i = 0; i < aFullCookies.length; i++)
  256. {
  257. var sFullCookie = aFullCookies[i];
  258. sFullCookie = sFullCookie.replace(/^ +/, "");
  259. var aCookieNamesAndValues = sFullCookie.split('=');
  260. var sCookieType = aCookieNamesAndValues[0];
  261. var sCookieValues = aCookieNamesAndValues[1]
  262. retval[sCookieType] = new Array();
  263. if (aCookieNamesAndValues.length > 1)
  264. {
  265. var aNameValuePairs = sCookieValues.split('|');
  266. for (var j = 0; j < aNameValuePairs.length; j++)
  267. {
  268. var aSplitPairs = aNameValuePairs[j].split(':');
  269. if (aSplitPairs.length === 1)
  270. {
  271. var sName = aSplitPairs[0];
  272. var sValue = sName;
  273. }
  274. else
  275. {
  276. var sName = aSplitPairs[0];
  277. var sValue = aSplitPairs[1];
  278. }
  279. retval[sCookieType][sName] = sValue;
  280. }
  281. }
  282. else
  283. {
  284. retval[sCookieType][sCookieType] = null;
  285. }
  286. }
  287. return retval;
  288. };
  289. function AddCamInfo( sUrlParams )
  290. {
  291. if ( typeof getConfigFrame == "function" )
  292. {
  293. var cf = getConfigFrame();
  294. if ( cf )
  295. {
  296. var sCAMNS = cf.cfgGet("CAMNamespace");
  297. if ( sCAMNS && typeof sUrlParams == "string" )
  298. {
  299. sUrlParams += "&CAMNamespace=" + encodeURIComponent( sCAMNS );
  300. }
  301. }
  302. }
  303. return sUrlParams;
  304. };