Digital Solutions & Online Creative 

Alex runs a small digital creative business from an office in London. It's called Outside In Media.

About

SOYREX is a web development and design resource intended as a place for me to share tips and tricks relating to html, css, web design, web development and other internet and web topics. If you like what you read, leave a comment, or send an email. Also, check out my company web site.

This form does not yet contain any fields.
    Search the Archives

    Online Schools

    Currently Reading..
    • Blink: The Power of Thinking Without Thinking
      Blink: The Power of Thinking Without Thinking
      by Malcolm Gladwell

      Blink talks about flash cognition and sub-conscious cognitive activity.. awesome read!

    • Confessions of an Economic Hit Man: The Shocking Story of How America Really Took Over the World
      Confessions of an Economic Hit Man: The Shocking Story of How America Really Took Over the World
      by John Perkins

      Confessions of an Economic Hit Man - i knew the world was a big conspiracy.. but this is a gripping insight into how the world really works.

    Recommended Reading
    • Designing with Web Standards (Voices That Matter)
      Designing with Web Standards (Voices That Matter)
      by Jeffrey Zeldman, Ethan Marcotte
    • Web Standards Creativity: Innovations in Web Design with XHTML, CSS, & DOM Scripting: Innovations in Web Design with XHTML, CSS, and DOM Scripting
      Web Standards Creativity: Innovations in Web Design with XHTML, CSS, & DOM Scripting: Innovations in Web Design with XHTML, CSS, and DOM Scripting
      by C et al Adams
    Monday
    Jul282008

    jQuery + Twitter + a night of coding

    I've always used prototype and scriptaculous to do JS stuff in the past. However I've been hearing a lot of good things about jQuery and i'd noticed that sites i'd seen using jQuery seemed to have much smoother animation etc.

    So in the spirit of keeping an open mind (and continuing to learn.. something I don't find myself doing that often anymore) i set about building a simple JS based web app to test how jQuery would suit my programming etc..

    After about 4 minutes of brainstorming, I found myself getting annoyed, and switched to my Tweetdeck to distract myself. In a semi-relevant aside, i have to say, tweetdeck makes my twitter usage about 100x as useful.. plug!

    So i decided it would be cool to try knocking upa simple Ajax application that emulated Tweetdeck's searching features - using the search.twitter.com api (previously summize).

    So i downloaded jQuery, and set up 3 simple div based columns to hold the tweets i was going to be grabbing. The beautiful thing i discovered with jQuery is it can cross domain ajax requests, so i can talk directly to the search.twitter.com api without having to write a proxy script on my server - cool!

    The twitter search API has an option to return JSON data, which is really great for building an app like this, since we end up receiving the data and handling it all in JS with no decoding necessary.. too easy.

    So, we have our 3 divs and at this point I started to get my hands dirty in jQuery (i'm not a complete beginner, but i never really used it extensively.. so i was keen to see how it was compared to prototype). Turns out, within 10 minutes of starting, i had fallen in love with jQuery's selectors, they are so much simpler and more flexible than prototype.. coupled with the style of programming that jQuery promotes, using it's each() method to map responses to all the results of a selection, it turns out that writing relatively complex JS applications is a piece of cake.

    Below is the code listing for the guts of the application it is the response to the Ajax call, it receives the JSON response from the twitter search api and turns each tweet into a div and prepends it into the relevant column of data.

    $.getJSON(url, function(json)
    {
    
        // clean up old ones:
        $('#col'+x+' div.tweet:gt(10)').each(function(){$(this).fadeOut('slow')});
    
        $(json.results).reverse().each(function()
        {
            if($('#col'+x+' .tweets #tw'+this.id).length == 0)
            {
    
                var divstr = '<div id="tw'+this.id+'" class="tweet">'+\
                '<img width="48" height="48" src="'+this.profile_image_url+'" >'+\
                '<p class="text">'+this.text.linkify().linkuser().linktag()+\
                ' -&nbsp;<b><a href="http://twitter.com/'+this.from_user+'">'+\
                this.from_user+'</a></b></p></div>';
    
                window.twitter['last_id'+x] = this.id;
    
                $('#col'+x+' .tweets').prepend(divstr);
                $('#col'+x+' .tweets #tw'+this.id).hide();
                $('#col'+x+' .tweets #tw'+this.id+' img').hide();
                $('#col'+x+' .tweets #tw'+this.id+' img').fadeIn(4000);
                $('#col'+x+' .tweets #tw'+this.id).fadeIn('slow');
    
            }
        });
        setTimeout('fetch_tweets('+x+')', 3000);
    });
    

    There are a few more tricks in here, like linkify and linkuser, which have been prototyped into JS so that i can convert the links for twitter on the fly (if you're really interested, grab the JS source off the site and have a poke around).

    So how did jQuery compare to Prototype? Once i got over my tendency to want to write Prototype JS into my files, i've actually come to prefer jQuery I find myself writing much prettier, more elegant code, without the iteration and procedural work I usually do in Prototype. jQuery is a definite winner, and i will slowly be moving all my sites over from using prototype to jQuery.

    So i now had a single working HTML file that produced 3 twitter streams in ajax.. what should i do with this useless piece of concept code? I know, turn it into a site.. so at 4am I bought http://monitter.com as a domain to host my twitter monitor (if you can't get the play on words, give up now).. Fired up photoshop and created a simple logo, favicon and a couple of simple textures.. tidied up the CSS a bit, added in some update-your-browser.com ie6 messages and uploaded the files.. voila Monitter is born... check it out: http://monitter.com - tell your friends! be sure to give me feedback in the comments here.. and keep smiling.

    PrintView Printer Friendly Version

    EmailEmail Article to Friend

    References (1)

    References allow you to track sources for this article, as well as articles that were written in response to this article.

    Reader Comments (17)

    Very very nice. I will be using this to check the pulse of some key topics in Twitter. Thank you for your hard work!

    A friend of mine just released: http://youtech.me where he reviews new web appps. If you submit monitter.com I'm sure he'll take the time to write up a review and get you some links!

    August 27, 2009 | Unregistered CommenterZach Katkin

    Hey Zach,

    Cheers for the link. Pitch submitted ;)

    Glad you liked Monitter.. i'd be curious to know if you have any thoughts about how i could make it better.. drop me a mail ;)

    August 27, 2009 | Registered Commenterrex

    Wow!
    Great article, Im in love with jQuery too! its so simple and powerfull.
    And monitter is great!!! the design is so cool. Congratulations!!

    August 27, 2009 | Unregistered CommenterJuan Pablo

    Do you by any chance have a basic working demo of this?

    October 7, 2009 | Unregistered CommenterBrian

    Monitter widget is simply wonderful, is there a way to input the search string by form instead of changin it directly by html?

    March 2, 2010 | Unregistered Commentermattwittek

    <p>We are a professional supplier of wholesale designer handbags ,wholesale gucci,please feel free to
    contact us if you need fashion handbags.
    Find all the latest fashion, brown handbag, celebrity gossip and leather handbags!
    Different Colors And Sizes Available. </p>
    We take pleasure to introduce ourselves as manufacturers and exporters of all kinds of ladies high heel shoes.We are manufacturers and exporters of all kinds of high shoes. We specialize in wedding shoes fitted with Swarovski and imitation diamond

    July 12, 2010 | Unregistered CommenterFrank

    These hermes bag are exclusively handcrafted and it takes almost 18 days to complete a single Hermes Lindy . It therefore comes as no surprise that most have had to wait for a maximum of two years to possess the bag. Those customers who are much more regular can expect their herme a bit quicker.
    Although the war between the FDA and the manufacturers of daidaihua rages on, the facts remain that lida slimming is an excellent fat burning tool. It is, generally speaking, both safe and effective when taken as directed. slimming capsule is a drug and needs to be treated with respect and never abused. If you've never taken slimming capsules before, you probably have many questions such as: Should I take an lida based product? How much should I take? When should I take the first dose? How long should I use lida daidaihua ?
    Therefore, if you are among those people who only go for branded stuff Chanel bag is the best choice to acquire as the Chanel handbags speaks for itself and show a class to what you are holding. Several celebrities are often spotted to be possessing wallets which are branded and Chanel handbag comes on the top list. Long and well reputed history has made chanel watches the bestselling brand where it is considered to be a symbol of quality and style.
    Tiffany jewellery shine through the body of every girl and when that happens, there are so many who will be attracted on it, how much more if the Jewelry she wears will be silver sets . If you will only think about how Tiffany charms are at its best, you can really think that it is all worthy after all. However, it is expensive, as it may seem to be. It can really make you get the things that you have always wanted, that it why; we have the silver charms in the market.

    July 13, 2010 | Unregistered Commentertiffanyjewellery

    The craze for this hermes handbags can well be felt by the fact that people are ready to wait for years for possessing Kelly handbag that certainly defines the person elitism and social status. For the past one seventy years, Kelly handbags has been holding an edge over its major competitors.
    Although the war between the FDA and the manufacturers of daidaihua rages on, the facts remain that lida slimming is an excellent fat burning tool. It is, generally speaking, both safe and effective when taken as directed. slimming capsule is a drug and needs to be treated with respect and never abused. If you've never taken slimming capsules before, you probably have many questions such as: Should I take an lida based product? How much should I take? When should I take the first dose? How long should I use lida daidaihua ?
    Perhaps Francois had a hand in the lovely Chanel bag Vintage Speedy Bag? I bet no one can prove to me that he didn’t – it’s vintage, after all. This is not your average vintage Chanel Wallet – classic flaps are fairly easy to find at high-end vintage shops and, if you have nerves of steel, but replica Chanel handbags styles that were only made for a short period of time and don’t have the “iconic” status of a flap Chanel handbag are what really intrigue me.
    The Tiffany uk is a really good choice for you to have and to purchase your very own jewelry. You can get this from your nearest Tiffany accessories store so you can already get the best that you can have and through that, you can really be well appreciated and you will never get less when it comes to getting the Tiffany sets that you will certainly love and you will certainly keep for a very long time. Tiffany charms is a timeless thing that can give you nothing but the best craft that it has been made for.

    July 13, 2010 | Unregistered Commentertiffanyjewellery

    Discount Louis louis vuitton handbags Vuitton Handbags,Wallets & Purse louis vuitton Online Store. In

    louis vuitton replica handbags the my lv replica handbags store buy designer handbags cheap Louis louis vuitton handbags Vuitton Handbags, You replica handbags best choice.louis vuitton,louis vuitton handbags,louis vuitton handbag,louis louis

    vuitton handbags vuitton bags,louis vuitton bag,louis vuitton wallets,louis vuitton wallet,gucci,gucci wholesale louis vuitton

    handbags handbags,gucci handbag,gucci bags,gucci bag,gucci wallets,gucci wallet,prada,prada handbags,prada handbag,prada bags,prada wholesale replica handbags bag,prada wallets,prada wallet,buy prada handbag.
    815GSW0715

    July 15, 2010 | Unregistered CommenterReplica Handbags

    Discount Louis louis vuitton handbags Vuitton Handbags,Wallets & Purse louis vuitton Online Store. In

    louis vuitton replica handbags the my lv replica handbags store buy designer handbags cheap Louis louis vuitton handbags Vuitton Handbags, You replica handbags best choice.louis vuitton,louis vuitton handbags,louis vuitton handbag,louis louis

    vuitton handbags vuitton bags,louis vuitton bag,louis vuitton wallets,louis vuitton wallet,gucci,gucci wholesale louis vuitton

    handbags handbags,gucci handbag,gucci bags,gucci bag,gucci wallets,gucci wallet,prada,prada handbags,prada handbag,prada bags,prada wholesale replica handbags bag,prada wallets,prada wallet,buy prada handbag.
    815GSW0715

    July 15, 2010 | Unregistered CommenterReplica Handbags

    <p>The cutting edge of <A href="http://www.b2bsharing.com/cheap-sunglasses-c-4390.html">Cheap Sunglasses</A> design is offered to you online because we only stock the Latest collection of Sunglasses. <A href="http://www.b2bsharing.com/cheap-sunglasses-rayban-glasses-c-4390_4460.html">RayBan Glasses</A> are a way to show off your own unique sense of style and we pride ourselves on offering the largest collection of <A href="http://www.b2bsharing.com/cheap-sunglasses-c-4390.html">wholesale Sunglasses</A> and eyewear to our customers.

    When you own a pair of new <A href="http://www.b2bsharing.com/cheap-sunglasses-oakley-glasses-c-4390_4457.html">Oakley Glasses</A>, you own a key to unlock the world of high fashion. People understand what ; they know that someone who wears <A href="http://www.b2bsharing.com/cheap-sunglasses-c-4390.html">2010 Sunglasses</A> is someone who has a high sense of fashion <A href="http://www.b2bsharing.com/cheap-sunglasses-burberry-glasses-c-4390_4393.html">Burberry Glasses</A> and a high standard of quality.</p>

    July 24, 2010 | Unregistered Commenterhei

    Individuals with average income would probably find it too costly to buy. But for the rich, this kind of a small amount of money is a piece of cake. And it is surely worthy of purchasing for the superiority, rareness, durability and profoundness. If I have enough money,replica versace watches I would buy it without doubt since it is just not only a timekeeper but also a good investment.

    July 27, 2010 | Unregistered Commenterivan.watcheslux

    Thank you for the insight! There is a lot of helpful information within those links.Tissot replica watches

    July 28, 2010 | Unregistered Commenterreplica watches

    PostPost a New Comment

    Enter your information below to add a new comment.

    My response is on my own website »
    Author Email (optional):
    Author URL (optional):
    Post:
     
    Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
    « Django, Nginx + Memcached | Main | Why iPhone developer program and mobileme annoy me.. »