I’m building a grid where each box has a different color value using HTML & Javascript.
Example: A 5×5 grid where I’d have 25 values to keep track of. I’d like to be able to send the grid’s information via a ‘grid’ parameter so when any user wants to view this specific grid, they’d see the fully drawn grid. Initially, the URL would be: http://www.mysite.com?grid=0123401234012340123401234 Ideally, the parameter would be under 25 characters.
How would I go about converting ‘0123401234012340123401234’ to a smaller string? Is it best using a compression algorithm or just using decimal to hex conversion?
You can just use a higher base. Something like 30, for example:
(123401234012340123401234).toString(30) --> "8i015nb02ib0c4ik". Note that, for this to work properly, the123401234012340123401234has to be a number rather than a string.