耀极客论坛

 找回密码
 立即注册
查看: 452|回复: 0

jsDecoder JavaScript 格式化整理工具

[复制链接]

193

主题

176

帖子

276

积分

中级会员

Rank: 3Rank: 3

积分
276
发表于 2022-5-8 00:08:59 | 显示全部楼层 |阅读模式
  1. var base_code='';var jsdecoder;var jscolorizer;var code='';var time=0;function decode()  {code='';base_code='';jsdecoder=new JsDecoder();jscolorizer=new JsColorizer();if($('msg').innerHTML.length){do_clean_init();}else{jsdecoder.s=$("a1").value;do_decode_init();}}
  2.   function do_decode_init()
  3.   {$('msg').innerHTML+='Decoding .. ';setTimeout(do_decode,50);}
  4.   function do_decode()
  5.   {time=time_start();try{code=jsdecoder.decode();base_code=code;}catch(e){$('msg').innerHTML+='error‹br>‹br>'+new String(e).replace(/\n/g,'‹br>');return;}
  6.   $('msg').innerHTML+='ok ('+time_end(time)+' sec)‹br>';setTimeout(do_colorize_init,50);}
  7.   function do_colorize_init()
  8.   {$('msg').innerHTML+='Colorizing .. ';setTimeout(do_colorize,50);}
  9.   function do_colorize()
  10.   {time=time_start();code=code.replace(/&/g,"&");code=code.replace(/‹/g,"<");code=code.replace(/>/g,">");jscolorizer.s=code;try{code=jscolorizer.colorize();}catch(e){$('msg').innerHTML+='error‹br>‹br>'+new String(e).replace(/\n/g,'‹br>');return;}
  11.   $('msg').innerHTML+='ok ('+time_end(time)+' sec)‹br>';setTimeout(do_insert_init,50);}
  12.   function do_insert_init()
  13.   {$('msg').innerHTML+='Inserting code .. ';setTimeout(do_insert,50);}
  14.   function do_insert()
  15.   {time=time_start();try{code=new String(code);code=code.replace(/(\r\n|\r|\n)/g,"‹br>\n");code=code.replace(/‹font\s+/gi,'‹font@@@@@');code=code.replace(/( |\t)/g,' ');code=code.replace(/‹font@@@@@/gi,'‹font ');code=code.replace(/\n$/,'');var count=0;var pos=code.indexOf("\n");while(pos!=-1){count++;pos=code.indexOf("\n",pos+1);}
  16.   count++;pad=new String(count).length;var lines='';for(var i=0;i‹count;i++){var p=pad-new String(i+1).length;var no=new String(i+1);for(k=0;k‹p;k++){no=' '+no;}
  17.   no+=' ';lines+='‹div>'+no+'‹/div>';}
  18.   $('lines').innerHTML=lines;$('code_area').style.display='block';$('sel_all').style.display='block';$("a2").innerHTML=code;}catch(e){$('msg').innerHTML+='error‹br>‹br>'+new String(e).replace(/\n/g,'‹br>');return;}
  19.   $('msg').innerHTML+='ok ('+time_end(time)+' sec)';code='';}
  20.   function do_clean_init()
  21.   {$('msg').innerHTML='';do_clean();}
  22.   function do_clean()
  23.   {time=time_start();$('code_area').style.display='none';base_code='';$('sel_all').style.display='none';$('insert_div').style.display='none';jsdecoder.s=$("a1").value;do_decode_init();}
  24.   function insert_textarea()
  25.   {$('insert_div').style.display='block';$('insert_area').value=base_code;$('insert_area').focus();$('insert_area').select();}
  26.   function $(id)
  27.   {return document.getElementById(id);}
  28.   function time_micro()
  29.   {var micro=new String(new Date().getTime());micro=micro.substr(0,micro.length-3)+'.'+micro.substr(micro.length-3,3);return parseFloat(micro);}
  30.   function time_start()
  31.   {return time_micro();}
  32.   function time_get(start)
  33.   {return time_micro()-start;}
  34.   function time_end(start)
  35.   {return time_round(time_micro()-start);}
  36.   function time_round(time)
  37.   {time=Math.round(time*100)/100;if(time===0){time=0.01;}
  38.   return time;}
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|耀极客论坛 ( 粤ICP备2022052845号-2 )|网站地图

GMT+8, 2022-12-7 11:04 , Processed in 0.069034 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表