zoukankan      html  css  js  c++  java
  • CSS代码格式化和加密化

    <html> 
     <head> 
      <title>CSS代码格式化和加密化</title> 
      <meta name="Generator" content="EditPlus"> 
      <meta name="Author" content=""> 
      <meta name="Keywords" content=""> 
      <meta name="Description" content=""> 
     </head> 
     <body> 
    <script language="JavaScript"> 
    <!-- 
    function $() { 
      var elements = new Array(); 
      for (var i = 0; i < arguments.length; i++) { 
      var element = arguments[i]; 
      if (typeof element == 'string') 
        element = document.getElementById(element); 
      if (arguments.length == 1)  
        return element;    
      elements.push(element); 
      }    
      return elements; 
    } 
    function CSSencode(code) 
    { 
     code = code.replace(/\n/ig,''); 
     code = code.replace(/(\s){2,}/ig,'$1'); 
     code = code.replace(/\t/ig,''); 
     code = code.replace(/\n\}/ig,'\}'); 
     code = code.replace(/\n\{\s*/ig,'\{'); 
     code = code.replace(/(\S)\s*\}/ig,'$1\}'); 
     code = code.replace(/(\S)\s*\{/ig,'$1\{'); 
     code = code.replace(/\{\s*(\S)/ig,'\{$1'); 
     return code; 
    } 
    function CSSdecode(code) 
    { 
     code = code.replace(/(\s){2,}/ig,'$1'); 
     code = code.replace(/(\S)\s*\{/ig,'$1\n{'); 
     code = code.replace(/\*\/(.[^\}\{]*)}/ig,'\*\/\n$1}'); 
     code = code.replace(/\/\*/ig,'\n\/\*'); 
     code = code.replace(/;\s*(\S)/ig,';\n\t$1'); 
     code = code.replace(/\}\s*(\S)/ig,'\}\n$1'); 
     code = code.replace(/\n\s*\}/ig,'\n\}'); 
     code = code.replace(/\{\s*(\S)/ig,'\{\n\t$1'); 
     code = code.replace(/(\S)\s*\*\//ig,'$1\*\/'); 
     code = code.replace(/\*\/\s*([^\}\{]\S)/ig,'\*\/\n\t$1'); 
     code = code.replace(/(\S)\}/ig,'$1\n\}'); 
     code = code.replace(/(\n){2,}/ig,'\n'); 
     return code; 
    } 
    //--> 
    </script> 
    CSS代码格式化和压缩化<hr> 
    <textarea name="" rows="" cols="" style="600px;height:300px;" id="code"> 
    /*请将CSS代码复制到这里,下面是示例*/ 
    </textarea><br> 
    <input type="submit" onclick="$('code').value = CSSdecode($('code').value);" value="格式化"> | <input type="submit" onclick="$('code').value = CSSencode($('code').value);" value="压缩化" /> 
     </body>  
    </html> 
    
  • 相关阅读:
    conn
    快速指数算法+Python代码
    扩展欧几里得算法+Python代码
    最速下降法+Matlab代码
    第二类生日攻击算法
    遗传算法+Python代码
    模糊聚类+Matlab代码
    数据库检索
    Spring Data Jpa依赖和配置
    上传Typora到博客园(解决图片缩放问题)
  • 原文地址:https://www.cnblogs.com/mahaisong/p/1970903.html
Copyright © 2011-2022 走看看