details:   https://code.openbravo.com/erp/devel/pi/rev/8b3dea147b15
changeset: 24271:8b3dea147b15
user:      Rafa Alonso <rafael.alonso <at> openbravo.com>
date:      Mon Aug 18 18:49:47 2014 +0200
summary:   Fixes issue 27362: The new variable 'isDebug' will be inserted at 
the beginning of the generated javascript file
- this variable will be inserted and set to true, if any module is in 
development or the application is running a test job

diffstat:

 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
 |  22 ++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diffs (32 lines):

diff -r e414f3f0e298 -r 8b3dea147b15 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
  Wed Aug 13 14:03:09 2014 +0530
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
  Mon Aug 18 18:49:47 2014 +0200
@@ -224,6 +224,28 @@
     }
 
     if (!"".equals(sb.toString())) {
+      final String referer = 
RequestContext.get().getRequest().getHeader("referer");
+      /*
+       * If a module is in development or the application is running the 
tests, add the isDebug
+       * variable to the generated javascript file.
+       * 
+       * If the isDebug variable is present in the javascript files, the code 
that calls
+       * OB.UTIL.Debug will not be executed
+       * 
+       * This option is intended to run additional code (checks, etc) that 
will not be run while in
+       * production.
+       * 
+       * This improves performance at the same time that the developer have a 
tool to improve
+       * stability.
+       * 
+       * TODO: add an algorithm to remove the OB.UTIL.Debug code and calls 
from the generated
+       * javacript file
+       * 
+       * TODO: don't load the ob-debug.js file if not in use
+       */
+      if (isInDevelopment() || referer.indexOf("/ret-") > 0) {
+        sb.insert(0, "var isDebug = true;\n\n");
+      }
       sb.append("if (window.onerror && window.onerror.name === '"
           + KernelConstants.BOOTSTRAP_ERROR_HANDLER_NAME + "') { 
window.onerror = null; }");
       sb.append("if (typeof OBStartApplication !== 'undefined' && 
Object.prototype.toString.call(OBStartApplication) === '[object Function]') { 
OBStartApplication(); }");

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to