If you want to see what I'm talking about at any point, go to
http://DanHakimi.com/works.php and hit the "web" button in the top-rightish area. Or, you know, check the source code, because you can't see any of that stuff right now.
So, I'm working on a portfolio for myself. And I want to make it for myself, because, well, I don't want to be lame. But I do need some help in figuring out what's wrong...
My portfolio has three parts: stuff I've designed on the web, stuff I've written, and other stuff. Those are separated by the three buttons in the top right. You hit one, and the old visible item fades out, and the new one fades in. It's pretty.
Now, the "web" section is the problem. Right now, the div associated with it contains 3 div's. Each of those divs contains a p, and is not visible by default. On ready, I do this:
function readyFunction()
{
var pages = [];
submenu();
portfolio();
pages = get_web_pages();
web_pages(pages);
back_and_forth(pages);
}
create an array out of them, and sort it randomly:
function get_web_pages() {
var pages = [];
pages = jQuery(".page").toArray();
pages.sort(random_sort);
return pages;
}
Then, I show the first page:
function web_pages(pages) {
pages[0].show();
}
And then, I set up back and forth buttons:
function back_and_forth(pages) {
var index = 0;
jQuery(".web.back").click(function() { index = webBack(pages, index);});
jQuery(".web.forth").click(function() { index = webForth(pages, index);});
}
//Back and Forth buttons for Web.
function webBack(pages, index){
pages[index].hide();
index=index-1;
if(index < 0) { index=pages.length-1; }
pages[index].show();
return index;
}
function webForth(pages, index){
pages[index].hide();
index=index+1;
if(index >= pages.length) { index=0; }
pages[index].show();
return index;
}
But when I try it out, nothing shows. It should show the first element, right?
I am aware that by calling toArray(), I am turning jQuery objects into DOM objects. That's not the problem, is it? How would I fix that?