Posted by lee on January 14th, 2009
I’ve been trying to get a slider bar working recently as part of a facebook application. To get the example on the Facebook wiki working out-of-the-box was no problem.
The problems came when I wanted to create the slider bar as the result of a user clicking on an input. For some reason, Facebook only loads 3rd party Javascript (ie. mine) in the body of the page. If a user clicks a link that calls a Javascript function before the page has finished loading, the function may fail if it depends on functions kept in external Javascript files (that have not yet loaded).
Because of the complexity of Facebook pages, there is often between 1 and 5 seconds when a user may click one of my links even though the page hasn’t technically finished loading. If this happens, the user will either see a very cryptic error or nothing will happen. It’s a completely unacceptable user experience so I was forced to come up with the workaround below.
var sliderCreated = false; // can only create one slider per-page with this
function createSlider() {
if (!sliderCreated) {
try {
new slider(document.getElementById('output'), document.getElementById('count_slider'), 0, 100000, 250, document.getElementById('salary_min'), , 500);
sliderCreated = true;
} catch (error) {
// Errors may get thrown if the fbslider.js wasn't loaded quickly enough, so we wait a second
setTimeout(function() { createSlider() }, 1000);
}
}
}
This will detect any errors thrown from the creation of the slider (which relies on an external Javascript file). If an error is found, then the attempt to create the slider will occur again after a second. This has the advantage that even if the second attempt fails (if the network is very slow), it will continue to retry with a delay between each attempt.
A variable (sliderCreated) is used to detect when the slider has been successfully created. In case the link that creates the slider is still clickable after the slider is created, this variable guards against multiple sliders being spawned on the page.
It is left as an exercise to the reader to add an upper limit to the retries if required.
Posted by lee on November 16th, 2008
Ning is pants. Google groups are pretty pants.
Each offer a useful set of limited features, but if you’re trying to create a dynamic community, your creativity will hit the limits of their capabilities fairly quickly.
What should a complete modern social network look like? A social network is a collection of people with something in common to bind the group together. This could be an interest, it could be their employer, etc.
But what features should the modern social network offer, and does it exist as an out-of-the-box software package or hosted solution?
Read the rest of this entry »
Posted by lee on February 16th, 2008
As a developer, have you ever wanted to banish your fears of hard disk failure and stupid mistakes in one easy step? Did you ever consider that using a hosted version control system could do just that? It’s long been established that using a version control system is A Good Thing for software quality and developer productivity. Joel on Software goes as far as claiming it as the very first step on the path to writing good code.
Read the rest of this entry »
Posted by lee on February 11th, 2008
Once you have come up with a great idea for a Facebook application, seeing an idea all the way through its implementation can be a tricky business. Once you’ve figured out how the application is supposed to work, your design of the implementation - the strategy of how you will code up your app - is crucial to the success of your initial version.
When targeting the Facebook platform, it’s essential we consider the following seven items before we even begin to start coding:
- Access control integration
- Life cycle callbacks
- Friend tracking
- Notification map
- Invite/request positioning
- Advert usage/placement
- Your main logic!
To guarantee your app’s successful development, read on for tips and tricks about all of the above.
Read the rest of this entry »
Posted by lee on February 4th, 2008
UPDATE: Facebook have completely discontinued support for notifications.
The Facebook platform can be a very restrictive mistress at times.
The documentation for sending notifications states:
“The notification parameter is a very stripped-down set of FBML which allows only tags that result in just text and links.”
But they’re lying - it’s even more restrictive than that. At the time of writing, enclosing any text in <strong> tags will cause it to disappear from the notification! It’s unclear why developers are restricted from emaphisizing the important text in a notification. I mistakenly assumed basic stylings would be possible.