Hello all
I hope you are all keeping safe at this crazy time.
A quick question - what's the correct syntax to reference a variable in a javascript if/else statement?
i.e.
how do I reference 'variable' below
if(variable = "x"){
skin.container_1.zIndex = "0"}
else{
skin.container_1.zIndex = "-1"}
Thank you in advance.
Paul
Referencing Variable in javascript
- Hopki
- Gnome
- Posts: 13026
- Joined: Thu Jan 10, 2008 3:16 pm
- Location: Layer de la Haye, Essex UK
- Contact:
Hi Paul,
Have you see this page: https://ggnome.com/doc/javascript-api/
It has examples as well as all the calls.
Regards,
Have you see this page: https://ggnome.com/doc/javascript-api/
It has examples as well as all the calls.
Regards,
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
Hello all
Here's a problem I'm facing and I can't fathom out what's happening!:
Here's the scenario:
I've a stack of 3 images the z-index is set to default.
I've a button that when clicked sets a counter which increments by 1 until it reaches 3 then goes back to 0.
This number is stored in a variable (var1) default value = 0.
Dependent on the number returned by the var1 an image needs to have it's zIndex set.
I have have written javascript code that achieves this.
The sequence is as follows:
1. mouse click: add 1 to var1
2. mouse click : mod / 3 to var1
3. mouse click: go to url:
4. mouse click: go to url: $(*varzindexjs)
I would expect the various images z-index(es) to change when the button is clicked but alas it does not.
Here's the strange thing - if I copy the resultant string from the above function and paste it directly into the action 4 above (Mouse click: go to url) event it works perfectly!
The string returned by the function, when var1 = 1 for example, is:
javascript:skin._imageone.style.zIndex = "3";
skin._imagetwo.style.zIndex = "2";
skin._imagethree.style.zIndex = "1";
Am I missing something fundamental here ? I've been at this for days and can't get it to work!
Hoping a fresh pair of eyes will help!
Many thanks
Paul
Here's a problem I'm facing and I can't fathom out what's happening!:
Here's the scenario:
I've a stack of 3 images the z-index is set to default.
I've a button that when clicked sets a counter which increments by 1 until it reaches 3 then goes back to 0.
This number is stored in a variable (var1) default value = 0.
Dependent on the number returned by the var1 an image needs to have it's zIndex set.
I have have written javascript code that achieves this.
The sequence is as follows:
1. mouse click: add 1 to var1
2. mouse click : mod / 3 to var1
3. mouse click: go to url:
Code: Select all
javascript:
var cc = pano.getVariableValue("var1");
var zi0;
var zi1;
var zi2;
var zIndexString;
function setZindex(){
if (cc == 0){
zi0 = 3
zi1 = 2
zi2 = 1;
}
else if (cc == 1){
zi0 = 1
zi1 = 3
zi2 = 2;
}
else if(cc == 2){
zi0 = 2
zi1 = 1
zi2 = 3;
}
}
setZindex()
zIndexString = `javascript:skin._imageone.style.zIndex = "${zi0}";
skin._imagetwo.style.zIndex = "${zi1}";
skin._imagethree.style.zIndex = "${zi2}";`;
pano.setVariableValue("varzindexjs", `${zIndexString}`);
I would expect the various images z-index(es) to change when the button is clicked but alas it does not.
Here's the strange thing - if I copy the resultant string from the above function and paste it directly into the action 4 above (Mouse click: go to url) event it works perfectly!
The string returned by the function, when var1 = 1 for example, is:
javascript:skin._imageone.style.zIndex = "3";
skin._imagetwo.style.zIndex = "2";
skin._imagethree.style.zIndex = "1";
Am I missing something fundamental here ? I've been at this for days and can't get it to work!
Hoping a fresh pair of eyes will help!
Many thanks
Paul
Hi,
Don't know if this helps or not.
In my skin, I have an element called 'blue' behind another element. To change its z-index I use an action: Mouse Click | Go to URL | javascript:skin._blue.style.zIndex = "0"; This brings it to the front. Another action: Mouse Click | Go to URL | javascript:skin._blue.style.zIndex = "3"; sends it to the back.
https://p2vr.s3-ap-southeast-2.amazonaw ... index.html
TONY
Don't know if this helps or not.
In my skin, I have an element called 'blue' behind another element. To change its z-index I use an action: Mouse Click | Go to URL | javascript:skin._blue.style.zIndex = "0"; This brings it to the front. Another action: Mouse Click | Go to URL | javascript:skin._blue.style.zIndex = "3"; sends it to the back.
https://p2vr.s3-ap-southeast-2.amazonaw ... index.html
TONY
Tony Redhead | Panoramic Photographer | mobile: +61438501002 | website: https://tonyredhead.com - https://redsquare.com | Pano2VR Tutorials: https://tonyredhead.com/pano2vr | instagram: https://www.instagram.com/tonyredhead/