This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
console error indicator for status bar #7639
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9c2112a
error icon for main-toolbar
zaggino 6752ad0
change style
zaggino 4248275
do not override window.onerror handler
zaggino 74a2085
add comments
zaggino 003890e
add debug menu item
zaggino e47dc5b
move to DebugCommands
zaggino 24be428
add space
zaggino 0a858d9
move error icon to the left of other status bar indicators
zaggino 9293591
blink the number when error count is increased
zaggino 74af922
pointer cursor on hover
zaggino 65b3866
clear counter with console.clear
zaggino b081a1a
correct if formatting
zaggino 7f38ad6
add a tooltip
zaggino eb17609
added background fade like ins/ovr
zaggino c25357d
fixed according to comments
zaggino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a | ||
| * copy of this software and associated documentation files (the "Software"), | ||
| * to deal in the Software without restriction, including without limitation | ||
| * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| * and/or sell copies of the Software, and to permit persons to whom the | ||
| * Software is furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| * DEALINGS IN THE SOFTWARE. | ||
| * | ||
| */ | ||
|
|
||
| /*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ | ||
| /*global define, $, brackets, window, document */ | ||
|
|
||
| define(function (require, exports, module) { | ||
| "use strict"; | ||
|
|
||
| var CommandManager = brackets.getModule("command/CommandManager"), | ||
| ExtensionUtils = brackets.getModule("utils/ExtensionUtils"); | ||
|
|
||
| var $span = null, | ||
| errorCount = 0, | ||
| _windowOnError = window.onerror, | ||
| _consoleError = window.console.error; | ||
|
|
||
| ExtensionUtils.loadStyleSheet(module, "style.css"); | ||
|
|
||
| function showDeveloperTools() { | ||
| CommandManager.execute("debug.showDeveloperTools"); | ||
| } | ||
|
|
||
| function showIcon() { | ||
| if ($span) { | ||
| $span.text(errorCount); | ||
| return; | ||
| } | ||
| $span = $("<span>").text(errorCount); | ||
| $("<a>") | ||
| .addClass("consoleErrorIcon") | ||
| .append($span) | ||
| .on("click", showDeveloperTools) | ||
| .appendTo("#main-toolbar .buttons"); | ||
| } | ||
|
|
||
| function incErrorCount() { | ||
| errorCount++; | ||
| showIcon(); | ||
| } | ||
|
|
||
| window.onerror = function (errorMsg, url, lineNumber) { | ||
| incErrorCount(); | ||
| if (_windowOnError) { | ||
| return _windowOnError(errorMsg, url, lineNumber); | ||
| } | ||
| return false; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers.onerror |
||
| }; | ||
|
|
||
| window.console.error = function () { | ||
| incErrorCount(); | ||
| return _consoleError.apply(window.console, arguments); | ||
| }; | ||
|
|
||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #main-toolbar .buttons .consoleErrorIcon { | ||
| position: relative; | ||
| } | ||
| #main-toolbar .buttons .consoleErrorIcon span { | ||
| color: #454545; | ||
| background-color: #f74687; | ||
| position: absolute; | ||
| left: 0; | ||
| right: 0; | ||
| top: 0; | ||
| bottom: 0; | ||
| margin: 2px; | ||
| line-height: 20px; | ||
| border-radius: 10px; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A default extension shouldn't rely on another default extension.
I don't know how to work around this, but maybe at least a
try {} catch {}.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried and no exception or console error is raised when you execute a command string that isn't registered. So no need to try-catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break if the other extension is not installed or disabled (eventually we'd like to add ability to disable extensions including default extensions). You should be able to call
brackets.app.showDeveloperTools()directly.