<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<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/"
	>

<channel>
	<title>Visum Media</title>
	<link>http://visummedia.com/articles</link>
	<description>all about web stuff</description>
	<pubDate>Thu, 14 Dec 2006 17:29:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>PHP config.php Config</title>
		<link>http://visummedia.com/articles/php/php-configphp-config.html</link>
		<comments>http://visummedia.com/articles/php/php-configphp-config.html#comments</comments>
		<pubDate>Fri, 08 Dec 2006 06:18:26 +0000</pubDate>
		<dc:creator>josh</dc:creator>
		
	<category>PHP</category>
		<guid isPermaLink="false">http://visummedia.com/articles/php/php-configphp-config.html</guid>
		<description><![CDATA[Rather than keeping two different versions of my configuration file for a website I use the HTTP_HOST variable so PHP can figure out where it’s at and use the appropriate settings.  The HTTP_HOST environment variable returns the domain name the files are being served from.  With a simple switch case you can setup [...]]]></description>
			<content:encoded><![CDATA[<p>Rather than keeping two different versions of my configuration file for a website I use the HTTP_HOST variable so PHP can figure out where it’s at and use the appropriate settings.  The HTTP_HOST environment variable returns the domain name the files are being served from.  With a simple switch case you can setup your config so you don’t have to make any changes when going live.</p>
<p>It’s also handy if you have multiple domains parked on one pile of code.  You can utilize HTTP_HOST to brand each of them seperately.</p>
<ol class="code">
<li>$server=$_SERVER[&#8217;HTTP_HOST&#8217;];</li>
<li>switch($server) {</li>
<li class="tab2">case &#8216;localhost&#8217;:</li>
<li class="tab3">define(&#8221;CONSTANT_NAME&#8221;, &#8220;schrodinger&#8221;);</li>
<li class="tab3">break;</li>
<li class="tab2">case &#8216;www.doyouknowwhere.com&#8217;:</li>
<li class="tab2">case &#8216;doyouknowwhere.com&#8217;:</li>
<li class="tab3">define(&#8221;CONSTANT_NAME&#8221;, &#8220;schumpeter&#8221;);</li>
<li class="tab3">break;</li>
<li>}</li>
</ol>
]]></content:encoded>
			<wfw:commentRSS>http://visummedia.com/articles/php/php-configphp-config.html/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>&#60;UL&#62; walking with transition effects: unordered list loop with scriptaculous</title>
		<link>http://visummedia.com/articles/javascript/ul-walking-with-transition-effects-unordered-list-loop-with-scriptaculous.html</link>
		<comments>http://visummedia.com/articles/javascript/ul-walking-with-transition-effects-unordered-list-loop-with-scriptaculous.html#comments</comments>
		<pubDate>Fri, 08 Dec 2006 01:20:05 +0000</pubDate>
		<dc:creator>josh</dc:creator>
		
	<category>JavaScript</category>
		<guid isPermaLink="false">http://visummedia.com/articles/javascript/ul-walking-with-transition-effects-unordered-list-loop-with-scriptaculous.html</guid>
		<description><![CDATA[To iterate over a &#60;ul&#62; list of items I wrote up the following javascript code.  It requires both the prototype &#038; scriptaculous javascript libraries and takes advantage of scriptaculous&#8217;s combination effects: Appear, Fade, Puff, BlindDown, BlindUp, SwitchOff, SlideDown, SlideUp, DropOut, Squish, Fold, Grow, and Shrink.
It&#8217;s envoked as follows where &#8216;list-ID&#8217; is the ID attribute [...]]]></description>
			<content:encoded><![CDATA[<p>To iterate over a &lt;ul&gt; list of items I wrote up the following javascript code.  It requires both the prototype &#038; scriptaculous javascript libraries and takes advantage of <a href="http://wiki.script.aculo.us/scriptaculous/show/CombinationEffectsDemo">scriptaculous&#8217;s combination effects</a>: Appear, Fade, Puff, BlindDown, BlindUp, SwitchOff, SlideDown, SlideUp, DropOut, Squish, Fold, Grow, and Shrink.</p>
<p>It&#8217;s envoked as follows where &#8216;list-ID&#8217; is the ID attribute of the list, &#8216;Effect-Hide&#8217; is the scriptaculous disappear effect (such as Fade), &#8216;Effect-Show&#8217; is the appear effect (such as Appear), and Time-Interval is the length of time to show the &lt;li&gt; item before moving on to the next one.</p>
<ol class="code">
<li>walkList(list-ID, Effect-Hide, Effect-Show, Time-Interval);</li>
</ol>
<p>So, here is the walkList Function.  It adds an onload event, using addEvent which I borrowed from <a href="http://www.scottandrew.com/weblog/articles/cbs-events">Scott Andrew</a>, to first hide all the list items using hideAll(list-ID) then initiates the list iteration with startWalking</p>
<ol class="code">
<li>function walkList(listID,eff1,eff2,intval) {</li>
<li class="tab2">addEvent(window, &#8216;load&#8217;, function() {</li>
<li class="tab3">hideAll(listID);</li>
<li class="tab3">startWalking(listID, eff1, eff2, intval); </li>
<li class="tab2">}, false);</li>
<li>}</li>
</ol>
<p>hideAll gets the list items, loops through, setting each to &#8216; dispay=&#8221;none&#8221; &#8216; to hide them all</p>
<ol class="code">
<li>function hideAll(listID) {</li>
<li class="tab2">var ul =$(listID).getElementsByTagName(&#8221;LI&#8221;);</li>
<li class="tab2">for(var i=0;i<br />
<ul.length;i++) {</li>
<li class="tab3">ul[i].style.display=&#8217;none&#8217;;</li>
<li class="tab2">}</li>
<li>}</li>
</ol>
<p>startWalking applies the specified hide effect to one item and a show effect to the next one.  Then uses setTimeout to schedule the next transition.</p>
<ol class="code">
<li>var showNum = 0;</li>
<li>var hideNum = 0;</li>
<li>function startWalking(listID, eff1, eff2, intval) {</li>
<li class="tab2">var ul =$(listID).getElementsByTagName(&#8221;LI&#8221;);</li>
<li class="tab2">eval(&#8217;Effect.&#8217;+eff1+&#8217;(ul[hideNum].id,{duration:.3});&#8217;);</li>
<li class="tab2">eval(&#8221;window.setTimeout(\&#8217;Effect.&#8221;+eff2+&#8221;(\&#8221;"+ul[showNum].id+&#8221;\&#8221;)\&#8217;,1000);&#8221;);</li>
<li class="tab2">hideNum = showNum;</li>
<li class="tab2">if(showNum == (ul.length-1)) {</li>
<li class="tab3">showNum=0;</li>
<li class="tab2">}</li>
<li class="tab2">else showNum++;</li>
<li class="tab2">setTimeout(&#8217;startWalking(\'&#8217;+listID+&#8217;\',\'&#8217;+eff1+&#8217;\',\'&#8217;+eff2+&#8217;\',&#8217;+intval+&#8217;)',intval);</li>
<li>}</li>
</ol>
<p>Here is the <a href="http://visummedia.com/demo/ullist.html">demo</a></p>
]]></content:encoded>
			<wfw:commentRSS>http://visummedia.com/articles/javascript/ul-walking-with-transition-effects-unordered-list-loop-with-scriptaculous.html/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Populate a form with AJAX</title>
		<link>http://visummedia.com/articles/javascript/populate-a-form-with-ajax.html</link>
		<comments>http://visummedia.com/articles/javascript/populate-a-form-with-ajax.html#comments</comments>
		<pubDate>Tue, 07 Nov 2006 09:20:44 +0000</pubDate>
		<dc:creator>josh</dc:creator>
		
	<category>JavaScript</category>
		<guid isPermaLink="false">http://visummedia.com/articles/javascript/populate-a-form-with-ajax.html</guid>
		<description><![CDATA[To fill in a forms&#8217; fields without reloading the page I used prototype&#8217;s handy Ajax.Updater class, called from an onclick event with the database row key as a parameter, to request the data.

function loadUpdate(id) {
new Ajax.Updater('&#8217;,'item.php?action=get&#038;id=&#8217;+id, {asynchronous:true, onSuccess:populateForm});
}

Used a PHP script in the item.php file to return the requested data in XML formatted as follows. [...]]]></description>
			<content:encoded><![CDATA[<p>To fill in a forms&#8217; fields without reloading the page I used <a href="http://prototype.conio.net/" title="prototype javascript framework">prototype&#8217;s</a> handy <a href="http://www.sergiopereira.com/articles/prototype.js.html#Ajax.Updater" title="ajax updater reference">Ajax.Updater</a> class, called from an onclick event with the database row key as a parameter, to request the data.</p>
<ol class="code">
<li>function loadUpdate(id) {</li>
<li class="tab">new Ajax.Updater('&#8217;,'item.php?action=get&#038;id=&#8217;+id, {asynchronous:true, onSuccess:populateForm});</li>
<li>}</li>
</ol>
<p>Used a PHP script in the item.php file to return the requested data in XML formatted as follows. Where id, fieldname, &amp; anotherfieldname all correlate to the forms element id&#8217;s and 1, field value, &amp; another field value are the data we&#8217;ll populate them with.</p>
<ol class="code">
<li>&lt;xmlresponse&gt;&lt;results&gt;</li>
<li class="tab">&lt;row&gt;</li>
<li class="tab2">&lt;id&gt;1&lt;/id&gt;</li>
<li class="tab2">&lt;fieldname&gt;field value&lt;/fieldname&gt;</li>
<li class="tab2">&lt;anotherfieldname&gt;another field value&lt;/anotherfieldname&gt;</li>
<li class="tab">&lt;/row&gt;</li>
<li>&lt;/results&gt;&lt;/xmlresponse&gt;</li>
</ol>
<p>Then used the populateForm function, referenced in the onSuccess parameter of the above mentioned loadUpdate(id) function, to parse the XML and assign each node to the correct form element</p>
<ol class="code" style="height:250px;overflow:auto;">
<li>var FORMNAME = &#8220;formname&#8221;;</li>
<li>var populateForm = function LoadEditLink_Callback(str) {  </li>
<li class="tab">var xmlResponse = str.responseXML;</li>
<li class="tab">var results = xmlResponse.getElementsByTagName(&#8217;row&#8217;)[0];</li>
<li class="tab">for(var i=0;i&lt;results.childNodes.length;i++) {</li>
<li class="tab2">var el = $(results.childNodes[i].nodeName);</li>
<li class="tab2">switch(el.type) {</li>
<li class="tab3">case &#8216;text&#8217;:</li>
<li class="tab4">el.value = results.childNodes[i].firstChild.data;</li>
<li class="tab4">break;</li>
<li class="tab3">case &#8217;select-one&#8217;:</li>
<li class="tab4">for(var j=0; j&lt;el.length;j++) {</li>
<li class="tab5">if (el.options[j].value == results.childNodes[i].firstChild.data) {</li>
<li class="tab6">el.selectedIndex = j;</li>
<li class="tab5">}</li>
<li class="tab4">}</li>
<li class="tab4">break;</li>
<li class="tab3">case &#8217;select-multiple&#8217;:</li>
<li class="tab4">var values = results.childNodes[i].firstChild.data.split(&#8221;,&#8221;);</li>
<li class="tab4">for(var j=0; j&lt;el.length;j++) {</li>
<li class="tab5">el.options[j].selected = false;</li>
<li class="tab5">for(var k=0;k&lt;values.length;k++){</li>
<li class="tab6">if (el.options[j].value == values[k]) {</li>
<li class="tab7">el.options[j].selected = true;</li>
<li class="tab6">}</li>
<li class="tab5">}</li>
<li class="tab4">}</li>
<li class="tab4">break;</li>
<li class="tab3">case &#8216;checkbox&#8217;:</li>
<li class="tab4">var values = results.childNodes[i].firstChild.data.split(&#8221;,&#8221;);</li>
<li class="tab4">var checkbox = Form.getInputs(FORMNAME, &#8216;checkbox&#8217;, results.childNodes[i].nodeName);</li>
<li class="tab4">for(var j=0;j&lt;checkbox.length;j++) {</li>
<li class="tab5"> checkbox[j].checked = false;</li>
<li class="tab5">for(var k=0;k&lt;values.length;k++){</li>
<li class="tab6">if(checkbox[j].value == values[k]) {</li>
<li class="tab7">checkbox[j].checked = true;</li>
<li class="tab6">}</li>
<li class="tab5">}</li>
<li class="tab4">}</li>
<li class="tab4">break;</li>
<li class="tab3">case &#8216;radio&#8217;:</li>
<li class="tab4">var radio = Form.getInputs(FORMNAME, &#8216;radio&#8217;, results.childNodes[i].nodeName);</li>
<li class="tab4">for(var j=0;j&lt;radio.length;j++) {</li>
<li class="tab5">if(radio[j].value == results.childNodes[i].firstChild.data) {</li>
<li class="tab6">radio[j].checked = true;</li>
<li class="tab5">}</li>
<li class="tab4">}</li>
<li class="tab4">break;</li>
<li class="tab3">case &#8216;textarea&#8217;:</li>
<li class="tab4">el.value = results.childNodes[i].firstChild.data;</li>
<li class="tab4">break;</li>
<li class="tab3">case &#8216;hidden&#8217;:</li>
<li class="tab4">el.value = results.childNodes[i].firstChild.data;</li>
<li class="tab4">break;</li>
<li class="tab2">}</li>
<li class="tab">}</li>
<li>}</li>
</ol>
<p>So, <a href="http://visummedia.com/demo/popajaxform.php" title="ajax form demo" target="_blank">here is a demo</a>. I&#8217;ve tested it in ie7 and Firefox 1.5.0.7, not sure how it works in other browsers.<br/><br />
You can download the full source <a href="http://visummedia.com/demo/popajaxform.zip" title="ajax form source">here</a>
</p>
]]></content:encoded>
			<wfw:commentRSS>http://visummedia.com/articles/javascript/populate-a-form-with-ajax.html/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>CSS Image Links</title>
		<link>http://visummedia.com/articles/css/css-image-links.html</link>
		<comments>http://visummedia.com/articles/css/css-image-links.html#comments</comments>
		<pubDate>Mon, 02 Oct 2006 21:54:37 +0000</pubDate>
		<dc:creator>josh</dc:creator>
		
	<category>css</category>
		<guid isPermaLink="false">http://visummedia.com/articles/uncategorized/css-image-links.html</guid>
		<description><![CDATA[I&#8217;ve used CSS to turn a list into a navigation bar and really like how clean and simple the resulting html code is.  When there is only one link, for say a button, I use the following code to get an image link with a hover effect:
CODE:

&#60;a href=&#8221;more.php&#8221; id=&#8221;btn-more&#8221; &#62;&#60;b&#62;learn more&#60;/b&#62;&#60;/a&#62;
&#160;
#btn-more {
 background: url(&#8221;../_images/btn-more.gif&#8221;) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve used CSS to turn <a title="css list to nav bar" href="http://www.456bereastreet.com/archive/200501/turning_a_list_into_a_navigation_bar/">a list into a navigation bar</a> and really like how clean and simple the resulting html code is.  When there is only one link, for say a button, I use the following code to get an image link with a hover effect:<br/><br />
CODE:</p>
<ol class="code">
<li>&lt;a href=&#8221;more.php&#8221; id=&#8221;btn-more&#8221; &gt;&lt;b&gt;learn more&lt;/b&gt;&lt;/a&gt;</li>
<li>&nbsp;<br/></li>
<li>#btn-more {</li>
<li class="tab"> background: url(&#8221;../_images/btn-more.gif&#8221;) no-repeat;</li>
<li class="tab"> width:75px; /* the width of your button image */</li>
<li class="tab"> height:21px; /* half the height of your image */</li>
<li class="tab"> display:block;</li>
<li class="tab"> text-decoration:none;</li>
<li> }</li>
<li>a:hover#btn-more {</li>
<li class="tab"> background-position: 0 -21px;</li>
<li> }</li>
<li>#btn-more b {</li>
<li class="tab"> display:none;</li>
<li> }</li>
</ol>
<p>For the image I made a GIF with both the normal and over button states <br/><img src="/_images/btn-more.gif"/> <br/><br />
and here is the final link: <a href="" id="btn-more"><b>learn more</b></a> </p>
]]></content:encoded>
			<wfw:commentRSS>http://visummedia.com/articles/css/css-image-links.html/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
