Developing Portable Mobile Web Applications
All you need to develop Web applications is a text editor to write JavaScript, CSS and HTML, and a browser to test the results. The job is a bit easier using a Web-oriented IDE, a JavaScript debugger and the Safari browser, along with an assortment of mobile devices for testing. Safari has a number of features that simplify development. You can select which User Agent the browser emulates (from the Developer menu), and the Web Inspector allows you to inspect and debug Web elements, including client-side databases. Safari isn't supported on Linux, but it runs just fine under VirtualBox. The code for this article was developed using the following:
Ubuntu 9.10 and the gedit editor.
Safari browser on Windows XP on VirtualBox.
Apache httpd Web server.
GIMP for icon graphics.
jQTouch and jQuery libraries.
iPhone, iTouch, iPad and Android devices.
Installation of the tools is well documented elsewhere. The Resources section for this article gives pointers to the download URLs. To install jQTouch, just put the JavaScript and CSS files in the directory tree of your Web application, and point to them from your HTML <head> element. jQTouch comes with minimized versions of the files and a minimized jQuery library.
As an example, let's look at a simple notes application that I'll call Webnotes. With it, a user could write notes, and view, edit or delete notes later. A note will consist of a title and an arbitrary-length string. The notes will be stored locally on the smartphone, using HTML5 client-side database APIs, and we'll test it running on a variety of Apple and Android devices. When we're done, we'll compare this to a similar Android sample application that ships with the Android SDK. Because we're using client-side database features that are part of HTML5, we'd expect it to work fine on the iPhone, the Droid and the iPad, and not to work on the HTC G1 (it does not support local storage).
Our app has three screens:
The opening screen will display a list of existing notes, listed by title, in order by the date they were last edited. Touching a title will select that note for edit. Touching a + button will add a new note (Figure 1).
An edit screen will allow viewing, editing or deletion of a note. (Figure 2).
An add screen will create a new note and store it in the database (Figure 3).
Listing 1 is the HTML file, index.html, primarily concerned with layout. Listing 2 is a JavaScript file, webnotes.js, that has the logic we need. Let's go through the HTML first.
Listing 1. index.html
<!DOCTYPE HTML PUBLIC>
<head>
<title>WebNotes</title>
<link type="text/css" rel="stylesheet"
media="screen" href="jqtouch/jqtouch.min.css">
<link type="text/css" rel="stylesheet"
media="screen" href="themes/jqt/theme.min.css">
<script type="text/javascript"
src="jqtouch/jquery.1.3.2.min.js"></script>
<script type="text/javascript"
src="jqtouch/jqtouch.min.js"></script>
<script type="text/javascript"
src="javascript/webnotes.js"></script>
</head>
<body>
<div id="home">
<div class="toolbar">
<h1>Web Notes</h1>
<a class="button add slideup"
href="#addNote">+</a>
</div>
<ul class="metal">
<li id="noteTemplate" class="arrow"
style="display:none">
<span class="title">Title</span>
</li>
</ul>
</div>
<div id="addNote">
<div class="toolbar">
<h1>Add Note</h1>
<a class="button cancel" href="#">Cancel</a>
</div>
<form method="post">
<ul>
<li><input type="text" class="title" /></li>
<li><textarea class="note" ></textarea></li>
<li>
<input type="submit" class="submit"
name="action" value="Save Note" /></li>
</ul>
</form>
</div>
<div id="editNote">
<div class="toolbar">
<h1>Edit Note</h1>
<a class="button cancel" href="#">Cancel</a>
<a class="button"
onclick="deleteNoteById()">Delete</a>
</div>
<form method="post">
<ul>
<li><input type="text" class="title" /></li>
<li><textarea class="note" ></textarea></li>
<li>
<input type="submit" class="submit"
name="action" value="Save Note" /></li>
</ul>
</form>
</div>
</body>
</html>
Rick Rogers has been a professional embedded developer for more than 30 years. Now specializing in mobile application software, when Rick isn't writing software for a living, he's writing books and magazine articles like this one.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Web Development News
Developer Poll
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- Tech Tip: Really Simple HTTP Server with Python
- RSS Feeds
- Find new cell phone and tablet pc
55 min 9 sec ago - Epistle
2 hours 24 min ago - Automatically updating Guest Additions
3 hours 32 min ago - I like your topic on android
4 hours 19 min ago - Reply to comment | Linux Journal
4 hours 40 min ago - This is the easiest tutorial
10 hours 54 min ago - Ahh, the Koolaid.
16 hours 33 min ago - git-annex assistant
22 hours 32 min ago - direct cable connection
22 hours 55 min ago - Agreed on AirDroid. With my
23 hours 5 min ago











Comments
Android compatibility.
I'm getting my feet wet with mobile development and am trying to get this working. I'm developing on an HTC Droid Eris with Android 2.1. All I'm getting is a black screen. Any one have any ideas if it should work? Or where I should be looking?
"well documented elsewhere"
"Installation of the tools is well documented elsewhere. The Resources section for this article gives pointers to the download URLs."
The resources indeed gives the pointers to the download URLs.
Is there also a link available for "well documented elsewhere"?
Is there also a pointer to the installation of the tools?
Regards,
M. Moon