javascript
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
Zillow neighborhoods on Google maps
I’m working on a neighborhood-related map feature for something at work. Zillow blog released its neighborhood shape file data to the public to be able to map the boundaries on various things, most notably Google Maps.
While doing some research into the situation, this undertaking is going to be pretty complicated. A brief Google search gave me several key blogs and tools that I think will help me in this project.
notes
Trying to use shp2text. Downloaded ZIP file. Damn thing won’t compile on Mac.
make: *** No rule to make target `shapefil.h’, needed by `shpopen.o’. Stop.
Downloaded shapefile C lib. Compiled shapefile and copied chapefil.h to my shp2text dir. Damn shp2text still won’t compile. Damn Mac.
cc -g -c dbfopen.c dbfopen.c:210:24: error: safe-ctype.h: No such file or directory make: *** [dbfopen.o] Error 1
Got shp2text to compile. Found a thread that had exact same problem as me. Comment out include safe-ctype.h from the dbfopen.c file. That file is in the shp2text dir.
Now I can use shp2text to convert my .shp file into 3 formats: tab-separated value spreadsheet, GPX (XML), or geo.location (XML). I’m not sure what these are but we’ll find out soon enough.
shp2text —gpx ZillowNeighborhoods-CA.shp
To convert into GPX it asks me to choose some fields. I presume the field selection availability is pulled from the .shp file somehow.
shp2text —gpx shape_file.shp name_field# attribute_field# ;utility to dump esri shapefiles into various text formats ;you must supply two field numbers Field 0: Type=String, Title=`STATE’, Width=2, Decimals=0 Field 1: Type=String, Title=`COUNTY’, Width=43, Decimals=0 Field 2: Type=String, Title=`CITY’, Width=64, Decimals=0 Field 3: Type=String, Title=`NAME’, Width=64, Decimals=0 Field 4: Type=Double, Title=`REGIONID’, Width=32, Decimals=10
Since I want neighborhood name and city, I picked 2 and 3.
shp2text —gpx ZillowNeighborhoods-CA.shp 2 3
But it pushes everything to standard output. So I need to send it to a file…
shp2text —gpx ZillowNeighborhoods-CA.shp 2 3 > cali.xml
Now I have a GPX file cali.xml of all the neighborhoods in California. I think I can use this static file in Google maps but I’m not sure if it will give me a filled polygon or not.
The geo.location option looks promising because it specifies a geo.polyline but it does not give me metadata for the city or neighborhood name. The format is useless to me. Damn!
Recent blog posts
- Amazon S3 Website CNAME
- Button labels for checkout
- Insert html django contrib messages
- Twitter Bootstrap not working with LESS.js
- Javascript libs that offer basic subset of jquery features
- Building the donor-matic
- Playing with free Google Map alternatives.
- Some flows are not as complicated as they appear
- Form design crib sheet
- Script to get IE9 Windows Virtual PC images into Virtual Box