<?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>This is not a mundane detail, Michael. &#187; javascript</title>
	<atom:link href="http://blog.mikejestes.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mikejestes.com</link>
	<description></description>
	<lastBuildDate>Mon, 04 Jul 2011 02:51:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>SWFUpload with flash 10</title>
		<link>http://blog.mikejestes.com/2008/12/02/swfupload-with-flash-10/</link>
		<comments>http://blog.mikejestes.com/2008/12/02/swfupload-with-flash-10/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 08:45:03 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.mikejestes.com/?p=203</guid>
		<description><![CDATA[Flash player version 10 has new security restrictions with it&#8217;s javascript interaction.  It is no longer possible to trigger the local file picker from a javascript event.  Basically breaking the most legitimate use of flash in websites that I&#8217;ve seen &#8230; <a href="http://blog.mikejestes.com/2008/12/02/swfupload-with-flash-10/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Flash player version 10 has new security restrictions with it&#8217;s javascript interaction.  It is no longer possible to trigger the local file picker from a javascript event.  Basically breaking the most legitimate use of flash in websites that I&#8217;ve seen in a while.</p>
<p>I use <a href="http://swfupload.org/">SWFUpload</a> in a few sites to get multiple file uploads and upload progess bars.  It&#8217;s pretty slick.</p>
<p>The SWFUpload project has a beta release out that can work with Flash 10.  Here&#8217;s the basic changes required in your code to work with the 2.2.0 betas:</p>
<p>Right above your html that contains a button to trigger the file picker:</p>
<pre lang="html"><span id="spanButtonPlaceholder"></span></pre>
<p>You will want to give your button a fixed width and height.</p>
<p>Add the following CSS rules:</p>
<pre lang="css">.swfupload {
    position: absolute;
    z-index: 1;
}</pre>
<p>And finally, add the following options to your SWFUpload settings object:</p>
<pre lang="javascript">     button_placeholder_id : "spanButtonPlaceholder",
    button_width: 100,
    button_height: 40,
    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
    button_cursor: SWFUpload.CURSOR.HAND,</pre>
<p>This adds a transparent flash object over your html button that is the same size.  Flash traps the click over your button and triggers the file picker from flash itself.  Ironically, this work around for the tighter security restrictions in Flash 10 seems like a compete security risk in inself&#8230;</p>
<p>Pat wrote about <a href="http://patcavit.com/2008/11/30/yui-uploader-updated/">fixing the flash 10 issue with the YUI libraries</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mikejestes.com/2008/12/02/swfupload-with-flash-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Greasemonkey script for twitter</title>
		<link>http://blog.mikejestes.com/2008/04/06/greasemonkey-script-for-twitter/</link>
		<comments>http://blog.mikejestes.com/2008/04/06/greasemonkey-script-for-twitter/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 03:45:37 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://blog.mikejestes.com/?p=141</guid>
		<description><![CDATA[A few weeks ago I was thinking about how hilarious it would be to view twitter pages with OMG: prepended to all the messages. I&#8217;ve had a post-it note attached to my monitor ever since that has 3 words: twitter &#8230; <a href="http://blog.mikejestes.com/2008/04/06/greasemonkey-script-for-twitter/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I was thinking about how hilarious it would be to view twitter pages with <strong>OMG:</strong> prepended to all the messages. I&#8217;ve had a post-it note attached to my monitor ever since that has 3 words: twitter greasemonkey omg.</p>
<p>I present my first greasemonkey script: <a href="http://mikejestes.com/greasemonkey/twitter.omg.user.js">twitter omg</a>.</p>
<p>To be honest, I&#8217;ve never actually installed greasemonkey before. Writing the script was quite fun. I&#8217;ll be looking for opportunities to make a script that is actually useful&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mikejestes.com/2008/04/06/greasemonkey-script-for-twitter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I love code snippet challenges</title>
		<link>http://blog.mikejestes.com/2008/03/17/i-love-code-snippet-challenges/</link>
		<comments>http://blog.mikejestes.com/2008/03/17/i-love-code-snippet-challenges/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 07:01:10 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.mikejestes.com/2008/03/17/i-love-code-snippet-challenges/</guid>
		<description><![CDATA[I stumbled upon a blog with a random code snippet challenge. Here was the problem at hand: Given a String (x) containing only characters a-z, write a function (f) that returns a base 10 integer, which converts the String as &#8230; <a href="http://blog.mikejestes.com/2008/03/17/i-love-code-snippet-challenges/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I stumbled upon a blog with a random <a href="http://blog.tmorris.net/rafs-problem/">code snippet challenge</a>. Here was the problem at hand:</p>
<blockquote><p>Given a String (x) containing only characters a-z, write a function (f) that returns a base 10 integer, which converts the String as if it were a base 26 numeral. Function f is bijective.</p></blockquote>
<p>I wanted to give it a stab in javascript not because it sounded particularly difficult but to play with different javascript code styles. Here&#8217;s my 4 versions:</p>
<pre lang="javascript">function f(i) {

    if (!i) { return 0; }

    var parts, n, pow, val;
    parts = i.split('');
    parts.reverse();

    val = 0;
    pow = 1;
    for (n = 0; n &lt; parts.length; ++n) {
        val += pow * (parts[n].charCodeAt(0) - 96);
        pow = pow * 26;
    }

    return val;
}</pre>
<p>The first one turns the string into an array and reverses it before doing the math loop.  My next try eliminates the array and iterates backwards over the string.</p>
<pre lang="javascript">function f(i) {

    if (!i) { return 0; }

    var n, mult = 1, val = 0, offset = 96, base = 26;

    for (n = i.length - 1; n &gt; -1; n--) {
        val += mult * (i.charCodeAt(n) - offset);
        mult = mult * base;
    }

    return val;

}</pre>
<p>Here I&#8217;m playing with chaining array functions.  While I don&#8217;t create an array, this is very similar to the first try.</p>
<pre lang="javascript">function f(i) {

    if (!i) { return 0; }

    var mult = 1, val = 0, offset = 96, base = 26;

    i.split('').reverse().forEach(function(el) {
        val += mult * (el.charCodeAt(0) - offset);
        mult = mult * base;
    });   

    return val;

}</pre>
<p>Finally, recursion instead of an iterative loop.</p>
<pre lang="javascript">function f(i, mult) {

    if (!i) { return 0; }
    if (!mult) { mult = 1; }

    var offset = 96, base = 26;
    return mult * (i.charCodeAt(i.length - 1) - offset)
             + f(i.substr(0, i.length - 1), mult * base);

}</pre>
<p>Checkout the <a href="http://blog.mikejestes.com/wp-content/uploads/2008/03/function.html">test output of my functions</a>.  Works in Firefox 1.5+ or other browsers that implement more modern javascript functions.  Shouldn&#8217;t work in IE.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mikejestes.com/2008/03/17/i-love-code-snippet-challenges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

