Created
May 27, 2009 11:57
-
-
Save FND/118609 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
| <html lang="en"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| <title>CSS Data Structures (proof of concept)</title> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> | |
| <script type="text/javascript"> | |
| //------------------------ | |
| (function($) { | |
| var cssObj = { | |
| ".tiddler": { | |
| border: "1px solid red", | |
| backgroundColor: "green" | |
| }, | |
| ".viewer": { | |
| border: "1px solid blue", | |
| backgroundColor: "yellow" | |
| } | |
| }; | |
| var cssRules = []; | |
| for(var selector in cssObj) { | |
| item = cssObj[selector]; | |
| var props = []; | |
| for(var prop in item) { | |
| var cssProp = prop.replace(/([A-Z])/, "-$1").toLowerCase(); // convert property name | |
| props.push(cssProp + ":" + item[prop]); | |
| } | |
| cssRules.push(selector + "{" + props.join(";") + "}"); | |
| } | |
| document.write("<pre>" + cssRules.join("\n") + "</pre>"); | |
| })(jQuery); | |
| //------------------------ | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment