faulterror.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: ps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2018
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  9. // Cognos and the Cognos logo are trademarks of Cognos Incorporated.
  10. function init() {
  11. if (g_PS_isQS == 'true') {
  12. // For Query Studio, we want to open the dialog frame to display the error
  13. // However, if we're running a QS command (ie at startup or a executing a runspec), it doesn't need to be opened because
  14. // the error will be displayed in the main window.
  15. if (parent
  16. && typeof parent.showDialogFrame == "function"
  17. && typeof parent.goApplicationManager == "object"
  18. && ! parent.goApplicationManager.getReportManager().isCommandRunning())
  19. {
  20. parent.showDialogFrame(300);
  21. }
  22. }
  23. }
  24. function processCommand(cmd) {
  25. switch (cmd) {
  26. case 'ok' : doCommandOK(); break;
  27. case 'cancel' : doCommandOK(); break;
  28. case 'close' : doCommandOK(); break;
  29. case 'help' : help(); break;
  30. }
  31. }
  32. function doCommandOK() {
  33. if (g_PS_isQS == 'true') {
  34. if (parent && typeof parent.errorExit == "function") {
  35. parent.errorExit();
  36. }
  37. } else {
  38. if (g_PS_isModal == 'true') {
  39. modalExit();
  40. } else if (g_PS_errURL != '') {
  41. errURLExit();
  42. } else if (_isClassicViewerPerspective()) {
  43. _classicViewerExit();
  44. } else {
  45. defaultExit();
  46. }
  47. }
  48. }
  49. function defaultExit()
  50. {
  51. if (history.length > g_PS_emptyHistoryThreshold)
  52. history.back();
  53. // try to close a win32 window if we appear inside of one
  54. else if (window.external && window.external.HasOnClose)
  55. window.external.OnClose(1);
  56. else
  57. window.close();
  58. }
  59. function _classicViewerExit()
  60. {
  61. if (history.length > g_PS_emptyHistoryThreshold) {
  62. var currContentView = _getCurrContentView();
  63. if (currContentView) {
  64. window.top.__glassAppController.closeAppView(currContentView.perspective, currContentView.id);
  65. }
  66. else
  67. history.back();
  68. }
  69. // try to close a win32 window if we appear inside of one
  70. else if (window.external && window.external.HasOnClose)
  71. window.external.OnClose(1);
  72. else
  73. window.close();
  74. }
  75. function modalExit()
  76. {
  77. <!-- Set the right call back target -->
  78. if (g_PS_callBackTargetJSVar) {
  79. g_PS_callBackTargetJSVar.ccModalCallBack('error', null); <!-- TODO: add error details in the call back -->
  80. }
  81. }
  82. function errURLExit()
  83. {
  84. if (g_PS_errURLTooLong == 'true' && document.errURLForm) {
  85. document.errURLForm.submit();
  86. } else if (_isClassicViewerPerspective()) {
  87. _errURLClassicViewerExit();
  88. } else {
  89. location.href = g_PS_errURL;
  90. }
  91. }
  92. function _errURLClassicViewerExit()
  93. {
  94. var currContentView = _getCurrContentView();
  95. window.top.__glassAppController.closeAppView(currContentView.perspective, currContentView.id);
  96. }
  97. function _getCurrContentView()
  98. {
  99. if (window.top.__glassAppController) {
  100. return window.top.__glassAppController.getCurrentContentView();
  101. }
  102. return null;
  103. }
  104. function _isClassicViewerPerspective()
  105. {
  106. var currContentView = _getCurrContentView();
  107. return (currContentView && currContentView.perspective === 'classicviewer') ? true : false;
  108. }