Twitter: raymondcamden


Address: Lafayette, LA, USA

Early Access to My Next Book - Apache Cordova in Action

11-25-2014 1,806 views Mobile, JavaScript, HTML5, Books

Hey - guess what? I'm working on a book. This time the publisher is Manning, and one of the cool things they do is allow early access to a book. You basically pay for it while it is being developed and you can provide feedback to help improve the text. Obviously you get corrected/new chapters as they come out as well. If this is appealing to you, you can head over to the book page now.

Determining installed plugins at runtime for Cordova and PhoneGap applications

11-19-2014 2,591 views Mobile, JavaScript, HTML5

Earlier today on Twitter a user asked an interesting question: How can I tell - via JavaScript - if a particular plugin is installed in a Cordova/PhoneGap application. I responded by asking how you wouldn't know since it is your own app, but then he mentioned that his code base was stand alone and would be used within other projects. (So basically - just JavaScript code that other Cordova/PhoneGap applications would use.)

Using the autodivider feature in jQuery Mobile (take two)

11-18-2014 3,220 views Mobile, jQuery, JavaScript, HTML5

Almost a year ago I blogged about using the autodivider feature in jQuery Mobile. This is a simple feature that enhances list views with dividers. It makes content a bit easier to parse when working with a large list.

One of my readers, Fher (who has a cool name - I kind of imagine her/him as a fire-breathing wolf), asked if there was a way to add a bubble count to the dividers. You can see an example of this on the docs for listview, but this is what the feature looks like:

So, the short answer is no, you can't do this with autodividers. Why? While the feature allows you to build a function to create dynamic dividers, it only lets you specify the text for the divider, not random HTML. However, if you are willing to give up having the "pretty bubble" effect, you can simply use it as part of the label. To make that work, I modified my code a bit from the previous demo (and again, you can read that here, I'd suggest checking it out just so you can see the context). Here is the complete JavaScript code. (The HTML didn't change.)

$(document).ready(function() {

	var dates = [
		"12/16/2013 12:00:00",
		"12/16/2013 14:00:00",		
		"12/17/2013 12:00:00",
		"12/18/2013 12:00:00",
		"12/19/2013 12:00:00",
		"12/19/2013 16:00:00"
	];

	var dateList = $("#dates");
	for(var i=0, len=dates.length; i<len; i++) {
		dateList.append("<li>"+dates[i]+"</li>");	
	}

	/*
	Create a generic func to return the label
	*/
	var getLabel = function(d) {
		return (d.getMonth()+1)+ "/" + d.getDate() + "/" + d.getFullYear();
	}
			
	/*
	Now that we have a func, use it to generate a label to count hash
	*/
	var dateCount = {};
	for(var i=0, len=dates.length; i<len; i++) {
		var l = getLabel(new Date(dates[i]));
		if(dateCount.hasOwnProperty(l)) {
			dateCount[l]++;
		} else {
			dateCount[l] = 1;
		}
	}
			
	dateList.listview({
		autodividers:true,
		autodividersSelector: function ( li ) {
			var d = new Date(li.text());
			var label = getLabel(d);
			
			return label + " (" +dateCount[label] +")";
		}
	}).listview("refresh");

});

The first change was to abstract out the code used to generate the divider - basically turning the date value into a label. Once I have that, I iterate over my data to figure out how many unique date labels I have. This is done with a simple object and a counter. Finally, my autodividersSelector function is modified to make use of this count. Here is the result.

There you go. Not exactly rocket science, but hopefully helpful. It is possible to create dividers with list bubbles, just not quite as simply as this entry demonstrates. I'll show that tomorrow.

Cordova's copy-from tip

11-14-2014 3,999 views Mobile

Yesterday I was proof-reading a blog post about an update to the PhoneGap CLI (which you should read - PhoneGap CLI 3.6.3) and I discovered something interesting. For a while now the Cordova CLI has had the ability to create a new project based on another. This is great because the default Cordova/PhoneGap application annoys the heck out of me.

Good post on Cordova, PhoneGap, and versioning

11-10-2014 4,120 views Mobile

This is from last week but it is still pretty important. Holly Schinsky wrote an excellent article about versioning and Cordova/PhoneGap. Things have gotten slightly more complex in this area and I strongly recommend reading her blog post. She really clears things up.

Cordova/PhoneGap Version Confusion

Cordova and Asset Downloads

11-07-2014 4,104 views Mobile, JavaScript

A few weeks ago (before I thought it would be a good idea to fly to China for a few weeks and dramatically increase the size of my family), I blogged about how a Cordova application could handle downloading binary assets after release. (You can find the discussion here: Cordova and Large Asset Downloads - An Abstract.) I finally got around to completing the demo.

List auto-dividers in Ionic

11-06-2014 2,551 views Mobile, JavaScript, HTML5

This question came up on StackOverflow recently and I took a stab at answering it. The user had a list of data that included dates. They were looking to see if there was an easy way to add dividers to the list automatically. jQuery Mobile actually supports this out of the box - and supports it well. By default it will use the first letter of your list data as a separator (so "Andy" and "Al" will be prefixed with an "A" divider) but you can also use a function to specify your own logic.

Cordova Example: Writing to a file

11-05-2014 2,954 views Mobile, JavaScript

As you know, lately I've been publishing simple Cordova examples that involve the file system. I'm working on a demo that involves background asset downloads (see the blog entry) but I thought I'd take a break from that and write up something super simple, but hopefully helpful, that demonstrates file writing.

Using PhoneGap Build? Check out the new support forum

11-03-2014 2,950 views Mobile

Edit: I'm sorry folks - it looks like this forum is not released yet. I'll edit the post when it is.

The title pretty much says it all. :) If you use PhoneGap Build, there is a new support site located here: https://forums.adobe.com/community/phonegap

And because I feel weird posting a blog entry that is so short, here is a random image from placekitten.com:

My review of Ionic's Visual Application Builder

10-10-2014 5,702 views Mobile, Development, Design, JavaScript

Let me begin by saying that - like most developers I think - I have a pretty strong distrust for visual builders for applications. I've been burned by too many tools that create something pretty on screen but generate a horrible mess of code behind the scenes. I think there are definitely tools that do a good job of it now, but once you've been scarred by seeing div tags nested twenty layers deep, you get a bit sensitive. I've recently become a bit more open minded about it. XCode, in general, has a very powerful UI building metaphor to it and I kinda dig how the Android tools handle it in Eclipse as well. Now that you understand how I approach these tools, let me talk to you a bit about the upcoming Ionic Creator tool from the folks behind Ionic.