ToolFk is a free test kit that programmers use online. ToolFk focuses on the tools that programmers use every day. You don’t need to install any software, just paste the content and press the execute button to get the results you want. ToolFk also supports BarCode BarCode generation online, QueryList collector, PHP code running online, PHP obfuscation, encryption, decryption, Python code online running, JavaScript online running, YAML Formatting Tool, HTTP simulation query tool, HTML online toolbox, JavaScript online toolbox, CSS online toolbox, JSON online toolbox, Unixtime timestamp conversion, Base64/URL/N Ative2Ascii conversion, CSV conversion toolbox, XML online toolbox, WebSocket online tool, Markdown online toolbox, Htaccess2nginx Conversion, base online conversion, online encryption toolbox, online pseudo-original tool, online APK decompile, online webpage screenshot tool, online random password generation, online Qrcode Qrcode generation, online Crontab expression generation, online short url generation, online calculator tool. Such as more than 20 daily programmer development tools, is a very comprehensive programmer toolbox site.


Site name: ToolFk Site Link: www.toolfk.com/ Tool link: www.toolfk.com/tool-format…

The code of teaching

This tool [online CSS beautification (Formatting)/ Encryption/Decryption/obfuscation] relies on Codemirror and its Github address is: github.com/codemirror/… Library, beautification to use csSO-Browser library, github.com/css/csso. Use the following code

STEP 1

STEP 2

The core code is as follows

beautify_start:function(options){
    if (toolfk.beautify_default.beautify_in_progress) {
        return;
    }
    var opts = $.extend({},toolfk.beautify_default, options);

    var source = opts.source.getValue();
    if(source= =' ') {return layer.msg(NOT_EMPTY);
    }

    toolfk.beautify_default.beautify_in_progress = true;
    if (opts.language === 'html') {
        output = beautifier.html(source, opts);
    } else if (opts.language === 'css') {
        output = beautifier.css(source, opts);
    } else {
        if (opts.detect_packers) {
            source = toolfk.beautify_unpacker_filter(source);
        }
        output = beautifier.js(source, opts);
    }

    opts.target.setValue(output);
    toolfk.report('beautify',output);
    toolfk.beautify_default.beautify_in_progress = false;
},

pack_js:function(options) {
    if (toolfk.beautify_default.beautify_in_progress) {
        return;
    }
    var opts = $.extend({},toolfk.beautify_default, options);

    var source = opts.source.getValue();
    if(source= =' ') {return layer.msg(NOT_EMPTY);
    }
    toolfk.beautify_default.beautify_in_progress = true;

    var packer = new Packer;
    if (opts.is_base64) {
        var output = packer.pack(source, 1, opts.is_shrink);
    } else {
        var output = packer.pack(source, 0, opts.is_shrink);
    }
    opts.target.setValue(output);
    toolfk.report('compress',output);
    toolfk.beautify_default.beautify_in_progress = false;
},

dec_pack:function(options){
    if (toolfk.beautify_default.beautify_in_progress) {
        return;
    }
    var opts = $.extend({},toolfk.beautify_default, options);

    var source = opts.source.getValue();
    if(source= =' ') {return layer.msg(NOT_EMPTY);
    }
    toolfk.beautify_default.beautify_in_progress = true;
    try {
        eval('var value=String' + source.slice(4));
        opts.target.setValue(value);
        toolfk.report('deciphering-compress',value);
    } catch (e) {
        layer.msg(TEXT_ERROR);
    }
    toolfk.beautify_default.beautify_in_progress = false;
},

dec_pack_shrink:function(options){
    if (toolfk.beautify_default.beautify_in_progress) {
        return;
    }
    var opts = $.extend({},toolfk.beautify_default, options);

    var source = opts.source.getValue();
    if(source= =' ') {return layer.msg(NOT_EMPTY);
    }
    toolfk.beautify_default.beautify_in_progress = true;
    try {
        eval('var value=String' + source.slice(4));
        var source = toolfk.beautify_unpacker_filter(value);
        output = beautifier.js(source, opts);
        opts.target.setValue(output);
        toolfk.report('decode-code',output);
    } catch (e) {
        layer.msg(TEXT_ERROR);
    }
    toolfk.beautify_default.beautify_in_progress = false;
},

code_code:function(options){
    if (toolfk.beautify_default.beautify_in_progress) {
        return;
    }
    var opts = $.extend({},toolfk.beautify_default, options);

    var target = opts.target.getValue();
    if(target==' ') {return layer.msg(NOT_EMPTY);
    }
    toolfk.beautify_default.beautify_in_progress = true;
    new ClipboardJS('.copy-code', {
        text: function(trigger) {
            layer.msg(COPY_SUCC);
            returntarget; }}); toolfk.beautify_default.beautify_in_progress =false;
},

/* css */
purify_css:function(options){
    if (toolfk.beautify_default.beautify_in_progress) {
        return;
    }
    var opts = $.extend({},toolfk.beautify_default, options);

    var source = opts.source.getValue();
    if(source= =' ') {return layer.msg(NOT_EMPTY);
    }
    toolfk.beautify_default.beautify_in_progress = true;

    var value   =   toolfk.purify_encode(source).replace(/\}/g,'}\n');
    opts.target.setValue(value);
    toolfk.report('purify_css',value);
    toolfk.beautify_default.beautify_in_progress = false;
},

purify_encode:function(text){ var val = text; val = val.replace(/\/\*(.|\n)*? \*\//g,' '); / / remove annotation val = val. Replace (/ ^ \ s + | \ s + $/ g,' '); Val = val.replace(/(:)\s+/g,'$1'); // width:100px => width:100px val = val.replace(/\s{2,}/g,' '); / / remove excess Spaces more than 2 Such as margin: 10 px 20 px 30 px = > margin: 10 px 30 px val = 20 px val. Replace (/ \ s + | \ s +, / g,', '); // Remove redundant Spaces when multiple styles are shared such as h1,h2,h3 =>h1,h2,h3 val = val.replace(/; {2} |; \s+/g,'; '); // Remove multiple semicolons or extra Spaces after semicolons such as width:200px; height:100px => width:200px; height:100px val = val.replace(/\s*\{\s*/g,'{'); Div {height:100px} => div{height:100px} val = val.replace(/\s*}\s*/g,'} '); Div {height:100px}a{} => div{height:100px}a{} val = val.replace(/[\n\t\f\r]/g,' '); // Remove newlines, tabs, page breaks, carriage return val = val.replace(/; }/g,'} ');
    return val;
},

optimize_css:function(options){
    if (toolfk.beautify_default.beautify_in_progress) {
        return;
    }
    var opts = $.extend({},toolfk.beautify_default, options);

    var source = opts.source.getValue();
    if(source= =' ') {return layer.msg(NOT_EMPTY);
    }
    toolfk.beautify_default.beautify_in_progress = true;

    var lastResult = csso.minify(source, {
        restructure: true
    });

    var value   =   lastResult.css;
    opts.target.setValue(value);
    toolfk.report('optimize_css',value);
    toolfk.beautify_default.beautify_in_progress = false;
},Copy the code


Three reasons it’s worth a try:

  1. Integrate a variety of development test tools commonly used in programmer development.

  2. Simple and beautiful atmosphere of the website page

  3. Support online formatting execution code, APK online decompilation, online high-strength password generation, online web page screenshots and more than 20 tool services

  4. Also recommend its sister network www.videofk.com video download toolbox


This paper links: www.hihubs.com/article/367