Integrate OLARK into Livecode App

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
escarroll
Posts: 11
Joined: Tue Jan 28, 2014 5:15 am

Integrate OLARK into Livecode App

Post by escarroll » Tue Jan 28, 2014 6:00 am

Hi,

I am trying to integrate OLARKs online chat service with a desktop, android, and iPhone/iPAD compatible method. I was hoping I could just feed HTML with the JavaScript code straight into the URL argument with out having to load from a file, but I can not find any code samples or documentation on how to do this.

I also thought about just saving a local file named "htmlheader.html" and appending the javascript calls onload so I could use the method with other webservices that are similar.

Can anyone provide a newcomer the best way to accomplish this? maybe using OLARK as an example.

It would be appreciated

Regards,
Shane C.

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

Re: Integrate OLARK into Livecode App

Post by Mark » Wed Jan 29, 2014 1:37 am

Ho Shane,

You can't send one line of JavaScript hoping that it will be executed. JavaScript must execute in a web browser. Your best bet is the RevBrowser external. Search the LiveCode dictionary for "brows" (without quotes).

Is there a particular reason why you want to use OLARK? If you want to build a chat feature into your standalone app, you might want to check out ChatRev.

Kind regards,

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

escarroll
Posts: 11
Joined: Tue Jan 28, 2014 5:15 am

Re: Integrate OLARK into Livecode App

Post by escarroll » Wed Jan 29, 2014 3:44 am

Hi Mark,

Thanks for the suggestion. I am not really looking to develop a chat application and server back-end when It may be possible to use something else that is bit more polished in the short term.

I have looked at the Browser Sampler stack and the provided examples. Each example loads from a URL or local File. I did not want to have to create a file outside of the application to send to revBrowser for loading. I guess in the end revBrowser is just calling OS browser specific objects and wrapping them or hooking into them, so they can not control the way the browser object for that operating system wants the info piped to it. I am just speculating here.

I just wanted to see if there was anything out there that made more creative use of the browser options and allowed the browser instance created by revBrowser to read output straight from a variable instead of having to write it out to file first and then have the browser object read it from the file.

Best Regards,
Shane

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

Re: Integrate OLARK into Livecode App

Post by Mark » Wed Jan 29, 2014 10:24 am

Hi Shane,

You can load URL's and HTML in the revBrowser control.

Code: Select all

revBrowserSet gBrowserID,"htmltext",the cHtmlFile25 of this stack
revBrowserSet gBrowserID,"url","http://ww.domain.xyz"
Have a look at the LiveCode dictionary to see all possibilities.

Edit: earlier, I wrote "html" and I have changed this to "htmltext".

Kind regards,

Mark
Last edited by Mark on Wed Jan 29, 2014 9:29 pm, edited 1 time in total.
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

escarroll
Posts: 11
Joined: Tue Jan 28, 2014 5:15 am

Re: Integrate OLARK into Livecode App

Post by escarroll » Wed Jan 29, 2014 9:17 pm

Thank you Mark =)
some more questions..

In the first line of code you reference "the cHtmlFile25 of this stack"

How do I get the file into the stack?
Do I import the file to some internal stack file system, like when you import images?
or do I need to generate the file and provide the path to the file?

Regards,
Shane
Last edited by escarroll on Wed Jan 29, 2014 9:38 pm, edited 2 times in total.

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

Re: Integrate OLARK into Livecode App

Post by Mark » Wed Jan 29, 2014 9:29 pm

Hi Shane,

You can store an html file in a custom property with:

Code: Select all

set the cSomeHtmlFile of this stack to url "binfile:/path/to/some file.html"
You can also use fields, buttons or any other control or a card instead of a stack.

You're right, I made a mistake writing "html", it should have been "htmltext". I'll change my previous post now.

Kind regards,

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

escarroll
Posts: 11
Joined: Tue Jan 28, 2014 5:15 am

Re: Integrate OLARK into Livecode App

Post by escarroll » Wed Jan 29, 2014 10:03 pm

so this code stores the file in binary format as "cSomeHtmlFile" with in the stack?

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

Re: Integrate OLARK into Livecode App

Post by Mark » Wed Jan 29, 2014 10:17 pm

Hi,

It stores the file "/path/to/some file.html" in the custom property cSomeHtmlFile of the current stack without converting the native line endings (crlf on Windows, lf on Unix system) into linefeeds.

Kind regards,

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

escarroll
Posts: 11
Joined: Tue Jan 28, 2014 5:15 am

Re: Integrate OLARK into Livecode App

Post by escarroll » Thu Jan 30, 2014 3:56 am

Well thanks for the input.

So far none of the methods provided have worked for me. I CAN load the file locally in Chrome and from a web server without issue. I can NOT load the file locally in IE or through the revBrowser call in Livecode.

I am using IE version 11 and newer versions of IE are very strict with loading local file content with scripts. I tried adding the "Mark-of-the-Web" (MOTW) comment to bypass the issue and that did not work. Now I am trying to figure out a workaround how to address Enhanced Protected Mode ( EPM ) with out compromising my browser security. I assume since revBrowser calls IE that any problems with IE are problems experienced with revBrowser too?

Regards,
Shane

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

Re: Integrate OLARK into Livecode App

Post by Mark » Thu Jan 30, 2014 12:29 pm

Hi Shane,

Problems experiences with IE are also to be expected in revBrowser and solution that work in IE may not work in revBrowser. For example, you can turn off error messages in IE but not in revBrowser.

Kind regards,

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

escarroll
Posts: 11
Joined: Tue Jan 28, 2014 5:15 am

Re: Integrate OLARK into Livecode App

Post by escarroll » Thu Jan 30, 2014 5:21 pm

Yes I tried passing in a few other websites, some of the websites would throw errors and I would have to click continue to get the sites to come up. I was looking into how to trap the errors and handle them.

so problematic, but I guess this is typical of trying to make calls and use another application through a 3rd party API.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Integrate OLARK into Livecode App

Post by BvG » Fri Jan 31, 2014 1:32 pm

Yeah, using IE to run a Jscript chat that connects to a server that you not control. That's too many things that can go wrong for my comfort. That's probably why I made my own. Just to clarify, you can use chatrev without doing (almost) any coding. Just make sure that in the client you set the server IP/url to your own server stack (Or do it like the scripters scrapbook, and let everyone connect to my server (but ask me first)).
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

escarroll
Posts: 11
Joined: Tue Jan 28, 2014 5:15 am

Re: Integrate OLARK into Livecode App

Post by escarroll » Sat Feb 01, 2014 2:31 am

Great BvG, Thanks for the input

Post Reply