mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-23 04:40:06 +00:00
Added buttons to website
This commit is contained in:
parent
dc44ce76f7
commit
08e044a9ec
@ -185,16 +185,20 @@
|
||||
<div>
|
||||
<div style="text-align: center;">
|
||||
<button class="submit"><strong>Beautify Code</strong> <em>(ctrl-enter)</em></button>
|
||||
<input type="file" onchange="changeToFileContent(this)">
|
||||
<button class="control" type="button" onclick="copyText()"><strong>Copy to Clipboard</strong></button>
|
||||
<button class="control" type="button" onclick="selectAll()"><strong>Select All</strong></button>
|
||||
<button class="control" type="button" onclick="clearAll()"><strong>Clear</strong></button>
|
||||
</div>
|
||||
|
||||
<textarea id="source" rows="30" cols="160"></textarea>
|
||||
|
||||
<div style="text-align: center;">
|
||||
<button class="submit"><strong>Beautify Code</strong> <em>(ctrl-enter)</em></button>
|
||||
<input type="file" onchange="changeToFileContent(this)">
|
||||
<button class="control" type="button" onclick="copyText()"><strong>Copy to Clipboard</strong></button>
|
||||
<button class="control" type="button" onclick="selectAll()"><strong>Select All</strong></button>
|
||||
<button class="control" type="button" onclick="clearAll()"><strong>Clear</strong></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*jshint strict:false, node:false */
|
||||
/*exported run_tests, read_settings_from_cookie, beautify, submitIssue, copyText, selectAll*/
|
||||
/*exported run_tests, read_settings_from_cookie, beautify, submitIssue, copyText, selectAll, clearAll, changeToFileContent*/
|
||||
var the = {
|
||||
use_codemirror: !window.location.href.match(/without-codemirror/),
|
||||
beautifier_file: window.location.href.match(/debug/) ? 'beautifier' : './beautifier.min',
|
||||
@ -342,3 +342,26 @@ function selectAll() {
|
||||
$('#source').select();
|
||||
}
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
if (the.editor) {
|
||||
the.editor.setValue('');
|
||||
} else {
|
||||
$('#source').val('');
|
||||
}
|
||||
}
|
||||
|
||||
function changeToFileContent(input) {
|
||||
var file = input.files[0];
|
||||
if (file) {
|
||||
var reader = new FileReader();
|
||||
reader.readAsText(file, "UTF-8");
|
||||
reader.onload = function(event) {
|
||||
if (the.editor) {
|
||||
the.editor.setValue(event.target.result);
|
||||
} else {
|
||||
$('#source').val(event.target.result);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user