Sie sind nicht angemeldet.

ZODIACBLUE

Anfänger

  • »ZODIACBLUE« ist der Autor dieses Themas

Beiträge: 37

Wohnort: Brighton, UK

Beruf: Photographer

  • Nachricht senden

1

Freitag, 25. Februar 2011, 02:07

passing data to javascript from xml files

Hi there I'm experimenting with linking tours together and want to be able to control/effect/change data within a javascript file from an xml file.

For example I have two tours one which links to a panorama in the other and vice versa I have managed to do this one way through javascript to the xml file but can't figure out the reverse route through javascript prob just tired and not thinking straight
*confused* *sleeping* *squint* *sleeping* *sleeping*

2

Freitag, 25. Februar 2011, 23:34

Hi,

there is the js() action,
with it can can call Javascript functions from krpano xml,

best regards,
Klaus

3

Donnerstag, 31. März 2011, 20:47

Hi Klaus:

Using code similar to the below, I can't seem to get information from a <data/> element passed to a Javascript function. Is this not possible currently?

Quellcode

1
2
3
4
5
6
7
8
//javascript:
var myText = krpano().call("get(data[myData].content);");
document.getElementById("somediv").innerHTML = "<span><strong>" + myText + "</strong></span>";

<!-- XML: -->
<data name="myData">
	<p>Hello<br />World</p>
</data>


Thanks in advance,

Patrick
QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

4

Donnerstag, 31. März 2011, 22:34

OK, so the call may not return data.
Big deal, almost assuredly, krpano can run javascript too.
JS -> Run krpano function, do variable stuff, run JS function to update the DOM.

Easy peazy.

JS function to run krpano function -> Krpano function to run JS function->
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

5

Freitag, 1. April 2011, 00:07

OK, so the call may not return data.
Big deal, almost assuredly, krpano can run javascript too.
JS -> Run krpano function, do variable stuff, run JS function to update the DOM.

Easy peazy.

JS function to run krpano function -> Krpano function to run JS function->


Hi Sacha:

I don't quite understand what you mean... Are you saying there's a way to get the data element's text into a Javascript function (from krpano xml --> javascript in the page)? That's what I'm trying to do... and it comes up as nothing, empty, or fails without error.

Or are you saying I can just run the Javascript from right within the XML? Or... ?

Thanks,

Patrick
QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

6

Freitag, 1. April 2011, 01:26

Exactly, you can grab the data element with krpano and use it, and you should be able to call a js function in krpano with those contents or at least, I don't see why not?
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

7

Freitag, 1. April 2011, 01:34

Exactly, you can grab the data element with krpano and use it, and you should be able to call a js function in krpano with those contents or at least, I don't see why not?


Well, me neither. Thus my original post ;-)

To wit:

Using code similar to the below, I can't seem to get information from a <data/> element passed to a Javascript function. Is this not possible currently?

Quellcode

1
2
3
4
5
6
7
8
//javascript:
var myText = krpano().call("get(data[myData].content);");
document.getElementById("somediv").innerHTML = "<span><strong>" + myText + "</strong></span>";

<!-- XML: -->
<data name="myData">
	<p>Hello<br />World</p>
</data>


Thanks in advance,

Patrick
QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

8

Freitag, 1. April 2011, 01:54

I don't think you getting me, call your js function to call your krpano function which gets your data content and call that content as the parameter in a js function which then uses that to update your dom.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

9

Freitag, 1. April 2011, 01:57

Do you have a working test Sacha? Love to see it! I've been trying various methods for a while (see other posts in the forum here). I can successfully call this and other JS from krpano; jsut can't get info from krpano xml into the javascript.
QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »patrickcheatham« (1. April 2011, 02:36)


10

Freitag, 1. April 2011, 07:29

Hi Klaus:

Using code similar to the below, I can't seem to get information from a <data/> element passed to a Javascript function. Is this not possible currently?

Quellcode

1
2
3
4
5
6
7
8
//javascript:
var myText = krpano().call("get(data[myData].content);");
document.getElementById("somediv").innerHTML = "<span><strong>" + myText + "</strong></span>";

<!-- XML: -->
<data name="myData">
	<p>Hello<br />World</p>
</data>


Sigh.

OK, below is the working implementation (both ways, from Javascript to KRPano or the reverse):

Quellcode

1
2
3
4
5
6
7
//javascript:
var myText;
myText = krpano().get("data[someData].content");

<!-- XML: -->
<!-- call javascript function "someFunction(arg1, arg2, arg3, [arg...])"-->
js( someFunction(get(data[someData].content), BlahBlah, Another Line of Blah) ) ;


Thanks for putting up with my whinery *g*

HTH,

Patrick
QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

11

Freitag, 1. April 2011, 16:31

You bastard, and I just finished my example. ;)

http://www.seeit360.net/jstest/


This passes a variable into krpano, increments it, and passes it back out ..

Hopefully, I learned something here as well.

Hi Klaus:

Using code similar to the below, I can't seem to get information from a element passed to a Javascript function. Is this not possible currently?

Quellcode

1
2
3
4
5
6
7
8
//javascript:
var myText = krpano().call("get(data[myData].content);");
document.getElementById("somediv").innerHTML = "" + myText + "";



	Hello
World


Sigh.

OK, below is the working implementation (both ways, from Javascript to KRPano or the reverse):

Quellcode

1
2
3
4
5
6
7
//javascript:
var myText;
myText = krpano().get("data[someData].content");



js( someFunction(get(data[someData].content), BlahBlah, Another Line of Blah) ) ;


Thanks for putting up with my whinery *g*

HTH,

Patrick
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

12

Freitag, 1. April 2011, 17:46

:-)

Well, you one-upped me with an actual example. ;-) Good work!

WHEW.

Cheers,

Patrick

ps: as was succinctly put to me, off-list, this morning:
"call() does not have a returnvalue, get() does."
QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »patrickcheatham« (1. April 2011, 18:03)