<?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>CAIH.org &#187; alpha</title>
	<atom:link href="http://caih.org/tag/alpha/feed/" rel="self" type="application/rss+xml" />
	<link>http://caih.org</link>
	<description>Movies, life and python</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:23:55 +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>Tri-state checkbox in JavaScript</title>
		<link>http://caih.org/open-source-software/tri-state-checkbox-in-javascript/</link>
		<comments>http://caih.org/open-source-software/tri-state-checkbox-in-javascript/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 00:52:28 +0000</pubDate>
		<dc:creator>César Izurieta</dc:creator>
				<category><![CDATA[Open Source Software]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tri-state]]></category>

		<guid isPermaLink="false">http://caih.org/?p=155</guid>
		<description><![CDATA[I found myself needing to implement a tri-state checkbox in javascript. A checkbox has initially 2 states: on or off. From the html perspective if the checkbox is checked then the value is submitted, if it is not then the value is not submitted. From the javascript perspective you can use: if &#40;checkbox.checked&#41; &#123; &#160; [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I found myself needing to implement a tri-state checkbox in javascript. A checkbox has initially 2 states: on or off. From the html perspective if the checkbox is checked then the value is submitted, if it is not then the value is not submitted. From the javascript perspective you can use:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checkbox.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;This checkbox is checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Some times a true or false is not enough. Other development platforms have tri-state checkboxes that can have either a true, false or null value. The following snippet adds a &#8220;greyable&#8221; functionality to checkboxes:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Element.<span style="color: #660066;">addMethods</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;INPUT&quot;</span><span style="color: #339933;">,</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><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> changeHandler <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">greyed</span> <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setGreyed</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">greyed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">greyed</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">checked</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> setGreyed<span style="color: #009900;">&#40;</span>checkbox<span style="color: #339933;">,</span> greyed<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; checkbox.<span style="color: #660066;">greyed</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">typeof</span> greyed <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;undefined&quot;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #339933;">!!</span>greyed<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; checkbox.<span style="color: #660066;">setOpacity</span><span style="color: #009900;">&#40;</span>checkbox.<span style="color: #660066;">greyed</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">0.33</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checkbox.<span style="color: #660066;">greyed</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; checkbox.<span style="color: #660066;">checked</span> <span style="color: #339933;">=</span> checkbox.<span style="color: #660066;">greyedState</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> setGreyable<span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> enable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>element <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/checkbox|radiobutton/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>element.<span style="color: #660066;">type</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> element.<span style="color: #660066;">greyedState</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;undefined&quot;</span> <span style="color: #339933;">||</span> enable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #339933;">,</span> changeHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">setGreyState</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">setGreyed</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">stopObserving</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #339933;">,</span> changeHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">setGreyed</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">checked</span> <span style="color: #339933;">=</span> element.<span style="color: #660066;">greyedState</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">greyedState</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">greyed</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> setGreyState<span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> greyedState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>element <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/checkbox|radiobutton/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>element.<span style="color: #660066;">type</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #660066;">greyedState</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">typeof</span> greyedState <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;undefined&quot;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">!!</span>greyedState<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setGreyed<span style="color: #339933;">:</span> setGreyed<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setGreyable<span style="color: #339933;">:</span> setGreyable<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setGreyState<span style="color: #339933;">:</span> setGreyState<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>This currently requires <a href="http://www.prototypejs.org" target="_blank">prototypejs</a> but could be easily modified to not depend on it. To enable it on some element do something like this:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">checkbox.<span style="color: #660066;">setGreyable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>To check if it is greyed or not:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checkbox.<span style="color: #660066;">greyed</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;This checkbox is greyed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>You can also change the state of the checkbox when it is greyed. To set this use the following:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">checkbox.<span style="color: #660066;">setGreyState</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>The parameter indicates whether the checkbox is checked when grey. Clicking on the checkbox (or changing the state by keyboard) loops through 3 states: checked, not checked and greyed.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://caih.org/open-source-software/tri-state-checkbox-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sectum: optimizing glass cutting</title>
		<link>http://caih.org/open-source-software/sectum/sectum-optimizing-glass-cutting/</link>
		<comments>http://caih.org/open-source-software/sectum/sectum-optimizing-glass-cutting/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 05:13:43 +0000</pubDate>
		<dc:creator>César Izurieta</dc:creator>
				<category><![CDATA[sectum]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://caih.org/?p=3</guid>
		<description><![CDATA[I&#8217;m starting a new project. The problem I need to address is now glass cutting and how to optimize a set of cuts to satisfy an order of cut glass sheets. The algorithm I used is the following: Get the largest piece of material from the order. Get the smallest piece of material from the [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m starting a new <a title="Sectum" href="http://sectum.googlecode.com" target="_blank">project</a>. The problem I need to address is now glass cutting and how to optimize a set of cuts to satisfy an order of cut glass sheets. The algorithm I used is the following:</p>
<ol>
<li>Get the largest piece of material from the order.</li>
<li>Get the smallest piece of material from the available material that can contain the ordered piece.</li>
<li>Cut.</li>
<li>Repeat the process.</li>
</ol>
<p>It seems to be working just fine for a large set of examples. I cannot find some example where it would fail to produce the best result. There were some constraints I had to take into account.</p>
<ul>
<li>Cuts should always be done from side to side on the available material and the cuts should be done perpendicular to the largest of the sides of the material whenever possible.</li>
<li>Each cut should be independent of the previous cuts and sequential in case there&#8217;s a glass breaking or anything else. In that case the cuts should be able to be &#8220;replayed&#8221; from the failure point forward after doing the correction.</li>
</ul>
<p>Here&#8217;s an image of the result.</p>
<div id="attachment_4" class="wp-caption aligncenter" style="width: 310px"><a href="http://caih.org/wp-content/uploads/2009/01/result-10.png" rel="shadowbox[post-3];player=img;"><img class="size-medium wp-image-4 " title="Cutting instructions." src="http://caih.org/wp-content/uploads/2009/01/result-10-300x228.png" alt="The 10th cut as calculated by sectum." width="300" height="228" /></a><p class="wp-caption-text">The 10th cut as calculated by sectum.</p></div>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://caih.org/open-source-software/sectum/sectum-optimizing-glass-cutting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
