<?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>cakebaker &#187; javascript</title>
	<atom:link href="http://cakebaker.42dh.com/tags/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:29:40 +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>Array iteration with JavaScript</title>
		<link>http://cakebaker.42dh.com/2011/04/01/array-iteration-with-javascript/</link>
		<comments>http://cakebaker.42dh.com/2011/04/01/array-iteration-with-javascript/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 14:51:54 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1487</guid>
		<description><![CDATA[Till recently I always used a for-loop when I had to iterate over an array in JavaScript. For example: var myArray = [1, 2, 3, 4]; for (var i = 0; i &#60; myArray.length; i++) { console.log(myArray[i]); } However, with ECMAScript 5 the Array object itself got some methods for iteration purposes. With those methods [...]]]></description>
			<content:encoded><![CDATA[<p>Till recently I always used a for-loop when I had to iterate over an array in JavaScript. For example:</p>
<pre>
<code>var myArray = [1, 2, 3, 4];

for (var i = 0; i &lt; myArray.length; i++) {
    console.log(myArray[i]);
}</code>
</pre>
<p>However, with <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript 5</a> the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array">Array object</a> itself got some methods for iteration purposes. With those methods you often can write cleaner code than by using a for-loop. Let&#8217;s have a (short) look at those methods. For details, please follow the provided links.</p>
<p><strong>forEach</strong></p>
<p>The <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach">forEach()</a> method calls the provided function for each array element. Using forEach(), we can rewrite the example from above to:</p>
<pre>
<code>var myArray = [1, 2, 3, 4];

myArray.forEach(function (element) {
    console.log(element);
});</code>
</pre>
<p><strong>filter</strong></p>
<p>The <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter">filter()</a> method applies the provided filter function to each array element and returns a new array with all elements for which the filter function returned a true value. </p>
<p>For example, to get only the even numbers of an array we could write the following code:</p>
<pre>
<code>var myArray = [1, 2, 3, 4];

var evenNumbers = myArray.filter(function (x) {
    return x % 2 == 0;
});
// evenNumbers is [2, 4]</code>
</pre>
<p><strong>every</strong> &#038; <strong>some</strong></p>
<p>The <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every">every()</a> and <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some">some()</a> methods are similar: whereas the every() method only returns true if the provided testing function returns a true value for each array element, the some() method returns true if there is at least one array element for which the testing function returns a true value. You can see the difference in this example:</p>
<pre>
<code>var oddNumbers = [1, 3, 5, 7];
var mixedNumbers = [1, 2, 3, 4];
var evenNumbers = [2, 4, 6, 8];

oddNumbers.every(isEven); // returns false
oddNumbers.some(isEven); // returns false

mixedNumbers.every(isEven); // returns false
mixedNumbers.some(isEven); // returns true

evenNumbers.every(isEven); // returns true
evenNumbers.some(isEven); // returns true

function isEven(x) {
    return x % 2 == 0;
}</code>
</pre>
<p><strong>map</strong></p>
<p>The <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map">map()</a> method applies the provided function to each array element and returns an array with the results.</p>
<p>For example, to square all values of an array we can do the following:</p>
<pre>
<code>var myArray = [1, 2, 3, 4];

var squared = myArray.map(function (x) {
    return x * x;
});
// squared is [1, 4, 9, 16]</code>
</pre>
<p><strong>reduce</strong> &#038; <strong>reduceRight</strong></p>
<p>The <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce">reduce()</a> and <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/ReduceRight">reduceRight()</a> methods reduce an array step-by-step to a single value by using the provided function and an optional initial value. It works in the following way: the first two array elements (or the initial value and the first array element) are passed as parameters to the provided function. The result of this function call plus the next array element are then used as new parameters for the function. And so on, until there are no more array elements left.</p>
<p>The difference between reduce() and reduceRight() is that reduce() iterates over the array from left-to-right whereas reduceRight() iterates in the opposite direction, from right-to-left.</p>
<p>Here is a simple example to calculate the sum of the values of an array:</p>
<pre>
<code>var myArray = [1, 2, 3, 4];
var initialValue = 10;

myArray.reduce(add); // performs 1 + 2 + 3 + 4 and returns 10
myArray.reduceRight(add); // performs 4 + 3 + 2 + 1 and returns 10

myArray.reduce(add, initialValue); // performs 10 + 1 + 2 + 3 + 4 and returns 20
myArray.reduceRight(add, initialValue); // performs 10 + 4 + 3 + 2 + 1 and returns 20

function add(x, y) {
    return x + y;
}</code>
</pre>
<p>That&#8217;s it. I hope I could give you an overview over the available iteration possibilities in JavaScript. Happy coding!</p>
<p>Update 2011-04-02: I found a site by Microsoft where you can test those methods in your browser: <a href="http://ie.microsoft.com/testdrive/HTML5/ECMAScript5Array/Default.html">ECMAScript 5 Arrays</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2011/04/01/array-iteration-with-javascript/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Navigation with the &#8220;j&#8221; and &#8220;k&#8221; keys</title>
		<link>http://cakebaker.42dh.com/2010/12/04/navigation-with-the-j-and-k-keys/</link>
		<comments>http://cakebaker.42dh.com/2010/12/04/navigation-with-the-j-and-k-keys/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 09:33:19 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1456</guid>
		<description><![CDATA[If you are using Vim you already know the meaning of the &#8220;j&#8221; and &#8220;k&#8221; keys: they navigate one line downwards resp. upwards. Some websites like The Big Picture adopted this functionality to provide an easy way to navigate, in the case of The Big Picture to jump from photo to photo. As I wanted [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using <a href="http://www.vim.org/">Vim</a> you already know the meaning of the &#8220;j&#8221; and &#8220;k&#8221; keys: they navigate one line downwards resp. upwards. Some websites like <a href="http://www.boston.com/bigpicture/">The Big Picture</a> adopted this functionality to provide an easy way to navigate, in the case of The Big Picture to jump from photo to photo.</p>
<p>As I wanted to use the same functionality and didn&#8217;t find an existing solution I wrote a simple <a href="http://jquery.com/">jQuery</a> plugin for this purpose: <a href="https://github.com/cakebaker/jquery-jknavigable">jquery-jknavigable</a>. Its usage is pretty simple, to make the posts of a blog navigable with the &#8220;j&#8221; and &#8220;k&#8221; keys you would use the following code:</p>
<pre>
<code>$('.post').jknavigable();</code>
</pre>
<p>By default the active element is marked with the class &#8220;active&#8221; so you can style it differently. If necessary, you can specify your own class name:</p>
<pre>
<code>$('.post').jknavigable({'activeClass': 'someClass'});</code>
</pre>
<p>That&#8217;s it. Feedback is, as always, welcome.</p>
<p>PS: a good starting point for writing your own plugin is jQuery&#8217;s <a href="http://docs.jquery.com/Plugins/Authoring">Plugin Authoring page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/12/04/navigation-with-the-j-and-k-keys/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Grouping &#8220;constants&#8221; with JavaScript</title>
		<link>http://cakebaker.42dh.com/2010/07/14/grouping-constants-with-javascript/</link>
		<comments>http://cakebaker.42dh.com/2010/07/14/grouping-constants-with-javascript/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 14:10:32 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1427</guid>
		<description><![CDATA[A while ago I wrote about how you can group related constants in PHP5 by using a constants class: class MyConstants { const AA = 'value'; const BB = 'another value'; } echo MyConstants::AA; // output: value Now, while experimenting with JavaScript (or more precisely with Node.js) I got some constants in my code I [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I wrote about how you can <a href="http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/">group related constants</a> in PHP5 by using a constants class:</p>
<pre>
<code>class MyConstants {
    const AA = 'value';
    const BB = 'another value';
}

echo MyConstants::AA; // output: value</code>
</pre>
<p>Now, while experimenting with JavaScript (or more precisely with <a href="http://nodejs.org">Node.js</a>) I got some constants in my code I wanted to organize with such a constants class. My first, albeit naive, approach looked like:</p>
<pre>
<code>var sys = require('sys');

function MyConstants() {
    const AA = 'value';
    const BB = 'another value';
}

sys.puts(MyConstants.AA); // output: undefined</code>
</pre>
<p>However, as you can see, this doesn&#8217;t work. One reason is that <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/const">const</a> &#8220;[c]reates a constant that can be global or local to the function in which it is declared.&#8221;. So it isn&#8217;t possible to create a constants class like I imagined&#8230;</p>
<p>This means we have to emulate a constants class by using static properties and relying on the naming convention that names of constants are uppercased (i.e. the &#8220;constants&#8221; are technically not constants and their value can be changed):</p>
<pre>
<code>var sys = require('sys');

function MyConstants() {
}

MyConstants.AA = 'value';
MyConstants.BB = 'another value';

sys.puts(MyConstants.AA); // output: value</code>
</pre>
<p>If there is a better approach, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/07/14/grouping-constants-with-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Jamal Helper</title>
		<link>http://cakebaker.42dh.com/2007/05/01/jamal-helper/</link>
		<comments>http://cakebaker.42dh.com/2007/05/01/jamal-helper/#comments</comments>
		<pubDate>Tue, 01 May 2007 07:32:50 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[jamal]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/01/jamal-helper/</guid>
		<description><![CDATA[In the last few days I experimented again with the Javascript MVC framework Jamal. To make its usage a bit easier I wrote a simple helper (you can find it in the downloads section). As usual, you have to add the helper to the $helpers array of your controller(s) before you can use it: var [...]]]></description>
			<content:encoded><![CDATA[<p>In the last few days I experimented again with the Javascript MVC framework <a href="http://jamal.moagil.de">Jamal</a>. To make its usage a bit easier I wrote a simple helper (you can find it in the <a href="http://cakebaker.42dh.com/downloads">downloads section</a>).</p>
<p>As usual, you have to add the helper to the $helpers array of your controller(s) before you can use it:</p>
<pre>
var $helpers = array('Jamal');
</pre>
<p>The helper provides two public methods: link() and set(). </p>
<p>The link() method is used in the head section of the layout to include all Jamal-related files. </p>
<pre>
echo $jamal->link();
</pre>
<p>If DEBUG is greater than 0, it creates something like:</p>
<pre>
&lt;script type="text/javascript" src="/js/src/jamal.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/models/example.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/plugins/metadata.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/controllers/examples_controller.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/views/examples.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/startup.js"&gt;&lt;/script&gt;
</pre>
<p>As soon as you switch DEBUG to 0, it will include the packed version of your scripts (you have to pack them &#8220;manually&#8221; with the Ant script that comes with Jamal):</p>
<pre>
&lt;script type="text/javascript" src="/js/dist/jamal_packed.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/dist/startup.js"&gt;&lt;/script&gt;
</pre>
<p>The second method, set(), is used to specify which (Javascript) controller action is executed when the respective view is loaded. So in the view you will do something like:</p>
<pre>
$jamal-&gt;set('MyController', 'myAction');
</pre>
<p>Additionally, you have to add the variable $jamal_for_layout to the body tag of your layout:</p>
<pre>
&lt;body &lt;?php echo $jamal_for_layout; ?&gt;&gt;
</pre>
<p>This will then generate the following code for Jamal:</p>
<pre>
&gt;body class="jamal {controller:'MyController',action:'myAction',debug:false}"&gt;
</pre>
<p>Happy baking with Jamal :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/05/01/jamal-helper/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MVC with Javascript</title>
		<link>http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/</link>
		<comments>http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/#comments</comments>
		<pubDate>Sat, 17 Mar 2007 14:38:03 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/</guid>
		<description><![CDATA[Javascript was one of those things I tried to avoid up to now. I don&#8217;t know why, but somehow I disliked it (probably because it was a pain to use it in the early days of Javascript) ;-) Sure, I used a bit of Ajax here and there, but thanks to the CakePHP Ajax helper [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript was one of those things I tried to avoid up to now. I don&#8217;t know why, but somehow I disliked it (probably because it was a pain to use it in the early days of Javascript) ;-)  Sure, I used a bit of Ajax here and there, but thanks to the CakePHP Ajax helper I didn&#8217;t had to touch the Javascript. </p>
<p>Lately, I decided to do an Ajax application and so I had to learn Javascript. To make my life easier, I decided to use the <a href="http://jquery.com">JQuery framework</a>. I have chosen JQuery over <a href="http://www.prototypejs.org">Prototype</a> because I heard many good things about JQuery, and the API documentation was (and still is) more intuitive. </p>
<p>Of course, my first attempt ended in a total mess. The result looked more like spaghetti than code ;-)  That&#8217;s when I recalled an <a href="http://cakebakery.de/2006/08/17/waschmittel-in-der-kuche/">article</a> (in German) about a Javascript MVC framework called <a href="http://jamal.moagil.de/">Jamal</a>, developed by <a href="http://teemow.com">Timo Derstappen</a>. From the Jamal website:</p>
<blockquote><p>
The MVC concept is easy to adopt for javascript </p>
<ul>
<li>Controller: Interaction with the user interface (events) </li>
<li>Model: Business Logic and AJAX calls </li>
<li>View: DOM, CSS modifications </li>
</ul>
</blockquote>
<p>That makes sense. So I had a closer look at Jamal. It looked nice, but it bothered me that you would have to use a CSS class &#8220;jamal&#8221; in the HTML code to make it work. So I wrote my own implementation called &#8220;jscake&#8221; which avoids that. You can find the first version in the <a href="http://cakebaker.42dh.com/downloads">downloads section</a>.</p>
<p>Let&#8217;s create a simple &#8220;Hello world&#8221; example with jscake. Our example (CakePHP) view will contain a link and a div to show the messages: </p>
<pre>
&lt;a href=""&gt;click&lt;/a&gt;
&lt;div id="messages"&gt;&lt;/div&gt;
</pre>
<p>First we create our model. All models are in the &#8220;$m&#8221; namespace (please correct me if that is the wrong term), which is a shortcut for &#8220;jscake.models&#8221;. So our model is called &#8220;$m.Example&#8221;. The model contains one function to return the text which should be displayed:</p>
<pre>
// app/webroot/js/models/example.js
$m.Example = {

    getText: function() {
        return "hello world";
    }
};
</pre>
<p>The view is similar to the model, it contains only one function, too. In the function the element with the id &#8220;messages&#8221; is located and the text appended to that element. Similar to the models the views are in the &#8220;$v&#8221; namespace.</p>
<pre>
// app/webroot/js/views/examples.js
$v.Examples = {

    showMessage: function(message) {
        $('#messages').append(message);
    }
};
</pre>
<p>Last, but not least, we have to create the controller. The index function is automatically called when the JQuery ready event occurs. In this function we simply say that when someone clicks on the link, the other function of the controller (sayHelloWorld) should be executed.</p>
<pre>
//app/webroot/js/controllers/examples_controller.js
$c.ExamplesController = {

    index: function() {
        $('a').click(this.sayHelloWorld);
    },

    sayHelloWorld: function() {
        $v.Examples.showMessage($m.Example.getText());

        return false;
    }
};
</pre>
<p>To make our example work we have to include all needed Javascript files in our view, with CakePHP 1.2 it looks like:</p>
<pre>
&lt;?php $javascript-&gt;link(array('jquery-1.1.2', 'jscake', 'controllers/examples_controller',
'models/example', 'views/examples', 'start'), false); ?&gt;
&lt;a href=""&gt;click&lt;/a&gt;
&lt;div id="messages"&gt;&lt;/div&gt;
</pre>
<p>Have fun with jscake! Feedback is welcome :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Referencing Javascript files</title>
		<link>http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/</link>
		<comments>http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/#comments</comments>
		<pubDate>Wed, 21 Feb 2007 16:52:44 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/</guid>
		<description><![CDATA[If you want to use a Javascript file, you usually reference it in the head section of your layout: &#60;head&#62; &#60;?php echo $javascript-&#62;link('script.js'); ?&#62; &#60;/head&#62; But sometimes you want to use a certain Javascript file only in one view. Then it doesn&#8217;t make sense to reference it in the layout. You could take the PHP [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to use a Javascript file, you usually reference it in the head section of your layout:</p>
<pre>
&lt;head&gt;
    &lt;?php echo $javascript-&gt;link('script.js'); ?&gt;
&lt;/head&gt;
</pre>
<p>But sometimes you want to use a certain Javascript file only in one view. Then it doesn&#8217;t make sense to reference it in the layout. You could take the PHP statement from above and place it in your view, that will work. But it is not a clean solution as the Javascript reference is placed somewhere in the middle of the generated HTML code. </p>
<p>Fortunately, CakePHP 1.2 allows you to define a reference to a Javascript file which is then added to the head section of the generated HTML code. For this purpose the variable $scripts_for_layout has to be added to the layout:</p>
<pre>
&lt;head&gt;
    &lt;?php echo $scripts_for_layout; ?&gt;
&lt;/head&gt;
</pre>
<p>In the view you can now link to the Javascript file with: </p>
<pre>
$javascript-&gt;link('script.js', false);
</pre>
<p>That&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>New projects on CakeForge</title>
		<link>http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/</link>
		<comments>http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/#comments</comments>
		<pubDate>Tue, 12 Sep 2006 09:27:16 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakeforge]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/</guid>
		<description><![CDATA[My latest post about projects on CakeForge was two months ago. Since then several new projects were started. Here a short overview. BehaviourJS Helper: As its name says it is a helper for the Behaviour JavaScript library, a library that allows you to apply JavaScript to your HTML elements by using CSS selectors. There is [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://cakebaker.42dh.com/2006/07/03/five-new-projects-on-cakeforge/">latest post</a> about projects on <a href="http://cakeforge.org">CakeForge</a> was two months ago. Since then several new projects were started. Here a short overview.</p>
<p><strong><a href="http://cakeforge.org/projects/behaviourhelper/">BehaviourJS Helper</a></strong>: As its name says it is a helper for the <a href="http://bennolan.com/behaviour/">Behaviour JavaScript library</a>, a library that allows you to apply JavaScript to your HTML elements by using CSS selectors. There is already a <a href="http://cakeforge.org/frs/?group_id=89&#038;release_id=129">release</a> available.</p>
<p><strong><a href="http://cakeforge.org/projects/minical/">MiniCalendar</a></strong>: The goal of this project is to provide a calendar for CakePHP. </p>
<p><strong><a href="http://cakeforge.org/projects/xmlparser/">XML Parser Component</a></strong>: It is obvious what the goal of that project is: to create an XML parser component. I don&#8217;t know how it will differ from the XML parser that is part of the coming 1.2 version of CakePHP.</p>
<p><strong><a href="http://cakeforge.org/projects/qubix/">Qubix CMS</a></strong>: The goal of this project is to create a CMS for Flash sites.</p>
<p><strong><a href="http://cakeforge.org/projects/capadonna/">Capadonna</a></strong>: This is another Flash project. From the project description: &#8220;CakeAMFPHP / Actionscript Type Mapping System. Client side type mapping system to convert Cake data to and from typed flash objects via CakeAMFPHP remoting.&#8221;</p>
<p><strong><a href="http://cakeforge.org/projects/dojo-helper/">DojoHelper</a></strong>: Another helper for a JavaScript library, this time for the <a href="http://dojotoolkit.org/">Dojo Javascript Toolkit</a>.</p>
<p><strong><a href="http://cakeforge.org/projects/hdcalendar/">hdCalendar Plugin</a></strong>: Another calendar. In contrast to the aforementioned MiniCalendar project there is already some code available (<a href="http://cakeforge.org/frs/?group_id=82">http://cakeforge.org/frs/?group_id=82</a>).</p>
<p><strong><a href="http://cakeforge.org/projects/cakeforum/">CakeForum</a></strong>: The goal of this project is obvious: to create a forum application. </p>
<p>As always, good luck to these developers :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updating multiple divs with Ajax. Without crashing Firefox</title>
		<link>http://cakebaker.42dh.com/2006/08/18/updating-multiple-divs-with-ajax-without-crashing-firefox/</link>
		<comments>http://cakebaker.42dh.com/2006/08/18/updating-multiple-divs-with-ajax-without-crashing-firefox/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 07:37:57 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=248</guid>
		<description><![CDATA[In an earlier post I showed you how you can update multiple divs with Ajax. But there was one problem: it crashed Firefox on my machine, and other people reported the same problem, whereas it worked for others&#8230; In a comment, Josh Southern, pointed me to the cause of the problem: the &#8220;latest&#8221; version, 1.4, [...]]]></description>
			<content:encoded><![CDATA[<p>In an earlier <a href="http://cakebaker.42dh.com/2006/06/29/how-to-update-multiple-divs-with-ajax/">post</a> I showed you how you can update multiple divs with Ajax. But there was one problem: it crashed Firefox on my machine, and other people reported the same problem, whereas it worked for others&#8230;</p>
<p>In a <a href="http://cakebaker.42dh.com/2006/06/29/how-to-update-multiple-divs-with-ajax/#1356">comment</a>, Josh Southern, pointed me to the cause of the problem: the &#8220;latest&#8221; version, 1.4, of <a href="http://prototype.conio.net/">prototype</a>, the Javascript framework used by CakePHP, caused the problem. After replacing the prototype library with the latest version (1.5.0_rc final) provided with <a href="http://script.aculo.us/">script.aculo.us</a>, the example worked fine with Firefox. Thanks to Josh for the hint!</p>
<p>Update (2006-10-01): Corrected links.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/08/18/updating-multiple-divs-with-ajax-without-crashing-firefox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A simple redirect component</title>
		<link>http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/</link>
		<comments>http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/#comments</comments>
		<pubDate>Tue, 28 Mar 2006 15:11:57 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=153</guid>
		<description><![CDATA[I already wrote about doing a redirect with Ajax. Now, I created a simple component from that code I presented there: // app/controllers/components/redirect.php class RedirectComponent extends Object { var $controller; var $components = array('RequestHandler'); function startup(&#38;$controller) { $this-&#62;controller =&#38; $controller; } function goto($url) { if ($this-&#62;RequestHandler-&#62;isAjax()) { $this-&#62;controller-&#62;set('url', $url); } else { $this-&#62;controller-&#62;redirect($url); } } [...]]]></description>
			<content:encoded><![CDATA[<p>I already wrote about doing a <a href="http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/">redirect with Ajax</a>. Now, I created a simple component from that code I presented there:</p>
<pre>
// app/controllers/components/redirect.php
class RedirectComponent extends Object
{
    var $controller;
    var $components = array('RequestHandler');

    function startup(&amp;$controller)
    {
        $this-&gt;controller =&amp; $controller;
    }

    function goto($url)
    {
        if ($this-&gt;RequestHandler-&gt;isAjax())
        {
            $this-&gt;controller-&gt;set('url', $url);
        }
        else
        {
            $this-&gt;controller-&gt;redirect($url);
        }
    }
}
</pre>
<p>The usage is easy. Add the component to the components array: </p>
<pre>
var $components = array('Redirect');
</pre>
<p>Afterwards you can use it in the following way:</p>
<pre>
$this-&gt;Redirect-&gt;goto('/mycontroller/myaction');
</pre>
<p>Do not forget do add the code snippet to your view which necessary to do the javascript redirect:</p>
<pre>
&lt;?php if (isset($url)) echo $javascript-&gt;codeBlock('window.location = '.json_encode($url)); ?&gt;
</pre>
<p>Update (2006-04-03): Small bug fixed in startup function.<br />
Update (2009-12-05): Using json_encode to prevent a possible javascript injection problem. Thanks to <a href="http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/#comment-141239">pb</a> for the hint.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Redirect with Ajax</title>
		<link>http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/</link>
		<comments>http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/#comments</comments>
		<pubDate>Wed, 15 Mar 2006 08:28:23 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=142</guid>
		<description><![CDATA[In my current project I have a login form I want to validate with Ajax. If everything is ok, the user should be redirected to the respective start page. As it seems to be impossible to do the redirect on the server-side (at least to me), I do it on the client-side. I use the [...]]]></description>
			<content:encoded><![CDATA[<p>In my current project I have a login form I want to validate with Ajax. If everything is ok, the user should be redirected to the respective start page. As it seems to be impossible to do the redirect on the server-side (at least to me), I do it on the client-side. I use the following snippet in my view:</p>
<pre>
&lt;div id="login"&gt;
    &lt;?php echo $ajax-&gt;form(array('action' =&gt; '/login'), 'post',
                                              array('update' =&gt; 'login')); ?&gt;
    ...
    &lt;/form&gt;
    &lt;?php if (isset($url)) echo $javascript-&gt;codeBlock('window.location = "'.$url.'"'); ?&gt;
&lt;/div&gt;
</pre>
<p>And in my controller I use the following code:</p>
<pre>
if ($this-&gt;RequestHandler-&gt;isAjax())
{
    $this-&gt;set('url', '/'.$page);
}
else
{
    $this-&gt;redirect($page);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

