from the coding point of view I'm looking for way to pass an bit array as url parameter in a small javascript application and I want to keep the parameter length as small as possible. I have an idea how to solve it, but that seems rather complicated for a problem that seems like a common one to me.
The context is the following: I'm currently trying out angularjs and wrote a simple app that is a bit like a shopping cart / configurator. I have a fairly small number of objects (>1024) and each object has a small number of configuration options (less than 6). Someone using the app might pick ~20 of these objects in a typical scenario and configure these with the tool. I'd like to make that configuration 'bookmarkable'. The App stores this configuration as an array.
I could jsonify that array I guess and pass it as url parameter, but this would be horribly long. As indicated above - all I need for each object would be 2 bytes (10 bit for the object ID and 6 bit for its configuration). Writing a function that translates my configuration array into a bit array shouldn't be difficult. If I'm not mistaken im restricted to 32 bit integers in javascript, but that shouldn't be too much trouble either. Eventually I could translate that bitarray into an integer version and use this as url parameter, but this would still a fairly long parameter and my guess is that I could make it much shorter if I'd not only use numbers in the url parameter, but as well letters.
Since this problem more or less sounds to me like a fairly common one, I'd be very happy if you could give me snippets or hints where I could look to solve the problem. If there are more effecient ways than my idea to use an array of bit arrays that's great too. I just want to avoid creating a really clumsy solution if there should be an elegant best practice version so to speak. The whole point is to get a bit more familar with javascript / angularjs.
Cheers
var myConfig = [{133,0,0,1,0,1,0},{254,0,1,1,0,1,0}],{...}
.. next I'd convert those into 16 bit arrays as described here: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… – io_berlin Jan 8 '14 at 13:53