<?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>botsko &#187; JavaScript</title>
	<atom:link href="http://www.botsko.net/blog/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.botsko.net/blog</link>
	<description>continuing education</description>
	<lastBuildDate>Sat, 24 Jul 2010 21:42:29 +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>Currently Scheduled PCC Courses</title>
		<link>http://www.botsko.net/blog/2009/07/22/currently-scheduled-pcc-courses/</link>
		<comments>http://www.botsko.net/blog/2009/07/22/currently-scheduled-pcc-courses/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 00:12:56 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=340</guid>
		<description><![CDATA[Javascript I am currently teaching Introduction to Javascript at the PCC Mt. Tabor center in SE Portland. Classes are every Monday until August 24, and there&#8217;s still room in the course for those interested. Follow the link above to enroll. The book was already chosen as I&#8217;m essentially a substitute on this one. Despite being [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Javascript</strong><br />
I am currently teaching <a href="http://www.pcc.edu/schedule/default.cfm?fa=dspCourse2&#038;thisTerm=200903&#038;crsCode=CEU978A&#038;subjCode=CEU&#038;crsNum=978A&#038;topicCode=CWB&#038;subtopicCode=WEBDEV&#038;crnList=33452">Introduction to Javascript</a> at the PCC Mt. Tabor center in SE Portland. Classes are every Monday until August 24, and there&#8217;s still room in the course for those interested. Follow the link above to enroll.</p>
<p>The <a href="http://www.amazon.com/JavaScript-TM-Step-Steve-Suehring/dp/0735624496/ref=sr_1_1?ie=UTF8&#038;qid=1247870366&#038;sr=8-1">book</a> was already chosen as I&#8217;m essentially a substitute on this one. Despite being published by Microsoft, it covers some essential topics for developing on the web today. It even mentions Firebug (a firefox extension) so it&#8217;s nice that it&#8217;s not biased towards MSFT.</p>
<p><strong>PHP</strong><br />
In October, I will be teaching the <a href="http://www.pcc.edu/schedule/default.cfm?fa=dspCourse2&#038;thisTerm=200904&#038;crsCode=CEU9789&#038;subjCode=CEU&#038;crsNum=9789&#038;topicCode=CWB&#038;subtopicCode=WEBDEV">Introduction to PHP</a> course a bit closer to where I live and work. I have not yet selected a book, but I&#8217;m currently working on adapting Trellis internal training materials.</p>
<p>There are still spots open so go ahead and register!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2009/07/22/currently-scheduled-pcc-courses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans 6.7RC1 Crashes on Mac OS X 10.5.7</title>
		<link>http://www.botsko.net/blog/2009/06/03/netbeans-67rc1-crashes-on-mac-os-x-1057/</link>
		<comments>http://www.botsko.net/blog/2009/06/03/netbeans-67rc1-crashes-on-mac-os-x-1057/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 23:48:43 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=313</guid>
		<description><![CDATA[After an hour of searching, I found that the problem for me was that java 1.5 on mac was forcing netbeans to run in 64bit mode which was causing it to crash before it even opened. By following the instructions (reposted with more info) at http://blogs.sun.com/yakshaving/entry/netbeans_will_not_start_on) I was able to get things resolved. As far [...]]]></description>
			<content:encoded><![CDATA[<p>After an hour of searching, I found that the problem for me was that java 1.5 on mac was forcing netbeans to run in 64bit mode which was causing it to crash before it even opened.</p>
<p>By following the instructions (reposted with more info) at <a href="http://blogs.sun.com/yakshaving/entry/netbeans_will_not_start_on">http://blogs.sun.com/yakshaving/entry/netbeans_will_not_start_on</a>) I was able to get things resolved. As far as I can tell, I have not affected anything else I have.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2009/06/03/netbeans-67rc1-crashes-on-mac-os-x-1057/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WYSIWYG Choices: Nicedit vs. Tinymce</title>
		<link>http://www.botsko.net/blog/2009/04/20/wysiwyg-choices-nicedit-vs-tinymce/</link>
		<comments>http://www.botsko.net/blog/2009/04/20/wysiwyg-choices-nicedit-vs-tinymce/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 00:34:40 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=309</guid>
		<description><![CDATA[In several recent projects we attempted to replace Tinymce as the leading content editor of choice with the much simpler Nicedit. We did not have any great need for the advanced features Tinymce offers and were looking for a much smaller, easier, faster tool. While I&#8217;ve used nicedit before in basic situations and had no [...]]]></description>
			<content:encoded><![CDATA[<p>In several recent projects we attempted to replace Tinymce as the leading content editor of choice with the much simpler Nicedit. We did not have any great need for the advanced features Tinymce offers and were looking for a much smaller, easier, faster tool.</p>
<p>While I&#8217;ve used nicedit before in basic situations and had no problems, I encountered several fatal issues which caused us to revert to Tinymce.</p>
<p><strong>Inner-DIV Implementation</strong><br />
Nicedit creates a new DIV element that relies on some newer HTML features to work properly. Multiple issues stemmed from this, but the primary problem was that all CSS from parent elements would cascade into the DIV, thus forcing me to reset or modify some of them.</p>
<p>Tinymce uses an iframe which is a completely new document, so all CSS does not filter through. This also helps avoid the following content problems.</p>
<p><strong>API</strong><br />
When ajax load/save techniques were used, there were problems with how Nicedit would copy it&#8217;s content back to the textarea, thus requiring extra programming. The API documentation is not that great, so it was a little difficult.</p>
<p><strong>Elements Used</strong><br />
In firefox, Nicedit would use a different set of markup elements than it would in IE, making the output harder to predict. This issue is partly due to the use of the Inner-DIV and contenteditable attribute. When filtering the input for markup, we had to allow for both sets of elements. In firefox, the elements were all SPANs with style attributes, which isn&#8217;t anywhere near semantic.</p>
<p><strong>Firefox LI Bug</strong><br />
Instances of the editor inside of a list item would have a fatal problem with newlines. While you could type alphanumeric characters, newline key presses would have no result. This was a fatal problem that took some time to debug, but it&#8217;s been <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=460740">filed and is awaiting resolution</a>.</p>
<p>Obviously, nicedit is a lot less powerful and has a much smaller community. While it works well for quick needs, nicedit just didn&#8217;t work for more standard uses, and we found tinymce a much better solution despite it&#8217;s bulk. Since then I&#8217;ve managed to weed out a lot of tinymce code we weren&#8217;t using, optimize it like crazy, and create some custom plugins for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2009/04/20/wysiwyg-choices-nicedit-vs-tinymce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Form Builder Plugin</title>
		<link>http://www.botsko.net/blog/2009/04/07/jquery-form-builder-plugin/</link>
		<comments>http://www.botsko.net/blog/2009/04/07/jquery-form-builder-plugin/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 23:26:11 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=295</guid>
		<description><![CDATA[Trellis Development (a parent company of web-based products which I co-founded) has been developing a custom content management system which needed a form creation tool. I adapted a form builder that I created for a previous project as a jQuery 1.3 plugin. It loads in existing form structure data through an XML file (which would [...]]]></description>
			<content:encoded><![CDATA[<p>Trellis Development (a parent company of web-based products which I co-founded) has been developing a custom content management system which needed a form creation tool. I adapted a form builder that I created for a previous project as a jQuery 1.3 plugin. It loads in existing form structure data through an XML file (which would be generated on the server) and passes the changes as a serialized array back to the server.</p>
<p><a href="http://experiments.botsko.net/tests/formbuilder/">View the Demonstration</a><br />
<a href="http://github.com/botskonet/jquery.formbuilder/tree/master">Get source from github</a></p>
<p>I&#8217;ve forked the code from the cms to serve as a stand-alone plugin. It&#8217;s extremely easy to setup, as all you need to do is to activate it on an un/ordered list item element. Then, write your backend code to handle the incoming array as you need, and output the xml data for when the form loads.</p>
<pre class="brush: xml;">
&lt;ul id=&quot;form-builder&quot;&gt;&lt;/ul&gt;
</pre>
<pre class="brush: jscript;">
$(document).ready(function(){
	$('#form-builder').formbuilder({
		'save_url': 'save.php',
		'load_url': 'form-a.xml'
	});
});
</pre>
<p>The <code>save_url</code> is the url that the ajax will be sent to when the user saves the form. The form information is serialized so that the backend programming may handle it as an array.</p>
<p>The <code>load_url</code> is the url of an xml file that describes any existing form information, and the system uses it to restore the fields.</p>
<p>This requires jQuery 1.3+ and uses the scrollTo plugin for nice scrolling.</p>
<p>This is the first revision that&#8217;s external to our cms so I&#8217;ve labeled it 0.1.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2009/04/07/jquery-form-builder-plugin/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Duplicate Line/Selection in Komodo 5</title>
		<link>http://www.botsko.net/blog/2009/02/19/duplicate-lineselection-in-komodo-5/</link>
		<comments>http://www.botsko.net/blog/2009/02/19/duplicate-lineselection-in-komodo-5/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 07:20:05 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech-Tidbit]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=275</guid>
		<description><![CDATA[Update: Trent from ActiveState (developers of Komodo) notified me that they&#8217;ve actually just completed this feature within the latest nightly builds. More information here. Exploring the ability to create macros and bind them to key commands in Komodo IDE. I&#8217;m reposting the below macro that duplicates the lines or the current selection. Thus functionality was [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Trent from ActiveState (developers of Komodo) notified me that they&#8217;ve actually just completed this feature within the latest nightly builds. <a href="http://trentm.com/blog/archives/2009/02/20/duplicate-line-or-selection-in-komodo/">More information here</a>.</p>
<p>Exploring the ability to create macros and bind them to key commands in Komodo IDE. I&#8217;m reposting the below macro that duplicates the lines or the current selection. Thus functionality was previously is Zend Studio 5, went missing from 6, and thanks to the macro, is available in Komodo. Enjoy!</p>
<pre class="brush: jscript;">
// Duplicate Line or Duplicate Selection
komodo.assertMacroVersion(2);
if (komodo.view) { komodo.view.setFocus() };

var ke = komodo.editor;

if (ko.views.manager.currentView.scimoz.selText){
    // Copy the current selection
    new_selection = komodo.interpolate('%s');
    var pos = ke.currentPos;
    ke.insertText(pos,new_selection);
}else {
    ke.lineDuplicate();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2009/02/19/duplicate-lineselection-in-komodo-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Serialize List Plugin</title>
		<link>http://www.botsko.net/blog/2009/01/29/jquery_serialize_list_plugin/</link>
		<comments>http://www.botsko.net/blog/2009/01/29/jquery_serialize_list_plugin/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 22:15:23 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=252</guid>
		<description><![CDATA[During several recent projects I needed the ability to serialize an unordered list and pass it back to the server. A google search didn&#8217;t reveal much and I didn&#8217;t want to go digging this functionality out of larger plugins like sortable, UI, etc. I decided to wrap it all up into a jQuery plugin so [...]]]></description>
			<content:encoded><![CDATA[<p>During several recent projects I needed the ability to serialize an unordered list and pass it back to the server. A google search didn&#8217;t reveal much and I didn&#8217;t want to go digging this functionality out of larger plugins like sortable, UI, etc.</p>
<p>I decided to wrap it all up into a jQuery plugin so that it&#8217;s easier to use in different projects. The serialized un/ordered list may be sent back to the server, and for example in PHP, will be interpreted as an array.</p>
<p>You may use this plugin by simply calling it on your UL or OL.</p>
<pre class="brush: jscript;">
$(document).ready(function(){
    $('ul').serializelist();
});
</pre>
<p>You may download the most recent version directly from github:</p>
<p><a href="http://github.com/botskonet/jquery.serialize-list">http://github.com/botskonet/jquery.serialize-list</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2009/01/29/jquery_serialize_list_plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AJAX-ified Selects Using Prototype</title>
		<link>http://www.botsko.net/blog/2006/05/17/ajaxified-selects-using-prototype/</link>
		<comments>http://www.botsko.net/blog/2006/05/17/ajaxified-selects-using-prototype/#comments</comments>
		<pubDate>Wed, 17 May 2006 19:58:22 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=82</guid>
		<description><![CDATA[Recently, I had another project where I needed to use AJAX to fill in a SELECT element based off of values from another SELECT. Previously I had used some very detailed and difficult javascript from an example found in the Apple Developer documentation. I have used this code before so I knew it, but I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I had another project where I needed to use AJAX to fill in a SELECT element based off of values from another SELECT. Previously I had used some very detailed and difficult javascript from an example found in the Apple Developer documentation. I have used this code before so I knew it, but I wanted to get something a bit easier. I was already using the <a href="http://prototype.conio.net/">Prototype framework</a> in my code, so I figured I&#8217;d use Prototype for this as well.</p>
<p>However, I found no documented way to parse XML using prototype, so with a bit of toying around I was able to find a pretty simple solution. </p>
<p>First of all, here is the html I have for the two selects I need to work with.</p>
<pre class="brush: xml;">
State:&lt;br /&gt;
  &lt;select onchange=&quot;searchStates()&quot; id=&quot;states&quot;&gt;
    &lt;option value=&quot;&quot;&gt;CHOOSE&lt;/option&gt;
    &lt;option value=&quot;CO&quot;&gt;CO&lt;/option&gt;
    &lt;option value=&quot;OR&quot;&gt;OR&lt;/option&gt;
  &lt;/select&gt;
&lt;br /&gt;&lt;br /&gt;  

Counties:&lt;br /&gt;
  &lt;select id=&quot;counties&quot;&gt;
      &lt;option value=&quot;&quot;&gt;Please select a state first&lt;/option&gt;
  &lt;/select&gt;
</pre>
<p>The first select field has a list of states that when selected, will fill in the second select element with counties from the selected state. I could have gone the easy way and just replaced the <code>counties</code> element with HTML, but I wanted my counties to be returned in XML. As I mentioned, Prototype didn&#8217;t have any documented way of easily parsing XML nodes.</p>
<p>To start, the <code>states</code> select calls this function when the selection is changed:</p>
<pre class="brush: jscript;">
 function searchStates(){
  var s = $F('states');
  var url = 'ajax_select.php';
  var pars = 'state=' + s;

  var myAjax = new Ajax.Request( url, { method: 'get', parameters: pars, onComplete: showResponse });

}
</pre>
<p>This function opens a new AJAX request through Prototype. It passes the value in the state selection box to ajax_select.php in the form of a GET request. On the server side I have the referenced php file to handle the request, and return some XML. (Obviously this file is simplified for example purposes).</p>
<pre class="brush: php;">
&lt; ?php

  header(&quot;Content-Type: text/xml&quot;);
  print'&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;'; 

?&gt;

&lt;response&gt;
&lt; ?php if($_GET['state'] == &quot;CO&quot;) { ?&gt;
  &lt;record&gt;
    &lt;id&gt;1&lt;/id&gt;
    &lt;state&gt;CO&lt;/state&gt;
    &lt;county&gt;Jefferson&lt;/county&gt;
  &lt;/record&gt;
&lt; ?php } ?&gt;
&lt; ?php if($_GET['state'] == &quot;OR&quot;) { ?&gt;
  &lt;record&gt;
    &lt;id&gt;2&lt;/id&gt;
    &lt;state&gt;OR&lt;/state&gt;
    &lt;county&gt;Washington&lt;/county&gt;
  &lt;/record&gt;
&lt; ?php } ?&gt;
&lt;/response&gt;
</pre>
<p>This file essentially returns an ID number, state, and county for the state passed in the GET request. It opens sending a ContentType of xml so that it doesn&#8217;t come back as text, and we add the xml declaration after that. These two statements are required otherwise the javascript gets text instead of XML, and can&#8217;t handle it the way we want.</p>
<p>To start out the response handling function, I call it <code>showResponse</code>. In the Prototype ajax request call, I told it <code>onComplete: showResponse</code>, which tells it to call the <code>showResponse</code> function if the request completes.</p>
<pre class="brush: jscript;">
function showResponse(originalRequest){

}
</pre>
<p>This is the basic outline of the script. Using the prototype call for an element by its ID, I get the counties element. I need to clear it out, so I loop through it&#8217;s options and remove any.</p>
<pre class="brush: jscript;">
  var c = $('counties');

  while (c.length &gt; 0) {
    c.remove(0);
  }
</pre>
<p>Now my target element is clear. But the problem I set out to resolve, is the fact that Prototype doesn&#8217;t have any easy way of sorting through the child nodes and returning values. My solution is to pull the nodes out by name, since I know the names of the nodes I need. </p>
<pre class="brush: jscript;">
var tagValue = originalRequest.responseXML.getElementsByTagName('county');
var tagId = originalRequest.responseXML.getElementsByTagName('id');
</pre>
<p>Now all we need to do is iterate through the array returned. I just picked the first array although it really doesn&#8217;t matter as both should have the same counts as they originate in the same records. I create a new option for the select element for each one, with a value of the ID I&#8217;m pulling from the XML, and text of the county name. IE handles this differently than other browsers, so I need to use <code>try/catch</code> to get past errors. IE uses <code>nodeName.text</code> while everyone else uses <code>nodeName.textContent</code>.</p>
<pre class="brush: jscript;">
  for (var i = 0; i &lt; tagValue.length; i++) {
    var opt = document.createElement(&quot;option&quot;);
    try {
      opt.text = tagValue[i].textContent;
      opt.value = tagId[i].textContent;
      c.add(opt, null);
    }
    // IE needs special handling
    catch(ex){
      opt.text = tagValue[i].text;
      opt.value = tagId[i].text;
      c.add(opt);
    }
}
</pre>
<p>That&#8217;s it! <a href="http://www.botsko.net/Test/AJAX_SELECT/ajax_select.html">Checkout the working example here!</p>
<p>Or you can <a href="http://www.botsko.net/Website/downloads.php?file_id=6">Download these source files along with Prototype here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2006/05/17/ajaxified-selects-using-prototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
