Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Created January 9, 2011 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexspeller/771876 to your computer and use it in GitHub Desktop.
Save alexspeller/771876 to your computer and use it in GitHub Desktop.
function parseXml(xml)
{
var i = -1;
var groupArray = new Array();
j$(xml).find("pic").each(function()
{
i++;
var name = "gallery/" + j$(this).find('name').text();
var thumb = "gallery/thumbs/" + j$(this).find('thumb').text();
var group = j$(this).find('group').text();
groupArray.push(group);
try {
if(groupArray[i].length == 6)
{
j$('td:eq(' + i + ')').html('<a class="pic" href="#" rel="lightbox[All]"></a>');
j$('.pic:eq(' + i + ')').attr('href',name);
switch (group)
{
case "Coll_1":
j$('.pic:eq(' + i + ')').addClass("coll1");
break;
case "Coll_2":
j$('.pic:eq(' + i + ')').addClass("coll2");
break;
case "Coll_3":
j$('.pic:eq(' + i + ')').addClass("coll3");
break;
}
j$('.pic:eq(' + i + ')').html('<img src="' + thumb + '" title="' + (i+1) + '" />');
}
} catch(error) {
console.log(error);
}
});
j$("#Coll_1,#Coll_2,#Coll_3").click(function(){
for(i=0;i<=24;i++)
{
j$('.pic:eq(' + i + ')').attr("rel","lightbox[" + groupArray[i] + "]");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment