js_trace.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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 traceDumpWin = null;
  14. var gRecordDumpWin = null;
  15. var gPushCmdWin = null;
  16. var gQSDebug = true;
  17. function trace(msg, useTraceDumpWin)
  18. {
  19. var winToDumpTo;
  20. if (typeof useTraceDumpWin != "undefined" && useTraceDumpWin === true)
  21. {
  22. if (!traceDumpWin || (traceDumpWin && traceDumpWin.closed))
  23. {
  24. traceDumpWin = window.open(goApplicationManager.getReportFrame().oCVQS.getWebContentRoot() + "/common/blank.html", "_trace_window_");
  25. }
  26. winToDumpTo = traceDumpWin;
  27. }
  28. else
  29. {
  30. winToDumpTo = window.open("", "_trace_window_");
  31. }
  32. winToDumpTo.document.writeln("<hr/><b>");
  33. var d = new Date();
  34. winToDumpTo.document.writeln(d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + ":" + d.getMilliseconds());
  35. winToDumpTo.document.writeln("</b><br/><pre>" + msg + "</pre>");
  36. };
  37. function traceObject(obj)
  38. {
  39. if (!traceDumpWin || (traceDumpWin && traceDumpWin.closed))
  40. {
  41. traceDumpWin = window.open(goApplicationManager.getReportFrame().oCVQS.getWebContentRoot() + "/common/blank.html", "_trace_window_");
  42. }
  43. traceDumpWin.document.open();
  44. traceDumpWin.document.writeln("<p>Output of an object. ["+(new Date())+"]</p>");
  45. traceDumpWin.document.writeln(traceObjectHtml(obj));
  46. traceDumpWin.document.close();
  47. };
  48. function traceObjectHtml(obj)
  49. {
  50. var str = "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><th>name</th><th>value(s)</th>";
  51. var p = new Array();
  52. var i;
  53. for (i in obj)
  54. {
  55. p.push(i);
  56. }
  57. p.sort();
  58. for (i = 0; i < p.length; i++)
  59. {
  60. var pre = "<tr><td>" + p[i] + "</td><td>";
  61. var mid = obj[p[i]];
  62. var post = "</td></tr>";
  63. if (typeof mid == "object")
  64. {
  65. mid = traceObjectHtml(mid);
  66. }
  67. str += pre + mid + post;
  68. }
  69. return str + "</table>";
  70. };
  71. function showConfigValues(showCalcFuns)
  72. {
  73. if (!traceDumpWin || (traceDumpWin && traceDumpWin.closed))
  74. {
  75. traceDumpWin = window.open(goApplicationManager.getReportFrame().oCVQS.getWebContentRoot() + "/common/blank.html", "_trace_window_");
  76. }
  77. var i;
  78. var HTMLout = "<html><head><title>Config values</title></head><body>";
  79. HTMLout += "<p>As of ["+(new Date())+"]</p><hr/>";
  80. HTMLout += retrieveConfigKeys(goApplicationManager, "Application Manager");
  81. HTMLout += retrieveConfigKeys(goApplicationManager.getReportManager(), "Report Manager");
  82. HTMLout += retrieveConfigKeys(goApplicationManager.getReportManager().getParameterManager(), "Parameter Manager");
  83. var aRegdFeatureList = goApplicationManager.getFeatureRegistry().getAllRegisteredFeatures();
  84. var aUnregdFeatureList = goApplicationManager.getFeatureRegistry().getAllUnregisteredFeatures();
  85. HTMLout += "<p style=\"color:red\">Feature Object Status</p>";
  86. HTMLout += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\"><th>Feature Name</th><th>State</th>";
  87. var iRegdFeatureCount = 0;
  88. var iUnregdFeatureCount = 0;
  89. var p = new Array();
  90. for (i in aRegdFeatureList)
  91. {
  92. iRegdFeatureCount++;
  93. p.push(i);
  94. }
  95. p.sort();
  96. for (i = 0; i < p.length; i++)
  97. {
  98. HTMLout += "<tr><td>" + aRegdFeatureList[p[i]].m_sFeatureName + "</td><td>" + aRegdFeatureList[p[i]].m_sFeatureState + "</td></tr>";
  99. }
  100. p = new Array();
  101. for (i in aUnregdFeatureList)
  102. {
  103. iUnregdFeatureCount++;
  104. p.push(i);
  105. }
  106. p.sort();
  107. if (p.length > 0)
  108. {
  109. HTMLout += "<tr><td colspan='2'><hr/></td></tr>";
  110. }
  111. for (i = 0; i < p.length; i++)
  112. {
  113. if (aUnregdFeatureList instanceof Object)
  114. {
  115. HTMLout += "<tr><td>" + aUnregdFeatureList[p[i]].m_sFeatureName + "</td><td>" + aUnregdFeatureList[p[i]].m_sFeatureState + "</td></tr>";
  116. }
  117. }
  118. HTMLout += "</table>";
  119. HTMLout += "<font color='green'><b> Total Registered Features: " + iRegdFeatureCount + "</b></font><br/>";
  120. HTMLout += "<font color='red'><b> Total Unregistered Features: " + iUnregdFeatureCount + "</b></font><br/>";
  121. HTMLout += "<font color='black'><b> Total Features: " + (iRegdFeatureCount + iUnregdFeatureCount) + "</b></font><br/><br/><hr/>";
  122. HTMLout += "<p style=\"color:red\">Config values</p>";
  123. HTMLout += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" style=\"width:100%;\"><th>name</th><th align=\"left\" style=\"width:100%;\">value(s)</th>";
  124. p = new Array();
  125. for (i in cfgValues)
  126. {
  127. p.push(i);
  128. }
  129. p.sort();
  130. for (i = 0; i < p.length; i++)
  131. {
  132. if (!(p[i] == "CalcFns" || p[i] == "CalcFnsRestricted") || showCalcFuns)
  133. {
  134. HTMLout += "<tr><td style=\"color:blue\">"+p[i]+"</td>"+printValue(cfgValues[p[i]])+"</tr>";
  135. }
  136. }
  137. HTMLout += "</table></body></html>";
  138. traceDumpWin.document.open();
  139. traceDumpWin.document.write(HTMLout);
  140. traceDumpWin.document.close();
  141. };
  142. function retrieveConfigKeys(oManager, sLabel)
  143. {
  144. var HTMLout = "<p style=\"color:red\">" + sLabel + " Variables</p>";
  145. HTMLout += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" style=\"width:100%;\"><th>Type</th><th>Name</th><th align=\"left\" style=\"width:100%;\">Value(s)</th>";
  146. var oManagerKeys = oManager.keys();
  147. for (i = 0; i < oManagerKeys.length; i++)
  148. {
  149. HTMLout += "<tr><td>" + typeof oManager.get(oManagerKeys[i]) + "</td><td style=\"color:blue\">" + oManagerKeys[i] + "</td>" + printValue(oManager.get(oManagerKeys[i])) + "</tr>";
  150. }
  151. HTMLout += "</table><br/><hr/>";
  152. return HTMLout;
  153. };
  154. function showDialogValues()
  155. {
  156. var now = new Date();
  157. if (!traceDumpWin || (traceDumpWin && traceDumpWin.closed))
  158. {
  159. traceDumpWin = window.open(goApplicationManager.getReportFrame().oCVQS.getWebContentRoot() + "/common/blank.html", "_trace_window_");
  160. }
  161. var HTMLout = "<html><head><title>Dialog values</title></head><body><p>Dialog <font color='red'><b>local</b></font> values [" + now + "]</p>";
  162. HTMLout += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" style=\"width:100%;\"><th>name</th><th align=\"left\" style=\"width:100%;\">value(s)</th>";
  163. var i = "none";
  164. var p = new Array();
  165. for (i in dialogFormValues)
  166. {
  167. p.push(i);
  168. }
  169. p.sort();
  170. if (p.length > 0)
  171. {
  172. for (i = 0; i < p.length; i++)
  173. {
  174. HTMLout += "<tr><td style=\"color:blue\">"+p[i]+"</td>"+printValue(dialogFormValues[p[i]])+"</tr>";
  175. }
  176. }
  177. if (i == "none")
  178. {
  179. HTMLout += "<tr><td colspan='2'>None</td></tr>";
  180. }
  181. HTMLout += "</table>";
  182. HTMLout += "<p>Dialog <font color='blue'><b>global</b></font> values [" + now + "]</p>";
  183. HTMLout += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" style=\"width:100%;\"><th>name</th><th align=\"left\" style=\"width:100%;\">value(s)</th>";
  184. i = "none";
  185. for (i in dialogGlobalValues)
  186. {
  187. HTMLout += "<tr><td style=\"color:blue\">"+i+"</td>"+printValue(dialogGlobalValues[i])+"</tr>";
  188. }
  189. if (i == "none")
  190. {
  191. HTMLout += "<tr><td colspan='2'>None</td></tr>";
  192. }
  193. HTMLout += "</table>";
  194. var aFeatureStack = goApplicationManager.getFeatureManager().getFeatureLaunchStack();
  195. HTMLout += "<p>Feature Object <font color='green'><b>" + aFeatureStack[aFeatureStack.length - 1] + "</b></font> [" + now + "]</p>";
  196. HTMLout += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" style=\"width:100%;\"><th>Type</th><th>Name</th><th align=\"left\" style=\"width:100%;\">Value(s)</th>";
  197. i = "none";
  198. var oFeature = goApplicationManager.getFeatureManager().getAllFeatureDetailsInStack();
  199. if (oFeature.length > 0)
  200. {
  201. for (i = 0; i < oFeature.length; i++)
  202. {
  203. HTMLout += "<tr><td>" + oFeature[i][0] + "</td><td style=\"color:blue\">" + oFeature[i][1] + "</td>" + printValue(oFeature[i][2]) + "</tr>";
  204. }
  205. }
  206. if (i == "none")
  207. {
  208. HTMLout += "<tr><td colspan='3'>None</td></tr>";
  209. }
  210. HTMLout += "</table></body></html>";
  211. traceDumpWin.document.open();
  212. traceDumpWin.document.write(HTMLout);
  213. traceDumpWin.document.close();
  214. };
  215. function printValue(n)
  216. {
  217. if (n === null)
  218. {
  219. return "<td style='color:blue;width:100%;'>null</td>";
  220. }
  221. if (typeof n == "string" && n === "")
  222. {
  223. return "<td style='color:red;width:100%;'>[Empty String]</td>";
  224. }
  225. var i;
  226. var t;
  227. if (typeof n == "object")
  228. {
  229. if (n.length > 0)
  230. {
  231. t = "<td>";
  232. for (i in n)
  233. {
  234. if (typeof n[i] == "object")
  235. {
  236. if (t == "<td>")
  237. {
  238. t += "<table><tr><td style=\"color:red;\">";
  239. }
  240. else
  241. {
  242. t += "<table style='border-top:1px solid #999999;'><tr><td style=\"color:red;\">";
  243. }
  244. t += i + ".</td><td style='color:#999999'>[object]</td><td style='width:100%;'>\n<textarea readonly='true' style='color:black;border:none;width:100%;";
  245. if (document.all)
  246. {
  247. t += "overflow:hidden;";
  248. }
  249. else
  250. {
  251. t += "min-";
  252. }
  253. t += "height:100%;'>";
  254. if (n[i].nodeName)
  255. {
  256. t += "[dom element]: " + n[i].nodeName;
  257. }
  258. else if (typeof n[i].length == "number" && n[i].length > 0)
  259. {
  260. for(var j = 0; j < n[i].length; j++)
  261. {
  262. t += "[array element " + j + "]: " + n[i][j] + "\n";
  263. }
  264. }
  265. else
  266. {
  267. t += "[UNKNOWN TYPE]";
  268. }
  269. t += "\n</textarea></td>";
  270. }
  271. else
  272. {
  273. if (t == "<td>")
  274. {
  275. t += "<table><tr><td style=\"color:red;\">" + i + ". </td>";
  276. }
  277. else
  278. {
  279. t += "<table style='border-top:1px solid #999999;'><tr><td style=\"color:red;\">" + i + ". </td>";
  280. }
  281. if (typeof n[i] == "string" && n[i] === "")
  282. {
  283. t += "<td style=\"color:red;width:100%;\">[Empty String]</td>";
  284. }
  285. else
  286. {
  287. t += "<td style='width:100%;'>\n<textarea readonly='true' style='color:black;border:none;width:100%;";
  288. if (document.all)
  289. {
  290. t += "overflow:hidden;";
  291. }
  292. else
  293. {
  294. t += "min-";
  295. }
  296. t += "height:100%;'>" + n[i] + "\n</textarea>\n</td>";
  297. }
  298. }
  299. t += "</tr></table>";
  300. }
  301. t += "</td>";
  302. }
  303. else
  304. {
  305. t = "<td style='color:red;width:100%;'><table style='width:100%;height:100%;'><tr><td style='color:#999999'>[object]</td></tr><tr><td style='width:100%;height:100%;'>\n<textarea readonly='true' style='color:black;border:none;width:100%;overflow:auto;";
  306. if (!document.all)
  307. {
  308. t += "min-";
  309. }
  310. t += "height:150px;'>";
  311. for (i in n)
  312. {
  313. if (typeof i != "undefined" && typeof i != "unknown")
  314. {
  315. t += "[attribute]: " + i;
  316. }
  317. else
  318. {
  319. t += "[attribute UNKNOWN]";
  320. }
  321. if (typeof n[i] != "undefined" && typeof n[i] != "unknown")
  322. {
  323. t += "\n [value]: " + n[i] + "\n";
  324. }
  325. else
  326. {
  327. t += "\n [value UNKNOWN]\n";
  328. }
  329. }
  330. t += "\n</textarea>\n</td></tr></table></td>";
  331. }
  332. return t;
  333. }
  334. t = "<td style='color:red;width:100%;'>\n<textarea readonly='true' style='color:black;border:none;width:100%;";
  335. if (document.all)
  336. {
  337. t += "overflow:hidden;";
  338. }
  339. else
  340. {
  341. t += "min-";
  342. }
  343. t += "height:100%;'>" + n + "\n</textarea></td>";
  344. return t;
  345. };
  346. function displayForm(f)
  347. {
  348. var t = "Parameters for form [" + f.id + "] for window \"" + f.target + "\" using " + f.action;
  349. var parms = f.document.getElementsByTagName("INPUT");
  350. for (var i = parms.length-1; i >= 0; i--)
  351. {
  352. t += "\n\t" + parms[i].name + " = " + parms[i].value;
  353. }
  354. trace(t);
  355. };
  356. function recordCommandsToggle()
  357. {
  358. if (!gRecordDumpWin || (gRecordDumpWin && gRecordDumpWin.closed))
  359. {
  360. gRecordDumpWin = window.open(goApplicationManager.getReportFrame().oCVQS.getWebContentRoot() + "/common/blank.html", "_record_window_");
  361. }
  362. gRecordDumpWin.document.open();
  363. gRecordDumpWin.document.writeln("<html><head><title>Command Recording</title></head><body><textarea id='recordText' style='width:100%;height:100%;'></textarea></body></html>");
  364. gRecordDumpWin.document.close();
  365. };
  366. function recordCommand(cmd)
  367. {
  368. if (!(!gRecordDumpWin || (gRecordDumpWin && gRecordDumpWin.closed)))
  369. {
  370. var recordText = gRecordDumpWin.document.getElementById("recordText");
  371. recordText.value += (cmd + "\n");
  372. }
  373. };
  374. function pushCommandsToggle()
  375. {
  376. if (!gPushCmdWin || (gPushCmdWin && gPushCmdWin.closed))
  377. {
  378. gPushCmdWin = window.open(goApplicationManager.getReportFrame().oCVQS.getWebContentRoot() + "/common/blank.html", "_push_cmd_window_");
  379. }
  380. gPushCmdWin.document.open();
  381. var HTMLOut = "<html><head><title>Push Commands</title></head><body>";
  382. HTMLOut += "<input type='text' id='encodeText' style='width:100%;'></input><button onclick=\"document.getElementById('encodeText').value = opener.escapeParam(document.getElementById('encodeText').value)\">Escape Parameter</button>";
  383. HTMLOut += "<textarea id='pushText' style='width:100%;height:80%;'></textarea><button onclick=\"opener.sendCmd(document.getElementById('pushText').value.replace(/\\s*\\n\\s*(\\w\\w:)/g,';$1'), '', true)\">Push Command</button>";
  384. HTMLOut += "<button onclick=\"opener.setMiniQuery(document.getElementById('pushText').value)\">Set MiniQuery to above</button>";
  385. HTMLOut += "</body></html>";
  386. gPushCmdWin.document.write(HTMLOut);
  387. gPushCmdWin.document.close();
  388. };
  389. function setMiniQuery(miniQuery)
  390. {
  391. cfgSet("conversation_qs_spec", miniQuery);
  392. goApplicationManager.getMiniQueryManager().setMiniQuery(miniQuery);
  393. goApplicationManager.getFeatureManager().launchFeature('Run', new Array('full'));
  394. };