Opened 6 years ago

Closed 6 years ago

#10410 closed enhancement (fixed)

WebPositive: Javascript console

Reported by: pulkomandy Owned by: pulkomandy
Priority: low Milestone: Unscheduled
Component: Applications/WebPositive Version: R1/Development
Keywords: gsoc2014 Cc:
Blocked By: Blocking:
Has a Patch: yes Platform: All

Description

JS console message currently go to stdout. This isn't very practical.

Add a window to show it from the UI instead.

Attachments (1)

0001-Added-a-simple-window-to-display-console-messages-fi.patch (8.8 KB ) - added by zhuowei 6 years ago.
Adds a simple console window

Download all attachments as: .zip

Change History (8)

comment:1 by dsjonny, 6 years ago

+1 And it would be also fine if in that window we can see any HTML/CSS alert too like in Firefox.

comment:2 by zhuowei, 6 years ago

Has a Patch: set

comment:3 by zhuowei, 6 years ago

I made a very simple console window that shows all the console messages in a list. The window can be opened with Window -> Script console. The patch is attached above. (gsoc2014)

comment:4 by pulkomandy, 6 years ago

Keywords: gsoc2014 added

There is at least one problem with this:

  • Open the script console
  • Close it
  • Try to open it again

When closing a window, the C++ object is automatically deleted. So, opening it again won't work. You can see the code in SettingsWindow::QuitRequested() to avoid this problem: the window is hidden, instead of destroyed.

I think the window could also be further improved:

  • A "clear" button would be useful
  • The list view could have a 5 pixel margin between it and the window border
  • The horizontal scrollbar should be disabled if there is no need for it

comment:5 by zhuowei, 6 years ago

I've added a clear button, a 5px border, and overrode QuitRequested to hide the window instead. Sorry about the delay.

I couldn't figure out how to disable the horizontal scrollbar, nor was I able to get the ListView to scroll down to the latest item when added. (for the autoscroll, I tried running ScrollBy(0, 1000) every time a message is added, but this caused repeated drawing, which froze the browser.)

comment:6 by pulkomandy, 6 years ago

You now have some style violations:

  • One line is over 80 columns in ConsoleWindow.cpp
  • Always two blank lines between top-level blocks: two methods definitions, includes and forward declarations, forward declarations and class definition, etc. (you have only one most of the time, and up to 3)
  • The members of ConsoleWindow class should be indented like the method declarations (in the .h file)
  • ConsoleWindow.h is missing a forward declaration of BButton
  • "final" is a keyword in C++11, and you use it as a variable name in ConsoleWindow::MessageReceived()

https://www.haiku-os.org/development/coding-guidelines

by zhuowei, 6 years ago

Adds a simple console window

comment:7 by pulkomandy, 6 years ago

Resolution: fixed
Status: newclosed

Applied in hrev47037. Thanks!

Note: See TracTickets for help on using tickets.