CarlRaymond/jquery.cardswipe

First track empty on student ID cards, Can I still make this work?

Closed this issue · 3 comments

The first track on our student id cards is left empty for if they live in the dorms, this is used as there room key. Since we are a commuter college, most students, by far, do NOT live in the dorms. Therefore, it seems I am having a very difficult time getting this to work, because as it says, it expects there to be something on the first track.

Is there anything I can do to get this to work?

In a plain text file, this is what the reader outputs from my card.

;0090073029910=?

Hmmm. The reason it wants something on the first track is because the first track starts with %B. The inital % causes the transition from IDLE to PENDING, and then any alphabetic character will cause a transition to the READING state. That two-character combination is unlikely to get typed into a form field, which would cause the plugin to swallow those characters and subsequent ones (as long as they come fast enough).

But ; followed by a digit is equally unlikely, so the plugin could be modified to recognize that as a starting sequence.

If you want to try some coding: add an extra state, PENDING2 (lines 162 and 165). Add code at line 215 just like what's above it, but check for a ; (code 59) and set the state to PENDING2. Then duplicate the PENDING block (line 226-249) as PENDING2, and instead of looking for a letter, look for a digit, and jump to the READING state if found.

That might do it. If your cards sometimes have line 1 as well, you could handle that in your card-specific parser. Just look for both versions of your format, or write a single regex that works on both forms.

You might want to try out any other kinds of cards you can find on your parser, like restaurant coupons, hotel room keys, credit cards, etc. just to be sure they won't trigger your parser. Though presumably you're doing something with your student number that would validate it.

I updated the code to handle these cards. I used your sample as a test case, and now the generic parser should be able to read it.

Sorry for not responding earlier @CarlRaymond , Thank you for getting back to me so quickly. I did manage to get this to work by replacing 37 with 59 so that it processes after the semicolon instead of %. However, your change to the generic parser is a much better fix and it is highly appreciated. Thank You.