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.

1

Friday, September 30th 2022, 9:27am

How to set XML attribute's value dynamically? (w/o using events)

Hello,

I want to set XML attribue's value dynamically, but not sure whether this is possible without using events (and actions).

From my html document, I am passing a parameter "langauge".

Quoted


<script>
embedpano(
{
id:'vr',
xml:"tour.xml",
target:"pano",
html5:"only",
mobilescale:1.0,
initvars:{
langauge: en
}
}
);
</script>


And I have multilanguage set in krpano XML format.

Quoted


<multi_language>
<welcome name="welcome" en="Welcome" de=Wilkommen" it="Benvenuti" .../>
...
</multi_language>


I want to set scene's title depending on the language setting using multi_language XML element.

I have tried following and realized that get() function doesn't work in attribute.


Quoted

<scene title="multi_langauge.welcome[welcome].get(lanauge)" .../>

I saw "get:..", "calc:" feature in the krpano vrtourskin.xml and thought maybe I could use this feature to achieve my goal, but no luck..







I know I could use events+actions (or JavaScript CDATA too?) to make it work but if possible, I want to use minimum code.

Anybody had this issue too?

Best Regards,
hyung

2

Friday, September 30th 2022, 12:41pm

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
embedpano({
	...
	initvars:{ language: "en" },
	...
});

<krpano>
	...

	<loc name="welcome" en="Welcome" de="Willkommen" />
	<loc name="goodbye" en="Good Bye" de="Auf Wiedersehen" />

	<scene name="test" title="calc:calc('loc[goodbye].'+language)" />

	...
</krpano>


ps.
calc:calc('loc[goodbye].'+language) --> calc:loc[goodbye].en --> "Good Bye"

@Klaus
shouldn't this work? (it doesn't)
title="get:calc('loc[goodbye].'+language)

This post has been edited 6 times, last edit by "indexofrefraction" (Sep 30th 2022, 2:56pm)


3

Tuesday, October 4th 2022, 10:14am

Hello indexofrefraction!

Thank you very much for your answer.

calc:calc('loc[goodbye].'+language)

-> I have never ever imaginged this expression! *thumbsup*


@Klaus
shouldn't this work? (it doesn't)
title="get:calc('loc[goodbye].'+language)
-> I am very curious too.

Have a nice day! *smile*

Best Regards,
hyung

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
embedpano({
	...
	initvars:{ language: "en" },
	...
});


	...

	
	

	

	...


ps.
calc:calc('loc[goodbye].'+language) --> calc:loc[goodbye].en --> "Good Bye"

@Klaus
shouldn't this work? (it doesn't)
title="get:calc('loc[goodbye].'+language)

4

Tuesday, October 4th 2022, 10:26am

shouldn't this work? (it doesn't)
title="get:calc('loc[goodbye].'+language)
-> I am very curious too.


answer from Klaus :
no, get: does not evaluate an expression (it only does a simple variable look up)