<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UnDeprived &#187; javascript</title>
	<atom:link href="http://www.un-deprived.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.un-deprived.com</link>
	<description>A webdev journal of the Moninator</description>
	<lastBuildDate>Fri, 30 Jul 2010 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>jQuery CSV2Table — Modified</title>
		<link>http://www.un-deprived.com/2009/webdev/jquery-csv2table-modified/</link>
		<comments>http://www.un-deprived.com/2009/webdev/jquery-csv2table-modified/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 23:02:10 +0000</pubDate>
		<dc:creator>Mon</dc:creator>
				<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[CSV2Table]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jquery Journal]]></category>
		<category><![CDATA[jQuery Plugins]]></category>

		<guid isPermaLink="false">http://www.un-deprived.com/?p=399</guid>
		<description><![CDATA[Version in this article: jQuery 1.3.2 / CSV2Table 0.03-b-2.9 Lately I started to like CSV (Common Separated Values) more and more comparing to XML.XML is a pain to setup even as entering data, then grabbing the data requires Einstein’s brain plus 3 sleepless and hair-pulling days of coding… okay, I maybe exaggerated a bit, but [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Version in this article: jQuery 1.3.2 / CSV2Table 0.03-b-2.9</p>
<p>Lately I started to like CSV (Common Separated Values) more and more comparing to XML.XML is a pain to setup even as entering data, then grabbing the data requires Einstein’s brain plus 3  sleepless and hair-pulling days of coding… okay, I maybe exaggerated a bit, but that’s how I feel about XML. My first encounter with CSV was InDesign, in there, you can import a bunch of data and generates PDF like Word’s Mail Merge feature. Then one day, someone asked me if I can find a better and easier way to help the non web people to maintain a site. I started out with search terms like “jQuery read text files” or something like that, one of the results returned as using CSV and there is a plugin called <a href="http://jsgt.org/lib/jquery/plugin/csv2table/v002/test.htm" target="_blank">CSV2Table</a> in the jQuery Plugins website by Toshiro Takahashi written earlier this year. Testing… <span id="more-399"></span>testing… and hot damned! It’s like magic!!!</p>
<p>The awesome thing about CSV is you can enter all the data using Excel, then simply save the file as something.csv and it’s ready to be used. No stupid header &lt;xml&gt;&lt;/xml&gt; tags, inner tags, child tags or whatever the heck tags. Just simple data. If you really, really want to be fancy; you can even add HTML such as &lt;img&gt; – believe it not, it worked like a charm. Although, it’s silly to format your CSV data within while you have your hands on the god-awsome jQuery framework to manipulate all of those data. Then to generate the table, all you simply have to do is:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">csv2table</span><span style="color: #009900;">&#40;</span>csvfile<span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span> <span style="color: #339933;">&lt;</span>em<span style="color: #339933;">&gt;</span>options<span style="color: #339933;">&lt;/</span>em<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>Well, I’m not going to get into the <em>options</em> detail but you can refer back to the <a href="http://jsgt.org/lib/jquery/plugin/csv2table/v002/test.htm#nview0" target="_blank">CSV2Table docs</a>. You can manipulate how the data display, format, colorize, draw a dragon or whatever. This plugin is very flexible when it comes to formatting the results. Some people describe me as lazy, but I like to describe myself as “efficient” because I don’t like to repeat myself or do extra work. So it doesn’t make sense to write the code above everytime I need to reuse it, that’s just not the Mon’s way, here’s Mon’s way:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	<span style="color: #003366; font-weight: bold;">function</span> csvReader<span style="color: #009900;">&#40;</span>container<span style="color: #339933;">,</span>csvfile<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span>container<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">csv2table</span><span style="color: #009900;">&#40;</span>csvfile<span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
				sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
				removeDoubleQuote <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
				nowloadingMsg<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Loading &quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#eblastsYear&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; eblasts archive...&quot;</span><span style="color: #339933;">,</span>
				errorMsg <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Error loading &quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#eblastsYear&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; eBlasts archive. Archive either doesn't exist or renamed. Please contact Mon (mlu@equuscs.com) for support.&quot;</span><span style="color: #339933;">,</span>
				<span style="color: #000066;">onload</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span>op<span style="color: #339933;">,</span>data<span style="color: #339933;">,</span>ary<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#totalEblasts&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>ary.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//Display the total rows of the eblasts</span>
					$<span style="color: #009900;">&#40;</span>container<span style="color: #339933;">+</span><span style="color: #3366CC;">' tr:even'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'#efefef'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//Every even row gets colorized</span>
					$<span style="color: #009900;">&#40;</span>container<span style="color: #339933;">+</span><span style="color: #3366CC;">' th'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;text-align&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//Just setting the TH rows will be left aligned</span>
				 <span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>I wrote a function that because I know I’m going to reuse the code to load the <em>exact</em> same data, just maybe the CSV file or the DIV container might be different. Instead of writing re-writing again. If I ever need it, all I have to do is:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	csvReader<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#csvContainer&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;data.csv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>Done. Now, you probably wonder, what the heck did I use it for? Well, see screenshot:</p>
<p><a href="http://www.un-deprived.com/wp-content/uploads/csv.jpg" rel="lightbox[399]" title="csv"><img class="alignnone size-medium wp-image-400" title="csv" src="http://www.un-deprived.com/wp-content/uploads/csv-171x125.jpg" alt="csv" width="171" height="125" /></a></p>
<p>So when the user clicks on “View Archive”, it loads a new CSV file like this:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#selectYear&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    csvReader<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#csv&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;eblasts/&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#eblastsYear&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.csv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>Less work = better. One  minor thing I felt missing was when the file is missing or failed to load, it just get stuck on the default “Now loading” message. I dug under the hood of the CSV2table codes, it uses $.get() to process the data which doesn’t really can tell whether the XHR request was successful or not; nor it can detect it unless you add the ajax.error() handle. So I’ve decided to change it to using the actual $.ajax() to call the data, and detect if there is a 404 error, it’ll display an error message accordingly instead of just “Loading…” – while I was at it, I felt, well, I and I’m pretty sure most people want to customize their sucessful load and error messages, right? So I added two more settings inside the plugin which are: <em>nowloadingMsg</em> and <em>errorMsg.</em> If you are so darn lazy and don’t want to customize it, it defaults to  “Now loading…” (fades out) and “CSV file not found.”. Here’s the modifications:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	op <span style="color: #339933;">=</span> $.<span style="color: #660066;">csv2table</span>.<span style="color: #660066;">setting</span><span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			url                <span style="color: #339933;">:</span> url<span style="color: #339933;">,</span>
			nowloadingImg      <span style="color: #339933;">:</span> $.<span style="color: #660066;">csv2table</span>.<span style="color: #660066;">loadImg</span><span style="color: #339933;">,</span>              <span style="color: #006600; font-style: italic;">//Image of now loading...</span>
			nowloadingMsg      <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>     						   <span style="color: #006600; font-style: italic;">//Message of now loading...</span>
			errorMsg		   <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>							   <span style="color: #006600; font-style: italic;">//Error Message</span>
       	<span style="color: #006600; font-style: italic;">// The rest of the codes...</span></pre>
</div>
</div>
<p>Do a search for “op.nowloadImg” and you’ll see “$.get()”.  I modified as follow around line 130 if you added what’s above:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	<span style="color: #006600; font-style: italic;">//Default loading message if not set in settings</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>op.<span style="color: #660066;">nowloadingMsg</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> op.<span style="color: #660066;">nowloadingMsg</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Now loading...&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    $<span style="color: #009900;">&#40;</span>contents<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'
&lt;div class=&quot;csv2table-loading&quot;&gt;&lt;img src=&quot;'</span><span style="color: #339933;">+</span>op.<span style="color: #660066;">nowloadingImg</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; alt=&quot;&quot; /&gt; '</span><span style="color: #339933;">+</span>op.<span style="color: #660066;">nowloadingMsg</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/div&gt;
'</span> <span style="color: #009900;">&#41;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//Default error message</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>op.<span style="color: #660066;">errorMsg</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> op.<span style="color: #660066;">errorMsg</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CSV file not found.&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
    $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
       type<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span>
       url<span style="color: #339933;">:</span> url<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;?&quot;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
       data<span style="color: #339933;">:</span> $.<span style="color: #660066;">csv2table</span>.<span style="color: #660066;">data</span><span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
       success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #339933;">,</span>textSatus<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.csv2table-loading&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.csv2table-loading&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         $<span style="color: #009900;">&#40;</span>contents<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>mkRowsAry<span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         setCSS<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         $<span style="color: #009900;">&#40;</span>contents<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>op.<span style="color: #660066;">use_api</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'jqchart'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>op.<span style="color: #660066;">use_api_type</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'jqchart:line'</span><span style="color: #009900;">&#41;</span>op.<span style="color: #660066;">type</span><span style="color: #339933;">=</span>$.<span style="color: #660066;">csv2table</span>.<span style="color: #660066;">setting</span><span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">type</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'line'</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>op.<span style="color: #660066;">use_api_type</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'jqchart:bar'</span><span style="color: #009900;">&#41;</span>op.<span style="color: #660066;">type</span><span style="color: #339933;">=</span>$.<span style="color: #660066;">csv2table</span>.<span style="color: #660066;">setting</span><span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">type</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'bar'</span><span style="color: #339933;">;</span>
            useChart<span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span>op<span style="color: #339933;">,</span>data<span style="color: #339933;">,</span>$.<span style="color: #660066;">csv2table</span>._rowsAry<span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">csv2table</span>.<span style="color: #660066;">setting</span><span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span>.<span style="color: #000066;">onload</span><span style="color: #009900;">&#41;</span>$.<span style="color: #660066;">csv2table</span>.<span style="color: #660066;">setting</span><span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span>.<span style="color: #000066;">onload</span><span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span>op<span style="color: #339933;">,</span>data<span style="color: #339933;">,</span>$.<span style="color: #660066;">csv2table</span>._rowsAry<span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
       error <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>xhr<span style="color: #339933;">,</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xhr.<span style="color: #000066;">status</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">404</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// page not found</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.csv2table-loading&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;csv2table_error&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>op.<span style="color: #660066;">errorMsg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>To sum it up for the CSV2Table mod, these are the changes I’ve made:</p>
<ul>
<li>2 extra settings: nowloadingMsg / errorMsg (defaults to “Now loading…” and “CSV file not found.”)</li>
<li>Changed $.get() method to $.ajax()</li>
<li>Added 1 extra CSS class: csv2table_error</li>
</ul>
<p>My modded: <a href='http://www.un-deprived.com/wp-content/uploads/jquery.csv2table-mod.js'>jquery.csv2table-mod</a><!-- PHP 5.x --></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.un-deprived.com/2009/webdev/jquery-csv2table-modified/feed/</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>Acrobat Batch Extract using Javascript</title>
		<link>http://www.un-deprived.com/2009/others/acrobat-batch-extract-using-javascript/</link>
		<comments>http://www.un-deprived.com/2009/others/acrobat-batch-extract-using-javascript/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 15:30:06 +0000</pubDate>
		<dc:creator>Mon</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[acrobat]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.un-deprived.com/?p=271</guid>
		<description><![CDATA[This was one of the old posts that got corrupted when I did a reinstall of WP 2.8.1.  Since this script is pretty handy, so I’m re-posting it. This scripts worked in Acrobat 8 &#38; 9 Pro. Instead of of manually extracting all the pages, and then manually optimize them, this script can ease the [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>This was one of the old posts that got corrupted when I did a reinstall of WP 2.8.1.  Since this script is pretty handy, so I’m re-posting it.</p>
<p>This scripts worked in Acrobat 8 &amp; 9 Pro. Instead of of manually extracting all the pages, and then manually optimize them, this script can ease the process. To access the Batch Processing menu: <em><strong>Advanced -&gt; Document Processing -&gt; Batch Processing</strong>.</em> The screen shot below shows where and how to add the script:</p>
<p><a href="http://www.un-deprived.com/wp-content/uploads/2009/08/acrobat1.jpg" rel="lightbox[271]" title="Acrobat Batch Extractions"><img class="alignnone size-medium wp-image-272" title="Acrobat Batch Extractions" src="http://www.un-deprived.com/wp-content/uploads/2009/08/acrobat1-212x125.jpg" alt="Acrobat Batch Extactions" width="212" height="125" /></a></p>
<p>Then add the following script into the “Javascript Editor”:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> filename <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">documentFileName</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.pdf&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>this.<span style="color: #660066;">numPages</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #003366; font-weight: bold;">var</span> num <span style="color: #339933;">=</span> i<span style="color: #339933;">+</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">extractPages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> nStart<span style="color: #339933;">:</span> i<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cPath<span style="color: #339933;">:</span> filename<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;_&quot;</span><span style="color: #339933;">+</span>num<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.pdf&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>cath <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> console.<span style="color: #660066;">println</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;Aborted: &quot;</span> <span style="color: #339933;">+</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Saves a lot of time if you have a lot of files to extract and need to optimized the files using custom settings.<!-- PHP 5.x --></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.un-deprived.com/2009/others/acrobat-batch-extract-using-javascript/feed/</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>Javascript: Pick a random number starting from 1</title>
		<link>http://www.un-deprived.com/2009/webdev/javascript-pick-a-random-number-starting-from-1/</link>
		<comments>http://www.un-deprived.com/2009/webdev/javascript-pick-a-random-number-starting-from-1/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 18:11:03 +0000</pubDate>
		<dc:creator>Mon</dc:creator>
				<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[random number]]></category>

		<guid isPermaLink="false">http://www.un-deprived.com/?p=253</guid>
		<description><![CDATA[Quickie note, a very simple script to pick a random number between 1–5, instead of 0–4 var rand = Math.floor&#40;Math.random&#40;&#41;*5&#41;; if&#40;rand &#38;gt; 0&#41;&#123; rand = rand+1; alert&#40;rand&#41;; &#125; else &#123; rand = 1; alert&#40;rand&#41;; &#125; No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Quickie note, a very simple script to pick a random number between 1–5, instead of 0–4</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	<span style="color: #003366; font-weight: bold;">var</span> rand <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>rand <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		rand <span style="color: #339933;">=</span> rand<span style="color: #339933;">+</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>rand<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
		rand <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>rand<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p><!-- PHP 5.x --></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.un-deprived.com/2009/webdev/javascript-pick-a-random-number-starting-from-1/feed/</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
	</channel>
</rss>
