浏览代码

Inspector - Console tab now display the caller of the function. GUI issue fixed when in popup mode.

Julian 8 年之前
父节点
当前提交
1d9c075f30
共有 4 个文件被更改,包括 56 次插入8 次删除
  1. 5 0
      inspector/sass/main.scss
  2. 5 0
      inspector/sass/tabs/_consoleTab.scss
  3. 8 0
      inspector/src/Inspector.ts
  4. 38 8
      inspector/src/tabs/ConsoleTab.ts

+ 5 - 0
inspector/sass/main.scss

@@ -22,6 +22,11 @@
   // The panel containing the two subpanel : tree and details
   .insp-right-panel {
     width: 750px;
+
+    &.popupmode {
+      width:100% !important;
+    }
+    
     display:flex; 
     flex-direction: column;
     flex-shrink: 0;

+ 5 - 0
inspector/sass/tabs/_consoleTab.scss

@@ -22,7 +22,12 @@
 
         .defaut-line {
             word-wrap: break-word;
+            padding: 3px 0 3px 5px;
+        }
+
+        .caller {
             padding: 3px 0 3px 0;
+            color:darken($color-bot, 10%);
         }
 
         .log {  

+ 8 - 0
inspector/src/Inspector.ts

@@ -148,6 +148,7 @@ module INSPECTOR {
                 this._buildInspector(inspector);   
                 // Send resize event to the window
                 Helpers.SEND_EVENT('resize');
+                this._tabbar.updateWidth();
             }
 
             // Refresh the inspector if the browser is not edge
@@ -297,10 +298,17 @@ module INSPECTOR {
                 this._c2diwrapper  = Helpers.CreateDiv('insp-wrapper', popup.document.body);
                 // add inspector     
                 let inspector      = Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
+                inspector.classList.add('popupmode');
                 // and build it in the popup  
                 this._buildInspector(inspector); 
                 // Rebuild it
                 this.refresh(); 
+
+                popup.addEventListener('resize', () => {                    
+                    if (this._tabbar) {
+                        this._tabbar.updateWidth()
+                    }
+                });
             }             
         }
     }

+ 38 - 8
inspector/src/tabs/ConsoleTab.ts

@@ -63,7 +63,7 @@ module INSPECTOR {
             };
 
             // Testing
-            // console.log("This is a console.log message");
+            console.log("This is a console.log message");
             // console.log("That's right, console.log calls are hooked to be written in this window");
             // console.log("Object are also stringify-ed", {width:10, height:30, shape:'rectangular'});
             // console.warn("This is a console.warn message");
@@ -83,7 +83,10 @@ module INSPECTOR {
 
         }
 
-        private _message(type:string, message:any) {
+        private _message(type:string, message:any, caller:string) {
+            let callerLine = Helpers.CreateDiv('caller', this._consolePanelContent);
+            callerLine.textContent = caller;
+
             let line = Helpers.CreateDiv(type, this._consolePanelContent);
             if (typeof message === "string") {
                 line.textContent += message ; 
@@ -94,23 +97,50 @@ module INSPECTOR {
         }
 
         private _addConsoleLog(...params : any[]) {
+            
+            // Get caller name if not null
+            let callerFunc = this._addConsoleLog.caller as Function;
+            let caller = callerFunc==null? "Window" : "Function "+callerFunc['name'] + ": ";
+
             for (var i = 0; i < params.length; i++) {
-                this._message('log', params[i]);
-                this._oldConsoleLog(params[i]);
+                this._message('log', params[i], caller);
+                // Write again in console does not work on edge, as the console object                 
+                // is not instantiate if debugger tools is not open
+                if (!Helpers.IsBrowserEdge()) {    
+                    this._oldConsoleLog(params[i]);
+                }
             }
         }
 
         private _addConsoleWarn(...params : any[]) {
+            
+            // Get caller name if not null
+            let callerFunc = this._addConsoleLog.caller as Function;
+            let caller = callerFunc==null? "Window" : callerFunc['name'];
+
             for (var i = 0; i < params.length; i++) {
-                this._message('warn', params[i]);
-                this._oldConsoleWarn(params[i]);
+                this._message('warn', params[i], caller);
+                // Write again in console does not work on edge, as the console object 
+                // is not instantiate if debugger tools is not open
+                if (!Helpers.IsBrowserEdge()) {    
+                    this._oldConsoleWarn(params[i]);
+                }
             }
         }
 
         private _addConsoleError(...params : any[]) {
+            
+            // Get caller name if not null
+            let callerFunc = this._addConsoleLog.caller as Function;
+            let caller = callerFunc==null? "Window" : callerFunc['name'];
+
             for (var i = 0; i < params.length; i++) {
-                this._message('error', params[i]);
-                this._oldConsoleError(params[i]);
+                this._message('error', params[i], caller);
+                // Write again in console does not work on edge, as the console object 
+                // is not instantiate if debugger tools is not open
+                if (!Helpers.IsBrowserEdge()) {    
+                    this._oldConsoleError(params[i]);
+                }
             }
         }