You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

  • "nathanfjohnson" started this thread

Posts: 11

Location: Calgary Canada

Occupation: Student

  • Send private message

1

Thursday, July 9th 2009, 7:04am

get the current xml file name. and calling external functions in the xml

I can't seem to figure out the get(variable) to get the name of the current xml file. Does someone know if this is possible?
it would also work for me to be able to use an action in the panorama xml to send the filename with a function. Could I get help with that syntax?

Thank you

Graydon

Professional

Posts: 614

Location: Texas

Occupation: Industrial gas turbine services.

  • Send private message

2

Friday, July 10th 2009, 9:22am

Here's a quick sample...

http://marlincreek.com/demo/xml_name/

Assuming I understood your request correctly.

When the grid loads up, press "O" (not zero) to get the info box to show up... you should see

Source code

1
2
3
4
5
INFO: krpano 1.0.8 beta 7 (build 2009-04-08)
INFO: Flashplayer WIN 10,0,22,87 PlugIn
INFO: registered to: Marlin Creek
INFO: --------------
INFO: my current xml is marlin_creek.xml


I used the onstart action to set a variable to the name of the xml... which has to be explicitly defined. I do not know of an automatic way. Once the variable is set... I call a js function that is defined in the html... and it defines a js variable from the xml / krpano variable and then sends it back to krpano in the trace function.

Here are the relevant pieces of code.

first, the onstart item...

Source code

1
onstart="set(current_xml, marlin_creek.xml); js(show_name());

... this could be called from different areas... The click me buttom references the same js function.

The html / js stuff...

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script type="text/javascript">
// <![CDATA[
	
	function krpano() 
	{
		return document.getElementById("panox");
	}

	function show_name()
	{

		krpano().call("trace(--------------)");

		var my_file =( krpano().get("current_xml") );
		krpano().call("trace(my current xml is " + my_file + ")");

	}

// ]]>
</script>


The "panox" reference in the "return document..." is based upon what I call the embedded swf. I use swfobject 2.x and here's the snippet from the attributes item...

Source code

1
2
3
4
			var attributes = {
				id: "panox",
				name: "apano"
			};


Graydon

edit: There are a couple of different ways to define some variables... unfortunately I don't remember them right now. Hopefully Klaus or others will chime in with any alternate methods.

edit2: Hope this helps... this shows that you can pass the info to js... from there, you can do whatever you'd like. I just passed it back through in the trace function to show it's possible.

  • "nathanfjohnson" started this thread

Posts: 11

Location: Calgary Canada

Occupation: Student

  • Send private message

3

Friday, July 10th 2009, 8:16pm

Thank you

Thanks for all your info, I'll have to read over it a few times but it looks like that's what I am looking for.
I'm very impressed with the helpfulness of everyone on these forms.

4

Monday, July 13th 2009, 8:54am

Hi,

there is also a other way to get the current xml (sorry, not documented yet )
there are two variables that can be accessed with get():
  • xml.url - the url of the current xml file
  • xml.content - the content of the current xml file as string

e.g. to call from javascript:

Source code

1
var xmlurl = krpano().get("xml.url");


best regards,
Klaus