The program has to be a command line tool which asks the user for the name of the JavaScript file and then compresses only the string values therein, saving the compressed version as an output file.
The compression algorithm looks for the biggest string pieces which occur in the code more than one time and replaces them with short name variable concatenations. Then it looks for the next big pieces and so on. If the repeatedly occuring piece is smaller than 13 characters, or if it is so small that a replacement makes no sense, it has to stay non-replaced. This is because the necassery code for preparing and doing the concatenation must be regarded (plus symbols, new quotes, semicolons, a replacement variable consisting of two characters).
It is important that the compressed code works as flawless as the uncompressed one. The objective is to keep the string data amount as small as possible. The code itself must not be compressed.
Example:
Uncompressed Version:
if(val1=="176666424890004920914453345888X00049209144533458881399")
alert("You won - now click on number 890004920914453345888X000492091445334588813");
Compressed Version:
aa="0004920914453345888";
ab="89"+aa+"X"+aa+"13";
if(val1=="176666424"+ab+"99")
alert("You won - now click on number "+ab);
Please consider that in this example a is a replacement inside another replacement, so it adds even more code characters and this only makes sense if the string to be replaced inside the replacement is bigger than 18 characters. But this minimum is only necessary if the string occurs only twice. If it occurs three times or more, a lower minimum would be possible. To find always the proper minimum has to be part of the algorithm.
The command line tool must be runnable on Windows XP, Windows Vista and Windows 7.
i want help to implement that tool