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:
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.
A closure might actually be the easiest for multiple galleries, but it might mean a bit of a rewrite. Basically I mean that each gallery would be an instance of a gallery object, with access to functions like start, stop, random etc., but with a different id each time. I'd also strongly suggest you read this. If you don't get what I'm talking about, ask, because I don't think I've explained that well.
As for your second question, I don't understand what you are getting at to be honest.
Great wit and madness are near allied, and fine a line their bounds divide.
This is kinda strange, I don't quite understand why your location would need to be set to something in order to display a gallery. In order to have seperate variables based off of your location, your location would need to be something like
galVariable1 = (i = location.hash.match(/#set1=(.+)&photo1=(\d+)/)) ? i[1] : null;
galVariable2 = (i = location.hash.match(/#set2=(.+)&photo2=(\d+)/)) ? i[1] : null;
and so one... However, this doesn't seem like a proper method. Maybe explaining the purpose of the location would help make sense of this. Also, how your gallery system works will determine the format in which you should store your gallery data & settings. Personally, Declan made a very good suggestion, instantiating the gallery would be your most versatile and unobtrusive approach, but like already mentioned it would most likely require a lot of modification.
Bookmarks