HTMLRender.ExecuteJavaScript under APL program control

No need to worry about going "off topic" here
Forum rules
This forum is for general chit-chat, not necessarily APL-related. However, it's not for spam or for offensive or illegal comments.

HTMLRender.ExecuteJavaScript under APL program control

Postby woody on Sat Sep 25, 2021 9:35 pm

Greetings.

Can I open the HTMLRender window (aka Chromium engine) by passing it DATA that I have constructed in APL that is in the form of an HTML web page ?

I have it working by referencing a WWW URL on the internet.

I'd like to dynamically construct my own HTML scripts inside the APL workspace ...
and pass them to HTMLRender.

Also, I'd like to RECEIVE BACK data from the Chromium browser DOM.
e.g. I create a JavaScript variable "NAME" ... and need a way to request that value to be returned from the Chromium engine.

As well as passing a new requests into the Chromium engine.

Thoughts?

This is the little browser prototype I have in hand and works great as simple browser:

I can invoke it via: ∆WEBBROWSER &'google.com'


Code: Select all
∆WEBBROWSER URL;f1;R
 ⍝ Right argument is target URL  (e.g.  'APLAPPS.com')
 ⍝ Establishes a Windows window session with Dyalog's  Chromium  DLL
 'f1'⎕WC'Form' 'Test Dyalog APL Web Browser for Windows'('Coord' 'ScaledPixel')('Size' 820 1200)
 'f1.Address'⎕WC'Edit' 'Address'('Posn' 6 8)('Size' 18 770)
 'f1.Go'⎕WC'Button' 'Go'('Posn' 6 775)('Size' 18 25)
 f1.Go.Event←('MouseUp' 'SETURL')
 f1.Address.Text←URL
 'f1.Browse'⎕WC'HTMLRenderer'('ASChild' 1)('Posn' 20 10)('Size' 800 1190)
UP:
 f1.Browse.URL←f1.Address.Text
 R←⎕DQ'f1'
 →(0=⍴R)/0
 →UP



Thanks in advance.

//W
Woodley Butler
Automatonics, Inc.
"Find your head in the APL Cloud"
http://www.APLcloud.com
User avatar
woody
 
Posts: 142
Joined: Tue Dec 28, 2010 12:54 am
Location: Atlanta, Georgia USA

Re: HTMLRender.ExecuteJavaScript under APL program control

Postby paulmansour on Mon Sep 27, 2021 12:45 pm

Can I open the HTMLRender window (aka Chromium engine) by passing it DATA that I have constructed in APL that is in the form of an HTML web page ?


Just set the HTML property (to a string with the actual HTML) rather than the URL property.

Also, I'd like to RECEIVE BACK data from the Chromium browser DOM.
e.g. I create a JavaScript variable "NAME" ... and need a way to request that value to be returned from the Chromium engine.


Not currently possible. ExecuteJavaScript is async, basically send it and forget it. You cannot get a result back. I have requested a synchronous version but apparently it is a non-trivial problem. I have also tried various work arounds, using threads and putting some javascript in the page to respond, but nothing really worked. I'm hoping that if Dyalog puts some resources into it, they can solve the problem.
paulmansour
 
Posts: 378
Joined: Fri Oct 03, 2008 4:14 pm

Re: HTMLRender.ExecuteJavaScript under APL program control

Postby paulmansour on Mon Sep 27, 2021 12:54 pm

Also, you may be interested in this (a work in progress):

https://github.com/the-carlisle-group/Abacus
paulmansour
 
Posts: 378
Joined: Fri Oct 03, 2008 4:14 pm

Re: HTMLRender.ExecuteJavaScript under APL program control

Postby woody on Mon Sep 27, 2021 2:20 pm

Thanks!

That helps!!!

I have been using a home-grown HTML elements to APL ARRAY mapping tool I created 4 years ago that I call "DivMapper". Every thing on the page is a unique DIV element. And, every DIV element is defined by attributes (columns) in the APL ARRAY. One of the DIV attributes is the X, Y and Z location on the page.

The front-end HTML uses a custom developed Angular framework and data is passed as JSON between front-end (DOM) and back-end APL. The array of DIVs are stored in an APL nested array (also saved to APL files to handle multiple user scenarios).

The user's front-end web browser (DOM) has a JavaScript "connector" that makes web service calls back to my MSERVER and executes the desired APL programs and manipulates reads/writes the data and element attributes between front-end browser and back-end APL running under MSERVER.

Any change on the Browser by the user (drag, input, etc.), triggers a Web Service call to the back-end MSERVER web service ... passing the name of the DIV(s) and the changed values. The browser user can switch into ADMIN mode, and physically DRAG / Position any DIV item on the page. The action triggers the call back to APL and the ARRAY item for that new X,Y,Z location values is updated.

Any changes to the back-end APL ARRAY are received by the JavaScript web service call, so both the DOM array and the APL array remain "in sync". I have the front-end Angular JavaScript set to POLL the MSERVER APL web service every "X" seconds.

Plan to eventually move to Web sockets.

Onward and upward !

//W
Woodley Butler
Automatonics, Inc.
"Find your head in the APL Cloud"
http://www.APLcloud.com
User avatar
woody
 
Posts: 142
Joined: Tue Dec 28, 2010 12:54 am
Location: Atlanta, Georgia USA


Return to Chat

Who is online

Users browsing this forum: No registered users and 0 guests