Riaanvs


Hi

I am trying to work with the WEBUI / HTTP-MSM interface, and in particular am trying put the interface in a frame on a site, and depending on the query, update other frames by using JS.

I sort of have an idea how to do this, but is there any form of documentation, or at least samples, available

Thanks
Riaan




Re: WebUI / HTTP-MSM examples / documentation

Gray Norton - MSFT


Hi, Riaan -

There aren't really any samples available, as far as I know. However, the process is relatively simple and the default template files include some basic support for this type of functionality.

Conceptually: there's no separate "channel" for passing extra data along with an agent's text response, so you need to simply include the extra data in the response in such a way that it can easily be parsed out by the JavaScript code in the Web template and processed separately.

In the default template, a newline followed by something like the following is considered to be extra data and will be parsed out:

Code Snippet
[!Key1:::Value1|||Key2:::Value2|||Key3:::Value3!]

However, nothing is done with this extra data by default -- it's just used to populate a JavaScript object. To do something with the data, you just need to flesh out the 'customProcessExtraData' function in your template's custom.js file. That function gets passed the JavaScript object with all of the extra data, and you can do with it what you want. In your case, you'll want to write some JS code that causes the right thing to happen in your target frame.

If you need to, you can override the default delimiters used for extra data ( [!...!], |||, ::: ) by changing the corresponding values in your template's define.txt file.

The cleanest way to implement the BuddyScript side of this is of course to define a procedure that takes a BuddyScript object with your extra data, serializes it into a string with all of the right delimiters, and then appends it to a response.

Hope this helps! Let us know if you have further questions or run into problems.

- Gray






Re: WebUI / HTTP-MSM examples / documentation

Riaanvs

Gray

Thank you for the reply. It makes sense and we've been playing around with it.

Just a quick, and rather more to do with the Javascript in custom.js / input.js:

If I embed the mainpage.html in an iFrame, and I have other Div elements on my overall page, why can't I do things like document.getElementById('DivNameHere').innerHTML = 'new content here';

If I do this in either input.js or custom.js, it just stops.

Riaan







Re: WebUI / HTTP-MSM examples / documentation

Gray Norton - MSFT

Hi, Riaan -

Yes, has to do with the way JavaScript variables are scoped. Each page (note that it's truly each page, not each JS file) has its own scope, so if you want to access DOM elements or JS objects that exist on a different page, you need to explicitly reference that page.

If you're working in custom.js and your function for handling extra data is being invoked in the usual way, I believe your code will be executed from within the input.html page, which is itself within an iframe in mainpage.html. If mainpage.html is in an iframe on your page, then you'll need to bump up two levels, doing something like this:

Code Snippet
parent.parent.document.getElementById("DivNameHere").innerHTML = 'new content here';

If your container page is the topmost page, you could also do:

Code Snippet
top.document.getElementById("DivNameHere").innerHTML = 'new content here';

But in either case, you may end up having cross-domain scripting issues to deal with if Microsoft is hosting your agent and you're hosting your own outer page, since browsers won't let script code from one domain interact with pages served by another domain. Ways around this include 1) Serving your outer page along with the other webui files in the template, so that they all live within the agent's domain; and 2) Serving your outer page on a server you have full administrative control over, and setting up a reverse proxy so that your agent will be accessible from yourdomain.com even though it's in fact being served from our hosting facility.

- Gray





Re: WebUI / HTTP-MSM examples / documentation

Gloobi

ABGray is back! Yeepeeeeee