NetTalk Central

Author Topic: Programmatically (without user intervention) run javascript using NT9  (Read 6515 times)

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Hi Bruce/Folks,

At the moment I'm currently wrangling with File Explorer 5, getting it/IE to run a custom built html page which has some javascript in it.

Basically it's a graphing engine, javascript, and I'm trying to get the graphs saved to disk programatically by running the code and calling the built-in save function.

Was thinking that perhaps ..

1. In the webhandler of a webserver, if the "download graph image" url is called with whatever credential checks, then potentially (like downloading a custom-built pdf) I could get the server to send back an image, that I could use in a NetWebClient object by calling .Fetch() and seeing how that goes.

What thinkest thou(s)?

Stu
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Programmatically (without user intervention) run javascript using NT9
« Reply #1 on: March 23, 2016, 04:33:33 AM »
I think I've read this 3 times, and I'm not sure I understand your sentence, and I'm pretty sure I don't understand the question... :)

perhaps try again?

Bruce

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: Programmatically (without user intervention) run javascript using NT9
« Reply #2 on: March 23, 2016, 05:29:24 AM »
My English is no better than that.  ;D

Best regards,

Djole

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Programmatically (without user intervention) run javascript using NT9
« Reply #3 on: March 23, 2016, 01:58:35 PM »
Okay :)

Can I get the webserver to receive a url, run some javascript which will save a file to disk, then return that file to whatever called the url?

The part I have a problem understanding is the midding "run some javascript". I'm good with receiving the url and returning the file.
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Programmatically (without user intervention) run javascript using NT9
« Reply #4 on: March 24, 2016, 12:34:53 AM »
Hi Stu,

>> Can I get the webserver to receive a url,

yes...

>>  run some javascript

no, the server does not run JavaScript code. The server runs Clarion code.
But maybe you meant "run some clarion?"... continuing as if you did...

>> which will save a file to disk,

[clarion code on the server] - yes, it can save a file. (Although you could equally construct the file in memory if
you didn't _need_ to make it on disk. And if it was on disk, then starting the name with $$$ will mean it gets deleted after being served.

>> then return that file to whatever called the url?

indeed.

An example of this (sort of) is the FileDownload example. In that example it calls a URL (ie netWebPage procedure) called ServeDocument.
The ServeDocument procedure then "finds" the file (could just as easily create it) and serves it back to the caller.

Of course the URL would not need to be limited to ServeDocument, you could add code to WebHandler (_SendFile method) which trapped any number of file names and sent them to your NetWebPage procedure.

cheers
Bruce



Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Programmatically (without user intervention) run javascript using NT9
« Reply #5 on: March 28, 2016, 04:08:13 PM »
Hi Bruce,

Yup, I realise that the webserver cannot normally run javascript.

But I'm asking if it can be made to.

Let me explain further.

I've got a javascript library that creates graphs.

I need to programatically be able to say "get me this graph", which calls javascript that saves an image file on disk, and then my code can take that file and do something with it.

I'm still wrestling with using FE5 to do this, having issues with Internet Explorer in FE5.

Another direction is that the guy who makes the graphing javascript engine pointed me to http://phantomjs.org/, so might see if that can get shoe-horned in somewhere.
Cheers,

Stu Andrews

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Programmatically (without user intervention) run javascript using NT9
« Reply #6 on: March 29, 2016, 07:40:16 PM »
Nevermind about this rabbit-hole, got the task solved using a combination of fileexplorer in the client to "run" the custom javascript html page, and then a little webserver that handles the base64 image url that is generated by the graph engine (uses toDataURL, which is a html5 thing apparently).

Cheers.
Cheers,

Stu Andrews

MyBrainIsFull

  • Full Member
  • ***
  • Posts: 134
    • View Profile
Re: Programmatically (without user intervention) run javascript using NT9
« Reply #7 on: March 29, 2016, 11:01:00 PM »
Y'know, I was going to msg you a similar possibility yesterday, but I was trying to think of a more elegant solution.  But then there is the invoice at the end of the month... Good man, you got out of the woods.
It was all about an easy (time effective) way to run js on the server side.

K