<?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>adam mokan &#187; javascript</title>
	<atom:link href="http://www.adammokan.com/category/development/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adammokan.com</link>
	<description>ramblings of a software developer, mad scientist, geek, and father</description>
	<lastBuildDate>Tue, 22 Nov 2011 19:11:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Slides from my &#8220;Intro to SignalR&#8221; presentation at Desert Code Camp</title>
		<link>http://www.adammokan.com/2011/11/08/intro-to-signalr-slides/</link>
		<comments>http://www.adammokan.com/2011/11/08/intro-to-signalr-slides/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 04:45:36 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[desert code camp 2011.2]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[presentations]]></category>
		<category><![CDATA[signalr]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[asp.net mvc 3]]></category>
		<category><![CDATA[dcc11]]></category>
		<category><![CDATA[desert code camp]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[long-polling]]></category>
		<category><![CDATA[SignalR]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=84</guid>
		<description><![CDATA[I uploaded the slides from my &#8220;Intro to SignalR&#8221; presentation at Desert Code Camp 2011.2 which was held this past weekend (11/05/2011) at Chandler-Gilbert Community College. I did add some additional bullet points and text content to the slide deck since I&#8217;m not a big fan of standing in front of a bunch of that [...]]]></description>
			<content:encoded><![CDATA[<p>I uploaded the slides from my &#8220;Intro to SignalR&#8221; presentation at Desert Code Camp 2011.2 which was held this past weekend (11/05/2011) at Chandler-Gilbert Community College.</p>
<p>I did add some additional bullet points and text content to the slide deck since I&#8217;m not a big fan of standing in front of a bunch of that during a presentation and would rather talk with the attendees and show some code. Either way, check the slides out if you&#8217;d like.</p>
<p><a href="http://www.slideshare.net/adammokan/introduction-to-signalr-10082193" target="_blank">http://www.slideshare.net/adammokan/introduction-to-signalr-10082193</a></p>
<p>Next up is some tweaks to my samples, which were not cooperating with me so much during my session. I will expose that repo on Github soon and post an update.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/11/08/intro-to-signalr-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>node.js running in a Windows Azure Worker Role</title>
		<link>http://www.adammokan.com/2011/07/20/node-js-in-a-windows-azure-worker-role/</link>
		<comments>http://www.adammokan.com/2011/07/20/node-js-in-a-windows-azure-worker-role/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 22:37:04 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[github]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[windows azure]]></category>
		<category><![CDATA[worker role]]></category>
		<category><![CDATA[node.js azure azure-worker-role node.exe]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=76</guid>
		<description><![CDATA[Since the release of node.js version 0.5.1 (download link here) on July 14th, the Windows platform finally has a native node.exe binary that doesn&#8217;t require Cygwin or any other work-around to play with node.js on Windows. I did a small test yesterday by downloading the exe and putting it&#8217;s folder in my local Win7 PATH [...]]]></description>
			<content:encoded><![CDATA[<p>Since the release of <a href="http://nodejs.org" target="_blank">node.js</a> version 0.5.1 (download link <a href="http://nodejs.org/#download" target="_blank">here</a>) on July 14th, the Windows platform finally has a native node.exe binary that doesn&#8217;t require Cygwin or any other work-around to play with node.js on Windows. I did a small test yesterday by downloading the exe and putting it&#8217;s folder in my local Win7 PATH environment variable and had simple node.js samples working right in Notepad++, which was entertaining. 0.5.1 is an &#8220;unstable&#8221; release, so don&#8217;t expect to launch your production site on it, but it removes a barrier of entry for those stuck on Windows.</p>
<p>Based on the test yesterday, I dug up an old <a href="http://blog.smarx.com/posts/using-other-web-servers-on-windows-azure" target="_blank">blog post by Steve Marx</a> (<a href="http://twitter.com/smarx" target="_blank">@smarx</a> on twitter) that demonstrated running the Mongoose web server in a Windows Azure Worker Role on port 80. Using his example as a basis, I did the same with node.exe and it worked on the first attempt.</p>
<p><strong>Check out the live site here*</strong> - <a href="http://nodetest.cloudapp.net/" target="_blank">http://nodetest.cloudapp.net/</a></p>
<div id="attachment_77" class="wp-caption alignleft" style="width: 310px"><a href="http://www.adammokan.com/wp-content/uploads/2011/07/node_in_worker_role.png" target="_blank"><img class="size-medium wp-image-77" title="Node worker role in my azure dashboard" src="http://www.adammokan.com/wp-content/uploads/2011/07/node_in_worker_role-300x35.png" alt="Node worker role in my azure dashboard" width="300" height="35" /></a><p class="wp-caption-text">node.js worker role in my azure dashboard</p></div>
<div id="attachment_78" class="wp-caption alignnone" style="width: 176px"><a href="http://www.adammokan.com/wp-content/uploads/2011/07/azure_settings.png" target="_blank"><img class="size-medium wp-image-78 " title="Azure Worker Role Settings" src="http://www.adammokan.com/wp-content/uploads/2011/07/azure_settings-166x300.png" alt="Azure Worker Role Settings" width="166" height="300" /></a><p class="wp-caption-text">worker role settings in azure</p></div>
<p>I&#8217;ve not even messed with nvm or npm on Windows (and have no clue if they even work yet) or frameworks such as <a href="http://expressjs.com/" target="_blank">Express</a>, which I enjoy for larger node projects. <a href="https://gist.github.com/1096057" target="_blank">Here is a gist</a> for the basic sample in the project. Even if you have never looked at node (but understand HTTP), it should be fairly clear.</p>
<p>I have posted the full source for the entire project on github and you should be able to simply download/clone and deploy to Azure with no issues. As mentioned in the readme file, the node application code is in the <em><a href="https://github.com/amokan/node-on-azure/tree/master/src/WorkerRole/node" target="_blank">src/WorkerRole/node/</a></em> directory, along with node.exe itself.</p>
<p>I used a single &#8216;Extra Small&#8217; instance and OSFamily &#8217;2&#8242; in case I wanted to do anything more advanced with PowerShell later on. I&#8217;m sure OSFamily &#8217;1&#8242; would be perfectly fine.</p>
<p>Github source - <a href="https://github.com/amokan/node-on-azure" target="_blank">https://github.com/amokan/node-on-azure</a></p>
<p>If anyone else is doing any work with node.exe in an Azure role, be sure to post your findings and let&#8217;s see how far we can push this thing. Node is an amazing piece of technology and a great solution for high-performance APIs and shows the true power of JavaScript. The next step is integrating node with Azure Table Storage and other features in the Azure ecosystem. Maybe that&#8217;s already been done?</p>
<p><em>* I will leave the live sample running on Azure for a while. If the extra small instance gets slammed for some odd reason, I will drop it and update the post.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/07/20/node-js-in-a-windows-azure-worker-role/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Looking for feedback on future content</title>
		<link>http://www.adammokan.com/2011/07/18/looking-for-feedback-on-future-content/</link>
		<comments>http://www.adammokan.com/2011/07/18/looking-for-feedback-on-future-content/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 19:26:46 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[asp.net mvc3]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[mvcscaffolding]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[razor]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[teamcity]]></category>
		<category><![CDATA[templify]]></category>
		<category><![CDATA[unit testing]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[htmlhelpers]]></category>
		<category><![CDATA[ninject]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=74</guid>
		<description><![CDATA[Yeah, yeah. I know this will probably show up as an empty promise since I always have the best intentions to post more, but I have some blog posts and samples in the works (some were literally ready to post and then a change came out and I have to make adjustments). My goal is [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, yeah. I know this will probably show up as an empty promise since I always have the best intentions to post more, but I have some blog posts and samples in the works (some were literally ready to post and then a change came out and I have to make adjustments). My goal is to get at least one of them out by the end of July. If anyone has feedback on what they&#8217;d like to see first, please comment.</p>
<p>On deck, in no particular order :</p>
<ul>
<li>A detailed post (with code and a Templify template to get you started) on a generic repository pattern for ASP.NET MVC 3 and Entity Framework 4.1 along with a unit tests that utilize SQL Compact edition that automatically create a new SQL Compact file upon starting tests, populates the schema with sample data, and then subsequently deletes the file after tests are complete. Dependency injection is done via Ninject, which is my IoC of choice for MVC3.</li>
<li>A post on consuming portable areas in MVC 3 for a plugin-like architecture. Think &#8220;modules&#8221; that can be dynamically loaded.</li>
<li>A post on the MVC lifecycle and when and why to use the various filter interfaces provided by ASP.NET MVC3.</li>
<li>A post on Node.js from a .NET developers perspective and how to get started with hosting, the current state of node on Windows and so-on.</li>
<li>A post on custom HtmlHelpers for MVC3 showing various techniques to keep those views nice and DRY.</li>
<li>A post on running JetBrains TeamCity 6.5 in the cloud using Amazon&#8217;s EC2 &#8220;micro&#8221; instance and automatically bringing up build agents and terminating them after the build. The post would be aimed at .NET development.</li>
</ul>
<div>If you have any feedback on what you&#8217;d like to see, please comment.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/07/18/looking-for-feedback-on-future-content/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>node.js and MongoDB</title>
		<link>http://www.adammokan.com/2011/03/17/node-js-and-mongodb/</link>
		<comments>http://www.adammokan.com/2011/03/17/node-js-and-mongodb/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 00:56:02 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=61</guid>
		<description><![CDATA[Over the past two weeks I&#8217;ve jumped head first into a new, and exciting, stack for a client project developing an API using node.js with a MongoDB data store. It&#8217;s been a fairly successful start, although I&#8217;m the first to admit my raw JavaScript skills have gotten rusty after years of web forms and, more [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past two weeks I&#8217;ve jumped head first into a new, and exciting, stack for a client project developing an API using <a href="http://nodejs.org/" target="_blank">node.js</a> with a <a href="http://www.mongodb.org/" target="_blank">MongoDB</a> data store.</p>
<p>It&#8217;s been a fairly successful start, although I&#8217;m the first to admit my raw JavaScript skills have gotten rusty after years of web forms and, more recently, relying on things like jQuery for UI work in my web applications. Combining that with my first heavy foray into Mongo, which I&#8217;ve tinkered with in the past, and it&#8217;s provided a lot of excitement for me to learn some totally new approaches to system architecture which always inspires me to look at how to leverage some of the approaches/techniques to my primary role as a .NET consultant.</p>
<p>As with many edge frameworks, node.js is easy to get going with on OSX or Linux. Windows is a bit trickier, but <a href="http://twitter.com/tathamoddie">Tatham Oddie</a> posted <a href="http://blog.tatham.oddie.com.au/2011/03/16/node-js-on-windows/">a good little tidbit of info</a> explaining how to get node up and running using the MinGW approach described. I tried this last night on my Windows7 boot and it worked pretty well.</p>
<p>I encourage those of you who at least haven&#8217;t looked into node.js to do so. Just to understand what it is. I&#8217;m not looking at this as a replacement for Rails, Sinatra, ASP.NET, or anything like that; But for an API that just responds to and receives data via RESTful calls, it seems ideal.</p>
<p>Once I get the project wrapped up, I plan to do some more posts showing what I&#8217;ve learned and pitfalls to avoid, from a .NET-developers perspective.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/03/17/node-js-and-mongodb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Links shown during my MVC3 presentation at the Southeast Valley .NET User Group</title>
		<link>http://www.adammokan.com/2011/02/24/links-shown-during-my-sevdnug-mvc3-presentation/</link>
		<comments>http://www.adammokan.com/2011/02/24/links-shown-during-my-sevdnug-mvc3-presentation/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 01:05:42 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[architectural patterns]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[asp.net mvc3]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[presentations]]></category>
		<category><![CDATA[razor]]></category>
		<category><![CDATA[sevdnug]]></category>
		<category><![CDATA[templify]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[mvc3]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=58</guid>
		<description><![CDATA[If you attended my presentation or not, I have compiled a list of valuable links to cover many aspects of ASP.NET MVC3 discussed in the presentation on Feb 24, 2011. Here is a bundle thanks to bit.ly and bridgeurl. http://bit.ly/sevdnug_mvc3_presentation_links]]></description>
			<content:encoded><![CDATA[<p>If you attended my presentation or not, I have compiled a list of valuable links to cover many aspects of ASP.NET MVC3 discussed in the presentation on Feb 24, 2011.</p>
<p>Here is a bundle thanks to bit.ly and bridgeurl.</p>
<p><a href="http://bit.ly/sevdnug_mvc3_presentation_links">http://bit.ly/sevdnug_mvc3_presentation_links</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/02/24/links-shown-during-my-sevdnug-mvc3-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery autocomplete plugin with ASMX web service and JSON</title>
		<link>http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/</link>
		<comments>http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 07:00:00 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[soa]]></category>
		<category><![CDATA[asmx]]></category>
		<category><![CDATA[autocomplete]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/</guid>
		<description><![CDATA[I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This is due to my excursions into Rails and Sinatra outside of work, and also because I feel like some of the MS Ajax Toolkit extenders seem to be bloated at times. I also figure that since [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This is due to my excursions into Rails and Sinatra outside of work, and also because I feel like some of the MS Ajax Toolkit extenders seem to be bloated at times. I also figure that since I intend to dip my feet more into the ASP.NET MVC framework, jQuery seems to be very standard there.&nbsp;</p>
<p>That brings me to (one of) the jQuery Autocomplete plugins. I need this functionality in an ASP.NET webforms application and wanted to give it a shot. I started messing with &#8220;jQuery Autocomplete plugin 1.1&#8243; by Jörn Zaefferer. You can find the code and info at&nbsp;<a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/">http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/</a>.&nbsp;</p>
<p>I&#8217;m mostly interested in doing an autocomplete via a remote web service call that returns json data. The example in the zip file includes a little php page that just responds to a HTTP-GET and spits out some hard-coded json. I&#8217;m working in .NET, so I made a simple ASMX web service to query my database and return a DataTable as json. (Note &#8211; There are isues with the built-in serializer to return a DataTable as json. A google search will find you a number of functions or alternate ways to generate a json string from a DataTable.)&nbsp;
</p>
<p>Right away, I found I was having problems with the autocomplete in this environment. First off, you have the whole issue with ASMX web methods only accepting a POST by default. This is easy to change, but not advised. You can find info on that issue here &#8211; <a href="http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/">http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/</a> and some other good info here &#8211; <a href="http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/">http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/</a>&nbsp;
</p>
<p>You&#8217;ll also notice in the above blog links that there can often be issues when POST-ing to a web method with encoding set to json, that you will need to pass your json params as a string. If you&#8217;re using something like Firebug to watch your ajax posts, you&#8217;ll catch this right away.&nbsp;
</p>
<p>But the main issue for me were&nbsp;the assumptions that the autocomplete plugin makes. It, by default, will only do a HTTP-GET. You can use the $.ajaxSetup in jQuery to set your future ajax calls to a default, but I wanted the ability to make this decision when calling the autocomplete plugin.&nbsp;
</p>
<p>I made these changes to jquery.autocomplete.js in the $.ajax section :</p>
<pre class="brush: js; highlight:[7,8,9,10];">
$.ajax({
// try to leverage ajaxQueue plugin to abort previous requests
mode: "abort",
// limit abortion to this input
port: "autocomplete" + input.name,
dataType: options.dataType,
//setup new options for asmx - amokan
type: options.httpMethod,
contentType: options.contentType,
//end new options - amokan
url: options.url,
</pre>
<p>This allows me to now handle my client side code a little better.</p>
<pre class="brush: js; highlight:[5,6];">
$("#task").autocomplete(
"http://somecomputername/jsonServiceTest/Testing.asmx/GetSomeDataNoParam",
{
dataType: 'json',
httpMethod: 'POST',
contentType: 'application/json; charset=utf-8',
max: 100,
scroll: true,
matchContains: true,
minChars: 3,
parse: function(data) {
var rows = new Array();
//your parsing logic
},
formatItem: function(row, i, n) {
//do something
},
width: 260
}
);
</pre>
<p>I&#8217;m still working on cleaning up the data parameter section of the plugin a bit before I post the full code.<br />
If you&#8217;re curious, here is my ASMX method. Be sure to add the [ScriptService] attribute to your class in the ASMX file so it can handle AJAX properly. If you are using an older .NET without the System.Web.Script.Services namespace, this will not work for you. Note that the parameters &#8220;q&#8221; and &#8220;limit&#8221; are sent automatically by the autocomplete plugin. &#8220;Q&#8221; is the string currently typed into the text control so you can filter your query based on what the user has typed and &#8220;limit&#8221; is the max number of rows. Obviously, its up to you to implement these in your query if you chose to. &nbsp;</p>
<pre class="brush: csharp">
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string GetSomeDataNoParam(string q, int limit)
{
DataTable dtSomething;
//connect to db, do your exception handling, etc
dtSomething = //your DAL or whatever you use
//use my method to parse the datatable into json
return GetJSONString(dtSomething);
}
</pre>
<p>Hope this helps a bit and I will be sure to upload some more code as I get this working a bit smoother in my environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

