/g, '>').replace(/ /g, ' ').replace(/\r/g, '·').replace(/\n/g, '
'); $('#testresults').html(results).show(); } function any(a, b) { return a || b; } function unpacker_filter(source) { var trailing_comments = '', comment = '', unpacked = '', found = false; do { found = false; if (/^\s*\/\*/.test(source)) { found = true; comment = source.substr(0, source.indexOf('*/') + 2); source = source.substr(comment.length).replace(/^\s+/, ''); trailing_comments += comment + "\n"; } else if (/^\s*\/\ found = true; comment = source.match(/^\s*\/\/.*/)[0]; source = source.substr(comment.length).replace(/^\s+/, ''); trailing_comments += comment + "\n"; } } while (found); var unpackers = [P_A_C_K_E_R, Urlencoded, MyObfuscate]; for (var i = 0; i < unpackers.length; i++) { if (unpackers[i].detect(source)) { unpacked = unpackers[i].unpack(source); if (unpacked != source) { source = unpacker_filter(unpacked); } } } return trailing_comments + source; } function beautify(text, type_code) { var source = text.text(); var output = ''; var opts = {}; var additional_options = '{}'; opts.indent_size = 4; opts.indent_char = ' '; opts.max_preserve_newlines = 5; opts.preserve_newlines = true; opts.keep_array_indentation = false; opts.break_chained_methods = false; opts.indent_scripts = 'normal'; opts.brace_style = 'collapse'; opts.space_before_conditional = true; opts.unescape_strings = false; opts.jslint_happy = false; opts.end_with_newline = false; opts.wrap_line_length = 0; opts.indent_inner_html = false; opts.comma_first = false; opts.e4x = false; opts.indent_empty_lines = false; var selectedOptions = JSON.stringify(opts, null, 2); $('#options-selected').val(selectedOptions); if (type_code === 'html') { output = html_beautify(source, opts); console.log(output); } else if (type_code === 'css') { output = css_beautify(source, opts); } else { if ($('#detect-packers').prop('checked')) { source = unpacker_filter(source); } output = js_beautify(source, opts); } text.html(output); the.beautify_in_progress = false; } function looks_like_html(source) { var trimmed = source.replace(/^[ \t\n\r]+/, ''); var comment_mark = '<' + '!-' + '-'; return (trimmed && (trimmed.substring(0, 1) === '<' && trimmed.substring(0, 4) !== comment_mark)); } $("body pre").each(function(){ var text = $(this).attr('class'); var clas = text.replace('brush:', ""); if(clas == 'js' || clas == 'php'){ clas = 'html'; } });