Ox.getJSON('json/pandora.json', function(pandora) { $(function() { var $body = $('body'), $icon = $('#icon') .bind({ click: function() { $('#menu > div').removeClass('selected'); $page.empty() .append($('
').html(pandora.pages.tour[tourIndex][1]) ); } else { text = pandora.pages[page]; } $head.empty().append( page == '' ? 'pan.do/ra — open media archive' : page == 'tour' ? $('') .addClass('button disabled') .attr({title: 'first'}) .html('tour') .click(function() { loadTour(0); }) : page ); $text.addClass(page).empty().append(text); if (page == 'tour') { $prevButton .click(function() { loadTour(-1); }) .appendTo($head); $nextButton .click(function() { loadTour(1); }) .appendTo($head); if (tourIndex == 0) { $prevButton.addClass('disabled'); } else if (tourIndex == pandora.pages.tour.length - 1) { $nextButton.addClass('disabled'); } } } } function loadTour(delta) { tourIndex = delta == 0 ? 0 : Ox.mod(tourIndex + delta, pandora.pages.tour.length); $('.button').removeClass('disabled'); if (tourIndex == 0) { $prevButton.addClass('disabled'); } else if (tourIndex == pandora.pages.tour.length - 1) { $nextButton.addClass('disabled'); } var $img = $text.find('img'), $p = $text.find('p'), src = pandora.pages.tour[tourIndex][0] $('') .load(function() { $img.css({opacity: 1}).attr({src: src}); $p.css({opacity: 1}).html(pandora.pages.tour[tourIndex][1]); }) .attr({ src: src }); $img.css({opacity: 0.25}); $p.css({opacity: 0.25}); } }); });