Javascript (15)

Postcode Anywhere Address Lookup Callback

The new Postcode Anywhere configurator is easy to setup, mapping their address fields to your form fields is as easy as using a nice simple interface – the greatest of ease! Trouble is with this way, there is no way of using a callback i.e when i have successfully selected an address from the select […]

jQuery UI slider change step above certain values

I needed a way to change the step increments on my jQuery UI slider when the value was above a certain number. For instance, I have a range slider from £0 – £2000. Steps of £10 increments are needed until the user slides up to £200, where the step should change to £100 increments. jQuery […]

google map pin not centered when using hidden embedded iframe

A bit of an issue this lately when embedding google maps iframes that are hidden by default, and are shown by the user clicking a button (for example). Seems the Google map pin not centered when using hidden embedded iframes… The pins end up not quite centered and out of the viewable area, took me […]

strip non alphanumeric characters using javascript

When entering text into a form input or textarea, you may want to remove anything that is not a letter or a number, or indeed a hyphen.We can strip non alphanumeric characters using javascript. The code snippet below will replace anything that is not: a through z, A through Z, and a hyphen (-) So, […]

convert text to links

to convert text containing unlinked URLs, use the follosing javascript function: [code]function convertLinks(t) { var urlRegExp = /((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w\/_\.]*(\?\S+)?)?)?)/gm; var u = t.replace(urlRegExp, ‘<a href="$1">$1</a>’); return u; }[/code]

display latest tweet

to display the latest tweet: [code] $.getJSON("", function(data) { $("#tweetWrap").html(data[0].text); }); [/code] the above, however, does not work if you need to get retweets etc, the following URL is slightly different (the api. and /1/ parts) and does include retweets etc: [code] $.getJSON("", function(data) { if ( data[0] != undefined ) { $("#tweetWrap").html(convertLinks(data[0].text)); } else […]