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

  • 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

    Code
    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...

    Code
    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...

    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...

    Code
    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.

  • 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:

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

    best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!