javascript

Make FQL queries using Facebook Javascript API

This allows me to use the Facebook JavaScript API to make a FQL multi-query.

query = {"query1":"SELECT ...", "query2":"SELECT ....", "queryname":"SELECT ..."};
 
FB.api(‘/fql’, {‘q’:query}, function (response) {
  // handle response.
  // each named  query will have the name in  the response obj.
});

Clean html for content pasted from Word into YUI rich text editor

I’ve been trying to come up with a good way to strip out crappy HTML pasted from MS Word into the Yahoo UI’s rich text editor. Thankfully I am not the only person with this problem and my procrastination pays off! Somebody else created a script to do it for me.

AntsCode has a nice tool to Strip Formatting on Paste using YUI Rich Text Editor

His solution is so simple I feel stupid for not thinking of it. He attaches a listener for the cut and paste command. When you paste into the Rich Text Editor it uses the standard YUI HTML stripper, then he goes in and strips out the unwanted word HTML formatting using a series of regular expressions. Clever.

Hide/show table rows using JavaScript

I wanted have a HTML table where toggle the visibility of its rows (TR elements) using display:block. This is wrong. You need to use display:table-row.

Without using the table-row property, the TR will not have the proper column widths. This is a problem when using Firefox or other Gecko-based browser.

Improper vs. Improper way to hide or show a TR element using javascript.

Sample Table

<table>
<tr id="showme" style="display:none"> <td>I am in a row</td>
</tr>
</table>

test = document.getElementById("showme");
test.style.display = ‘block’; //wrong
test.style.display = ‘table-row’; //correct
Syndicate content