1、js工具 a=62; function encode() var code = document.getElementById(code).value; code = code.replace(/rn+/g, ); code = code.replace(/g, ); var tmp = code.match(/b(w+)b/g); tmp.sort(); var dict = ; var i, t = ; for(var i=0; itmp.length; i+) if(tmpi != t) dict.push(t = tmpi); var len = dict.length; var ch
2、; for(i=0; ilen; i+) ch = num(i); code = code.replace(new RegExp(b+dicti+b,g), ch); if(ch = dicti) dicti = ; document.getElementById(code).value = eval(function(p,a,c,k,e,d)e=function(c)return(c35?String.fromCharCode(c+29):c.toString(36);if(!.replace(/,String)while(c-)de(c)=kc|e(c);k=function(e)retu
3、rn de;e=function()returnw+;c=1;while(c-)if(kc)p=p.replace(new RegExp(b+e(c)+b,g),kc);return p( + +code+,+a+,+len+,+ dict.join(|)+.split(|),0,); function num(c) return(c35?String.fromCharCode(c+29):c.toString(36); function run() eval(document.getElementById(code).value); function decode() var code =
4、document.getElementById(code).value; code = code.replace(/eval/, ); document.getElementById(code).value = eval(code); function do_js_beautify() document.getElementById(beautify).disabled = true; js_source = document.getElementById(code).value.replace(/s+/, ); tabsize = document.getElementById(tabsiz
5、e).value; tabchar = ; if (tabsize = 1) tabchar = t; if (js_source & js_source.charAt(0) = ) document.getElementById(code).value = style_html(js_source, tabsize, tabchar, 80); else document.getElementById(code).value = js_beautify(js_source, tabsize, tabchar); document.getElementById(beautify).disabl
6、ed = false; return false; function pack_js(base64) var input = document.getElementById(code).value; var packer = new Packer; if (base64) var output = packer.pack(input, 1, 0); else var output = packer.pack(input, 0, 0); document.getElementById(code).value = output; function Empty() document.getEleme
7、ntById(code).value = ; document.getElementById(code).select(); function GetFocus() document.getElementById(code).focus(); function js_beautify(js_source_text, indent_size, indent_character, indent_level) var input, output, token_text, last_type, last_text, last_word, current_mode, modes, indent_stri
8、ng; var whitespace, wordchar, punct, parser_pos, line_starters, in_case; var prefix, token_type, do_block_just_closed, var_line, var_line_tainted; function trim_output() while (output.length & (outputoutput.length - 1 = | outputoutput.length - 1 = indent_string) output.pop(); function print_newline(
9、ignore_repeated) ignore_repeated = typeof ignore_repeated = undefined ? true: ignore_repeated; trim_output(); if (!output.length) return; / no newline on start of file if (outputoutput.length - 1 != n | !ignore_repeated) output.push(n); for (var i = 0; i indent_level; i+) output.push(indent_string);
10、 function print_space() var last_output = output.length ? outputoutput.length - 1 : ; if (last_output != & last_output != n & last_output != indent_string) / prevent occassional duplicate space output.push( ); function print_token() output.push(token_text); function indent() indent_level+; function
11、unindent() if (indent_level) indent_level-; function remove_indent() if (output.length & outputoutput.length - 1 = indent_string) output.pop(); function set_mode(mode) modes.push(current_mode); current_mode = mode; function restore_mode() do_block_just_closed = current_mode = DO_BLOCK; current_mode
12、= modes.pop(); function in_array(what, arr) for (var i = 0; i = input.length) return , TK_EOF; c = input.charAt(parser_pos); parser_pos += 1; if (c = n) n_newlines += 1; while (in_array(c, whitespace); if (n_newlines 1) for (var i = 0; i 2; i+) print_newline(i = 0); var wanted_newline = (n_newlines
13、= 1); if (in_array(c, wordchar) if (parser_pos input.length) while (in_array(input.charAt(parser_pos), wordchar) c += input.charAt(parser_pos); parser_pos += 1; if (parser_pos = input.length) break; / small and surprisingly unugly hack for 1E-10 representation if (parser_pos != input.length & c.matc
14、h(/0-9+Ee$/) & input.charAt(parser_pos) = -) parser_pos += 1; var t = get_next_token(parser_pos); c += - + t0; return c, TK_WORD; if (c = in) / hack for in operator return c, TK_OPERATOR; return c, TK_WORD; if (c = ( | c = ) return c, TK_START_EXPR; if (c = ) | c = ) return c, TK_END_EXPR; if (c = )
15、 return c, TK_START_BLOCK; if (c = ) return c, TK_END_BLOCK; if (c = ;) return c, TK_END_COMMAND; if (c = /) var comment = ; / peek for comment /* . */ if (input.charAt(parser_pos) = *) parser_pos += 1; if (parser_pos input.length) while (! (input.charAt(parser_pos) = * & input.charAt(parser_pos + 1
16、) & input.charAt(parser_pos + 1) = /) & parser_pos = input.length) break; parser_pos += 2; return /* + comment + */, TK_BLOCK_COMMENT; / peek for comment / . if (input.charAt(parser_pos) = /) comment = c; while (input.charAt(parser_pos) != x0d & input.charAt(parser_pos) != x0a) comment += input.char
17、At(parser_pos); parser_pos += 1; if (parser_pos = input.length) break; parser_pos += 1; if (wanted_newline) print_newline(); return comment, TK_COMMENT; if (c = | / string c = | / string (c = / & (last_type = TK_WORD & last_text = return) | (last_type = TK_START_EXPR | last_type = TK_END_BLOCK | las
18、t_type = TK_OPERATOR | last_type = TK_EOF | last_type = TK_END_COMMAND) / regexp var sep = c; var esc = false; c = ; if (parser_pos = input.length) break; parser_pos += 1; if (last_type = TK_END_COMMAND) print_newline(); return sep + c + sep, TK_STRING; if (in_array(c, punct) while (parser_pos = inp
19、ut.length) break; return c, TK_OPERATOR; return c, TK_UNKNOWN; /- indent_character = indent_character | ; indent_size = indent_size | 4; indent_string = ; while (indent_size-) indent_string += indent_character; input = js_source_text; last_word = ; / last TK_WORD passed last_type = TK_START_EXPR; /
20、last token type last_text = ; / last token text output = ; do_block_just_closed = false; var_line = false; var_line_tainted = false; whitespace = nrt .split(); wordchar = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$.split(); punct = + - * / % & + - = += -= *= /= %= = = != != = =
21、= = & &= | | ! ! , : ? = |=.split( ); / words which should always start on new line. line_starters = continue,try,throw,return,var,if,switch,case,default,for,while,break,function.split(,); / states showing if we are currently in expression (i.e. if case) - EXPRESSION, or in usual block (like, proced
22、ure), BLOCK. / some formatting depends on that. current_mode = BLOCK; modes = current_mode; indent_level = indent_level | 0; parser_pos = 0; / parser position in_case = false; / flag for parser that case/default has been processed, and next colon needs special attention while (true) var t = get_next
23、_token(parser_pos); token_text = t0; token_type = t1; if (token_type = TK_EOF) break; switch (token_type) case TK_START_EXPR: var_line = false; set_mode(EXPRESSION); if (last_type = TK_END_EXPR | last_type = TK_START_EXPR) / do nothing on ( and )( and and ( . else if (last_type != TK_WORD & last_typ
24、e != TK_OPERATOR) print_space(); else if (in_array(last_word, line_starters) & last_word != function) print_space(); print_token(); break; case TK_END_EXPR: print_token(); restore_mode(); break; case TK_START_BLOCK: if (last_word = do) set_mode(DO_BLOCK); else set_mode(BLOCK); if (last_type != TK_OP
25、ERATOR & last_type != TK_START_EXPR) if (last_type = TK_START_BLOCK) print_newline(); else print_space(); print_token(); indent(); break; case TK_END_BLOCK: if (last_type = TK_START_BLOCK) / nothing trim_output(); unindent(); else unindent(); print_newline(); print_token(); restore_mode(); break; case TK_WORD: if (do_block_just_c
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1