You are not logged in.

1

Thursday, November 5th 2015, 6:04pm

js pass array to xml

Hi,everyone
In JS I want to pass the array to the XML inside, what I need to do???
Worry,Worry,Worry
Thanks,Thanks

Posts: 1,082

Location: Russia, Kaliningrad

  • Send private message

2

Saturday, November 7th 2015, 12:36pm

Hi
what kind of array?
array system in krpano looks like this or so
<myarray name="somename">
<item name="i0" value="value0_or_what_ever"/>
<item name="i1" value="value1_or_what_ever"/>
<item name="i2" value="value2_or_what_ever"/>
<item name="i3" value="value3_or_what_ever"/>
<item name="i4" value="value4_or_what_ever"/>
</myarray>

access to array items and values
array[somename].item[2] (used index)
array[somename].item[i2] (used name)

it's just example

or even so

<myarray name="i0" value="200"/>
<myarray name="i1" value="400"/>
<myarray name="i2" value="300"/>
<myarray name="i3" value="100"/>

myarray[2].value == 300

and read docu here http://www.krpano.com/docu/actions/#arrays

Regards
Andrey
VRAP - desktop VR content player based on krpano.
Common tasks in one place in one click! Discussion thread
DOWNLOAD for MAC
DOWNLOAD for WIN

Posts: 1,082

Location: Russia, Kaliningrad

  • Send private message

3

Saturday, November 7th 2015, 12:59pm

And about pass from javascript to krpano
there is javascript krpano interface http://www.krpano.com/docu/js/#top
so you can use normal javascript for set/add variables http://www.krpano.com/docu/js/#interfaceobject

Regards
Andrey
VRAP - desktop VR content player based on krpano.
Common tasks in one place in one click! Discussion thread
DOWNLOAD for MAC
DOWNLOAD for WIN

4

Tuesday, May 2nd 2017, 6:41pm

set dynamically new sub-Nodes to an existing array

just wondering how to set dynamically new sub-Nodes to the existing array?

I take the array
<myarray name="somename">

<item name="i0" value="value0_or_what_ever"/>

<item name="i1" value="value1_or_what_ever"/>

<item name="i2" value="value2_or_what_ever"/>

<item name="i3" value="value3_or_what_ever"/>

<item name="i4" value="value4_or_what_ever"/>

</myarray>

How to add a new subnode like:
<item name="i5" value="value5_or_what_ever"/>

tried:
txtadd(myarray[somename].item[name], i5, 'value=value5_or_what_ever');

No success...

Any Ideas?

Steve

-----------------------------------------------------------------------------------------------
EDIT:
OK, found the solution:
set(myarray[somename].item[i5].value, value5_or_what_ever)

This post has been edited 1 times, last edit by "svb" (May 2nd 2017, 10:58pm)


5

Monday, May 8th 2017, 3:10pm

hi

try it like that:

Source code

1
txtadd(myarray[somename].item[i5].value, value5_or_what_ever);



use a for loop to create several items at once:

Source code

1
for(set(i, 0), i LT youritemcount, inc (i),set(myarray[somename].item[get(i)].value, get(value)););



sven