<?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>Kristo Vaher &#187; Web Development</title>
	<atom:link href="http://waher.net/archives/category/web-development/feed" rel="self" type="application/rss+xml" />
	<link>http://waher.net</link>
	<description>inventas vitam iuvat excoluisse per artes</description>
	<lastBuildDate>Thu, 02 Feb 2012 12:13:16 +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>WWW &#8211; PHP micro-framework developer preview released!</title>
		<link>http://waher.net/archives/1042</link>
		<comments>http://waher.net/archives/1042#comments</comments>
		<pubDate>Wed, 01 Feb 2012 21:57:09 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://waher.net/?p=1042</guid>
		<description><![CDATA[I am happy to announce the first release of my open-source micro-framework. It has taken hours of evening-coding and frustrations, but it&#8217;s finally here and stable enough for early release. Simply called WWW, this framework is intended for websites and infosystems and is strongly driven by API principles. Software is developed with Factory and MVC [...]]]></description>
			<content:encoded><![CDATA[<p>I am happy to announce the first release of my open-source micro-framework. It has taken hours of evening-coding and frustrations, but it&#8217;s finally here and stable enough for early release.</p>
<p>Simply called WWW, this framework is intended for websites and infosystems and is strongly driven by API principles. Software is developed with Factory and MVC principles in mind and is released as open-source, licensed under GNU Lesser General Public License Version 3.</p>
<p>Please note that this is only a developer-preview at the moment and only meant for developers. I will try to build tutorials, Wiki documentation and a sample bootstrap site within a few months.</p>
<p><a href="http://sourceforge.net/projects/www-php/" target="_blank">It is available on SourfeForge here</a></p>
<p>I shall be posting updates about WWW in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/1042/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Notepad++ theme and style for developers</title>
		<link>http://waher.net/archives/1013</link>
		<comments>http://waher.net/archives/1013#comments</comments>
		<pubDate>Thu, 29 Sep 2011 17:25:13 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://waher.net/?p=1013</guid>
		<description><![CDATA[If you are using Windows and use Notepad++ as one of your main source-code editors and happen to be a web developer then you might just love this.  I originally developed this for personal use for I was unhappy with other themes or found them a little inconsistent across different web development languages. By now [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1014" class="wp-caption alignright" style="width: 250px"><a href="http://www.waher.net/blog/waher-style.jpg"><img class="size-full wp-image-1014" title="Waher-style Theme" src="http://waher.net/wp-content/uploads/2011/09/theme.jpg" alt="Waher-style Theme" width="240" height="200" /></a><p class="wp-caption-text">Waher-style Theme</p></div>
<p>If you are using Windows and use <a href="http://notepad-plus-plus.org/" target="_blank">Notepad++</a> as one of your main source-code editors and happen to be a web developer then you might just love this.  I originally developed this for personal use for I was unhappy with other themes or found them a little inconsistent across different web development languages. By now I have used this theme in Notepad++ for more than a year now.</p>
<p><em>Thanks to this being shared in <a href="http://www.reddit.com/r/programming/comments/kvpld/reddit_encouraged_me_to_release_this/" target="_blank">reddit</a>, <a href="http://twitter.com/#!/search/%22http%3A%2F%2Fwaher.net%2Farchives%2F1013%22" target="_blank">Twitter</a> and Facebook, it has been downloaded more than ten thousand times in one day.</em></p>
<p><span id="more-1013"></span>It is recommended to use this theme with <a href="http://www.microsoft.com/download/en/details.aspx?id=17879" target="_blank">Consolas</a> font.</p>
<p>You can download the theme archive <a href="http://www.waher.net/blog/waher-style.rar" target="_blank">HERE</a> <em>(*.rar archive)</em> or the theme XML directly <a href="http://waher.net/blog/Waher-style.xml">HERE</a> <em>(right click and save-as)</em>. Preview is available <a href="http://www.waher.net/blog/waher-style.jpg" target="_blank">here</a>.</p>
<p><strong>Features:</strong></p>
<ul>
<li>Comfortable color scheme with a dark background and eye-friendly colors for working long hours</li>
<li>The styles used are intended for a web developer and cover most common files associated with web development</li>
<li>Supports Notepad++ styles for following languages and files: <strong>CSS</strong>, <strong>HTML</strong>, <strong>*.ini</strong> files, <strong>JavaScript</strong>, <strong>PHP</strong>, <strong>SQL</strong> and <strong>XML</strong>.</li>
<li>Covered by <a href="http://www.gnu.org/licenses/fdl.html" target="_blank">GNU Free License</a>, you can modify and redistribute it in however way you like.</li>
<li>Some support for Java and Python files <em>(recently added, might require some testing)</em></li>
</ul>
<p><strong>Install:</strong></p>
<ol>
<li>Unpack the *.rar archive into your <strong>Notepad++</strong> installation directory under subfolder <em>/themes/</em></li>
<li>Open <strong>Notepad++</strong></li>
<li>Go to <em>Settings -&gt; Style Configurator</em></li>
<li>Select <strong>Waher-style</strong> from <em>Select Theme</em> dropdown</li>
<li>Click <em>Save &amp; Close</em></li>
</ol>
<p>I hope this theme will serve you as well as it has served me!</p>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/1013/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Open source &#8216;WebViewApp v1.12&#8242; for Android released!</title>
		<link>http://waher.net/archives/989</link>
		<comments>http://waher.net/archives/989#comments</comments>
		<pubDate>Sun, 28 Aug 2011 11:48:17 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://waher.net/?p=989</guid>
		<description><![CDATA[I have only recently become curious about developing for Android phones. As a web developer the most important thing for me was to provide a way to bridge the gap between web applications and native applications. Free and open source WebViewApp application is a simple base setup for developing Android applications that communicate with web [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_990" class="wp-caption alignright" style="width: 250px"><a href="http://waher.net/wp-content/uploads/2011/08/primitive.jpg"><img class="size-full wp-image-990" title="WebViewApp" src="http://waher.net/wp-content/uploads/2011/08/primitive.jpg" alt="" width="240" height="241" /></a><p class="wp-caption-text">WebViewApp</p></div>
<p>I have only recently become curious about developing for Android phones. As a web developer the most important thing for me was to provide a way to bridge the gap between web applications and native applications.</p>
<p>Free and open source WebViewApp application is a simple base setup for developing Android applications that communicate with web services. WebViewApp is released as open source and developers can use this base application to build their own fully functional web applications in Android.</p>
<p><span id="more-989"></span>This application is as bare bones as possible and includes commented code and some examples.</p>
<p>Following features are included:</p>
<ul>
<li>Cookie management (application stores cookies)</li>
<li>Cache management (application stores cache based on web service cache lifetime and maintains it when user is not using the app)</li>
<li>Javascript interface (Web service can execute commands in Java and vice versa, such as for scripting hardware keys or executing alerts from web service, displayed in Android.)</li>
<li>Contained URL&#8217;s (Web service only opens its own URL&#8217;s in app, every other URL is launched in browser.)</li>
<li>Online Checks (App checks if user is online, if not then shows an offline page with an option to continue and reload where user left off once internet is back)</li>
<li>Sending custom user agent string to web service for testing if web service is used through Android app. Also includes a (possibly) unique device ID and application version for update checks.</li>
<li>Can load local HTML pages that uses local resources</li>
<li>Can be installed on SD card.</li>
<li>Can save settings and preferences</li>
<li>Can set background services and timed services</li>
<li>Can start a service at boot time</li>
<li>Can make HTTP connections to online API&#8217;s</li>
<li>Can use private and public file system, read and write files</li>
<li>Can use SQLite database</li>
</ul>
<p>This application shows that it is possible to create very extensive Android applications while relying mostly on HTML and JavaScript user interface, which makes it much easier to port to other systems or create a counterpart to browser version of a website.</p>
<p>Please note that there is no ‘guide’ on how to change the base application into your own new application, but source package does include a short overview of all the necessary modifications. Basic knowledge of Android and web development is recommended.</p>
<p>The bare-bones application can be downloaded from Android Market with its name &#8216;WebViewApp&#8217; or from <a href="https://market.android.com/details?id=com.webviewapp.app" target="_blank">Android Market</a>.</p>
<p>Source code can be downloaded from <a href="http://webviewapp.waher.net/webviewapp-source.rar" target="_blank">here</a>. This includes source code for both the Android app as well as the web service.</p>
<p>VERSION HISTORY:</p>
<blockquote><p>v1.12 Database and file system examples, HTTP request examples<br />
v1.11 Starting service at boot time<br />
v1.10 Background services and timed services<br />
v1.09 Notifications, settings and preferences<br />
v1.08 Local image test for local HTML<br />
v1.07 Activity checks and local file support<br />
v1.06 Better examples and descriptions<br />
v1.05 Possibility to keep previous scroll position<br />
v1.04 Back button now works with POST variables<br />
v1.03 Fix for back button in certain conditions<br />
v1.02 Reload page now uses Javascript interface<br />
v1.01 Fix for no-internet reload page<br />
v1.00 Release</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/989/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Estonian e-payments solution for PHP released (updated 1.4 stable 20.04.2011)</title>
		<link>http://waher.net/archives/852</link>
		<comments>http://waher.net/archives/852#comments</comments>
		<pubDate>Tue, 11 Jan 2011 18:10:08 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Web Business]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://waher.net/?p=852</guid>
		<description><![CDATA[E-payment systems and bank services are everyday and common in Estonia, but both developers and companies, who implement e-payments to websites, tend to ask large sums of money for solutions that should be relatively simple. Having developed e-payment systems for years, I had not put together a single solution for this very common problem until [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp"></div>
<div id="attachment_853" class="wp-caption alignright" style="width: 324px"><a href="http://waher.net/wp-content/uploads/2011/01/epayment.jpg"><img class="size-full wp-image-853" title="Electronic Payments" src="http://waher.net/wp-content/uploads/2011/01/epayment.jpg" alt="Electronic Payments" width="314" height="206" /></a><p class="wp-caption-text">Electronic Payments</p></div>
<p>E-payment systems and bank services are everyday and common in Estonia, but both developers and companies, who implement e-payments to websites, tend to ask large sums of money for solutions that should be relatively simple. Having developed e-payment systems for years, I had not put together a single solution for this very common problem until now, when Estonia has adopted Euro as its main currency. This solution is released open source, under <a href="http://www.gnu.org/licenses/lgpl-3.0.txt" target="_blank">LGPL</a> license.</p>
<p><span id="more-852"></span>Please note that while this e-payment system is now considered stable and has not run into major problems ever since it was released, some of the connections have been tested more often than others and it is still recommended to test the implementation and make sure it works accordingly before going live.</p>
<p><strong>E-payment systems and Bank e-services that are supported with this solution:</strong></p>
<p>Swedbank (<em>Estonia</em>)<br />
SEB (<em>Estonia</em>)<br />
Sampo (<em>Estonia &amp; Finland</em>)<br />
Nordea (<em>Estonia &amp; Finland</em>)<br />
Estcard (<em>Estonian credit card web service, Mastercard, Visa, etc</em>)</p>
<p><strong>Requirements:</strong></p>
<p>Solution is built with PHP and requires PHP support. The website or service that implements this solution should be modern and utilize UTF-8 for data encoding. This e-payment system assumes that it gets its data as UTF-8 and acts accordingly. This system may not work properly if website is not encoded in UTF-8. OpenSSL support is also required from the web server for some epayment profiles. Multibyte String extension support is required for certain UTF-8 calculations.</p>
<p><strong>Files descriptions:</strong></p>
<p><em>config.epay.php &#8211; </em>Configuration file for each profile. This also includes testing environment access informatin, if that profile has it (read the comments). Whenever setting up a e-payment link, this file should be configured accordingly.</p>
<p><em>class.epay.php</em> &#8211; Main class, this file also calls the configuration file and expects the file to be in the same directory as the <em>class.epayments.php</em> file. This file should not be edited, unless necessary for some reason.</p>
<p><em>gate.epay.php</em> &#8211; This is gateway file that is used to submit data to the bank service or parse the result from the service.</p>
<p><em>example-submit.php</em> &#8211; This is example file, which generates the form that submits order data to gateway and gateway then submits it to the bank.</p>
<p><em>example-return.php</em> &#8211; This is example return page, which receives returned information from bank.</p>
<p><strong>Example:</strong></p>
<p>This package has a working example that is easy and quick to set-up. Package includes SEB bank e-service testing environment. The only thing you have to do, to get the example up and running, is download the package below and upload it to your website under root or subfolder. For example, if you upload the files to:</p>
<p><em>http://www.example.com/epayment/</em></p>
<p>Then you have to change only two configuration settings in<em> example-submit.php</em> file, related to order information and return URL. Using the previous example, the lines should be changed accordingly:</p>
<p><em>line 22. $config['gateway-url']=&#8217;http://www.example.com/epayment/gate.</em><em>epay</em><em>.php&#8217;;<br />
line 23. $config['return-url']=&#8217;http://www.example.com/epayment/example-return.php&#8217;;</em></p>
<p>Don&#8217;t forget to change the <em>example.com</em> website address to your own website address. Nothing else needs to be changed to test if the class works.</p>
<p><strong>From example to Live implementation:</strong></p>
<p>The example runs on &#8216;seb-est&#8217; (SEB Estonia) profile. To use another bank, such as Swedbank, you need to assign correct payment-type before generating the form (like in <em>example-submit.php</em> file). Then you also need to assign proper values to<em> config.</em><em>epay</em><em>.php</em> to the profile. The settings in configuration file are commented and self-explanatory. It is important to note though that some e-payment services offer no testing environments and other epayment services cannot even be tested without the testing environment being set up by the other side first (such as the case with Estcard solutions).</p>
<p><strong>Download:</strong></p>
<p><a href="http://waher.net/waher-net-epayments.rar">waher.net e-payments solution 1.4 stable</a><strong><br />
</strong></p>
<p><strong>Other notes:</strong></p>
<p>As BETA, this solution does not check for errors in every location and there may be quirks as a result. These will be ironed out in future versions. Please report any bugs or problems you find either here in comments or personally to my e-mail kristo@waher.net</p>
<p><em><strong>Version history:</strong></em></p>
<p><em>1.4 stable<br />
20.04.2011<br />
Minor change for Nordea, switching the language keyword (estonian and english were switched)</em><strong><em> </em></strong></p>
<p><em>1.3 beta<br />
04.03.2011<br />
</em>VK_AUTO requests did not work with some banks, gateway now attempts a cURL request to remedy that, if cURL is enabled.<em><strong><br />
</strong></em></p>
<p><em>1.2 beta</em><em><strong><br />
</strong>31.01.2011</em><em><strong><br />
</strong></em>VK_AUTO assigned for ipizza profiles (Sampo, SEB and Swedbank) for automatic pings on success URL<em><strong></strong></em></p>
<p><em>1.1 beta<br />
13.01.2011</em><br />
Sampo profile now works properly, taking into account UTF-8 characters</p>
<p><em>1.0 beta</em><br />
<em>11.01.2011</em><br />
<em>First release</em></p>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/852/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Movie about making a few enemies</title>
		<link>http://waher.net/archives/492</link>
		<comments>http://waher.net/archives/492#comments</comments>
		<pubDate>Fri, 08 Oct 2010 21:00:38 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Web Business]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[movies]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://waher.net/?p=492</guid>
		<description><![CDATA[Please note that this is not review of the movie, but an opinion piece about its topics. For a review, I recommend a review from one of my most trusted reviewers, Roger Ebert of Chicago Sun-Times. David Fincher&#8217;s &#8216;The Social Network&#8217; really is more of a movie about making enemies, than making those 500 million [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_493" class="wp-caption alignright" style="width: 186px"><img class="size-full wp-image-493" title="socialnetwork" src="http://waher.net/wp-content/uploads/2010/10/socialnetwork.jpg" alt="The Social Network" width="176" height="260" /><p class="wp-caption-text">The Social Network</p></div>
<p><em>Please note that this is not review of the movie, but an opinion piece about its topics. For a review, I recommend a <a href="http://rogerebert.suntimes.com/apps/pbcs.dll/article?AID=/20100929/REVIEWS/100929984">review</a> from one of my most trusted reviewers, Roger Ebert of Chicago Sun-Times.</em></p>
<p>David Fincher&#8217;s &#8216;The Social Network&#8217; really is more of a movie about making enemies, than making those 500 million friends. But what the <a href="http://www.youtube.com/watch?v=lB95KLmpLR4">trailer</a> depicts is not what the movie is really about. After seeing the trailer, I expected something entirely different. I expected what I guess Mark Zuckerberg  &#8211; one of the creators of The Facebook &#8211; expected, a movie that paints him as a monster. Instead it was a movie about our dreams, hopes and aspirations and how, at times, we exploit, manipulate and so completely cause self-conflict because of those things we like and want to achieve. The older generation will never understand and we can only hope that our experiences will be able to serve our children better. No one was holding our hand when the internet took over the world.</p>
<p><span id="more-492"></span></p>
<p>The movie focuses primarily on relationships and on the business side of  things, it is intertwined with internet and development of applications  for the internet. I loved the subtle nuances about the role that  software developers play in this world and how it so strongly conflicts  with the way your traditional business used to work. By creating these  castles in the air, from air, a developer is in a unique position that  no other job has shared in the history of the world. There are no rules  to follow, you simply need a good idea and an even better execution. A symbiosis of art and science. What the movie displays very well is that web business does not even require huge investments and resources to become a success: merely couple of  thousand of dollars and a passionate codewriter were needed to push things off to a running start. Even some of the smarter business strategies were covered, which explain  why Facebook did not run into problems that Friendster did (which was  the first very popular Facebook-style social network).</p>
<p>These years media still wonders if Zuckerberg stole the idea for  Facebook or not. David Fincher, being a smart director that he is, never  lets that take over the role of characters in the movie. In fact, it  does not even answer the question for the viewer. But in all honesty, this was not what the movie was  about, it simply tied everything and everyone neatly together.</p>
<p>It helps that the movie takes the perspective of the most known flawed hero of this generation to carry what otherwise might end up being a cluttered movie. Zuckerberg found his creative stride during the years this so-called Web 2.0 (or simply Social Web) was catching on. Smart &#8211; but not popular. Ambitious &#8211; but not charming. He was not driven by clichèd motivations of common biographical movies, such as father issues or chase for perfection or becoming better than your competition. He wanted to become accepted and he wanted to prove to people that hurt him &#8211; and tragically himself &#8211; that making something great and popular can become something he can excuse his shortcomings with. Instead of fixing his problems, he was looking for ways to mask and excuse them.</p>
<p>&#8216;I wish I was special,&#8217; say the lyrics of the song in the trailer. So did Mark Zuckerberg and so do all of us.</p>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/492/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX controller also released as a class</title>
		<link>http://waher.net/archives/331</link>
		<comments>http://waher.net/archives/331#comments</comments>
		<pubDate>Sun, 20 Jun 2010 09:54:57 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://waher.net/?p=331</guid>
		<description><![CDATA[For phpclasses.org purposes I also converted the Smart AJAX Controller into a class, it is available here. While there aren&#8217;t big differences between the two, class structure makes the backend script more seamless and easy to use. Another improvement is the ability to return the result from the server compressed with GZip, thus making the [...]]]></description>
			<content:encoded><![CDATA[<p>For phpclasses.org purposes I also converted the Smart AJAX Controller into a class, it is available <a href="http://www.phpclasses.org/package/6276-PHP-Generate-AJAX-request-responses-in-JSON-format.html" target="_blank">here</a>. While there aren&#8217;t big differences between the two, class structure makes the backend script more seamless and easy to use. Another improvement is the ability to return the result from the server compressed with GZip, thus making the whole communication very lightweight.</p>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/331/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smart AJAX/JSON/PHP solution with jQuery</title>
		<link>http://waher.net/archives/319</link>
		<comments>http://waher.net/archives/319#comments</comments>
		<pubDate>Tue, 01 Jun 2010 21:45:57 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://waher.net/?p=319</guid>
		<description><![CDATA[I have seen a number of complicated solutions for front-end AJAX development and it has become quite clear such solutions are difficult thing to grasp for someone not that experienced with AJAX. Today I am offering a very simple and easy to extend solution that not only is less than two hundred lines of code [...]]]></description>
			<content:encoded><![CDATA[<p>I have seen a number of complicated solutions for front-end AJAX development and it has become quite clear such solutions are difficult thing to grasp for someone not that experienced with AJAX. Today I am offering a very simple and easy to extend solution that not only is less than two hundred lines of code in total &#8211; together with detailed comments &#8211; but also gives the ropes to jQuery AJAX development and using JSON as the preferred type of returned data from the server. Fear not, this is actually easier than it sounds.</p>
<p><span id="more-319"></span></p>
<p>For those of you looking for the files directly, they can grab them <a title="smart-json-ajax-solution.rar" href="http://waher.net/blog/smart-json-ajax-solution.rar">here</a>. Individual source code can be viewed here: <a href="http://waher.net/blog/smart-ajax/index.htm.txt">index.htm</a>, <a href="http://waher.net/blog/smart-ajax/javascript.js.txt">javascript.js</a>, <a href="http://waher.net/blog/smart-ajax/ajax.php.txt">ajax.php</a>. Note that jquery.js file is also required (1.4.2), should you copy-paste from the source code instead of downloading the archive.</p>
<p>The code is licensed under LGPL, so you can use it for personal as well as commercial purposes. All files are commented and a working example is provided within. You do not need a firm grasp of jQuery in order to understand this example and you do not need experience with JSON data format. PHP and jQuery handle the conversions for you. I will not explain everything step by step &#8211; for that refer to the files and the example provided &#8211; but I will give a general overview of what is happening here.</p>
<p>Front-end user-interface has the various actions built through a uiAction() javascript function. This is a general-use function that takes two variables, an &#8216;action&#8217; that acts as an action identifier, and &#8216;data&#8217; variable. Data variable can be whatever you want, it can be a string, integer, array or an object, depending on your needs. Since you will control how the &#8216;data&#8217; variable will be used, it is entirely up to you. In the example files I am calling the uiAction() on a &lt;button&gt; element like this:</p>
<p><em>uiAction(&#8216;alertLowercaseString&#8217;,$(&#8216;#example&#8217;).val());</em></p>
<p>For those of you who know jQuery, know that I am sending the value of an input field with an id of &#8216;example&#8217; to the function. Action&#8217;s name itself is &#8216;alertLowercaseString&#8217; in that case. Then, within uiAction() function in the &#8216;action&#8217;-switch I am executing the function that sends data to AJAX, like this:</p>
<p><em>input['string']=data;<br />
executeAjaxAction(action,input);</em></p>
<p>Action is, by default, the same as action identifier used to call uiAction(). executeAjaxAction() is a function that submits data to PHP backend (but you can customize it, such as have different uiAction() calls execute same function in back-end). &#8216;input&#8217; is an uiAction() specific javascript object. This is defined at the start of the uiAction() function and is used for convenience in order to send specific data to AJAX. &#8216;executeAjaxAction()&#8217; expects &#8216;input&#8217; to be an object or an array, since this is what will be sent to PHP backend. After submitting data to executeAjaxAction() the front-end will connect PHP back-end with AJAX. In this case I am sending an &#8216;action&#8217; of alertLowercaseString. PHP backend will solve the &#8216;input&#8217; into a variable named $inputVariables and again &#8211; as it was in front-end, within a switch you can define what you want to take place in the back-end and what will be returned. In this example it is:</p>
<p><em>$return['action']=&#8217;alert&#8217;;<br />
$return['message']=&#8217;Your string lowercased: &#8216;.strtolower($inputVariables['string']);</em></p>
<p>&#8216;$return&#8217; is an array that is used to create a JSON object from. &#8216;action&#8217; for &#8216;$return&#8217; needs to be always defined, but every other variable can be whatever you want, since &#8211; as before &#8211; you get to decide what data you need to use later on in front end. Basically everything you want to return to front-end should be placed in &#8216;$return&#8217; array. PHP then creates a JSON string of the &#8216;$return&#8217; array and returns it to the browser. executeAjaxAction() function will then call a javascript function parseAjaxReturn(), which will check what action PHP defined for callback (if any) and then &#8211; in this example of &#8216;alert&#8217; as the action &#8211; does the following:</p>
<p><em>alert(json['message']);</em></p>
<p>And this alerts to the user the lowercased string.</p>
<p>This quick explanation may be difficult to understand at first, but I strongly suggest that you take a look at the fully working examples provided within. Files are fully commented and examples provided within are minimal, so you can take this into production use right away should you want.</p>
<p><a title="smart-json-ajax-solution.rar" href="http://waher.net/blog/smart-json-ajax-solution.rar">Download fully working example files here</a></p>
<p>If you have any questions, go ahead and contact me directly or comment this article. I will get back to you as soon as possible.</p>
<p>All the best!</p>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/319/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A simple PHP pathfinder class &#8211; as promised</title>
		<link>http://waher.net/archives/313</link>
		<comments>http://waher.net/archives/313#comments</comments>
		<pubDate>Tue, 25 May 2010 20:55:58 +0000</pubDate>
		<dc:creator>Kristo Vaher</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://waher.net/?p=313</guid>
		<description><![CDATA[I recently shared a simple PHP and jQuery animated pathfinding tech-demo through my Twitter account and promised to share the simple pathfinding class used for pathfinding calculations. The example shared in Twitter is still available here. This example has a few limits, that is you can easily confuse it by clicking on two tile locations [...]]]></description>
			<content:encoded><![CDATA[<p>I recently shared a simple PHP and jQuery animated pathfinding tech-demo through my Twitter account and promised to share the simple pathfinding class used for pathfinding calculations. The example shared in Twitter is still available <a href="http://waher.net/pathfinder/" target="_blank">here</a>.</p>
<p><span id="more-313"></span></p>
<p>This example has a few limits, that is you can easily confuse it by clicking on two tile locations in a row. But in general it works and what I will be using this for will be something a bit different, so this limitation was of no concern to me. However the entire pathfinding calculation takes place on PHP backend. Each map is essentially a square (currently a limitation of pathfinder, but can easily be tweaked) and stored as an associative array, every tile in that array like this:</p>
<p><strong>$map['1x1']['weight']=1.0;</strong></p>
<p>The first key is the coordinate of the single map tile and the weight key is used to store weight of this map tile for calculations. Nothing else is needed (and an example is provided in the files below). For actual game purposes or whatnot you can store additional information on that very map as long as the coordinate and weight are assigned as shown in the example. For example, in my own tech-demo I also store the graphic tile used in the map array.</p>
<p>Finding the actual path is just as simple:</p>
<p><strong>$map=getMap();<br />
require(&#8216;class.pathfinder.php&#8217;);<br />
$path=new PathFinder(); </strong><em>//Create new pathfinder object</em><strong><br />
$path-&gt;setOrigin(1,1); </strong><em>//Set the start location</em><strong><br />
$path-&gt;setDestination(20,20); </strong><em>//Set the destination</em><strong><br />
$path-&gt;setMap($map); </strong><em>//Assign the map to use for calculations</em><strong><br />
$result=$path-&gt;returnPath(); </strong><em>//Returns an array of all the walked steps</em></p>
<p>Working example, as well as commented pathfinder class is available below:<em><br />
</em></p>
<p><a href="http://www.waher.net/blog/pathfinder.rar">Download the class and example file here</a></p>
<p>Please note that this is not a definitive pathfinder. It only takes into account one square ahead and on very large maps I am sure there are more ideal solutions. But for your basic browser based game this is a good starting point and I learned a lot by creating it. This is also easy to expand based on your needs.</p>
<p>If you have any other questions, let me know.</p>
<p>The code is shared entirely free for personal or commercial use.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://waher.net/archives/313/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

