js-beautify 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitmodules +4 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +27 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +13 -0
- data/Rakefile +29 -0
- data/VERSION +1 -0
- data/bin/js-beautify +5 -0
- data/init.sh +3 -0
- data/js-beautify-copy/.gitmodules +3 -0
- data/js-beautify-copy/Makefile +71 -0
- data/js-beautify-copy/README.md +39 -0
- data/js-beautify-copy/attic/beautify-cl/beautify-cl.js +142 -0
- data/js-beautify-copy/attic/bin/beautify_js +80 -0
- data/js-beautify-copy/attic/opera-userscript/beautifier.js +1087 -0
- data/js-beautify-copy/attic/opera-userscript/make_opera_userscript.sh +42 -0
- data/js-beautify-copy/attic/qtscript/jsbeautify.cpp +121 -0
- data/js-beautify-copy/attic/qtscript/jsbeautify.pro +5 -0
- data/js-beautify-copy/attic/qtscript/jsbeautify.qrc +6 -0
- data/js-beautify-copy/attic/qtscript/readme.txt +28 -0
- data/js-beautify-copy/attic/readme.txt +2 -0
- data/js-beautify-copy/attic/unmaintained/bbedit/jsBeautify_BBED.scpt +522 -0
- data/js-beautify-copy/attic/unmaintained/c-sharp/JSBeautify.cs +801 -0
- data/js-beautify-copy/attic/v8/README.txt +40 -0
- data/js-beautify-copy/attic/v8/beautify.h +2390 -0
- data/js-beautify-copy/attic/v8/jsbeautify.cpp +215 -0
- data/js-beautify-copy/beautify-css.js +198 -0
- data/js-beautify-copy/beautify-html.js +514 -0
- data/js-beautify-copy/beautify.js +1293 -0
- data/js-beautify-copy/favicon.png +0 -0
- data/js-beautify-copy/index.html +401 -0
- data/js-beautify-copy/jquery/jquery.cookie.js +96 -0
- data/js-beautify-copy/jquery/jquery.js +167 -0
- data/js-beautify-copy/license.txt +24 -0
- data/js-beautify-copy/php/jsbeautifier.php +1599 -0
- data/js-beautify-copy/php/test.php +476 -0
- data/js-beautify-copy/python/MANIFEST.in +2 -0
- data/js-beautify-copy/python/js-beautify +7 -0
- data/js-beautify-copy/python/js-beautify-profile +16 -0
- data/js-beautify-copy/python/js-beautify-test +10 -0
- data/js-beautify-copy/python/jsbeautifier/__init__.py +1166 -0
- data/js-beautify-copy/python/jsbeautifier/tests/__init__.py +1 -0
- data/js-beautify-copy/python/jsbeautifier/tests/testindentation.py +43 -0
- data/js-beautify-copy/python/jsbeautifier/tests/testjsbeautifier.py +464 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/README.specs.mkd +25 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/__init__.py +67 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/evalbased.py +39 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/javascriptobfuscator.py +58 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/myobfuscate.py +86 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/packer.py +104 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/__init__.py +2 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/test-myobfuscate-input.js +1 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/test-myobfuscate-output.js +65 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/test-packer-62-input.js +1 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/test-packer-non62-input.js +1 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/testjavascriptobfuscator.py +46 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/testmyobfuscate.py +40 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/testpacker.py +34 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/tests/testurlencode.py +36 -0
- data/js-beautify-copy/python/jsbeautifier/unpackers/urlencode.py +34 -0
- data/js-beautify-copy/python/setup.py +17 -0
- data/js-beautify-copy/tests/beautify-tests.js +489 -0
- data/js-beautify-copy/tests/run-tests +17 -0
- data/js-beautify-copy/tests/sanitytest.js +128 -0
- data/js-beautify-copy/unpackers/javascriptobfuscator_unpacker.js +103 -0
- data/js-beautify-copy/unpackers/myobfuscate_unpacker.js +81 -0
- data/js-beautify-copy/unpackers/p_a_c_k_e_r_unpacker.js +61 -0
- data/js-beautify-copy/unpackers/urlencode_unpacker.js +51 -0
- data/lib/js-beautify.rb +0 -0
- data/test/helper.rb +18 -0
- data/test/test_js-beautify.rb +7 -0
- data/update.sh +23 -0
- metadata +173 -0
Binary file
|
@@ -0,0 +1,401 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<!--[if lt IE 7]><html lang="en-us" class="ie6"><![endif]-->
|
3
|
+
<!--[if IE 7]><html lang="en-us" class="ie7"><![endif]-->
|
4
|
+
<!--[if IE 8]><html lang="en-us" class="ie8"><![endif]-->
|
5
|
+
<!--[if gt IE 8]><!--><html lang="en-us"><!--<![endif]-->
|
6
|
+
<head>
|
7
|
+
<meta charset="utf-8">
|
8
|
+
<title>Online JavaScript beautifier</title>
|
9
|
+
<link rel="icon" href="favicon.png" type="image/png">
|
10
|
+
<script src="third-party/codemirror2/lib/codemirror.js"></script>
|
11
|
+
<script src="third-party/codemirror2/mode/javascript/javascript.js"></script>
|
12
|
+
<link rel="stylesheet" href="third-party/codemirror2/lib/codemirror.css">
|
13
|
+
|
14
|
+
<style>
|
15
|
+
body {
|
16
|
+
background: #eee;
|
17
|
+
color: #333;
|
18
|
+
}
|
19
|
+
|
20
|
+
img {
|
21
|
+
border: 0;
|
22
|
+
}
|
23
|
+
|
24
|
+
p, select, label, .blurb {
|
25
|
+
font:13px/1.231 arial, sans-serif;
|
26
|
+
*font-size:small;
|
27
|
+
}
|
28
|
+
|
29
|
+
a {
|
30
|
+
color: #36d;
|
31
|
+
}
|
32
|
+
|
33
|
+
button#submit {
|
34
|
+
clear: both;
|
35
|
+
margin-top: 5px;
|
36
|
+
width: 100%;
|
37
|
+
padding: 10px 0;
|
38
|
+
cursor: pointer;
|
39
|
+
}
|
40
|
+
|
41
|
+
#source {
|
42
|
+
width: 100%;
|
43
|
+
padding-left: 0;
|
44
|
+
padding-right: 0;
|
45
|
+
}
|
46
|
+
|
47
|
+
button#submit em {
|
48
|
+
font-size: 11px;
|
49
|
+
font-style: normal;
|
50
|
+
color: #999;
|
51
|
+
}
|
52
|
+
|
53
|
+
label {
|
54
|
+
cursor: pointer;
|
55
|
+
}
|
56
|
+
|
57
|
+
select {
|
58
|
+
width: 220px;
|
59
|
+
}
|
60
|
+
|
61
|
+
table#options {
|
62
|
+
float: right;
|
63
|
+
}
|
64
|
+
table#options td {
|
65
|
+
vertical-align: top;
|
66
|
+
padding-left: 10px;
|
67
|
+
}
|
68
|
+
|
69
|
+
#about p {
|
70
|
+
margin: 0 6px 6px 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
li {
|
74
|
+
line-height: 150%;
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
#testresults {
|
79
|
+
display: none;
|
80
|
+
font-family: monaco, "lucida console", "courier new", monospace;
|
81
|
+
}
|
82
|
+
|
83
|
+
.CodeMirror {
|
84
|
+
border: 1px solid #ccc;
|
85
|
+
margin-bottom: 6px;
|
86
|
+
background: white;
|
87
|
+
}
|
88
|
+
.CodeMirror-scroll {
|
89
|
+
min-height: 400px;
|
90
|
+
max-height: 100%;
|
91
|
+
height: auto;
|
92
|
+
overflow-y: hidden;
|
93
|
+
overflow-x: auto;
|
94
|
+
width: 100%
|
95
|
+
}
|
96
|
+
</style>
|
97
|
+
<script src="jquery/jquery.js"></script>
|
98
|
+
<script src="jquery/jquery.cookie.js"></script>
|
99
|
+
|
100
|
+
|
101
|
+
<script src="beautify.js"></script>
|
102
|
+
<script src="beautify-css.js"></script>
|
103
|
+
<script src="beautify-html.js"></script>
|
104
|
+
<script src="tests/sanitytest.js"></script>
|
105
|
+
<script src="tests/beautify-tests.js"></script>
|
106
|
+
<script src="unpackers/javascriptobfuscator_unpacker.js"></script>
|
107
|
+
<script src="unpackers/urlencode_unpacker.js"></script>
|
108
|
+
<script src="unpackers/p_a_c_k_e_r_unpacker.js"></script>
|
109
|
+
<script src="unpackers/myobfuscate_unpacker.js"></script>
|
110
|
+
|
111
|
+
<script>
|
112
|
+
|
113
|
+
var the = {
|
114
|
+
use_codemirror: ( ! window.location.href.match(/without-codemirror/)),
|
115
|
+
beautify_in_progress: false,
|
116
|
+
editor: null // codemirror editor
|
117
|
+
};
|
118
|
+
|
119
|
+
function run_tests() {
|
120
|
+
var st = new SanityTest();
|
121
|
+
run_beautifier_tests(st);
|
122
|
+
JavascriptObfuscator.run_tests(st);
|
123
|
+
P_A_C_K_E_R.run_tests(st);
|
124
|
+
Urlencoded.run_tests(st);
|
125
|
+
MyObfuscate.run_tests(st);
|
126
|
+
// $('#testresults').html(results.replace(/r/g, '').replace(/\n/g, '<br>'));
|
127
|
+
var results = st.results_raw().replace(/ /g, ' ').replace(/\r/g, '·').replace(/\n/g, '<br>');
|
128
|
+
$('#testresults').html(results).show();
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
function any(a, b) {
|
133
|
+
return a || b;
|
134
|
+
}
|
135
|
+
|
136
|
+
function read_settings_from_cookie() {
|
137
|
+
$('#tabsize').val(any($.cookie('tabsize'), '4'));
|
138
|
+
$('#brace-style').val(any($.cookie('brace-style'), 'collapse'));
|
139
|
+
$('#detect-packers').attr('checked', $.cookie('detect-packers') !== 'off');
|
140
|
+
$('#preserve-newlines').attr('checked', $.cookie('preserve-newlines') !== 'off');
|
141
|
+
$('#keep-array-indentation').attr('checked', $.cookie('keep-array-indentation') === 'on');
|
142
|
+
$('#indent-scripts').val(any($.cookie('indent-scripts'), 'normal'));
|
143
|
+
$('#space-before-conditional').attr('checked', $.cookie('space-before-conditional') !== 'off');
|
144
|
+
}
|
145
|
+
|
146
|
+
function store_settings_to_cookie() {
|
147
|
+
var opts = { expires: 360 };
|
148
|
+
$.cookie('tabsize', $('#tabsize').val(), opts);
|
149
|
+
$.cookie('brace-style', $('#brace-style').val(), opts);
|
150
|
+
$.cookie('detect-packers', $('#detect-packers').attr('checked') ? 'on' : 'off', opts);
|
151
|
+
$.cookie('preserve-newlines', $('#preserve-newlines').attr('checked') ? 'on' : 'off', opts);
|
152
|
+
$.cookie('keep-array-indentation', $('#keep-array-indentation').attr('checked') ? 'on' : 'off', opts);
|
153
|
+
$.cookie('space-before-conditional', $('#space-before-conditional').attr('checked') ? 'on' : 'off', opts);
|
154
|
+
$.cookie('indent-scripts', $('#indent-scripts').val(), opts);
|
155
|
+
}
|
156
|
+
|
157
|
+
function unpacker_filter(source) {
|
158
|
+
var trailing_comments = '';
|
159
|
+
var comment = '';
|
160
|
+
var found = false;
|
161
|
+
|
162
|
+
do {
|
163
|
+
found = false;
|
164
|
+
if (/^\s*\/\*/.test(source)) {
|
165
|
+
found = true;
|
166
|
+
comment = source.substr(0, source.indexOf('*/') + 2);
|
167
|
+
source = source.substr(comment.length).replace(/^\s+/, '');
|
168
|
+
trailing_comments += comment + "\n";
|
169
|
+
} else if (/^\s*\/\//.test(source)) {
|
170
|
+
found = true;
|
171
|
+
comment = source.match(/^\s*\/\/.*/)[0];
|
172
|
+
source = source.substr(comment.length).replace(/^\s+/, '');
|
173
|
+
trailing_comments += comment + "\n";
|
174
|
+
}
|
175
|
+
} while (found);
|
176
|
+
|
177
|
+
if (P_A_C_K_E_R.detect(source)) {
|
178
|
+
// P.A.C.K.E.R unpacking may fail, even though it is detected
|
179
|
+
var unpacked = P_A_C_K_E_R.unpack(source);
|
180
|
+
if (unpacked != source) {
|
181
|
+
source = unpacker_filter(unpacked);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
if (Urlencoded.detect(source)) {
|
185
|
+
source = unpacker_filter(Urlencoded.unpack(source))
|
186
|
+
}
|
187
|
+
if (JavascriptObfuscator.detect(source)) {
|
188
|
+
source = unpacker_filter(JavascriptObfuscator.unpack(source))
|
189
|
+
}
|
190
|
+
if (MyObfuscate.detect(source)) {
|
191
|
+
source = unpacker_filter(MyObfuscate.unpack(source))
|
192
|
+
}
|
193
|
+
|
194
|
+
return trailing_comments + source;
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
function beautify() {
|
199
|
+
if (the.beautify_in_progress) return;
|
200
|
+
|
201
|
+
store_settings_to_cookie();
|
202
|
+
|
203
|
+
the.beautify_in_progress = true;
|
204
|
+
|
205
|
+
var source;
|
206
|
+
if (the.editor) {
|
207
|
+
source = the.editor.getValue();
|
208
|
+
} else {
|
209
|
+
source = $('#source').val();
|
210
|
+
}
|
211
|
+
var indent_size = $('#tabsize').val();
|
212
|
+
var indent_char = indent_size == 1 ? '\t' : ' ';
|
213
|
+
var preserve_newlines = $('#preserve-newlines').attr('checked');
|
214
|
+
var keep_array_indentation = $('#keep-array-indentation').attr('checked');
|
215
|
+
var indent_scripts = $('#indent-scripts').val();
|
216
|
+
var brace_style = $('#brace-style').val();
|
217
|
+
var space_before_conditional = $('#space-before-conditional').attr('checked');
|
218
|
+
|
219
|
+
|
220
|
+
var opts = {
|
221
|
+
indent_size: indent_size,
|
222
|
+
indent_char: indent_char,
|
223
|
+
preserve_newlines:preserve_newlines,
|
224
|
+
brace_style: brace_style,
|
225
|
+
keep_array_indentation:keep_array_indentation,
|
226
|
+
space_after_anon_function:true,
|
227
|
+
space_before_conditional: space_before_conditional,
|
228
|
+
indent_scripts:indent_scripts};
|
229
|
+
|
230
|
+
var output;
|
231
|
+
if (looks_like_html(source)) {
|
232
|
+
output = style_html(source, opts);
|
233
|
+
} else {
|
234
|
+
if ($('#detect-packers').attr('checked')) {
|
235
|
+
source = unpacker_filter(source);
|
236
|
+
}
|
237
|
+
output = js_beautify(source, opts);
|
238
|
+
}
|
239
|
+
if (the.editor) {
|
240
|
+
the.editor.setValue(output);
|
241
|
+
} else {
|
242
|
+
$('#source').val(output);
|
243
|
+
}
|
244
|
+
|
245
|
+
the.beautify_in_progress = false;
|
246
|
+
}
|
247
|
+
|
248
|
+
function looks_like_html(source)
|
249
|
+
{
|
250
|
+
// <foo> - looks like html
|
251
|
+
// <!--\nalert('foo!');\n--> - doesn't look like html
|
252
|
+
|
253
|
+
var trimmed = source.replace(/^[ \t\n\r]+/, '');
|
254
|
+
var comment_mark = '<' + '!-' + '-';
|
255
|
+
return (trimmed && (trimmed.substring(0, 1) === '<' && trimmed.substring(0, 4) !== comment_mark));
|
256
|
+
}
|
257
|
+
|
258
|
+
$(function() {
|
259
|
+
|
260
|
+
read_settings_from_cookie();
|
261
|
+
|
262
|
+
var default_text = "// This is just a sample script. Paste your real code (javascript or HTML) here.\n\nif ('this_is'==/an_example/){of_beautifer();}else{var a=b?(c%d):e[f];}";
|
263
|
+
|
264
|
+
if (the.use_codemirror) {
|
265
|
+
the.editor = CodeMirror.fromTextArea($('#source').get(0))
|
266
|
+
the.editor.setValue(default_text);
|
267
|
+
$('.CodeMirror').click(function () {
|
268
|
+
if (the.editor.getValue() == default_text) {
|
269
|
+
the.editor.setValue('');
|
270
|
+
}
|
271
|
+
});
|
272
|
+
} else {
|
273
|
+
$('#source').val(default_text).bind('click focus', function () {
|
274
|
+
if ($(this).val() == default_text) {
|
275
|
+
$(this).val('');
|
276
|
+
}
|
277
|
+
}).bind('blur', function () {
|
278
|
+
if ( ! $(this).val()) {
|
279
|
+
$(this).val(default_text);
|
280
|
+
}
|
281
|
+
});
|
282
|
+
}
|
283
|
+
|
284
|
+
|
285
|
+
$(window).bind('keydown', function (e) {
|
286
|
+
if (e.ctrlKey && e.keyCode == 13) {
|
287
|
+
beautify();
|
288
|
+
}
|
289
|
+
})
|
290
|
+
$('#submit').click(beautify);
|
291
|
+
$('select').change(beautify);
|
292
|
+
|
293
|
+
|
294
|
+
});
|
295
|
+
</script>
|
296
|
+
</head>
|
297
|
+
<body>
|
298
|
+
|
299
|
+
<table id="options">
|
300
|
+
<tr>
|
301
|
+
<td>
|
302
|
+
<select name="tabsize" id="tabsize">
|
303
|
+
<option value="1">indent with a tab character</option>
|
304
|
+
<option value="2">indent with 2 spaces</option>
|
305
|
+
<option value="3">indent with 3 spaces</option>
|
306
|
+
<option value="4">indent with 4 spaces</option>
|
307
|
+
<option value="8">indent with 8 spaces</option>
|
308
|
+
</select><br>
|
309
|
+
|
310
|
+
<select id="brace-style">
|
311
|
+
<option value="collapse">Braces with control statement</option>
|
312
|
+
<option value="expand">Braces on own line</option>
|
313
|
+
<option value="end-expand">End braces on own line</option>
|
314
|
+
<!-- option value="expand-strict">Braces always on own line (not recommended)</option -->
|
315
|
+
</select>
|
316
|
+
|
317
|
+
<p style="margin:6px 0 0 0">HTML <style>, <script> formatting:</p><select id="indent-scripts">
|
318
|
+
<option value="keep">Keep indent level of the tag</option>
|
319
|
+
<option value="normal">Add one indent level</option>
|
320
|
+
<option value="separate">Separate indentation</option>
|
321
|
+
</select>
|
322
|
+
|
323
|
+
</td><td>
|
324
|
+
|
325
|
+
<input class="checkbox" type="checkbox" id="preserve-newlines"><label for="preserve-newlines"> Preserve empty lines?</label><br>
|
326
|
+
<input class="checkbox" type="checkbox" id="detect-packers"><label for="detect-packers"> Detect packers and obfuscators?</label><br>
|
327
|
+
<input class="checkbox" type="checkbox" id="keep-array-indentation"><label for="keep-array-indentation"> Keep array indentation?</label><br>
|
328
|
+
<input class="checkbox" type="checkbox" id="space-before-conditional"><label for="space-before-conditional"> Space before conditional: "if(x)" / "if (x)"
|
329
|
+
<br><a style="margin-left: 25px" href="?without-codemirror">Turn off bells and whistles?</a>
|
330
|
+
|
331
|
+
|
332
|
+
</td></tr>
|
333
|
+
</table>
|
334
|
+
|
335
|
+
<div id="about">
|
336
|
+
<p><strong>Beautify, unpack or deobfuscate JavaScript and HTML, make JSON/JSONP readable, etc.</strong>.</p>
|
337
|
+
<p>All of the source code is completely free and open, available on the <a href="https://github.com/einars/js-beautify">github</a> under MIT licence, <br>and we have a command-line version and a python library as well.
|
338
|
+
</div>
|
339
|
+
|
340
|
+
|
341
|
+
<button id="submit"><strong>Beautify JavaScript or HTML</strong> <em>(ctrl-enter)</em></button>
|
342
|
+
<textarea id="source" rows="30" cols="160"></textarea>
|
343
|
+
|
344
|
+
<div class="blurb">
|
345
|
+
<div style="float:right; width: 210px;">
|
346
|
+
<a style="display:block; float: left; padding-top: 3px" href="http://flattr.com/thing/94550/jsbeautifier-org" target="_blank"><img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr" /></a>
|
347
|
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
348
|
+
<input type="hidden" name="cmd" value="_s-xclick">
|
349
|
+
<input type="hidden" name="hosted_button_id" value="TL28UJK2ARCUJ">
|
350
|
+
<input style="border:0" type="image" src="http://spicausis.lv/misc/paypal-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
351
|
+
<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
352
|
+
</form>
|
353
|
+
</div>
|
354
|
+
|
355
|
+
<p>Browser extensions and other uses:</p>
|
356
|
+
<ul id="uses">
|
357
|
+
|
358
|
+
<li>A <a href="javascript:(function(){s=document.getElementsByTagName('SCRIPT');tx='';sr=[];for(i=0;i<s.length;i++){with(s.item(i)){t=text;if(t){tx+=t;}else{sr.push(src)};}};with(window.open()){document.write('<textarea id="t">'+(sr.join("\n"))+"\n\n-----\n\n"+tx+'</textarea><script src="http://jsbeautifier.org/beautify.js"></script><script>with(document.getElementById("t")){value=js_beautify(value);with(style){width="99%";height="99%";borderStyle="none";}};</script>');document.close();}})();"><strong>bookmarklet</strong></a> (drag it to your bookmarks) by Ichiro Hiroshi to see all scripts used on the page,</li>
|
359
|
+
|
360
|
+
<li style="margin-top: 8px"><strong>Chrome</strong>: <a href="https://github.com/rixth/jsbeautify-for-chrome">jsbeautify-for-chrome</a> by Tom Rix,</li>
|
361
|
+
<li><strong>Chrome</strong>: <a href="https://chrome.google.com/webstore/detail/piekbefgpgdecckjcpffhnacjflfoddg">Pretty Beautiful JavaScript</a> by Will McSweeney,</li>
|
362
|
+
<li style="margin-top: 8px"><strong>Firefox</strong>: <a href="https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/">Javascript deminifier</a> by Ben Murphy,<br>to be used together with the firebug (<a href="https://github.com/benmmurphy/jsdeminifier_xpi/">github</a>),</li>
|
363
|
+
<li style="margin-top: 8px"><strong>Safari</strong>: <a href="http://spadin.github.com/js-beautify-safari-extension">Safari extension</a> by Sandro Padin,</li>
|
364
|
+
<li style="margin-top: 8px"><strong>Opera</strong>: <a href="https://addons.opera.com/addons/extensions/details/readable-javascript/">Readable JavaScript</a> (<a href="https://github.com/Dither/readable-javascript">github</a>) by Dither,</li>
|
365
|
+
<li><strong>Opera</strong>: <a href="https://addons.opera.com/addons/extensions/details/source/">Source</a> extension by Deathamns,</li>
|
366
|
+
<li style="margin-top: 12px"><a style="font-weight: bold" href="http://fiddler2.com/">Fiddler</a> proxy: <a href="http://fiddler2.com/Fiddler2/extensions.asp">JavaScript Formatter addon</a>,
|
367
|
+
<li><strong>gEdit</strong> <a href="https://github.com/nagaozen/gedit-tunnings/">tips by Fabio Nagao</a>,</li>
|
368
|
+
<li><strong>Akelpad</strong> <a href="http://akelpad.sourceforge.net/forum/viewtopic.php?p=11246#11246">extension</a> by Infocatcher,</li>
|
369
|
+
<li>Beautifier in <a style="font-weight: bold" href="http://sethmason.com/2011/04/28/jsbeautify-in-emacs.html">Emacs</a> write-up by Seth Mason,</li>
|
370
|
+
<li><a style="font-weight:bold" href="http://c9.io">Cloud9</a>, a lovely IDE running in a browser, working in the node/cloud, uses jsbeautifier (<a href="https://github.com/ajaxorg/cloud9">github</a>),</li>
|
371
|
+
<li><a style="font-weight:bold" href="http://www.symetronapps.com/pages/apps/shrinker.html">Shrinker</a>, a non-free JavaScript packer for Mac. I haven't used it, so I have no idea if it's any good,</li>
|
372
|
+
<li><a style="font-weight:bold" href="http://www.restconsole.com/">REST Console</a>, a request debugging tool for Chrome, beautifies JSON responses (<a href="https://github.com/codeinchaos/rest-console">github</a>),</li>
|
373
|
+
<li><a style="font-weight:bold" href="http://mitmproxy.org/">mitmproxy</a>, a nifty SSL-capable HTTP proxy, provides pretty javascript responses (<a href="https://github.com/cortesi/mitmproxy">github</a>).</li>
|
374
|
+
<li><a style="font-weight:bold" href="http://www.wakanda.org/">wakanda</a>, a neat IDE for web and mobile applications has a <a href="http://forum.wakanda.org/showthread.php?1483-3-new-extensions-JSLint-Beautifier-and-Snippet">Beautifier extension</a> (<a href="https://github.com/Wakanda/wakanda-extensions/tree/master/Beautifier">github</a>).</li>
|
375
|
+
<li><a style="font-weight:bold" href="https://github.com/michalliu/sourcebeautify.vim">sourcebeautify.vim</a>, a nice vim plugin by michalliu (needs a supported js runtime),</li>
|
376
|
+
<li><a style="font-weight:bold" href="http://portswigger.net/burp/">Burp Suite</a> now has a <a href="http://code.google.com/p/burp-suite-beautifier-extension/">beautfier extension</a>, thanks to Soroush Dalili,</li>
|
377
|
+
<li><a style="font-weight:bold" href="http://plugins.netbeans.org/plugin/43263/jsbeautify">Netbeans jsbeautify</a> plugin by Drew Hamlett (<a href="https://github.com/drewhjava/netbeans-jsbeautify">github</a>).</li>
|
378
|
+
<li class="writeme">Doing anything interesting? Write me to einar@jsbeautifier.org and I'll include your link.</li>
|
379
|
+
</ul>
|
380
|
+
|
381
|
+
<p class="me-me-me">Written by Einar Lielmanis, <a href="mailto:einar@jsbeautifier.org">einar@jsbeautifier.org</a>, Python version flourished by <a href="http://github.com/satufk">Stefano Sanfilippo</a>. We use the wonderful <a href="http://codemirror.net">CodeMirror</a> syntax highlighting editor, written by Marijn Haverbeke.</p>
|
382
|
+
<p class="contributors">Made with a great help of <a href="http://jason.diamond.name/weblog/">Jason Diamond</a>, Patrick Hof, Nochum Sossonko, Andreas Schneider, Dave Vasilevsky, <a href="http://my.opera.com/Vital/blog/">Vital Batmanov,</a> Ron Baldwin, Gabriel Harrison, <a href="http://shullian.com">Chris J. Shull</a>, <a href="http://mathiasbynens.be/">Mathias Bynens</a> and others.
|
383
|
+
</p>
|
384
|
+
|
385
|
+
<p style="text-align:right">
|
386
|
+
<a href="#" style="color: #ccc; border-bottom: 1px dashed #ccc; text-decoration: none;" onclick="run_tests(); return false;">Run the tests</a>
|
387
|
+
</p>
|
388
|
+
|
389
|
+
</div>
|
390
|
+
<div id="testresults"></div>
|
391
|
+
<script>
|
392
|
+
var _gaq = [['_setAccount', 'UA-7409939-1'], ['_trackPageview']];
|
393
|
+
(function(d, t) {
|
394
|
+
var g = d.createElement(t),
|
395
|
+
s = d.getElementsByTagName(t)[0];
|
396
|
+
g.src = '//www.google-analytics.com/ga.js';
|
397
|
+
s.parentNode.insertBefore(g, s);
|
398
|
+
}(document, 'script'));
|
399
|
+
</script>
|
400
|
+
</body>
|
401
|
+
</html>
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/**
|
2
|
+
* Cookie plugin
|
3
|
+
*
|
4
|
+
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
5
|
+
* Dual licensed under the MIT and GPL licenses:
|
6
|
+
* http://www.opensource.org/licenses/mit-license.php
|
7
|
+
* http://www.gnu.org/licenses/gpl.html
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Create a cookie with the given name and value and other optional parameters.
|
13
|
+
*
|
14
|
+
* @example $.cookie('the_cookie', 'the_value');
|
15
|
+
* @desc Set the value of a cookie.
|
16
|
+
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
17
|
+
* @desc Create a cookie with all available options.
|
18
|
+
* @example $.cookie('the_cookie', 'the_value');
|
19
|
+
* @desc Create a session cookie.
|
20
|
+
* @example $.cookie('the_cookie', null);
|
21
|
+
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
22
|
+
* used when the cookie was set.
|
23
|
+
*
|
24
|
+
* @param String name The name of the cookie.
|
25
|
+
* @param String value The value of the cookie.
|
26
|
+
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
27
|
+
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
28
|
+
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
29
|
+
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
30
|
+
* when the the browser exits.
|
31
|
+
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
32
|
+
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
33
|
+
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
34
|
+
* require a secure protocol (like HTTPS).
|
35
|
+
* @type undefined
|
36
|
+
*
|
37
|
+
* @name $.cookie
|
38
|
+
* @cat Plugins/Cookie
|
39
|
+
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
40
|
+
*/
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Get the value of a cookie with the given name.
|
44
|
+
*
|
45
|
+
* @example $.cookie('the_cookie');
|
46
|
+
* @desc Get the value of a cookie.
|
47
|
+
*
|
48
|
+
* @param String name The name of the cookie.
|
49
|
+
* @return The value of the cookie.
|
50
|
+
* @type String
|
51
|
+
*
|
52
|
+
* @name $.cookie
|
53
|
+
* @cat Plugins/Cookie
|
54
|
+
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
55
|
+
*/
|
56
|
+
jQuery.cookie = function(name, value, options) {
|
57
|
+
if (typeof value != 'undefined') { // name and value given, set cookie
|
58
|
+
options = options || {};
|
59
|
+
if (value === null) {
|
60
|
+
value = '';
|
61
|
+
options.expires = -1;
|
62
|
+
}
|
63
|
+
var expires = '';
|
64
|
+
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
65
|
+
var date;
|
66
|
+
if (typeof options.expires == 'number') {
|
67
|
+
date = new Date();
|
68
|
+
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
69
|
+
} else {
|
70
|
+
date = options.expires;
|
71
|
+
}
|
72
|
+
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
73
|
+
}
|
74
|
+
// CAUTION: Needed to parenthesize options.path and options.domain
|
75
|
+
// in the following expressions, otherwise they evaluate to undefined
|
76
|
+
// in the packed version for some reason...
|
77
|
+
var path = options.path ? '; path=' + (options.path) : '';
|
78
|
+
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
79
|
+
var secure = options.secure ? '; secure' : '';
|
80
|
+
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
81
|
+
} else { // only name given, get cookie
|
82
|
+
var cookieValue = null;
|
83
|
+
if (document.cookie && document.cookie != '') {
|
84
|
+
var cookies = document.cookie.split(';');
|
85
|
+
for (var i = 0; i < cookies.length; i++) {
|
86
|
+
var cookie = jQuery.trim(cookies[i]);
|
87
|
+
// Does this cookie string begin with the name we want?
|
88
|
+
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
89
|
+
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return cookieValue;
|
95
|
+
}
|
96
|
+
};
|