Recent

Author Topic: HTMLViewer JavaScript demos problems  (Read 6916 times)

JD

  • Hero Member
  • *****
  • Posts: 1848
HTMLViewer JavaScript demos problems
« on: February 10, 2018, 05:40:58 pm »
Hi there,

I want to try the javascript demos included with HTMLViewer (FrameDemJavaScriptUsingBesen and/or FrameDemJavaScriptUsingBesenW).

I've already downloaded the extra Besen files needed by these examples. After much tweaking, I finally compiled them both.

However running both programs has no visible result apart from eating up my CPU.

Has anyone succeeded in using HTMLViewer to display HTML with javascript files.

Thanks,

JD
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: HTMLViewer JavaScript demos problems
« Reply #1 on: February 10, 2018, 05:57:53 pm »
Has anyone succeeded in using HTMLViewer to display HTML with javascript files.

Why not use an actual Web browser-based control instead of ancient stuff like HTMLViewer?

That's the idea behind TWebBrowser.

https://macpgmr.github.io/

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: HTMLViewer JavaScript demos problems
« Reply #2 on: February 10, 2018, 06:22:40 pm »
Has anyone succeeded in using HTMLViewer to display HTML with javascript files.

Why not use an actual Web browser-based control instead of ancient stuff like HTMLViewer?

That's the idea behind TWebBrowser.

https://macpgmr.github.io/

Thanks for the tip Phil. I've downloaded and installed the TWebBrowser component. How does it work? Do you have a demo you can share? I want to be able to display an HTML/JavaScript file like the one at https://developers.google.com/chart/interactive/docs/quick_start

Code: HTML5  [Select][+][-]
  1.   <head>
  2.     <!--Load the AJAX API-->
  3.     <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  4.     <script type="text/javascript">
  5.  
  6.       // Load the Visualization API and the corechart package.
  7.       google.charts.load('current', {'packages':['corechart']});
  8.  
  9.       // Set a callback to run when the Google Visualization API is loaded.
  10.       google.charts.setOnLoadCallback(drawChart);
  11.  
  12.       // Callback that creates and populates a data table,
  13.       // instantiates the pie chart, passes in the data and
  14.       // draws it.
  15.       function drawChart() {
  16.  
  17.         // Create the data table.
  18.         var data = new google.visualization.DataTable();
  19.         data.addColumn('string', 'Topping');
  20.         data.addColumn('number', 'Slices');
  21.         data.addRows([
  22.           ['Mushrooms', 3],
  23.           ['Onions', 1],
  24.           ['Olives', 1],
  25.           ['Zucchini', 1],
  26.           ['Pepperoni', 2]
  27.         ]);
  28.  
  29.         // Set chart options
  30.         var options = {'title':'How Much Pizza I Ate Last Night',
  31.                        'width':400,
  32.                        'height':300};
  33.  
  34.         // Instantiate and draw our chart, passing in some options.
  35.         var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
  36.         chart.draw(data, options);
  37.       }
  38.     </script>
  39.   </head>
  40.  
  41.   <body>
  42.     <!--Div that will hold the pie chart-->
  43.     <div id="chart_div"></div>
  44.   </body>
  45. </html>
  46.  

Thanks a lot,

JD
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: HTMLViewer JavaScript demos problems
« Reply #3 on: February 10, 2018, 06:27:11 pm »
Do you have a demo you can share?

Yes, it includes the PasMap app, which is the Laz version of this Xcode app:

https://macpgmr.github.io/MacXPlatform/WebAppOverview_3.html#EmbeddedBrowser



JD

  • Hero Member
  • *****
  • Posts: 1848
Re: HTMLViewer JavaScript demos problems
« Reply #4 on: February 10, 2018, 07:26:04 pm »
Do you have a demo you can share?

Yes, it includes the PasMap app, which is the Laz version of this Xcode app:

https://macpgmr.github.io/MacXPlatform/WebAppOverview_3.html#EmbeddedBrowser

The PasMap app is not working for me. Nothing is displayed in the form.

In addition the following simple example does not work either

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   WebBrowser;
  10.  
  11. type
  12.   { TForm1 }
  13.   TForm1 = class(TForm)
  14.     Button1: TButton;
  15.     WebBrowser1: TWebBrowser;
  16.     procedure Button1Click(Sender: TObject);
  17.     procedure WebBrowser1PageLoaded(Sender: TObject);
  18.     procedure WebBrowser1PageLoadError(Sender: TObject);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.Button1Click(Sender: TObject);
  35. begin
  36.   WebBrowser1.LoadPage('www.microsoft.com');
  37. end;
  38.  
  39. procedure TForm1.WebBrowser1PageLoaded(Sender: TObject);
  40. begin
  41.   ShowMessage('Page loaded successfully');
  42. end;
  43.  
  44. procedure TForm1.WebBrowser1PageLoadError(Sender: TObject);
  45. begin
  46.   ShowMessage('Error loading page');
  47. end;
  48.  
  49. end.
  50.  

I just want something that can display local HTML/JavaScript files created by another application. I don't want to go the Electron route because of bloat and memory consumption of Electron apps.

cheers,

JD
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: HTMLViewer JavaScript demos problems
« Reply #5 on: February 10, 2018, 07:31:42 pm »
The PasMap app is not working for me. Nothing is displayed in the form.

TWebBrowser currently only supports Cocoa and Qt4 widgetsets, as documented in point 1 of readme.txt. Maybe you're using win32?

I just want something that can display local HTML/JavaScript files created by another application. I don't want to go the Electron route because of bloat and memory consumption of Electron apps.

Understood. And agree.

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: HTMLViewer JavaScript demos problems
« Reply #6 on: December 06, 2019, 04:00:56 pm »
Quote
Why not use an actual Web browser-based control instead of ancient stuff like HTMLViewer?

I dig up this topic, because HTMLViewer does the work for me (without Javascript, however). It allows me to easily create an offline desktop help window with related HTML pages (with a HTML <frameset> tag), integrated into my program (it can do a lot more, but that's enough for me).

ps: amho, it would benefit from being documented (comment cartridges before important functions, some UML diagrams with the "Dia" program, for example) before anything else.
« Last Edit: December 06, 2019, 04:03:38 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: HTMLViewer JavaScript demos problems
« Reply #7 on: December 06, 2019, 05:41:05 pm »
amho, it would benefit from being documented (comment cartridges before important functions, some UML diagrams with the "Dia" program, for example) before anything else.
HTMLViewer is a Delphi component, and I think it was initially adapted by CodeTyphoon and later by avra to Lazarus. But I don't know that anybody of the Lazarus group is taking care of the Lazarus port (there is also a now abandoned THtmlPort on CCR). So, if you want more comments in the source files you should contact the maintainer of the delphi version (https://github.com/BerndGabriel/HtmlViewer), eventually then this commented version will diffuse back to Lazarus after some time.

But on the other hand, if you look at the github of the Delphi version you'll find a documentation folder "HtmlHelp" with a chm help file which should answer most of your questions (https://github.com/BerndGabriel/HtmlViewer/blob/HtmlViewer-11.9/HtmlHelp/THtmlViewer.chm).

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: HTMLViewer JavaScript demos problems
« Reply #8 on: December 06, 2019, 06:36:43 pm »
Quote
HTMLViewer is a Delphi component, and I think it was initially adapted by CodeTyphoon and later by avra to Lazarus.

So, thanks to CodeTyphoon and @avra.

HTMLViewer does the job for me. But, better and faster than comments, a "small" diagram of all the classes (  ::) ) with a line on each of their respective role, could maybe, give a quicker holistic view of such a library.

use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

 

TinyPortal © 2005-2018