<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-26602852</atom:id><lastBuildDate>Sun, 20 May 2012 16:06:09 +0000</lastBuildDate><category>Cryptography</category><category>extensions</category><category>Jasper</category><category>jQuery</category><category>MySQL</category><category>Compatibility</category><category>Political</category><category>AJAX</category><category>Microsoft Word</category><category>Google Charts</category><category>DVR</category><category>VB.NET</category><category>Security</category><category>Java</category><category>Apple</category><category>IDE</category><category>Google</category><category>Web</category><category>Reporting</category><category>Distributed Computing</category><category>PHP</category><category>XHR</category><category>Frameworks</category><category>Games</category><category>Google Chrome</category><category>gbpvr</category><category>Eclipse</category><category>HTML</category><category>Web Browsers</category><category>Google Documents</category><category>Google API</category><category>JSF</category><category>MD5</category><category>Hiring</category><category>JavaScript</category><category>HTML5</category><title>Robs Programming Junk</title><description>Welcome to my programming blog.  This Blog contains my research and notes pertaining to programming. You are free to use any information on this site however you must make a comment on the blog, and put credit in your code that you obtained it from here. You can contact me directly at rob @at@ robsprogrammingjunk.com.</description><link>http://www.robsprogrammingjunk.com/</link><managingEditor>noreply@blogger.com (Rob)</managingEditor><generator>Blogger</generator><openSearch:totalResults>80</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1669223578021203772</guid><pubDate>Tue, 10 Apr 2012 21:25:00 +0000</pubDate><atom:updated>2012-04-10T14:25:58.920-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>HTML5</category><category domain='http://www.blogger.com/atom/ns#'>Web Browsers</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><category domain='http://www.blogger.com/atom/ns#'>jQuery</category><title>Internet explorer is the devils work!</title><description>For some time I have bashed IE. &amp;nbsp;It's non-compliant DOM to performance issues to just hating Microsoft as a whole. &amp;nbsp;Why? &amp;nbsp;Microsoft takes the approach that because they are big they don't have to change. &amp;nbsp;Clearly not everyone fears Microsoft. &amp;nbsp;I read an article recently in TechCrunch (Thanks to Alex for sending it) how a&amp;nbsp;&lt;a href="http://techcrunch.com/2012/04/01/bootstrapped-startup-saves-over-100k-by-dropping-ie/"&gt;Bootstrapped Startup Saves Over $100K By Dropping IE&lt;/a&gt;. &amp;nbsp;I don't care if this article is&amp;nbsp;blatant&amp;nbsp;Microsoft bashing or not. &amp;nbsp;The point is this article is true. &amp;nbsp;I speak from experience that I can develop awesome software then throw it into IE to unit test and have it FAIL! &amp;nbsp;That is unacceptable in my mind given that Webkit (Chrome/Safari) is standards based. &amp;nbsp;The "Big guy" on the block IE should be leading the pack not trailing behind it. &lt;br /&gt;&lt;br /&gt;This article proves companies can be successful by not adopting IE. &amp;nbsp;I find that there are many people out there living in fear over IE. &amp;nbsp;They simply believe people are not able to install another web browser. &amp;nbsp;I was one of those people. &amp;nbsp;I thought that I had to adopt IE simply because people were unable to install and use Chrome. &amp;nbsp;I realized this was just a scare tactic when I was going to recommend using Chrome to my Dad and he said he was already using it. &amp;nbsp;I was floored. &amp;nbsp;My Dad while not technically inept, doesn't just install software on his PC. &amp;nbsp;I have him fearing most software out there because of the number of times I've had to reset his machine. &amp;nbsp;Much to my surprise he took this upon himself to install and use. &amp;nbsp;If he can do it, anyone can.&lt;br /&gt;&lt;br /&gt;This raises the question as a developer why we are not supporting Chrome more. &amp;nbsp;Clearly users would use Chrome on our website if we told them we preferred it. &amp;nbsp;We know we prefer it as developers. &amp;nbsp;Perhaps now is the time to start changing and&amp;nbsp;encouraging&amp;nbsp;users to use this fine piece of software. &amp;nbsp;Oddly Google is not supporting a "Best viewed in Chrome" badge. &amp;nbsp;I was unable to find any sort of download button/badge for websites. &amp;nbsp;Hard to believe this momentum for Chrome is built from a few simple links on Google's search page. &lt;br /&gt;&lt;br /&gt;I believe Chrome will evolve the web to what it should be. &amp;nbsp;The question is will Microsoft be able to keep up with Chrome before it's too late. &amp;nbsp;I pity the IE development team. &amp;nbsp;That has to be the worst job in the world.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1669223578021203772?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2012/04/internet-explorer-is-devils-work.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-6899258859775021687</guid><pubDate>Thu, 05 Apr 2012 15:05:00 +0000</pubDate><atom:updated>2012-04-25T08:48:00.989-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>HTML5</category><category domain='http://www.blogger.com/atom/ns#'>Google Documents</category><category domain='http://www.blogger.com/atom/ns#'>Google API</category><category domain='http://www.blogger.com/atom/ns#'>Google</category><category domain='http://www.blogger.com/atom/ns#'>Google Charts</category><title>Google Chart From Google Spreadsheet</title><description>Excellent piece of code here that allows you to extract data from your google spreadsheet into a google chart or in this case a table. &amp;nbsp;Simple filters in the setQuery you can show daily status out of a shared spreadsheet. &amp;nbsp;Very nice for collaborators that need public viewers of google spreadsheets in a more polished format.&lt;br /&gt;&lt;pre class="brush: html"&gt;    &lt;br /&gt;&lt;!--&lt;br /&gt;You are free to copy and use this sample in accordance with the terms of the&lt;br /&gt;Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)&lt;br /&gt;--&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;  &lt;head&gt;&lt;br /&gt;    &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt;&lt;br /&gt;    &lt;title&gt;&lt;br /&gt;      Google Visualization API Sample&lt;br /&gt;    &lt;/title&gt;&lt;br /&gt;    &lt;script src="http://www.google.com/jsapi" type="text/javascript"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;    &lt;script type="text/javascript"&gt;&lt;br /&gt;      google.load('visualization', '1', {packages: ['table']});&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;&lt;/script&gt;&lt;br /&gt;    &lt;script type="text/javascript"&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    function drawVisualization() {&lt;br /&gt;    &lt;br /&gt;      var opts = {dataType:'jsonp'};&lt;br /&gt;      var query = new google.visualization.Query('https://docs.google.com/spreadsheet/pub?key=0AiEVKSSB6IaqdFBCd181YUpZVjVwdm5zUDRiNHNhdHc&amp;gid=0', opts);&lt;br /&gt;      &lt;br /&gt;      // Optional request to return only column C and the sum of column B, grouped by C members.&lt;br /&gt;      query.setQuery("select * where date '2012-04-04' = F");&lt;br /&gt;      &lt;br /&gt;      // Send the query with a callback function.&lt;br /&gt;      query.send(handleQueryResponse);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    function handleQueryResponse(response) {  &lt;br /&gt;      // Create and populate the data table.&lt;br /&gt;      var data = response.getDataTable();&lt;br /&gt;    &lt;br /&gt;      // Create and draw the visualization.&lt;br /&gt;      visualization = new google.visualization.Table(document.getElementById('table'));&lt;br /&gt;      visualization.draw(data, null);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    google.setOnLoadCallback(drawVisualization);&lt;br /&gt;    &lt;br /&gt;&lt;/script&gt;&lt;br /&gt;    &lt;div id="table"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-6899258859775021687?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2012/04/google-chart-from-google-spreadsheet.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-5588080580370666033</guid><pubDate>Thu, 15 Mar 2012 14:21:00 +0000</pubDate><atom:updated>2012-03-15T07:22:52.695-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Java</category><category domain='http://www.blogger.com/atom/ns#'>Frameworks</category><category domain='http://www.blogger.com/atom/ns#'>Distributed Computing</category><title>Hazelcast</title><description>&lt;a href="http://www.hazelcast.com/"&gt;http://www.hazelcast.com/&lt;/a&gt;&amp;nbsp;This makes me drool with&amp;nbsp;possibilities. &amp;nbsp;How many times I could have used this in the past. &amp;nbsp;I'm glad to have stumbled across this, I guarantee I'll be using this in the future.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-5588080580370666033?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2012/03/hazelcast.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1022741461395386681</guid><pubDate>Fri, 02 Mar 2012 21:20:00 +0000</pubDate><atom:updated>2012-03-15T07:23:22.533-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><category domain='http://www.blogger.com/atom/ns#'>jQuery</category><title>jQuery Class</title><description>I use jQuery all the time and for those of you that don't you can now take some classes on it.&amp;nbsp;&lt;a href="http://learnjquery.tutsplus.com/"&gt;http://learnjquery.tutsplus.com/&amp;nbsp;&lt;/a&gt;&amp;nbsp;gives you a new lesson each day and allows you to become a jQuery pro in just a month. &amp;nbsp;Worth checking out. &amp;nbsp;Props to my friend Daniel who alerted me to this.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1022741461395386681?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2012/03/jquery-class.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-6472615868529128599</guid><pubDate>Tue, 21 Feb 2012 20:58:00 +0000</pubDate><atom:updated>2012-03-15T07:24:24.019-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>Security</category><category domain='http://www.blogger.com/atom/ns#'>MD5</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><title>MD5 Hash function in Javascript</title><description>I recently had to create an MD5 hash for some test code I was writing. &amp;nbsp;With some persistent googling I ran across&amp;nbsp;&lt;a href="http://code.google.com/p/crypto-js/"&gt;http://code.google.com/p/crypto-js/&lt;/a&gt;&amp;nbsp;which is a fantastic set of&amp;nbsp;library&amp;nbsp;for javascript crypto. &amp;nbsp;I was easily able to integrate it into my javascript.&lt;br /&gt;&lt;br /&gt;A simple Crypto.MD5() call is all that's necessary to run a quick MD5 hash. SHA1 and other popular cryptos are available as well.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-6472615868529128599?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2012/02/md5-hash-function-in-javascript.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-2436081059512884145</guid><pubDate>Wed, 18 Jan 2012 16:16:00 +0000</pubDate><atom:updated>2012-03-15T07:24:45.573-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Political</category><title>Watching the SuperBowl? - You Support SOPA!</title><description>Are you planning on watching the SuperBowl this year? &amp;nbsp;If so you are supporting SOPA! &amp;nbsp;The National Football League is one of the supporters of SOPA! &amp;nbsp;Simply take a look at &lt;a href="http://www.opencongress.org/bill/112-h3261/show" target="_blank"&gt;SOPA HR 3261&lt;/a&gt;&amp;nbsp;and you will see the &lt;a href="http://www.opencongress.org/bill/112-h3261/money" target="_blank"&gt;NFL supports SOPA&lt;/a&gt;! &amp;nbsp;So if you are wearing your NFL jersey, watching a football game or planning to watch the SuperBowl you are supporting SOPA. &lt;br /&gt;&lt;br /&gt;You can feel free to contact the NFL and tell them what you think of your money going to support this bill. &amp;nbsp;I know I sent an email and I'm not planning on watching the SuperBowl until they publicly say they wont be supporting it. &amp;nbsp;clare.graff@nfl.com and Amy.Jorgensen@nfl.com who are their media contacts and tell them what you think!&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-2436081059512884145?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2012/01/watching-superbowl-you-support-sopa.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-849001176787353628</guid><pubDate>Thu, 20 Oct 2011 22:14:00 +0000</pubDate><atom:updated>2012-03-15T07:25:24.135-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Political</category><category domain='http://www.blogger.com/atom/ns#'>Apple</category><title>More reasons to hate apple</title><description>&lt;div&gt;&lt;a href="http://rss.slashdot.org/~r/Slashdot/slashdotDevelopers/~3/JdkZla1HKQI/os-x-notifier-app-growl-goes-closed-source"&gt;OS X Notifier App Growl Goes Closed Source&lt;/a&gt;&lt;br /&gt;this is exactly why I hate apple this is where software development goes the wrong direction.&amp;nbsp; we shouldn't be taking open source and make you closed source so we can make a quick buck.&amp;nbsp;&amp;nbsp; shame on apple I hope you end up with a big fat law suit.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-849001176787353628?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2011/10/more-reasons-to-hate-apple.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7090283039168226600</guid><pubDate>Thu, 20 Oct 2011 22:09:00 +0000</pubDate><atom:updated>2012-03-15T07:25:56.263-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Hiring</category><category domain='http://www.blogger.com/atom/ns#'>Political</category><title>alternative hiring</title><description>&lt;div&gt;&lt;a href="http://rss.slashdot.org/~r/Slashdot/slashdotDevelopers/~3/QupotvMTTZk/gnarly-programming-challenges-help-recruit-coders"&gt;Gnarly Programming Challenges Help Recruit Coders&lt;/a&gt;&lt;br /&gt;I wonder how many of these people don't fit the job description.&amp;nbsp; I've always said you don't have to have a degree to be a good programmer. &amp;nbsp;This goes to prove that the traditional model doesn't always work when it comes to programming.&amp;nbsp; I'm in favor of hiring based on skills not based on a phd od degree.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7090283039168226600?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2011/10/alternative-hiring.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-3005201550276440475</guid><pubDate>Thu, 20 Oct 2011 15:11:00 +0000</pubDate><atom:updated>2012-03-15T07:26:20.170-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Games</category><title>48 hours?</title><description>&lt;div&gt;&lt;a href="http://rss.slashdot.org/~r/Slashdot/slashdotDevelopers/~3/PAE3tGfMsFo/coding-games-in-48-hours"&gt;Coding Games In 48 Hours&lt;/a&gt;&lt;br /&gt;How does one keep sane coding for that long?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-3005201550276440475?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2011/10/48-hours.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7500225106445867689</guid><pubDate>Thu, 18 Aug 2011 15:58:00 +0000</pubDate><atom:updated>2011-08-18T08:58:44.103-07:00</atom:updated><title>Free Standford AI Classes</title><description>Stanford University School of Engineering offers free online courses (October-December, 2011) for the following topics:&lt;br /&gt;* Artifical Intelligence: http://www.ai-class.com/&lt;br /&gt;* Databases: http://www.db-class.com/&lt;br /&gt;* Machine Learning: http://www.ml-class.com/&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7500225106445867689?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2011/08/free-standford-ai-classes.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-2203242444336765910</guid><pubDate>Thu, 18 Aug 2011 15:47:00 +0000</pubDate><atom:updated>2011-08-18T08:51:01.384-07:00</atom:updated><title>Comparing files across linux or unix boxes</title><description>I recently had the problem of needing to compare files across linux boxes.  The problem was that I  wanted to diff them easily.  After some trial and error I found out how to easily diff two files on two different boxes. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ssh user@myserver.com "cat /var/www/html/myfile.php" |diff - myfile.php&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What this does is SSH into the box, then cat the output of the file.  This is piped into diff and then compared to the local file. &lt;br /&gt;&lt;br /&gt;I used the -b option as well (though not shown) to ignore white space changes since they were html files.&lt;br /&gt;&lt;br /&gt;This saved a lot of time comparing files vs copying them to a local filesystem and doing a diff there. &lt;br /&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-2203242444336765910?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2011/08/comparing-files-across-linux-or-unix.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-8683263556438735848</guid><pubDate>Tue, 05 Jan 2010 17:34:00 +0000</pubDate><atom:updated>2012-03-15T07:28:10.807-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>IDE</category><category domain='http://www.blogger.com/atom/ns#'>PHP</category><category domain='http://www.blogger.com/atom/ns#'>Eclipse</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><category domain='http://www.blogger.com/atom/ns#'>jQuery</category><title>Aptana, FTP, WebDav, PDT and Eclipse - Why cant FTP be easy?</title><description>&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;I've used Aptana now for quite some time and I was disappointed to hear they were discontinuing PHP development.  Not surprising considering the PDT acceptance and integration from everything from Eclipse to Zend as the primary PHP development toolkit.  The &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;huge&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; hassle for me was that the &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;FTP and WebDav&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; plugins for Eclipse are useless from a web developer perspective.  Frequently I'm challenged with small modifications to existing sites and uploading and downloading with other tools or "importing" and exporting is unrealistic.  I would spend more time and effort in setting up a project than making some of the changes on a clients website.  This also doesn't address the issues surrounding a team environment where you might need to sync back and forth on the same FTP server with multiple users.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"&gt; &lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;So, after much hassle with Aptana, Eclipse and PHP I figured out how to have everything I need for development.  This allows me to continue to use Aptana's FTP/SFTP plugins, JavaScript and jQuery tools as well as use PDT as the development IDE.  This also enabled me to use other eclipse plugins I liked the &lt;/span&gt;&lt;a href="http://www.jcraft.com/eclipse-sftp/"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;SFTP Plugin&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; which I couldn't get installed in Aptana's standalone version.  So here is the process for getting everything you had in Aptana 1.5 working with Aptana 2.0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Step 1.  Download and install &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;a href="http://www.eclipse.org/downloads/"&gt;Eclipse PHP Tools &lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;a href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR1/eclipse-php-galileo-SR1-linux-gtk.tar.gz" style="color: #5797b0;" target="_blank"&gt;&lt;/a&gt;Step 2. Add Eclipse as a new site and install it as a plugin to Eclipse &lt;/span&gt;&lt;a href="http://www.aptana.org/studio/plugin" style="color: #5797b0;" target="_blank"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;http://www.aptana.org/studio/plugin&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; This will require a restart of the IDE.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Step 3. After that is complete, go to Window -&amp;gt; My Studio, Click the plugins graphic.  Using the Ajax Tab, find Jquery, and click Get It.  This runs the update manager, you'll need to select jQuery in the list of ajax plugins.  You can optionally install all, but jquery is the only framework I generally use.  Restart of IDE Required&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Step 4. Window -&amp;gt; Open Perspective, choose Aptana Web&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;You should then be able to use the file manager to create FTP connections and continue as before.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; Apatana folks really need to make this part of the FAQ.  &lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-8683263556438735848?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2010/01/aptana-ftp-webdav-pdt-and-eclipse-why.html</link><author>noreply@blogger.com (Rob)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1269116425951284931</guid><pubDate>Thu, 23 Jul 2009 18:17:00 +0000</pubDate><atom:updated>2012-03-15T07:27:21.476-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Reporting</category><category domain='http://www.blogger.com/atom/ns#'>Java</category><category domain='http://www.blogger.com/atom/ns#'>Jasper</category><title>Dynamic Query Parameters for Jasper Reports</title><description>Recently I've been working with Jasper Reports.  I don't often do a lot of report writing so I enjoyed the opportunity to work on something different.  &lt;br /&gt;&lt;br /&gt;Once I had a query full of data I began to use the Jasper Parameters to filter out items in my query.  For example I might have a query that looks like this.&lt;br /&gt;&lt;br /&gt;select * from employees where first='$P{first_name}' and last='$P{last_name)'&lt;br /&gt;&lt;br /&gt;Really simple stuff here nothing that Jasper didn't do or support.  So I of course took this to the next level and said ok, I'm just looking for a last name so lets put in just the last name, leave the first name blank.  Well when I did that the whole thing blew up because I had a query that looked like this at runtime&lt;br /&gt;&lt;br /&gt;select * from employees where first='' and last='Smith'&lt;br /&gt;&lt;br /&gt;So I have to put a parameter in?  That's ridiculous! Searching around the meager JasperReports documentation I couldn't find anything helpful either.  Checking with co-workers who use this more than I do I found that most of the time they build SQL in a stored procedure for this.  I'm not opposed to a stored procedure but when you just want to filter a few things it's really stupid to have to jump through those kind of hoops.&lt;br /&gt;&lt;br /&gt;I came up with a elegant solution to this that I could do within iReport and with no extra classes (as jasper suggests using a scriptlet - which isnt really a script its a java class).&lt;br /&gt;&lt;br /&gt;The solution was quite simple once I figured it out.  I created the regular parameter for input.  This would be first_name, I then created a second parameter (not for input) called first_name_value.  Inside the first_name_value "Default Value Expression" I entered this java code:&lt;br /&gt;&lt;br /&gt;($P{first_name}.isEmpty()==true ? "" : " and first='" + $P{first_name} +"'" )&lt;br /&gt;&lt;br /&gt;Now, once I had that inside my SQL code I used the following&lt;br /&gt;&lt;br /&gt;select * from employees where last='$P{last_name)' $P!{first_name_value}&lt;br /&gt;&lt;br /&gt;What this does is output NOTHING if first_name is blank.  If it is filled with a value we add the entire "and first='John'" at runtime into the SQL statement.  This of course has the drawback that you have to have at least 1 qualifier in your sql statement.  Try something like where last!='' as a default.  This then gives you every row and any "and" clauses are appended to the end.  Also notice the $P! with the ! in there.  That means it will evaluate before the query.&lt;br /&gt;&lt;br /&gt;Why not just use a stored procedure?  Well a couple of reasons.  First, SP's take time.  Sure, you might be good at them and can get your SP written in a short amount of time.  Go for it.  This solution works well because you don't have to bother with an SP at all.  A simple query can be done within iReport and these filters applied.&lt;br /&gt;&lt;br /&gt;Get fancy.  You could get fancy with this and use your expression code to handle replacements as well.  For example you could allow a &amp;gt; 95 and change the code to remove the = sign if something like that is input.  &lt;br /&gt;&lt;br /&gt;Hope this helps in your report development.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1269116425951284931?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/07/dynamic-query-parameters-for-jasper.html</link><author>noreply@blogger.com (Rob)</author><thr:total>13</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1682031522933401049</guid><pubDate>Fri, 08 May 2009 15:14:00 +0000</pubDate><atom:updated>2009-05-08T08:24:15.549-07:00</atom:updated><title>IE8 Developer Tools</title><description>I have never been a fan of IE8.  Most serious developers (web or otherwise) know that it is rubbish that unfortuneately has a very large adoption.  I generally do most of my web development in &lt;a href="http://www.mozilla.com/firefox/"&gt;FireFox&lt;/a&gt; and use &lt;a href="http://www.getfirebug.com/"&gt;Fire Bug&lt;/a&gt; to do my web site debugging and design.  I like of course the on-the-fly features of changing and prototyping different web layouts.&lt;br /&gt;&lt;br /&gt;IE has always been a pain my side not only because of their refusal to adopt widely used DOM standards but buggy browsers that are impossible to reasonably debug.  &lt;br /&gt;&lt;br /&gt;Today I needed to verify a layout issue and with my recent IE8 upgrade noticed the developers tools in the menu.  I nearly fell out of my chair in shock to see a robust set of developer tools.  This was just amazing that I could now do nearly the same things I could do in Fire Bug.  I am in no way going to ditch firebug but I now have a rather decent means to debug IE problems specifically.&lt;br /&gt;&lt;br /&gt;I could use Fire Bug Lite but I find that it's performance is poor in IE.  This does work well however.  I imagine that Microsoft is trying to muscle-in on the developer market but I think most serious developers are going to do ground-up development in FireFox.&lt;br /&gt;&lt;br /&gt;Chrome is still my favorite browser to surf in.  I can't wait till they get the developer tools in it so I can use it for more web development.&lt;br /&gt;&lt;br /&gt;Anyhow, IE8 gained a few (very few) points with me today since they finally got some developer tools that actually work.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1682031522933401049?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/05/ie8-developer-tools.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-520837291356017639</guid><pubDate>Sat, 18 Apr 2009 21:31:00 +0000</pubDate><atom:updated>2009-04-18T14:39:24.033-07:00</atom:updated><title>Portable Ubuntu - Take Linux With You</title><description>I have to admit that I first thought that portable Ubuntu was going to be a install on a flash drive.  It actually runs UNDER windows.  The real credit though goes to &lt;a href="http://www.colinux.org/"&gt;Cooperative Linux&lt;/a&gt;.  This allows a linux distro (almost any) to run while windows is running.  Now I took the easy route and ran Ubuntu which is a decent distro for most desktop users.  &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Performance&lt;/b&gt;&lt;br /&gt;It ran sluggish at first.  I was really kind of disappointed and thought that it was because it was running from the flash drive.  It really was just not getting enough CPU.  I was able to improve the experience considerably on my laptop by setting the colinux and associated exe's to a high priority.  This allowed them to get a bit more task scheduling from windows.  This was enough to kill the little bit of sluggishness and get me rocking with all that linux has to offer.&lt;br /&gt;&lt;br /&gt;On a side note this isnt my first experience with linux or ubuntu.  I've run it under VM's and dedicated boxes for some time.  It is just very nice to be able to start it up, shut it down and run it while I'm running windows apps.  I'm going to go download aptana for linux and try it out under there.  Would be nice to be able to take my favorite IDE everywhere regardless of the PC I'm on.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-520837291356017639?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/04/portable-ubuntu-take-linux-with-you.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-4837593458802025866</guid><pubDate>Thu, 09 Apr 2009 18:18:00 +0000</pubDate><atom:updated>2012-04-25T06:50:55.809-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Microsoft Word</category><category domain='http://www.blogger.com/atom/ns#'>PHP</category><category domain='http://www.blogger.com/atom/ns#'>Compatibility</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><title>Quote Curling Function</title><description>I recently had to add some curly quotes to text on the page.  The following function allows you to add Microsoft Word Style Curly Quotes in replacement of standard quotes.  Uses some basic regex to accomplish this quickly and easily.  &lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: php"&gt;&lt;br /&gt;echo curlQuotes('"This" is a "test", a great "test" I think. Don\'t you?');&lt;br /&gt;&lt;br /&gt;// Curl Quote Function rob@mechsoftware.com&lt;br /&gt;function curlQuotes($curlme) {&lt;br /&gt; // Adds fancy Microsoft Word Style Quotes to standard text.&lt;br /&gt; $curlme = preg_replace('/(.+)"(.+)"(.+)/Ss',"$1&amp;#8220;$2&amp;#8221;$3",$curlme);&lt;br /&gt; $curlme = preg_replace('/(.+)"(.+)"/Ss',"$1&amp;#8220;$2&amp;#8221;",$curlme);&lt;br /&gt; $curlme = preg_replace('/"(.+)"(.+)/Ss',"&amp;#8220;$1&amp;#8221;$2",$curlme);&lt;br /&gt; $curlme = str_replace("'",'&amp;#8217;',$curlme); &lt;br /&gt; return $curlme;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Output is:&lt;br /&gt;&lt;br /&gt;&amp;#8220;This&amp;#8221; is a &amp;#8220;test&amp;#8221;, a great &amp;#8220;test&amp;#8221; I think. Don&amp;#8217;t you?&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-4837593458802025866?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/04/quote-curling-function.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-4843878042967551873</guid><pubDate>Mon, 16 Feb 2009 14:55:00 +0000</pubDate><atom:updated>2009-02-16T06:58:09.781-08:00</atom:updated><title>Same Blog, New Look</title><description>You have to be blind not to notice the new look on my blog. It now matches the www.mechsoftware.com look and feel for a uniform look across my sites.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-4843878042967551873?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/02/same-blog-new-look.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1675291598727079424</guid><pubDate>Fri, 23 Jan 2009 21:33:00 +0000</pubDate><atom:updated>2011-06-05T12:06:46.225-07:00</atom:updated><title>On the fly JavaScript Packing - Speed up your site!</title><description>&lt;a href="http://developer.yahoo.com/performance/rules.html#minify"&gt;Minification of javascript has many benefits.&lt;/a&gt;  One thing that is a pain for developers is remembering to pack your javascript before deployment.  Another big pain is if you need to do an on-server change of some JavaScript code.  Using &lt;a href="http://joliclic.free.fr/php/javascript-packer/en/"&gt;Packer JavaScript en PHP&lt;/a&gt; a small PHP file and a tweak to .htaccess you can minify your JavaScript on the fly and never again have to worry about minifying your javascript.  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First, download the &lt;a href="http://joliclic.free.fr/php/javascript-packer/en/"&gt;Packer JavaScript en PHP&lt;/a&gt; and extract class.JavaScriptPacker.php to some location on your server.  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now create a .PHP file with the following code.&lt;br /&gt;&lt;pre  class="brush: php"&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;require 'class.JavaScriptPacker.php';&lt;br /&gt;if(substr($_REQUEST['js'],0,1)=="/")&lt;br /&gt;  $_REQUEST['js']=substr($_REQUEST['js'],1);&lt;br /&gt;$script = file_get_contents($_REQUEST['js']);&lt;br /&gt;&lt;br /&gt;$packer = new JavaScriptPacker($script, 'Normal', true, false);&lt;br /&gt;$packed = $packer-&gt;pack();&lt;br /&gt;&lt;br /&gt;echo $packed;&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next, bust open the .htaccess and add the following.  Note you should have mod_rewrite enabled and mod_rewrite set to ON.  If you dont know how to do this, contact your sysadmin or check it out on apache's website.&lt;br /&gt;&lt;pre  class="brush: php"&gt;&lt;br /&gt;RewriteRule ^(.+)\.js$ jsProxy.php?js=/$1.js&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, the concept here is pretty simple.  You take any .js javascript file and route it through the proxy.  Once the proxy gets it, the packer compresses it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Need to exclude a file? Simply make it .jsx or some other extension other than .js, the browser doesn't care but mod_rewrite will ignore it.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1675291598727079424?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/on-fly-javascript-packing-speed-up-your.html</link><author>noreply@blogger.com (Rob)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-8258804849709082197</guid><pubDate>Thu, 22 Jan 2009 08:00:00 +0000</pubDate><atom:updated>2012-04-25T06:37:07.130-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>XHR</category><category domain='http://www.blogger.com/atom/ns#'>PHP</category><category domain='http://www.blogger.com/atom/ns#'>AJAX</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><category domain='http://www.blogger.com/atom/ns#'>jQuery</category><title>Super Simple AJAX Forms with jQuery and JSON : dataservice.php</title><description>Our last installment of the Super Simple AJAX Forms with jQuery and JSON we cover the server side of things.  The dataservice.php file covers the business logic behind the web form.  Like the webpage.html I boiled this down to the smallest and most reusable code possible.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The very top of the file contains MySQL setup code for connecting to the database.  If this is not familiar by now then this tutorial is probably a bit over your head anyhow.  In any case set that up, i'm not going to cover it in detail here.  Let's get to the meat of our discussion.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;PHP Parameters&lt;br /&gt;&lt;pre class="brush: php"&gt; &amp;lt;br /&amp;gt;// Make sure we have a full Request&amp;lt;br /&amp;gt; if(!isset($_REQUEST['action']) || !isset($_REQUEST['id'])){&amp;lt;br /&amp;gt;  echo "Invalid Request";&amp;lt;br /&amp;gt; exit(0);&amp;lt;br /&amp;gt; }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;// Which action do we take?  If we dont find one we do nothing.&amp;lt;br /&amp;gt; if($_REQUEST['action']=='getuser')&amp;lt;br /&amp;gt; getUser((int)$_REQUEST['id']);  // sanitize  ID by converting to int&amp;lt;br /&amp;gt; if($_REQUEST['action']=='update')&amp;lt;br /&amp;gt; updateUser((int)$_REQUEST['id']);  // sanitize  ID by converting to int&amp;lt;br /&amp;gt;&lt;/pre&gt;&lt;br /&gt;This code is straightforward.  We simply make sure we have our unique key (id) and our action (something to do).  If we do we proceed to map the parameter action to a function we'll call.  We sanitize the ID coming in to prevent SQL injection.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;getUser() function&lt;br /&gt;&lt;pre class="brush: php"&gt; &amp;lt;br /&amp;gt;// Get User Method&amp;lt;br /&amp;gt;function getUser($id){&amp;lt;br /&amp;gt;  $query  = "select * from users where uid=".$id;&amp;lt;br /&amp;gt;  $result = mysql_query($query);&amp;lt;br /&amp;gt;  while($row = mysql_fetch_array($result, MYSQL_ASSOC)){&amp;lt;br /&amp;gt;  $records[]= $row; // Push into array all records&amp;lt;br /&amp;gt; }&amp;lt;br /&amp;gt; if(!isset($records))&amp;lt;br /&amp;gt;  echo "[{error:'No Records Found',status:'error'}]";&amp;lt;br /&amp;gt; else&amp;lt;br /&amp;gt;  echo json_encode($records); // Encode everything from SQL&amp;lt;br /&amp;gt;  /*&amp;lt;br /&amp;gt;   * If you dont have php 5, or pear installed on your host&amp;lt;br /&amp;gt;   * check out http://mike.teczno.com/json.html&amp;lt;br /&amp;gt;   */&amp;lt;br /&amp;gt;}&amp;lt;br /&amp;gt;&lt;/pre&gt;&lt;br /&gt;This function is called when we load our webpage.html.  It's called by the jQuery ready() in the HTML.  You can see here, it is a very simple query, then we push the result set into an array.  I do this in the example to show that with JSON you can have multiple row results in the response going back.  That way you can even persist the data locally and re-use it when you need to.  If we have a result set we call json_encode() with our records.  This turns it into JSON that we read with javascript on the browser side.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So really, all we do here is build a JSON string out of our MySQL resultset.  The big key is to understand that this is stored in a JSON array.  You need to get a good understanding of JSON to be effective with this sort of application.  Once you do it all falls in line.  Basically a JSON array is a container of JSON objects.  Check out &lt;a href="http://www.json.org/"&gt;Introducing JSON&lt;/a&gt; for more details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, you may not be on PHP5 which has json_encode() natively.  So I put in here a link to the source code for a JSON encode function.  Pear also has this type of library but depending on your web host situation you may need to fall back on the JSON.php file itself.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;updateUser() function&lt;br /&gt;&lt;pre class="brush: php"&gt; &amp;lt;br /&amp;gt;function updateUser($id){&amp;lt;br /&amp;gt; // Build update statement&amp;lt;br /&amp;gt; $sql="";&amp;lt;br /&amp;gt; foreach($_REQUEST as $key =&amp;gt; $value){&amp;lt;br /&amp;gt;   if(strpos($key,"FLD_")!==false){ // Something to post&amp;lt;br /&amp;gt;    $sql.=str_replace("FLD_","",$key)."='".mysql_real_escape_string(stripslashes($value))."', ";&amp;lt;br /&amp;gt;   }&amp;lt;br /&amp;gt;  }&amp;lt;br /&amp;gt; $sql="update users set ".substr($sql,0,-2)." where uid=".$id;&amp;lt;br /&amp;gt; // Update&amp;lt;br /&amp;gt; mysql_query($sql);&amp;lt;br /&amp;gt; // Check for an updated record&amp;lt;br /&amp;gt; if(mysql_affected_rows()&amp;gt;0){&amp;lt;br /&amp;gt;  echo "{status: 'OK'}";&amp;lt;br /&amp;gt; }else{&amp;lt;br /&amp;gt;  echo "{status: 'Update Failed '}";&amp;lt;br /&amp;gt; }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;}&amp;lt;br /&amp;gt;&lt;/pre&gt;&lt;br /&gt;Finally, our update statement.  This is as simple as our process for filling the FLD_ in the webpage.html file.  We scan the entire $_REQUEST array for any FLD_ and then post those to our database string.  It works just like how we built our queryString in the webpage.html post.  We set the values to update, then we runs the mysql_query() to update records.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Take note of a few things here.  First we &lt;b&gt;strip off&lt;/b&gt; the FLD_ prefix.  We also sanitize the input data by stripping out slashes and escaping special characters for mysql.  Again this is to prevent SQL injection.  I see many people who don't do this with AJAX services and thus are very open to attack on their back end.  I also pull off the last ", " off the end of the update statement.  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We last check to see we updated a row or we return an error.  The webpage.html code looks for the OK, so if we don't have it then we display the error.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;That is it.  You should be able to use this as an example and start to your own AJAX code.  Remember this is a learning example and that you should make sure you have far better error checking and recovery from SQL errors.  You might also want to adapt this code for an insert statement or a delete statement to have full CRUD updates to your database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My purpose here was to show you that asynchronous web calls are not that complicated with the right library (jQuery).  Now get out there and write some code!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-8258804849709082197?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/super-simple-ajax-forms-with-jquery-and_22.html</link><author>noreply@blogger.com (Rob)</author><thr:total>3</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7067890369096756918</guid><pubDate>Wed, 21 Jan 2009 14:04:00 +0000</pubDate><atom:updated>2012-04-25T06:56:42.456-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>XHR</category><category domain='http://www.blogger.com/atom/ns#'>PHP</category><category domain='http://www.blogger.com/atom/ns#'>AJAX</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><category domain='http://www.blogger.com/atom/ns#'>jQuery</category><title>Super Simple AJAX Forms with jQuery and JSON : webpage.html</title><description>In this installment of the super simple AJAX forms with jQuery we look at the webpage.html file.  This is a pretty simple HTML file all things considered. &amp;nbsp;The key components of this HTML file are the &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: #660000;"&gt;.changed&lt;/span&gt;&lt;/span&gt; style in the header, the form (called testForm) and the block of javascript code at the bottom. &amp;nbsp;We'll take a look at each of these parts. &amp;nbsp;You can download the entire set of source code and following along.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;CSS Style&lt;br /&gt;&lt;pre class="brush: html"&gt;&amp;lt;br /&amp;gt; &amp;lt;style&amp;gt;&amp;lt;br /&amp;gt;  /* apply specific formatting for changed fields */&amp;lt;br /&amp;gt;  .changed{&amp;lt;br /&amp;gt;   background-color:yellow;&amp;lt;br /&amp;gt;  }&amp;lt;br /&amp;gt; &amp;lt;/style&amp;gt;&amp;lt;br /&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="text-align: auto;"&gt;The CSS style here outlines the effect applied to the input boxes when they have been changed.  We name it changed so you can clearly see how e apply this style and use it as a flag to determine what changes need to be posted to the server.  This is really a nice feature of this example.  I see far too often entire records updated when just a single field is changed.  That or complex PHP code is used to compare what is currently in the database.  &lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;The Form&lt;br /&gt;&lt;pre class="brush: html"&gt;&amp;lt;br /&amp;gt; &amp;lt;form id="testForm"&amp;gt;&amp;lt;br /&amp;gt;  name: &amp;lt;input type="text" id="FLD_name" class="inputfield" onchange="$(this).addClass('changed')"&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;  mail: &amp;lt;input type="text" id="FLD_mail" class="inputfield" onchange="$(this).addClass('changed')"&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;  &amp;lt;input type="hidden" id="FLD_uid"&amp;gt;&amp;lt;br /&amp;gt;  &amp;lt;input type="button" onclick="submitChanges('testForm')" value="Submit Changes"&amp;gt;&amp;lt;br /&amp;gt; &amp;lt;/form&amp;gt;&amp;lt;br /&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;This form is nothing special for the most part.  The key items to look at here are the ID names contain a FLD_ prefix.  We do this so we can identify in the PHP code which elements are "fields" that need to be processed.  In the PHP code we read ALL the data sent and filter out just what we need.  So having a unique identifier is critical to make sure our posting of data with MySQL doesnt fail.  The onchange attribute is used to apply the "changed" class with jQuery when the field changes.  This means that unless someone changes the data, it won't be flagged as an item to update.  I added an inputfield class here so you can see that you can have multiple CSS classes applied.    The last item to note is that we have an input button with a method call to submitChanges.  We pass the form ID name along with it.  This is done so you can use the same code regardless of the number of forms.  So with this you are not building form specific code, youre writing a very re-usable element.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;The Javascript&lt;br /&gt;&lt;pre class="brush: js"&gt; &amp;lt;br /&amp;gt;  // Function to handle the submission of changed &amp;lt;br /&amp;gt;  // only fields on the form we want (multiple form support)&amp;lt;br /&amp;gt;  function submitChanges(formName){&amp;lt;br /&amp;gt;   // Build list of changed variables&amp;lt;br /&amp;gt;   var queryString="";&amp;lt;br /&amp;gt;   $('#'+formName+' .changed').each(function(){&amp;lt;br /&amp;gt;    // Add new varialbe for each "Changed" item&amp;lt;br /&amp;gt;    queryString+="&amp;amp;"+this.id+"="+this.value;&amp;lt;br /&amp;gt;   });&amp;lt;br /&amp;gt;   if(queryString==""){&amp;lt;br /&amp;gt;    alert("Nothing changed on the form");&amp;lt;br /&amp;gt;    return;&amp;lt;br /&amp;gt;   }&amp;lt;br /&amp;gt;   queryString+="&amp;amp;id="+$('#FLD_uid').val(); // Add ID number&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;   // Send Data, get reply&amp;lt;br /&amp;gt;   $.getJSON("dataservice.php?action=update"+queryString,function(data){&amp;lt;br /&amp;gt;    // Display Message on errors&amp;lt;br /&amp;gt;    if(data.status!="OK"){&amp;lt;br /&amp;gt;     alert(data.status);&amp;lt;br /&amp;gt;    }else{&amp;lt;br /&amp;gt;     // Remove Changed Attribute on success&amp;lt;br /&amp;gt;     $('#'+formName+' .changed').each(function(){&amp;lt;br /&amp;gt;      $('#'+this.id).removeClass('changed');&amp;lt;br /&amp;gt;     });&amp;lt;br /&amp;gt;    }&amp;lt;br /&amp;gt;   });&amp;lt;br /&amp;gt;  }&amp;lt;br /&amp;gt;  // Sample, get 1 row of data from database&amp;lt;br /&amp;gt;  $(document).ready(function(){&amp;lt;br /&amp;gt;   $.getJSON("dataservice.php?action=getuser&amp;amp;id=2",function(data){&amp;lt;br /&amp;gt;    // find fields we have data for, regardless of form.&amp;lt;br /&amp;gt;    for(var key in data[0]){&amp;lt;br /&amp;gt;         $('#FLD_'+key).val(eval('data[0].'+key));&amp;lt;br /&amp;gt;       }&amp;lt;br /&amp;gt;   });&amp;lt;br /&amp;gt;  });&amp;lt;br /&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;Finally this is where all the work is done.  It is not a large amount of code so it should be easy to follow along.  There are 2 items here.  The first is "submitChanges" the second is the jQuery "ready()" function.  We'll talk about the $(document).ready() at the bottom first.&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;Once the page loads, jQuery fires a ready method to run some code.  We use jQuery $.getJSON to talk to our dataservice.php and pull down 1 record from our users database.  You can see here we pass an action of "getuser", and the "id" of 2 which matches the id number in the database.  You'll see this is clear by looking at the dataservice.php.  &lt;br /&gt;&lt;br /&gt;Once we pull this data down, we iterate the "keys" of the JSON data, then using javascript eval() function, we grab the data and post it to any &lt;b&gt;matching&lt;/b&gt; #FLD_&lt;key&gt; on the form.  So for example, if the JSON contains a "name" key {name:'Smith'} in the JSON, we map it to #FLD_name.  We do this for a few reasons.  First, we introduce some logical consistency into how we use our database.  This pulls down a database field name, and we use the same field name in our form.  We get away from problems like a database field called first_name and a form field name called userFirstName.  Later on you'll thank yourself in keeping things consistent and searchable.  We also do this to save time mapping data.  Since we use the same name (with just a prefix added) its easy to do this programatically vs. having to do a lot of formField=dataFieldValue in the code.  Less code for everyone.  So this function is pretty simple, pull down the data, map it into the input fields by name.&lt;/key&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;Now we move onto the submitChanges method.  Really, this looks more daunting that it really is.  There is a very limited amount of code here I commented it well so you can see just what you would want to change in your own application&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We first set an empty queryString which will be used to send the changed data to the dataservice.php.  We next tell jQuery to find all the .changed class items in the particular form we just passed.  If that code is a little unclear here is what the expression would look like hardcoded.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #660000;"&gt;$('#testForm .changed').each()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, lets just talk about what we asked jQuery to iterate through.  We said find the ID "testForm" then, find all tags with the "changed" CSS class applied. Then, we ask jQuery to iterate through it with the .each() function.  This exposes each tag to us one at a time so we can use it to build our queryString.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;queryString is built, or it's not based on each changed item.  We pull out the FLD_ names of changed data, apply it to the queryString forming something like&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #660000;"&gt;&amp;amp;FLD_name=smith&amp;amp;FLD_mail=email@domain.com&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Should we not have any changed data, queryString wont have anything in it and we'll tell the user that nothing changed on the form.  If data changes do need to be posted we skip that IF statement, add the "id" of the record manually and prepare for our posting back to dataservice.php.  &lt;b&gt;NOTE:&lt;/b&gt; The ID is the only hard coded field form element.  "FLD_uid" is a unique key in the database that allows you to map it back to the right element.  You don't necessarily have to do it this way.  Alternatively you could hard code "changed" as a class to it, and it would always be picked up.  The down side to this is that if there is no changed data you'll fire an empty query.  I also like hard coding the ID number because as a primary key of a DB you should always have it. This type of code ensures I don't forget it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next, we call our $.getJSON again, we tell it the action is to update, and append on our queryString.  This is posted to the server and we wait for the response asynchronously. Once we receive it, if it's not OK we return the server message.  Finally if everythig is good, we pull off all the "changed" values.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can see here we have some very streamlined code, and not much of it.  Adding more form fields requires no changes to our javascript.  We can basically include this into a .js file and stamp it on any form we want.  A little tweaking and we could make it work for multiple databases as well.  You get the idea.&lt;br /&gt;&lt;br /&gt;Next, we'll talk about the dataservice.php in detail.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7067890369096756918?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/super-simple-ajax-forms-with-jquery-and_21.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-8172768462717530430</guid><pubDate>Tue, 20 Jan 2009 21:56:00 +0000</pubDate><atom:updated>2012-04-25T08:41:48.245-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>MySQL</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>XHR</category><category domain='http://www.blogger.com/atom/ns#'>PHP</category><category domain='http://www.blogger.com/atom/ns#'>AJAX</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><category domain='http://www.blogger.com/atom/ns#'>jQuery</category><title>Super Simple AJAX Forms with jQuery and JSON : Introduction</title><description>I am a huge advocate of SOA architecture. I find it reduces code, encapsulates and makes for a very cohesive web environment. &amp;nbsp;Wow, what a sales pitch eh? &amp;nbsp;Seriously if you think that doing an&amp;nbsp;asynchronous&amp;nbsp;web application is more effort than it's worth then you need to keep reading. &amp;nbsp;I developed this code example to illustrate just how elegant, simple and effective your web application can be. &amp;nbsp;Furthermore this code you are about to see is completely reusable. &amp;nbsp;You should be able to use it over and over again as a framework for all your web applications. &lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To illustrate just how simple this all is I have done it with just 2 files (3 if you count jQuery). &amp;nbsp;The client side webpage.html and the server side dataservice.php. &amp;nbsp;You can download the complete source code for these example, upload it to a PHP server and you'll be on your way. &amp;nbsp;You'll need only to create a simple database called users and some dummy data. &amp;nbsp;I did not include that in these examples since you should really be able to do all that yourself. &amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The entire purpose of this&amp;nbsp;exercise was to create some clean and reusable code for managing a form where users need to edit data. &amp;nbsp;These type of forms have typically the following types of problems when you do it with traditional HTML and PHP.&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;How do you know what data changed. &amp;nbsp;Usually developers replace all the data or do compares manually.&lt;/li&gt;&lt;li&gt;Many times code is placed inside the HTML/PHP to do the update. &amp;nbsp;Not very easy to read, poor design.&lt;/li&gt;&lt;li&gt;Code sometimes has includes or functions, hard to track things down. &amp;nbsp;It's better but still very difficult to work with on larger systems.&lt;/li&gt;&lt;li&gt;HTML/PHP often has business logic mixed into the presentation layer. &amp;nbsp;Validation, etc.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;You wont find these types of problems in the code I'm providing you here. &amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;webpage.html&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The only logic in the HTML (and it's just HTML and JavaScript) is the very simple aggregation and posting of data. &amp;nbsp;It also pulls data down and posts it into the form fields. &amp;nbsp;It also tracks which fields have been modified and only sends the data that needs to update. &amp;nbsp;That's it.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;dataservice.php&lt;/span&gt;&lt;/div&gt;&lt;div&gt;This is the meat and potatoes. &amp;nbsp;This pulls data from the database and posts changes to it. &amp;nbsp;There is no "insert" code in here but you can easily build your own should you need it. &amp;nbsp;The framework in this example is designed to show you how easy AJAX/JSON can be. &amp;nbsp;The dataservice.php can easily be extended to validate and return responses such as "missing data", "bad data", etc. &amp;nbsp;Nice thing is your business logic is contained here. &amp;nbsp;It's also not exposed out on the web where someone can use it against you and spam you or worse. &amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;jQuery&lt;/span&gt; is used to save ourselves a boatload of work. &amp;nbsp;It's free and the AJAX libraries are easy to use. &amp;nbsp;I only use the simple methods here, I have used the more robust features in jQuery but for 99% of the users/web pages out there this works just fine.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;How it works&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The application works by pulling down a single record in the database. &amp;nbsp;After it pulls down the record it uses the JSON data (by parsing the key names) to find HTML ID's using jQuery. &amp;nbsp;If there is a match with a FLD_ prefix on the field name then we populate it with our JSON data. &amp;nbsp;Then, anytime a field is changed on the form, we add a CSS class to it. &amp;nbsp;The CSS class serves two purposes. &amp;nbsp;First the user can see what data has changed and what will be posted. &amp;nbsp;Second, the code uses the class to determine which fields need to be sent to the server. &amp;nbsp;Finally, once the user clicks submit the changed fields are read, tied together in a GET url and sent off to the dataservice.php. &amp;nbsp;The service updates the record and returns success/failure.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The next post we will&amp;nbsp;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;disassemble&amp;nbsp;&lt;/span&gt;webpage.html&lt;/span&gt; and cover how it works in detail.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;a href="http://goo.gl/DBNi9"&gt;Download Super Simple AJAX Source Code Example&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-8172768462717530430?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/super-simple-ajax-forms-with-jquery-and.html</link><author>noreply@blogger.com (Rob)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1190969888498260147</guid><pubDate>Sat, 10 Jan 2009 16:38:00 +0000</pubDate><atom:updated>2012-03-15T07:30:29.629-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Web</category><category domain='http://www.blogger.com/atom/ns#'>JavaScript</category><category domain='http://www.blogger.com/atom/ns#'>HTML</category><category domain='http://www.blogger.com/atom/ns#'>jQuery</category><title>Print Buttons Anywhere</title><description>On item web developers often have to deal with is printing of web information for meetings.  You have information on the web page that looks great but is difficult to print without having a lot of extra information on the page.  &lt;br /&gt;&lt;br /&gt;Often, this problem is solved by creating a specific HTML page that then is handled by the server which in turn regenerates the information in a limited view and is placed in a popup window.  Which is not a bad solution but it does take some time to create that.  If you're working in a framework this might be a lot of effort for you.&lt;br /&gt;&lt;br /&gt;Here is a solution with jQuery that allows you to basically pick information off the page, stick it into a new document and then allow the user to print it.  You'll love the elgance of this small piece of code.&lt;br /&gt;&lt;br /&gt;First, lets start with the HTML.  Simply include a DIV around any elements you want to pick off the page.  Then, somewhere in there include a button, link, etc. which fires off the javascript to create the printable window.&lt;br /&gt;&lt;br /&gt;&lt;textarea class="html" name="codeblock"&gt;&amp;lt;br /&amp;gt;&amp;lt;script src="http://code.jquery.com/jquery-latest.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;div id="webContent"&amp;gt;&amp;lt;br /&amp;gt; This is content you want to show on the page&amp;lt;br /&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;input type="button" onclick="printMessage()" value="Printable View"&amp;gt;&amp;lt;br /&amp;gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Once you have the content on your site marked up (which you probably had done already) include this tasty nugget on your webpage.&lt;br /&gt;&lt;br /&gt;&lt;textarea class="javascript" name="codeblock"&gt;&amp;lt;br /&amp;gt;&amp;lt;script&amp;gt;&amp;lt;br /&amp;gt;    var printWP = "";&amp;lt;br /&amp;gt;    function printMessage(){&amp;lt;br /&amp;gt;  // Get Message From Content on Page&amp;lt;br /&amp;gt;        var msgHTML = "";&amp;lt;br /&amp;gt;        msgHTML += "&amp;lt;p&amp;gt;Printable View&amp;lt;/p&amp;gt;";&amp;lt;br /&amp;gt;        msgHTML += "&amp;lt;p&amp;gt;" + $("#webContent").html() + "&amp;lt;/p&amp;gt;";&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;  // Build Web Page&amp;lt;br /&amp;gt;        var windowHTML = "&amp;lt;HTML&amp;gt;\n&amp;lt;HEAD&amp;gt;\n" +&amp;lt;br /&amp;gt;        "\n&amp;lt;/HEAD&amp;gt;\n&amp;lt;BODY&amp;gt;\n" +&amp;lt;br /&amp;gt;        msgHTML +&amp;lt;br /&amp;gt;        "\n&amp;lt;/BODY&amp;gt;\n&amp;lt;/HTML&amp;gt;";&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        // Open new browser window&amp;lt;br /&amp;gt;        printWP = window.open("", "webMessage", &amp;lt;br /&amp;gt;    "width=600,height=300,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes");&amp;lt;br /&amp;gt;        printWP.document.open();&amp;lt;br /&amp;gt;        // Insert Web Content&amp;lt;br /&amp;gt;        printWP.document.write(windowHTML);&amp;lt;br /&amp;gt;        printWP.document.close();&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        // Open print dialog &amp;lt;br /&amp;gt;        setTimeout("printWP.window.focus();printWP.window.print();", 2000);&amp;lt;br /&amp;gt;    }&amp;lt;br /&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;br /&amp;gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Let me explain what we do here.  We use jquery to pick off the webContent HTML.  $("#webContent").html() we stuff that into msgHTML.  We then use windowHTML to build up the actual HTML page that we will place into the new window.&lt;br /&gt;&lt;br /&gt;Note that the windoHTML code could have included the $("#webContent").html() call, but I listed them separately to better illustrate what exactly we are doing here.&lt;br /&gt;&lt;br /&gt;After we build the page, we open the web browser window with the window.open() call.&lt;br /&gt;&lt;br /&gt;Last, we call the print dialog.  Now you're probably wondering why I placed that in a settimeout.  Well I found on a few browsers (namely firefox 2) that if the page hasnt rendered that the print button can create a blank page.  This timeout allows the user to see the page, then a couple of seconds later the print dialog shows.  &lt;br /&gt;&lt;br /&gt;Alternatively (but not shown in this example) you could add jquery to the printable window then call the window.print() from within the actual page when the document is ready.  &lt;br /&gt;&lt;br /&gt;You get the idea though, this allows you to quickly be able to print any region of a website without all the extras and without having to create new pages on the server.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1190969888498260147?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/print-buttons-anywhere.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1701427315771421920</guid><pubDate>Thu, 08 Jan 2009 16:22:00 +0000</pubDate><atom:updated>2009-01-08T08:29:58.637-08:00</atom:updated><title>Icons after your links</title><description>Well this week I solved a problem with some highly creative jQuery code.   The problem was that IE6 doesnt support images in CSS in an anchor tag.  Well I came up with some jQuery code that allows you to easily add images after links with a very high level of control.  Far more control than CSS.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="javascript"&gt;&lt;br /&gt;   $(document).ready(function(){&lt;br /&gt;    $('a').each(function(){&lt;br /&gt;     if ($(this).attr('href').match(".pdf") != null) {&lt;br /&gt;      $(this).html($(this).html() + " &lt;img src=\"/images/icon.link.pdf.jpg\" border=\"0\" class=\"linkicon\" /&gt;");&lt;br /&gt;     }else if($(this).attr('href').match(".xls")!=null){&lt;br /&gt;      $(this).html($(this).html() + " &lt;img src=\"/images/icon.link.xls.jpg\" border=\"0\" class=\"linkicon\" /&gt;");&lt;br /&gt;     }else{&lt;br /&gt;      // do nothing&lt;br /&gt;     }&lt;br /&gt;    })&lt;br /&gt;   });  &lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;This example illustrates that once the document is ready, iterate each anchor tag and check to see if it's pointing at a PDF or an XLS file, if so, replace the HTML &lt;b&gt;inside&lt;/b&gt; the anchor tag with the existing content plus the image itself.&lt;br /&gt;&lt;br /&gt;This helps considerably when you want to enable this site wide.  You can see that I use the .match() function to see if the URL contains that piece of information.  &lt;br /&gt;&lt;br /&gt;This code works great if you place it in a footer and then enable it site wide.  This also has the advantage that you can have different CSS files for different pages and not worry about includes or copying references.  This works regardless of what page content is.&lt;br /&gt;&lt;br /&gt;The down side to using this is that the images are &lt;b&gt;not&lt;/b&gt; SEO friendly because this is done in javascript and not part of the page content itself.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1701427315771421920?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/icons-after-your-links.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1836457860736664250</guid><pubDate>Thu, 11 Dec 2008 18:16:00 +0000</pubDate><atom:updated>2008-12-11T10:30:37.778-08:00</atom:updated><title>Changes in web hosting</title><description>I have had the same web host for so many years I thought it might be good for me to research what the latest and greatest hosts are and what differences might be available.  When doing this I thought that others might like to understand how I research web hosts.&lt;br /&gt;&lt;br /&gt;When looking for &lt;a href="http://www.fusepoint.com/"&gt;managed hosting services&lt;/a&gt; you really should look for providers who have a good reputation, excellent value and knowledgeable staff. &lt;br /&gt;&lt;br /&gt;I generally break down my research into a few categories.  These categories allow you to rate each type of web host by each category and then decide which one best fits your needs.&lt;br /&gt;&lt;br /&gt;The categories I use are below.  You should rate from 1-5 how well the host performs in each area then decide if they are a good fit.&lt;br /&gt;&lt;br /&gt;1. Hosting presence - what sort of &lt;a href="http://www.fusepoint.com/english/html/data_centre_information.html"&gt;data center&lt;/a&gt; does the provider have.  What sort of bandwidth do they have available.  Is their pipline small or large?  Do they have a raised floor and fire prevention.  &lt;br /&gt;&lt;br /&gt;2. Features - What sort of features do they have.  Do they have cpanel, plesk or other hosting interfaces?  Do they allow you shell access, unlimited bandwidth and data pacakges, etc.&lt;br /&gt;&lt;br /&gt;3. Stability - This is big key.  There are a million fly by night places out there offering hosting.  You should make sure that the people running the place are reviewing their practices and methods of running their web hosting.  A good place to start is making sure they have &lt;a href="http://fusepoint.com/english/landing/landing_sas.html"&gt;SAS 70&lt;/a&gt; compliance.  What this means is basically they have someone independently audit them.  &lt;br /&gt;&lt;br /&gt;4. Knowledge in the industry - Feel free to ask them if they know the latest trend in security.  Ask them what the toughest problem they solved recently was.  It's important to have staff that can figure things out.  &lt;br /&gt;&lt;br /&gt;5. Value - Make sure you compare and weigh all the costs in your web hosting.&lt;br /&gt;&lt;br /&gt;Remember, when you're looking for hosting it's not about price but a combination of many things.  It only take a few days of downtime for someone to go surfing the web elsewhere!&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1836457860736664250?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/12/changes-in-web-hosting.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7260405523527604088</guid><pubDate>Thu, 11 Dec 2008 17:15:00 +0000</pubDate><atom:updated>2008-12-11T09:31:37.441-08:00</atom:updated><title>Web Table Sorting (Without the headache)</title><description>Most web developers at one time or another are going to run across a medium sized table they want to sort.  Sure, you can do this with PHP and send parameters clicking on each header but why?  You can use a little &lt;a href="http://www.jquery.com/"&gt;jQuery&lt;/a&gt; plug in called table sorter to get everything you need without any significant overhead.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://tablesorter.com/docs/#Demo"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://www.robsprogrammingjunk.com/uploaded_images/tablesort-738398.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Christians website has some really great tutorials and sample code.  If you're not using &lt;a href="http://www.jquery.com/"&gt;jQuery&lt;/a&gt; I suggest you give it a shot.  I've been using it for some time and it allows you to work considerably faster.  I've used this on a few projects now and ever user has been happy with the results.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7260405523527604088?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/12/web-table-sorting-without-headache.html</link><author>noreply@blogger.com (Rob)</author><thr:total>0</thr:total></item></channel></rss>
