Home › Forums › JavaScript › FlikR API
- This topic is empty.
-
AuthorPosts
-
March 3, 2010 at 6:02 pm #28265
Wes
ParticipantAlright so I was following the jCarousel files essentially building a site around it. I attempted to get my specific photos from it but from what I understand these photos are randomly generated.
here is my HTML
Code:
function mycarousel_itemLoadCallback(carousel, state) { if (carousel.prevFirst != null) { // Remove the last visible items to keep the list small for (var i = carousel.prevFirst; i <= carousel.prevLast; i++) { // jCarousel takes care not to remove visible items carousel.remove(i); } } var per_page = carousel.last - carousel.first + 1; var currPage = 0; var f,l; var cr = carousel; for (var i = carousel.first; i <= carousel.last; i++) { var page = Math.ceil(i / per_page); if (currPage != page) { currPage = page; f = ((page - 1) * per_page) + 1; l = f + per_page - 1; f = f < carousel.first ? carousel.first : f; l = l > carousel.last ? carousel.last : l;
if (carousel.has(f, l)) { continue; }
mycarousel_makeRequest(carousel, f, l, per_page, page); } } };
function mycarousel_makeRequest(carousel, first, last, per_page, page) { // Lock carousel until request has been made carousel.lock();
jQuery.get( 'dynamic_flickr_api.php', { 'per_page': per_page, 'page': page }, function(data) { mycarousel_itemAddCallback(carousel, first, last, data, page); }, 'xml' ); };
function mycarousel_itemAddCallback(carousel, first, last, data, page) { // Unlock carousel.unlock();
// Set size carousel.size($('photos', data).attr('total'));
var photos = $('photo', data); var per_page = carousel.last - carousel.first + 1;
for (var i = first; i <= last; i++) { var pos = i - 1; var idx = Math.round(((pos / per_page) - Math.floor(pos / per_page)) * per_page); carousel.add(i, mycarousel_getItemHTML(photos.get(idx))); } }; /** * Global item html creation helper. */ function mycarousel_getItemHTML(photo) { var url = 'http://farm'+$(photo).attr('farm')+'.static.flickr.com/'+$(photo).attr('server')+'/'+$(photo).attr('id')+'_'+$(photo).attr('secret')+'_s.jpg'; return '
'; };
jQuery(document).ready(function() { jQuery('#mycarousel').jcarousel({ itemLoadCallback: mycarousel_itemLoadCallback }); });
Pioneer
and here is my php
Code:I am sure it is quite obvious, but I just do not understand it at all. I’m trying really hard to learn but its becoming pretty hard for me.
Please help me
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.