diff --git a/static/js/init.js b/static/js/init.js index 9590acdf..2677771f 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -1,7 +1,6 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript -/*** - Pandora -***/ + +// FIXME: this should be named pandora.js /* ---- UI Tree ---- @@ -20,18 +19,18 @@ appPanel statusbar */ -window.onerror = function(error, url, line) { - try { - pandora.api.log({ - text: error, - url: url, - line: line - }); - } catch(e) {} -}; - (function() { + window.onerror = function(error, url, line) { + try { + pandora.api.log({ + text: error, + url: url, + line: line + }); + } catch(e) {} + }; + var debug = localStorage && localStorage.debug, theme = localStorage && localStorage.theme || 'modern'; diff --git a/static/js/pandora/logsDialog.js b/static/js/pandora/logsDialog.js index 747c5149..e62de313 100644 --- a/static/js/pandora/logsDialog.js +++ b/static/js/pandora/logsDialog.js @@ -77,7 +77,7 @@ pandora.ui.logsDialog = function() { id: 'url', title: 'URL', format: function(value, data) { - return value.split('?')[0] + ':' + data.line; + return formatURL(value, data.line); }, operator: '+', visible: true, @@ -116,6 +116,33 @@ pandora.ui.logsDialog = function() { $list.reloadList(); Ox.Request.clearCache('findLogs'); }); + }, + open: function(data) { + var value = $list.value(Ox.last(data.ids)), + $dialog; + if (/^Traceback/.test(value.text)) { + $dialog = Ox.Dialog({ + buttons: [ + Ox.Button({ + id: 'close', + title: 'Close' + }) + .bindEvent({ + click: function() { + $dialog.close(); + } + }) + ], + closeButton: true, + content: $('').append($('
').css({margin: '16px'}).html(value.text)),
+                            height: height - 48,
+                            keys: {enter: 'close', escape: 'close'},
+                            maximizeButton: true,
+                            title: formatURL(value.url, value.line),
+                            width: width - 48
+                        })
+                        .open();
+                    }
                 }
             }),
 
@@ -171,6 +198,9 @@ pandora.ui.logsDialog = function() {
             })
             .appendTo(that.$element.find('.OxButtonsbar'));
 
+    function formatURL(url, line) {
+        return url.split('?')[0] + ':' + line;
+    }
 
     function renderLog(logData) {
         var $checkbox;
diff --git a/static/js/pandora/menu.js b/static/js/pandora/menu.js
index eebe4050..c2b502c8 100644
--- a/static/js/pandora/menu.js
+++ b/static/js/pandora/menu.js
@@ -143,7 +143,8 @@ pandora.ui.mainMenu = function() {
                             { id: 'clearcache', title: 'Clear Cache'},
                             { id: 'reloadapplication', title: 'Reload Application'},
                             { id: 'resetui', title: 'Reset UI Settings'},
-                            { id: 'debug', title: (localStorage.debug?'Disable':'Enable')+' Debug Mode'}
+                            { id: 'debug', title: (localStorage.debug?'Disable':'Enable')+' Debug Mode'},
+                            { id: 'triggererror', title: 'Trigger JavaScript Error'},
                         ] }
                     ]
                     : []
@@ -277,8 +278,9 @@ pandora.ui.mainMenu = function() {
                     } else {
                         localStorage.debug = 1;
                     }
-
                     that.setItemTitle('debug', (localStorage.debug ? 'Disable' : 'Enable') + ' Debug Mode');
+                } else if (data.id == 'triggererror') {
+                    var e = error;
                 }
             },
             key_control_f: function() {