So i've written up the code to do a lightbox esque overlay image gallery. everything is working smooth and fine. The only concern is that I have the following:
lets say that I have a page that has multiple galleries. Obviously I would have to make each literal array with the gallery data different names, ex:
Code:
var _gallery1 = {
'images': [
{ 'id' : 1, 'src' : "" }
]
}
var _gallery2 = {
'images': [
{ 'id' : 1, 'src' : "" }
]
}
or would it be easier to do it multi dimensional?
Code:
var gallery_data = {
'gallery1': [
'images': [
{ 'id' : 1, 'src' : "" }
]
]
'gallery2': [
'images': [
{ 'id' : 1, 'src' : "" }
]
]
}
regardless of which direction I use... my main question is this:
I have two variables which are the following:
Code:
galVariable = (i = location.hash.match(/#set=(.+)&photo=(\d+)/)) ? i[1] : null;
galArray = _gallery2.images;
I'm unfamiliar with a way of doing something along the lines of this, and having it actually work:
Code:
galVariable = (i = location.hash.match(/#set=(.+)&photo=(\d+)/)) ? i[1] : null;
galArray = galVariable.images;
obviously "galVariable" would be undefined... as i'm trying to get "_gallery2.images" but trying to use "galVariable" to point to "_gallery2"
I'm familiar with solving a problem like this in PHP, not so much javascript. is there a JS function that can be used to ensure that it's using whatever "galVariable" equals to, and then that array's content is? Or is there a different way to go on about this.
thanks in advance. if anyone needs some more clarification. please feel free to ask, and I'll respond asap.