<?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>Thronic.com &#187; Javascript</title>
	<atom:link href="http://thronic.com/category/development/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://thronic.com</link>
	<description>Personal Computing and Development by Dag J. Nedrelid</description>
	<lastBuildDate>Wed, 28 Apr 2010 12:21:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Google-like search suggestion tool</title>
		<link>http://thronic.com/2010/development/devlog/google-like-search-suggestion-tool/</link>
		<comments>http://thronic.com/2010/development/devlog/google-like-search-suggestion-tool/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 11:53:57 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Devlog]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=202</guid>
		<description><![CDATA[A search tool that resembles the way google shows suggestions when typing keywords. Basically a simple javascript application that I wrote from scratch to see if I could create something similar.

&#160;
ReviewSpindle
A gateway between articles and affiliate links.
Key features:
* It dynamically updates the suggestion list with bold character recognition.
* The suggestion list can be navigated using [...]]]></description>
			<content:encoded><![CDATA[<p>A search tool that resembles the way google shows suggestions when typing keywords. Basically a simple javascript application that I wrote from scratch to see if I could create something similar.<br />
<span id="more-202"></span>
<p>&nbsp;</p>
<p><a href="http://reviewspindle.com/" target="_blank">ReviewSpindle</a><br />
A gateway between articles and affiliate links.</p>
<p>Key features:<br />
* It dynamically updates the suggestion list with bold character recognition.<br />
* The suggestion list can be navigated using arrow keys and mouse.<br />
* When using arrow keys, movement takes over from mouse location.</p>
<p>The application JS code is easily available through viewing the source. The PHP used is just a 2-dimensional array with titles and urls. And a foreach-loop to check for form submits, along with populating the JS version of the array.</p>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2010/development/devlog/google-like-search-suggestion-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Animation Engine</title>
		<link>http://thronic.com/2009/development/devlog/javascript-image-animation-engine/</link>
		<comments>http://thronic.com/2009/development/devlog/javascript-image-animation-engine/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 11:10:33 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Devlog]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=131</guid>
		<description><![CDATA[This is a small animation engine I made to handle an animation that a good friend of mine created in 3D Max and exported to images. This should have been made in Flash for any serious use, but for a quick experiment and FPS testing it worked out fine.

You can check it out here.
You can [...]]]></description>
			<content:encoded><![CDATA[<p>This is a small animation engine I made to handle an animation that a good friend of mine created in 3D Max and exported to images. This should have been made in Flash for any serious use, but for a quick experiment and FPS testing it worked out fine.</p>
<p><span id="more-131"></span></p>
<p>You can check it out <a href="http://deepbytes.thronic.com/TheRing/" target="_blank">here</a>.</p>
<p>You can view all the javascript code simply by right-clicking and &#8220;view source&#8221; after it opens in a new window.</p>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2009/development/devlog/javascript-image-animation-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE7 and onclick events</title>
		<link>http://thronic.com/2008/development/javascript/ie7-and-onclick-events/</link>
		<comments>http://thronic.com/2008/development/javascript/ie7-and-onclick-events/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 01:06:35 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=60</guid>
		<description><![CDATA[The onclick event is getting more used than ever before these days as AJAX is becoming increasingly used for interactive web site functions. But there is a problem sometimes when using it with IE7.
An onclick event will work perfectly in Firefox, but when you try in Internet Explorer 7 (and maybe 6) it will seemingly [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The onclick event is getting more used than ever before these days as AJAX is becoming increasingly used for interactive web site functions. But there is a problem sometimes when using it with IE7.</strong></p>
<p>An onclick event will work perfectly in Firefox, but when you try in Internet Explorer 7 (and maybe 6) it will seemingly bug out without any error or warnings at all.</p>
<p><span id="more-60"></span></p>
<p><strong>Reason</strong><br />
This is simply because of how IE decides to &#8220;remember&#8221; visited links (the one you call in the AJAX function), and it simply don&#8217;t run your onclick event more than perhaps once per click.</p>
<p>I solved this by adding something I&#8217;d like to call a no-cache-seed to the url that will be unique for every click, forcing the browser to handle every event as a new URL. Then it worked perfectly.</p>
<p>The following javascript snippet will create a variable with the number of seconds since January 1, 1970. Needless to say it will always be different unless you demand reaction times under 1 millisecond which is unrealistic from a single user.</p>
<blockquote><p><code>var currentTime = new Date();<br />
var nocacheseed = currentTime.getTime();</code></p></blockquote>
<p>Code in effect:<br />
http://example.com/file.php?foo=1&amp;bar=1&amp;nocacheseed=<script type="text/javascript">// <![CDATA[
  var currentTime = new Date();  var nocacheseed = currentTime.getTime(); document.write(nocacheseed);
// ]]&gt;</script></p>
<p>Reload the page to see how it is different every time.</p>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2008/development/javascript/ie7-and-onclick-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KiKi Trix &#8211; A Tetris Clone</title>
		<link>http://thronic.com/2007/development/devlog/kiki-trix-a-tetris-clone/</link>
		<comments>http://thronic.com/2007/development/devlog/kiki-trix-a-tetris-clone/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 20:23:54 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Devlog]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=21</guid>
		<description><![CDATA[A tetris clone. Tested OK in FF2 and IE7. Programming a tetris game is a fun challenge. A basic tetris clone covers many real-time gaming mechanics that can be used outside the gaming genre as well for other types of applications.

Click here to play (opens in a new window).

]]></description>
			<content:encoded><![CDATA[<p>A tetris clone. Tested OK in FF2 and IE7. Programming a tetris game is a fun challenge. A basic tetris clone covers many real-time gaming mechanics that can be used outside the gaming genre as well for other types of applications.<br />
<span id="more-21"></span><br />
<a title="KiKi Trix" href="/pubfiles/KiKiTrix/KTrix.html" target="_blank">Click here</a> to play (opens in a new window).</p>
<p><a href="http://thronic.com/wp-content/uploads/2007/12/kikitrix.jpg"><img src="http://thronic.com/wp-content/uploads/2007/12/kikitrix.jpg" alt="" title="KiKi Trix illustration" width="456" height="764" class="aligncenter size-full wp-image-197" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2007/development/devlog/kiki-trix-a-tetris-clone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D Rotation Trig</title>
		<link>http://thronic.com/2007/development/devlog/3d-rotation-trig/</link>
		<comments>http://thronic.com/2007/development/devlog/3d-rotation-trig/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 20:42:31 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Devlog]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=30</guid>
		<description><![CDATA[I started off easy with a simple simulated z-axis rotation in a 2D script. However 2D is not 3D which is what I wanted to learn. I was eager to get a better grasp on the underlying trigonometry math of 3D rotation behavior.

Below I have created a small matrix with 8 vectors rotating around a [...]]]></description>
			<content:encoded><![CDATA[<p>I started off easy with a simple simulated z-axis rotation in a 2D script. However 2D is not 3D which is what I wanted to learn. I was eager to get a better grasp on the underlying trigonometry math of 3D rotation behavior.</p>
<p><span id="more-30"></span></p>
<p>Below I have created a small matrix with 8 vectors rotating around a center point by using the vector coordinates instead of a preset radius like I did in the 2D rotation. I&#8217;ve used DHTML for functionality and illustration. Viewing the source may help you grasp the use of the formula.</p>
<p><a href="/pubfiles/Trig-rotation/3D-Rotation-Trig.html" target="_blank">Click here</a> to open the script in a new window.</p>
<p>In the 2D script I used this formula to rotate around a center point:</p>
<blockquote><p><code><span style="color: #0066cc;">x = Math.cos(Radian)*XRadius(hypotenuse)<br />
y = Math.sin(Radian)*YRadius(hypotenuse)</span></code></p>
<p><code><span style="color: #0066cc;">By changing the radius, you can simulate x,y rotation as well, but only on a 2D plane. It would be simulation, not real 3D. Add depth with another z calculation with the above formula, and you would have the 3D effect available.</span></code></p></blockquote>
<p>It means to give the coordinate or a vector&#8217;s &#8216;x&#8217; and/or &#8216;y&#8217; new values based on finding the radian x and y ratio through cosine and sine multiplied by hypotenuse to keep the proper center point (radius). This formula could be used for simulating 3D on a 2D plane.<br />
It could even be used for real 3D calculation, but you would need to find a way to make the rotation radius/hypotenus values work together when e.g crossing a z-axis with a y-axis rotation. When e.g. the z-rotation closes in on the y-axis, the radius of z-rotation (x) would have to be shortened accordingly, start a x-rotation as well and you have a calculation challenge.</p>
<p>Here is a formula that does the proper job of 3D calculation.<br />
It respects every axis radius/hypotenuse in regards to each other.</p>
<blockquote><p><code><span style="color: #0066cc;">// Rotation around the X axis<br />
xy = Math.cos(RadianX)*y - Math.sin(RadianX)*z<br />
xz = Math.sin(RadianX)*y + Math.cos(RadianX)*z</span></code></p>
<p><code><span style="color: #0066cc;">// Rotation around the Y axis<br />
yz = Math.cos(RadianY)*xz - Math.sin(RadianY)*x<br />
yx = Math.sin(RadianY)*xz + Math.cos(RadianY)*x</span></code></p>
<p><code><span style="color: #0066cc;">// Rotation around the Z axis<br />
zx = Math.cos(RadianZ)*yx - Math.sin(RadianZ)*xy<br />
zy = Math.sin(RadianZ)*yx + Math.cos(RadianZ)*xy</span></code></p>
<p><code><span style="color: #0066cc;">Where zx(X), zy(Y), yz(Z) are the new values to use after every calculation in a 3D space of coordinated rotation. By running this formula on every vector in my little ASCII cube matrix, I get coordinated movement based on the Radians given to it.</span></code></p></blockquote>
<p>By changing the RadianX, RadianY, RadianZ up to 2π(6.28)(360°) in this formula you control every axis rotation, and each rotation radius/hypotenuse should work in harmony. The trick here is basically how each axis calculation inherits the results from the previous.</p>
<p>It will help to repeat the chapter in a math book on trigonometry (especially sine and cosine) if you are having a hard time understanding the formula above.</p>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2007/development/devlog/3d-rotation-trig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2D Rotation Trig</title>
		<link>http://thronic.com/2007/development/devlog/2d-rotation-trig/</link>
		<comments>http://thronic.com/2007/development/devlog/2d-rotation-trig/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 20:37:25 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Devlog]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=26</guid>
		<description><![CDATA[I made this little script to play with sine and cosine to perform a 2D rotation. These are trigonometric functions to measure the ratio between the hypotenuse and the adjacent, or opposed line from θ. sine and cosine can be calculated in 2 ways, either dividing lines with hypotenuse, or through feeding a calculating function [...]]]></description>
			<content:encoded><![CDATA[<p>I made this little script to play with <a title="View more info about sine and cosine at Wikipedia" href="http://en.wikipedia.org/wiki/Trigonometric_function" target="_blank">sine and cosine</a> to perform a 2D rotation. These are trigonometric functions to measure the ratio between the hypotenuse and the adjacent, or opposed line from θ. sine and cosine can be calculated in 2 ways, either dividing lines with hypotenuse, or through feeding a calculating function the θ.</p>
<p><span id="more-26"></span></p>
<p>In this script the rotation is made around the &#8216;would be&#8217; z-axis in a 3D environment. As we keep looping the angle θ value in radian up to 2π(6.28)(360°), sine and cosine relationship/ratio values will keep changing accordingly. So, in math when you want to know the exact length of the θ&#8217;s opposite line, you multiply hypotenuse with its sine, in our case the coordinate Y. Multiply hypotenuse with co-sinus, and you get the actual length of the adjacent line as well, in our case the coordinate X. Hypotenuse becomes the range(line) from θ to the coordinates X/Y, ie. the radius.</p>
<p><a href="/pubfiles/Trig-rotation/2D-Rotation-Trig.html" target="_blank">Click here</a> to open the script in a new window.</p>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2007/development/devlog/2d-rotation-trig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The ternary operator and If/Else</title>
		<link>http://thronic.com/2007/development/the-ternary-operator-and-ifelse/</link>
		<comments>http://thronic.com/2007/development/the-ternary-operator-and-ifelse/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 13:17:33 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=112</guid>
		<description><![CDATA[The ternary operator &#8220;:?&#8221; to make If/Else structures smaller and compact is a beautiful thing. Evaluate the following example and how it could be written in a much more compact and faster way. You can use this technique in several languages. I have personally used it during PHP and Javascript quite often.


 Example with "if/else"
$true_or_false [...]]]></description>
			<content:encoded><![CDATA[<p>The ternary operator &#8220;:?&#8221; to make If/Else structures smaller and compact is a beautiful thing. Evaluate the following example and how it could be written in a much more compact and faster way. You can use this technique in several languages. I have personally used it during PHP and Javascript quite often.</p>
<p><span id="more-112"></span></p>
<blockquote>
<pre><code> <strong>Example with "if/else"</strong>
$true_or_false = true;
$need_a_value = '';

if($true_or_false == true) {
  $need_a_value = 'It was true.';
} else {
  $need_a_value = 'It was not true.';
} </code></pre>
</blockquote>
<blockquote>
<pre><code> <strong>Example with the ternary operator "?:"</strong>
$true_or_false = true;
$need_a_value = '';

$need_a_value = ($true_or_false==true?'It was true.':'It was not true.'); </code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2007/development/the-ternary-operator-and-ifelse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX basics in javascript</title>
		<link>http://thronic.com/2007/development/ajax-basics-in-javascript/</link>
		<comments>http://thronic.com/2007/development/ajax-basics-in-javascript/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 12:50:25 +0000</pubDate>
		<dc:creator>Dag Jonny Nedrelid</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://thronic.com/?p=103</guid>
		<description><![CDATA[Illustrates the use of AJAX (Asynchronous JavaScript And XML). It involves a javascript function, third-party file saved on the server side to get data from, and a call being made to it from the client side without refreshing the browser &#8211; this is the main concept of AJAX.

First the javascript function.

function ajaxFunction() {
var xmlHttp;

if(window.XMLHttpRequest) {
 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Illustrates the use of AJAX (Asynchronous JavaScript And XML). It involves a javascript function, third-party file saved on the server side to get data from, and a call being made to it from the client side without refreshing the browser &#8211; this is the main concept of AJAX.</strong></p>
<p><span id="more-103"></span></p>
<p>First the javascript function.</p>
<blockquote>
<pre><code>function ajaxFunction() {
var xmlHttp;

if(window.XMLHttpRequest) {
  xmlHttp=new XMLHttpRequest();
} else if (window.ActiveXObject) {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} else {
  alert("Your browser does not support AJAX!");
  return false;
}

xmlHttp.open("GET","links.txt",true);
xmlHttp.onreadystatechange=function() {
  if(xmlHttp.readyState==4) {
    document.getElementById('relatedLinks').innerHTML = xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
</code></pre>
</blockquote>
<p>The HTML.</p>
<blockquote><p><code> &lt;div id="relatedLinks"&gt;This will be filled with the link in links.txt.&lt;/div&gt;<br />
&lt;a href="#" onclick="ajaxFunction()"&gt;Click me to change div content&lt;/a&gt; </code></p></blockquote>
<p>And the links.txt.</p>
<blockquote><p><code> &lt;a href="http://www.domain.com/"&gt;The Domain!&lt;/a&gt; </code></p></blockquote>
<p>Sending GET data example</p>
<blockquote><p><code> xmlHttp.open("GET","getreceiver.php?foo=bar",true);<br />
xmlHttp.send(null); </code></p></blockquote>
<p>Sending POST data example</p>
<blockquote><p><code> xmlHttp.open("POST","postreceiver.php",true);<br />
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');<br />
xmlHttp.send('foo=bar');<br />
</code></p></blockquote>
<p>One thing I had a problem with when playing around in the beginning was that you can&#8217;t call data sources outside of the domain of the file calling it, this is a safety measure in some browsers. There are some ways to get outside this. Absolutely nice to know in advance to save some headache.</p>
<p>Deeper details of AJAX can be found through an online search engine very easily.</p>
<p>Microsoft.XMLHTTP might be worth checking for as well if the browser check above fails. There are many ways and means of checking validation of browsers, the one illustrated is just one of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://thronic.com/2007/development/ajax-basics-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
