Get info from a webpage?

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
benoestrada
Posts: 27
Joined: Thu Jan 31, 2008 12:30 am
Location: Mexico
Contact:

Get info from a webpage?

Post by benoestrada » Thu Mar 20, 2008 4:03 pm

Hi,

Is it possible to assign the result of a JavaScript function to a RunRev variable?

I want to interact with my webpage, it loads javascript functions and would like to get some of those results in my RR application.

Ideas?

Thanks for your time.

Benito

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Mar 20, 2008 10:00 pm

Hi Benito,

What kind of Javascript function do you want to have the result from? Could you perhaps five a link to that web page?

There might be three possibilities, completely depending on what you actually need. First, you could translate your script to Transcript and execute it in Rev. Or you make a CGI to replace your Javascript code and call that from Rev. Or you translate your script to JScript (for windows) or run it using JavaScriptOSA by LateNight Software (for Mac) and run it inside Revolution.

If you could provide more information, we might come up with a solution.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

benoestrada
Posts: 27
Joined: Thu Jan 31, 2008 12:30 am
Location: Mexico
Contact:

Post by benoestrada » Mon Mar 24, 2008 4:46 pm

Hi Mark,

What I am trying to do is to incorporate a javascript wysiwyg html editor in a RR project.

The ones I am testing (FCKEditor and TinyMCE) both returns the contents of the textarea (the html edited by the user) using a javascript funtions that returns a string. Something like:

Code: Select all

var myHTML = GetHTML()
So there is got to be a way to assign the contents of MyHTML to a RR Variable.

I can not find a solution yet. There is a function revBrowserGet wich has a property named htmltext. But this does not works because it does not returns the updated contents of the webpage. The contents of the textarea where the html editors do the editing stuff.

I tried something similar to revBorwserGet(ID, htmltext) with other tools with the same results. But this is why both editors offers this javascript function to obtain the edited HTML.

If we are able to pass this js variable content to a RR variable then we would be able to save the edited html and we would have a wysiwyg editor in our RR projects.

This type of functionality is important for my project and is missing in RR.

So any idea will be real appreciated.

Thanks a lot for your time,

Benito

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 25, 2008 2:12 pm

Hi Benito,

I have no idea how to copy the html source text from a field to a Transcript variable, but do you know that we have a complete HTML editor in Rev? You can even add pictures!

You can change the text style of text in a Revolution field and add pictures using

set the imageSource of char x of fld y to ("binfile:" & myPathToImageFile)

You get the html source using:

put the htmlText of fld y

I believe you can do almost everything you can do in either fo the HTML editors, except adding tables inside a field.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

benoestrada
Posts: 27
Joined: Thu Jan 31, 2008 12:30 am
Location: Mexico
Contact:

Post by benoestrada » Tue Mar 25, 2008 3:58 pm

Hi Mark,
I have no idea how to copy the html source text from a field to a Transcript variable
It is not a field, is a javascript variable. But Ok, thanks a lot for your time.
but do you know that we have a complete HTML editor in Rev?
Oops!, sorry but I do not consider that a editor. None of my customers would accept to edit a note/html file using this approach.

What I am looking for is a basic wysiwyg editor. RR lacks something like this.

Thanks for your attention.

Regards,

Benito

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 25, 2008 4:01 pm

Hi Benito,

In what way isn't a Rev field WYSIWYG? Or more precisely, how are the two JS-based editors more WYSIWYG than a Rev field?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

benoestrada
Posts: 27
Joined: Thu Jan 31, 2008 12:30 am
Location: Mexico
Contact:

Post by benoestrada » Tue Mar 25, 2008 6:13 pm

Hi Mark,
In what way isn't a Rev field WYSIWYG? Or more precisely, how are the two JS-based editors more WYSIWYG than a Rev field?
This is what I am looking for:

Image

(Taken from tinymce website)

I see a lot of differences between this and a RunRev field.

Take a look at:

http://forums.runrev.com/phpBB2/viewtopic.php?t=365

I may be missing something, but have not seen something like it in RR.

Mmmmh, RR seems not to offer lots of features needed for this task.

Thanks for your attention and time.

Regards,

Benito

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 25, 2008 6:24 pm

Hi Benito,

Your application could be its own server. It could serve everything that is needed to display and use the the JavaScript-based HTML editor like a true web server, but you'll need to use a port different from 80, e.g. 8081

You can display the editor using the revBrowser external. The submit button of the editor should submit to localhost:8081. When you do this, Rev can read the html, reply to the browser with the needed, adjusted, HTML page and at the same time read out the user-defined and submitted webform values, which contain the HTML code.

Note: this should be possible because the webkit used by revBrowser is a different process. Normally, you can't have a Rev stack connect to itself.

Best,

Mark

P.S. You _are_ aware that Rev can display pictures in fields?
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mcgrath3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 149
Joined: Thu Feb 23, 2006 8:49 pm
Location: Bethel Park, Pittsbrugh, Pennsylvania USA
Contact:

Post by mcgrath3 » Wed Mar 26, 2008 4:16 pm

benoestrada wrote:Hi Mark,

What I am trying to do is to incorporate a javascript wysiwyg html editor in a RR project.

The ones I am testing (FCKEditor and TinyMCE) both returns the contents of the textarea (the html edited by the user) using a javascript funtions that returns a string. Something like:

Code: Select all

var myHTML = GetHTML()
So there is got to be a way to assign the contents of MyHTML to a RR Variable.

I tried something similar to revBorwserGet(ID, htmltext) with other tools with the same results. But this is why both editors offers this javascript function to obtain the edited HTML.

Benito
The thing is if you return myHTML from the JS script then you can put that in a variable in RR. You would need access to the JS script to add a return line.

Tom
Tom McGrath III
Lazy River Software
3mcgrath@comcast.net

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Mar 26, 2008 4:22 pm

Hi Tom,

You can do that inside Revolution, but then you wouldn't have a way to disply the editor.

You can't return a value from a JavaScript in a browser window directly, regardless of whether the window is displayed by the revBrowser external or in an IE/Safari window. Or do you know a cool trick I don't know about?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mcgrath3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 149
Joined: Thu Feb 23, 2006 8:49 pm
Location: Bethel Park, Pittsbrugh, Pennsylvania USA
Contact:

Post by mcgrath3 » Wed Mar 26, 2008 5:50 pm

Mark,

I was thinking that if you had access to the JS code then you could set it up to reveal the variable data in the URL link and then parse that link from within rev by using the BrwoserBeforeNavigate function you could parse out the URL and any items in it. This is done heavily in mashups and widgets where the JS generates the url and the mashup captures the url for reuse.

Just a thought,

Tom
Tom McGrath III
Lazy River Software
3mcgrath@comcast.net

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Mar 26, 2008 6:05 pm

Hi Tom,

Yes, that might work. Actually, if the JavaScript code allows it and the submit button uses or could use the GET method, it seems like a very good idea.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

benoestrada
Posts: 27
Joined: Thu Jan 31, 2008 12:30 am
Location: Mexico
Contact:

Post by benoestrada » Wed Mar 26, 2008 10:44 pm

Hi Tom,
The thing is if you return myHTML from the JS script then you can put that in a variable in RR. You would need access to the JS script to add a return line.
Yes, we have access to the JS script. My idea is to use a open source editor like the ones mentioned.

I am not a RR expert, but I use another Multimedia Authoring Syetem that provides access to JS variables, and more control of the web browser object. So it is possible to communicate the browser contents with the application, which opens a LOT of possibilities (not only for this HTML edito idea).

Of course this is not the place to talk about THAT Authoring System, but I'm looking for a functionality like this in RR because it is cross platform.

I think RR authors should include features like this.
I was thinking that if you had access to the JS code then you could set it up to reveal the variable data in the URL link and then parse that link
I have not tried this, sounds interesting... mmmh is'nt here a size limitation?, I mean, what happens when the editor contents is huge or just big?

How would you do something like this?

Regards,

Benito

[/b]

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Location: London, UK
Contact:

Post by Mark Smith » Thu Apr 10, 2008 1:08 am

A bit of a wild guess, but couldn't you get the javascript to post the data to "http://localhost:55555/" (or some port number of your choice) and have your application accept connections on port 55555, read from the socket, parse out the http headers and store the postData?

Probaby a crazy idea.

Best,

Mark Smith

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Thu Apr 10, 2008 4:03 am

Results to a a txt file? Maybe a second page in another browser window off the visible window?

Post Reply

Return to “Internet”