JavaScript: edit web page in browser

Here is small bookmarklet, which allows to edit the web page for any site (ok, You could save the results on Your local machine only).

javascript:document.body.contentEditable=’true’; document.designMode=’on’; [...]

JavaScript: Soundex implementation

There is a special algorithm for comparision strings, which sound similar (Soundex).

Here is JavaScript Soundex implementation:

function soundex ( s_src )
{    
 var s_rez = "0000" ;
 var new_code, prev, idx
 
 a_codes = { "bfpv": 1, "cgjkqsxz":2, "dt": 3, "l": 4, "mn": 5, "r": 6 };
 
 s_src = s_src.toLowerCase().replace(/ /g,"")
 
 if ( s_src.length < 1) {
   return(s_rez);
 }
 
 s_rez = s_src.substr(0,1);
 prev = "0";
 
 for [...]

JavaScript: build table dynamically

<script type="text/javascript">
function buildTable(n_rows,n_columns) {

var the_body = document.getElementsByTagName("body")[0];

<code>var new_table = document.createElement("table");
var new_tbody = document.createElement("tbody");

var new_row, new_col, new_text ;

for(row=1;row<=n_rows;row++) {
new_row = document.createElement("tr");
new_row.className = "tr"+row ;
for(col=1;col<=n_columns;col++) {
new_col = document.createElement("td");
new_col.className = "td"+col ;
new_text = document.createTextNode("text:" + row + ":" + col );

new_col.appendChild(new_text);
new_row.appendChild(new_col);
}
new_tbody.appendChild(new_row);
}

new_table.appendChild(new_tbody);
new_table.setAttribute("border", "2");

the_body.appendChild(new_table);

return new_table ;

}
</script>
<body>
Example:
<script type="text/javascript">
buildTable(4,3)
</script>
</body>

There is also interesting article on oreillynet.com, discussing performance improvement for [...]

Code for adding the project to bookmarks

Add the project to del.icio.us

http://del.icio.us/post?title=www.memosoup.com&url=http://www.memosoup.com

Post a project on digg.com

http://digg.com/submit?phase=2&url=http://www.memosoup.com

Add the site to bookmarks:

function add2Bookmarks(title,url) {
  if (window.sidebar) {
   window.sidebar.addPanel(title, url,"");
 } else if( document.all ) {
    window.external.AddFavorite( url, title);
 } else if( window.opera &amp;&amp; window.print ) {
    return true;
 }
}
<a href="#" onmousedown="add2Bookmarks(‘www.memosoup.com’,'http://www.memosoup.com’)">
<img src="project.gif" alt="bookmark" border="0">
Put this site to [...]