Blog | Iron Lasso | Changing the Internet one website at a time.
Just in case you need to know how to flatten a multi dimensional array.
Recursively, although a tad more elegant this could blow your stack up if data.length === huge. ES6 fixes the recursion problem.
Recently I ran into a problem while making an events widget. Problem was, after making a bunch of Facebook Graph API requests for Facebook events some returned event objects had image urls that didn't resolve. My fix was to check each image url, see if it resolves, if it doesn't replace it with a default image. Last, after all images have been checked render the events mark up that is built with the Events data.
Gather all Image urls and make requests for them.
Generate events mark up and add it to the page.
jQuery Deferreds to the rescue.
Considering I have a bunch of Facebook events json in eventsData.
//Make a deferred array to store a jQuery deferred for every image request.
Have you used the HTML5 template tag? I have too. Seems like a really great idea. Then QA tests your project and you realize it won't work in IE. Better yet, not just IE 7 or 8, all versions of IE. Super bummer.
This was a real kick in the Jimmy.
When the user clicks a print button add an iframe to the end of the body tag.
Hide it by moving it off the view port.
Get the modal contents and load them into the iframe.
Finally tell the browser to print the iframe.
Easier said than done. Here is my final code hope this helps someone else not lose an entire Sunday. I started working from this code http://www.bennadel.com/blog/1591-ask-ben-print-part-of-a-web-page-with-jquery.htm so props to the Ben for writing and posting it. Note if you want to use this you will have change some of the jQuery selectors to suite your project.
Help! My Facebook plugin doesn't retrieve any data!
The problem may be you are trying to retrieve data from a Facebook profile rather than a Facebook page. Facebook puts much tighter restrictions on data its Graph API makes available to public profiles than it does for pages.
The reason you are not retrieving any data is because profiles limit data sharing to other profiles who are 'friends'. Profile posts and photos have permissions that govern who can access them. This means the data on profiles is not necessarily available for public consumption. Meaning, when you post on your profile wall your friends can all see your post if they are logged into Facebook, but the rest of the Internet can not. Consider a website that the whole world can see, it doesn't have permission to retrieve and display private posts that have been made between you and your friends on each others walls. There are exceptions to this rule. If you and your friends change a posts permissions to remove these restrictions, plugins and apps can use Facebooks Graph API to retrieve them.
But wait that's not all! Even with permissions set, outside sources still may not be able to retrieve posts. Consider an example post where multiple friends are mentioned or a photo where multiple friends are tagged. Just because the profile owner says it's ok for the world to see does not necessarily mean all the other friends agree. If they have not also lifted the restriction by changing the post permissions Facebook will not all the data to be returned via the API.
To increase the data you can retrieve from your Facebook profile, you have a couple of options.
This one took me a bit so thought it might be worth writing it down.
3) All characters between first and last can be a letter, number, or a non-repeating – or .
so lorenzo.gangi-test would be valid.