Jump to content

Does anyone know about makeLinks()?


melting_dog

Recommended Posts

Hi all,

 

I have been experimenting with a JQuery Twitter Plugin. In it, is has this line:

 

//place the tweet within a paragraph tag within the main div.

holder.append("<p>"+item.text.makeLinks()+"</p>");

 

Now, that makes sense: It simply puts the Tweet in paragraph tags and appends it to the holder. But I am unsure of what makeLinks() does. In fact it causes an error:

 

Uncaught TypeError: Object Tweet text blah blah blah http://t.co/W6GNA4ps has no method 'makeLinks'

 

If I remove the makeLinks() it runs fine but any links in the tweet to it do not work.

 

Heres the full code:

 

(function($){
//Creating Function called Twitterize
    $.fn.twitterize = function(username,options){
 //check to see if the username has been set.
        if (username){
            //create an object full of default settings.
            var defaultSettings = {
                count:'1'
            }
           // Finds which default settings have been overwritten by the options object
            // and creates a new object with all the new and untouched settings.
            var settings = $.extend(defaultSettings, options);
			 // The URL for the Twitter JSON API.
            		var url = "http://twitter.com/status/user_timeline/"+username+".json?count="+settings.count+"&callback=?";
            		//Variable to get around scope problem in callback function.
    	        var holder = this;
            		//Contact Twitter
	            $.getJSON(url,
        		    //This function is called when twitter responds with the appropriate information.
	            function(data){
        		        //Step through each tweet.
                		$.each(data, function(i, item) {
	                    //place the tweet within a paragraph tag within the main div.
        		            holder.append("<p>"+item.text.makeLinks()+"</p>");
                });
            });  
        }
	else{
            //Username paramater has not been set.
            console.debug("jquery plugin twitterize requires a username! Check your parameters");
        }
        //Return itself
        return this;
    };//END TWITTERIZE    
})(jQuery);

 

Any help would be appreciate!

Link to comment
Share on other sites

makeLinks is not a standard JavaScript function, you cannot pass functions through JSON so it's not coming from Twitter, and there is no attempt to bind item.text.makeLinks to a function in that code.  The only way I could possible see this working is if the plugin author had bound makeLinks to the string prototype, but that's not done in the code either.

 

The plugin is either incomplete or has a dependency on some external library that you don't have.  You might want to check to see if the plugin author has a working demonstration of this script, as it would show you where makeLinks is defined.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.