Wednesday, October 20, 2010

Text Flow in Columns (CSS, HTML, JS)

I was helping someone get some text to automatically overflow into adjoining columns. Much like a news paper. This is possible to do at run time with simply some javascript.
   1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   2: "http://www.w3.org/TR/html4/loose.dtd">
   3: <html xmlns="http://www.w3.org/1999/xhtml">
   4:     <head>
   5:         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   6:         <title>Text Flow</title>
   7:         <!--jq UI -->
   8:         <link rel="stylesheet" type="text/css" href="./lib/lightness/jquery-ui-1.8.5.custom.css" />
   9:         <!-- jQuery -->
  10:         <script type="text/javascript" src="./lib/jquery/jquery-1.4.2.min.js"></script>
   1:  
   2:         <script type="text/javascript" src="./lib/jquery/jquery-ui-1.8.5.custom.min.js">
   1: </script>
   2:         <!-- Custom JS-->
   3:         <script type="text/javascript" src="./lib/app-js/text-flow.js">
</script>
  11:  
  12:         <style>
  13:             #container {
  14:                 width:1024px;
  15:             }
  16:             
  17:         </style>
  18:     </head>
  19:     <body>
  20:         <p>
  21:             <div id="container">
  22:                 <div id="flow-container"></div>
  23:                 <div id="flow-button-container"></div>
  24:                 <div id="text-container">
  25:                     <h2>What is it?</h2>
  26:                     <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  27:                     
  28:                     <h2>Why do we use it?</h2>
  29:                     
  30:                     <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
  31:                      
  32:                     <h2>Where does it come from?</h2>
  33:                     
  34:                     <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
  35:                     
  36:                     <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>
  37:                     
  38:                     <h2>Where can I get some?</h2>
  39:                     <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>
  40:                 </div>    
  41:             </div>
  42:         </p>        
  43:     </body>
  44: </html>

Sunday, October 10, 2010

Javascript Singleton

I was working on something that required a store of arrays returned from an ajax call; so I came up with the following snippet of code.

I don’t think I words explain it better than the code below.

Saturday, October 09, 2010

Optimized vs Unoptimized JSON Return in CFML

I was writing a test script for returning some user-data to a UI client. The client expected a return in two formats in different places: 1. A jqGrid to display a datagrid of users and 2. for a config object that expected data in name value pairs.

Using cfml as the middle tier makes life so easy. I banged out a simple cfml script.

Saturday, October 02, 2010

Take that Times-of-India

Download & Rate latest version from Adobe Marketplace: http://www.adobe.com/cfusion/marketplace/index.cfm?event=marketplace.offering&offeringID=19225


I read the almost every morning. I like to consume the news and the rest of the “masala”  with my “Cup’O Joe”. However, people running the newspaper’s electronic version seem to have forgotten that they are in the business of delivering news and not advertisements (…purely from a consumer point of view). I am aware there are ads everywhere, but nytimes.com, wsj.com, they do it “unobtrusively”.
Why don’t you try, TOI?
TimesOfIndia_normal