<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6383044476205366608</id><updated>2011-04-21T13:20:02.300-07:00</updated><title type='text'>TAD: Coding for fun</title><subtitle type='html'>Some silly code related snippets, some size optimization stuff and other general tips and tricks with Javascript.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://taduk.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6383044476205366608/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://taduk.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>TAD_UK</name><uri>http://www.blogger.com/profile/14854403280386959490</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6383044476205366608.post-2018410538854455771</id><published>2007-08-21T14:17:00.000-07:00</published><updated>2007-08-21T14:38:50.080-07:00</updated><title type='text'>Easy storage of css properties using Javascript</title><content type='html'>For some time I've been looking at how to parse and store a raw css file in javascript, asking questions like should I use an xml document or nested arrays or some long list of nested custom objects? These three techniques are all valid but none ideal.&lt;br /&gt;&lt;br /&gt;Well, tonight I had the idea, which I'll share with the world now. The simplicity and easy of implementation makes it look like a worthy place to invest some time and energy.&lt;br /&gt;&lt;br /&gt;Take the following example &lt;strong&gt;css&lt;/strong&gt; snippet:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="font-family:courier new;"&gt;#nav {&lt;br /&gt;font-size: 12px;&lt;br /&gt;color: #f00;&lt;br /&gt;border: 1px solid #000;&lt;br /&gt;margin: 4px;&lt;br /&gt;} &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Well, which storage method is the best candidate for the complexity of nested css rules and statements?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;JSON. (JavaScript Object Notation)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We can easily describe the above css snippet using Javascript:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#3366ff;"&gt;var csstest = {"#nav": {"font-size":"12px;", "color":"#f00;","border":"1px solid #000;","margin":"4px;"}};&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;color:#3366ff;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3366ff;"&gt;alert(csstest["#nav"]["font-size"]);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;In fact, its spooky how similiar CSS and JSON are considering the fact they're used for completely different purposes.  Apart from the obvious need for ("...") quotes the format looks very compact, ideal for other processing inside JavaScript itself.&lt;br /&gt;&lt;br /&gt;Have fun with parsing css and JSON.&lt;br /&gt;&lt;br /&gt;Enjoy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6383044476205366608-2018410538854455771?l=taduk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://taduk.blogspot.com/feeds/2018410538854455771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6383044476205366608&amp;postID=2018410538854455771' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6383044476205366608/posts/default/2018410538854455771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6383044476205366608/posts/default/2018410538854455771'/><link rel='alternate' type='text/html' href='http://taduk.blogspot.com/2007/08/easy-storage-of-css-properties-using.html' title='Easy storage of css properties using Javascript'/><author><name>TAD_UK</name><uri>http://www.blogger.com/profile/14854403280386959490</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6383044476205366608.post-99398135179737986</id><published>2007-08-20T10:58:00.000-07:00</published><updated>2007-08-20T11:10:47.876-07:00</updated><title type='text'>A compact Javascript multi onload function</title><content type='html'>Theres plenty of other javascript snippets to allow multiple 'onload' events on the net, but probably none as small as this.&lt;br /&gt;&lt;br /&gt;Heres a little example with the magic function&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&amp;lt;script&amp;gt;&lt;br /&gt;function Multi(f){var o=window.onload;window.onload=function(){o?o():o;f()}}&lt;br /&gt;&lt;br /&gt;//the old way ;)&lt;br /&gt;window.onload = function() {alert("onload!");}&lt;br /&gt;//example :)&lt;br /&gt;new Multi(function() {alert('second');});&lt;br /&gt;new Multi(function() {alert('three');});&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6383044476205366608-99398135179737986?l=taduk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://taduk.blogspot.com/feeds/99398135179737986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6383044476205366608&amp;postID=99398135179737986' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6383044476205366608/posts/default/99398135179737986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6383044476205366608/posts/default/99398135179737986'/><link rel='alternate' type='text/html' href='http://taduk.blogspot.com/2007/08/compact-javascript-multi-onload.html' title='A compact Javascript multi onload function'/><author><name>TAD_UK</name><uri>http://www.blogger.com/profile/14854403280386959490</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
