WordPress.org

Forums

Advanced AJAX Page Loader
[HELP ME!] Reload code for Flickr and Twitter widget of Resizable theme (2 posts)

  1. Mandrake990
    Member
    Posted 2 years ago #

    Hi,

    I have two widgets that need to be reloaded every time AAPL load the content.

    Those widgets, installed with Resizable theme, are the Twitter widget and Flickr Widget.

    The Twitter widget uses JSON call from this URL:

    http://api.twitter.com/1/statuses/user_timeline/username.json?callback=twitterCallback2&count=5&include_rts=t

    And load this script:

    <!--//--><![CDATA[//><!--
    function twitterCallback2(twitters) {
    var statusHTML = [];
    for (var i=0; i<twitters.length; i++){
    var username = twitters[i].user.screen_name;
    var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
    return '<a href="'+url+'">'+url+'</a>';
    }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
    return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
    });
    statusHTML.push( '<li><span class="content">'+status+'</span> <a style="font-size:85%" class="time" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'">'+relative_time(twitters[i].created_at)+'</a></li>' );
    }
    document.getElementById( 'twitter_update_list_tj_twitter-2').innerHTML = statusHTML.join( '' );
    }
    function relative_time(time_value) {
    var values = time_value.split( " " );
    time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
    var parsed_date = Date.parse(time_value);
    var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
    var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
    delta = delta + (relative_to.getTimezoneOffset() * 60);
    if (delta < 60) {
    return 'less than a minute ago';
    } else if(delta < 120) {
    return 'about a minute ago';
    } else if(delta < (60*60)) {
    return (parseInt(delta / 60)).toString() + ' minutes ago';
    } else if(delta < (120*60)) {
    return 'about an hour ago';
    } else if(delta < (24*60*60)) {
    return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
    } else if(delta < (48*60*60)) {
    return '1 day ago';
    } else {
    return (parseInt(delta / 86400)).toString() + ' days ago';
    }
    }
    //-->!]]>

    Then i have the Flickr widget.

    It calls a script that returns directly the HTML that has to be injected into the widget:

    http://www.flickr.com/badge_code_v2.gne?count=9&display=random&&layout=x&source=user&user=USERID&size=s

    And it returns this markup:

    var b_txt = '';
    
    // write the badge
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image1"><a href=""><img src="someimage" alt="" title="" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image2"><a href=""><img src="" alt="" title="" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image3"><a href=""><img src="" alt="" title="" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image4"><a href=""><img src="" alt="" title=" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image5"><a href=""><img src="" alt="" title="" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image6"><a href=""><img src="" alt="" title="" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image7"><a href=""><img src="" alt=" title="" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image8"><a href=""><img src="" alt="Una foto su Flickr" title="" height="75" width="75"></a></div>';
    
    	b_txt+= '<div class="flickr_badge_image" id="flickr_badge_image9"><a href=""><img src="" alt="" title="" height="75" width="75"></a></div>';
    
    b_txt += 'blablabla';
    
    document.write(b_txt);

    http://wordpress.org/extend/plugins/advanced-ajax-page-loader/

  2. Mandrake990
    Member
    Posted 2 years ago #

    Thank you,

    Roberto.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced AJAX Page Loader
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic