RhoElements CardReader Problems

For one of our applications we are using the Motorola ET1 and the new ET1 Scan/MSR Module(MSRSCAN) with RhoElements  To access the MSR interface we then use the RhoElements Card Reader interface to scan the mag-stripe.

From the example, this should be a simple matter of configuring the event with a META tag or JavaScript and then processing the returned object.  But alas it is not that simple.

Incorrect Example Code

First, the JavaScript Example code that is provided  uses a META tag to specify the event handler and a sample event handler.  Unfortunately this does NOT work because it is not in the proper format which must either be a URI or JavaScript object.

So instead of using string parameters for the event like this:

<!-- BAD -->
<META HTTP-Equiv="CardReader" Content="ReadEvent:url('javascript:doTransaction('%s', '%s');')">
<script language="javascript" type="text/javascript">
    function doTransaction(data, mode)

You need to specify it as a JavaScript like this:

<META HTTP-Equiv="CardReader" Content="ReadEvent:url('javascript:doTransaction(%json);')">    
<script language="javascript" type="text/javascript">
     function doTransaction(jsonObject) {

Invalid Object Returned

I actually had another problem that I posted to the Motorola Launchpad Site (CardReader Event Problems) that is now fixed thanks to Darryn Campbell.

What I was doing was putting single quotes around the event argument, ‘%json’ instead of just %json itself.  This causes the event processor to escape the returned data, which is obviously not what we needed.


jQuery – Multiple Selectors, Referring Page

Multiple Selectors

Just separate the selectors with commas.

$("#btnOK,#btnRetryCheckout,#btnDone").bind('click', function()
   { runState(EEvent.OK); });

Referring Page

To return to the referring page set the window location with the referring pages URL.

window.location.href = document.referrer;

jQuery – Abort Ajax Requests

Aborting an Ajax Request

To abort a jQuery Ajax request, you simply call abort on the HTMLRequest that is returned by the $.ajax call.  For instance:

var xhr = $.ajax({
     type: "POST",
     url: "some.php",
     data: "name=John&amp;location=Boston",
     success: function(msg){
        alert( "Data Saved: " + msg );
 //kill the request

From SO – Abort Ajax requests using jQuery

 Examples of monitoring the transaction in Chrome and Firebug

Aborted Ajax Transaction in Chrome

Aborted Ajax Transaction in Firebug



HTML5 Signature Pad

 Signature Pad

Signature Pad is a jQuery plugin for assisting in the creation of an HTML5 canvas based signature pad. Records the drawn signature in JSON for later regeneration.  Here’s a demo.  And a nice video walk-through, Capture a Signature with jQuery and HTML 5.

This all looked great, and seems to be very nice, but it relies on FlashCanvas, which is an HTML5 Canvas for Internet Explorer via Flash.  This in turn relies on Flash which of course does not run on iPads, so its a non-starter.  Perhaps there’s a way to just use it directly with Canvas, but I didn’t look that closely.

Andrew Trice: Mobile Signature Capture

Next I found Andrew Trice’s Mobile Signature Capture Project (the JavaScript version) which is just a basic HTML5 Canvas signature capturing module.  It just captures the mouse or touch events, draws it on the canvas, and then can be saved as a .png file.  Here’s the demo.

It doesn’t save the strokes, like the one we developed for Windows CE, but its good enough for now.  I stripped out the Modernizr check to determine if it is a touch device and just used ‘ontouchstart’ in window to save some overhead, and I was in business.

This is also nicely written up in Capturing User Signatures in Mobile Applications.


WordPress Code Highlighting

For a long time I have been using the Code Snippet Plugin for formatting source code in the blog.  It uses the GeSHi engine which always seemed to work well.  Now that I’m moving some stuff around I went to load it and I see that it is no longer active and only supports up to WordPress 2.8.1 so I guess I need a new one.

Now it seems like the choice is WP-Syntax which also uses the GeSHi engine so I’m optimistic that it will handle the parsing for me.  However the syntax is different so it will take some work if I want to migrate old stuff forward.

The syntax for the various options is located on the WP-Syntax Usage page and includes line numbers (line=”42″), escaped html (“escaped="true"), highlighting (highlight="3"), and captions (src"https://github.com/shazahm1/Connections/blob/master/connections.php").  You can even do your own custom GeSHi configurations.

For instance:

<pre lang="<lang>" line="1" highlight="3" src="myfile.cs">
  [Some Code]

For me the main languages are Java(java), C# (csharp), HTML(XML), and JavaScript (javascript) so here are a couple of examples in those:


public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");

C# (with line numbers and highlight line 4)

// Hello1.cs
public class Hello1
  public static void Main()
    System.Console.WriteLine("Hello, World!");

JavaScript (with a caption):

function myFunction() {
alert("Hello World!");

HTML(XML – escaped):

<TITLE>Hello, World Page!</TITLE>
Hello, World!


ASP.NET WebMethods – Request Information

When handling a Web Service it’s easy to focus on the parameters passed in to the web method, but there is a lot of additional information that comes along with the overall web platform.  You can access the various Uri information at System.Web.HttpContext.Current.Request.Url.

User Information including the Host Address and Name

UserHostAddress: “”
UserHostName: “”

The URL Infomation

  •     AbsoluteUri: “” – The full path of the URL.
  •     OriginalString: “” – The Uri as entered on the client.

 Server Host Information

  • Host: “”
  • DnsSafeHost: “”
  • Port: 80
  • Scheme: “http”

Note: DnsSafeHost is the one that can be used to do a call that is processed by DNS, it is sanitized to eliminate extended characters that don’t work with DNS.  Host is the original value which can included these characters.  Also see SO: Host vs DnsSafeHost.

The referring page.

  • UrlReferrer: {}