通过c#进行javascript压缩的帮助 [英] help in javascript compressing by c#

查看:51
本文介绍了通过c#进行javascript压缩的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该程序必须是一个命令行工具,该工具要求用户提供JavaScript文件的名称,然后仅压缩其中的字符串值,并将压缩后的版本保存为输出文件.
压缩算法会查找代码中多次出现的最大字符串,并将其替换为短名称变量串联.然后,它寻找下一个大块,依此类推.如果重复出现的字符少于13个字符,或者如果字符太小以至于替换没有意义,则必须保持不变.这是因为必须考虑用于准备和进行串联的加密代码(加上符号,新引号,分号,由两个字符组成的替换变量).
重要的是,压缩后的代码应与未压缩后的代码一样完美无瑕.目的是使字符串数据量尽可能小.代码本身不能被压缩.
示例:
未压缩版本:

if(val1 =="176666424890004920914453345888X00049209209533533458881399")
alert(您赢了-现在单击编号890004920914453345888X000492091445334588813");
压缩版本:

aa ="0004920914453345888";
ab ="89" + aa +"X" + aa +"13";
if(val1 =="176666424" + ab +"99")
alert(您赢了-现在单击数字" + ab);

请注意,在此示例中,a是另一个替换中的替换,因此它添加了更多的代码字符,并且仅当替换中要替换的字符串大于18个字符时才有意义.但是只有当字符串仅出现两次时,才需要此最小值.如果发生三遍或三遍以上,则最小值可能会更低.要始终找到适当的最小值,必须成为算法的一部分.
命令行工具必须可在Windows XP,Windows Vista和Windows 7上运行.
我需要帮助来实现该工具

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

推荐答案

如果这是有偿工作,请自己完成.如果是家庭作业,请自己做.如果您想编写供自己使用的文件,请做一些研究并尝试自己启动,或者付钱找其他人为您做.不要在此处发布您的规范,希望有一些随机的陌生人会为您编写.
If this is paid work, do it yourself. If it''s homework, do it yourself. If you want to write it for your own use, do some research and try to start it yourself, or pay someone else to do it for you. Don''t post your spec here and hope some random stranger will write it for you.


不,这不是有偿工作
这是我的大学里的一项任务
我认为将变量放在堆栈中并与它的内容进行比较以压缩变量的字符串
但我不知道该怎么做以及如何通过JavaScript代码搜索变量

我需要的只是一些想法或帮助.
thnks ..........
no it is not paid work
it is a task in my colleage
and i think to put the variable in stack and compare it with it''s content to compress the string of variable
but i don''t know how to do so and how to search the variables throgh the javascript code

and all i need is some ideas or some help.
thnks..........


这篇关于通过c#进行javascript压缩的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆