• Css格式化/压缩(代码)


    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(/
    /ig,'');
    
    code = code.replace(/(s){2,}/ig,'$1');
    
    code = code.replace(/	/ig,'');
    
    code = code.replace(/
    }/ig,'}');
    
    code = code.replace(/
    {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 {');
    
    code = code.replace(/*/(.[^}{]*)}/ig,'*/
    $1}');
    
    code = code.replace(//*/ig,'
    /*');
    
    code = code.replace(/;s*(S)/ig,';
    	$1');
    
    code = code.replace(/}s*(S)/ig,'}
    $1');
    
    code = code.replace(/
    s*}/ig,'
    }');
    
    code = code.replace(/{s*(S)/ig,'{
    	$1');
    
    code = code.replace(/(S)s**//ig,'$1*/');
    
    code = code.replace(/*/s*([^}{]S)/ig,'*/
    	$1');
    
    code = code.replace(/(S)}/ig,'$1
    }');
    
    code = code.replace(/(
    ){2,}/ig,'
    ');
    
    code = code.replace(/:/ig,': ');
    
    code = code.replace(/ /ig,' ');
    
    return code;
    
    }
  • 相关阅读:
    MFC菜单快捷键的应用
    TDD in C++
    Mapping
    初入股市者怎样看盘
    C++随笔分类列表(高级)
    C++代码优化
    IT生活
    十一年炒股的感悟
    框架设计(第2版)CLR Via C#(1)
    Visual Assist X自己常用的快捷功能
  • 原文地址:https://www.cnblogs.com/superjt/p/3275371.html
Copyright © 2020-2023  润新知