diff --git a/index.html b/index.html index 8b51ac81..772f6019 100644 --- a/index.html +++ b/index.html @@ -185,16 +185,20 @@
+ +
+ +
diff --git a/web/common-function.js b/web/common-function.js index 83e38744..f341a010 100644 --- a/web/common-function.js +++ b/web/common-function.js @@ -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); + } + }; + } +}