Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
118 lines (109 sloc) 5.38 KB
<!DOCTYPE html>
<html><head><meta charset='UTF-8'><title id='widget_title'>Readable JavaScript</title>
<link rel='stylesheet' href='css/options.css'>
<script type='text/javascript' src='includes/common.js'></script>
<script>
document.getElementsByTagName('html')[0].setAttribute('lang', window.navigator.language.slice(0,2));
addEventListener('DOMContentLoaded', function() {
var storage = widget.preferences;
function setRadioValue(radioNodeList, value) {
if (!radioNodeList || typeof value !== 'number') return;
for (var i = radioNodeList.length - 1; i > -1; i--) { if (radioNodeList[i].value == value) return radioNodeList[i].checked = true; }
}
function setOptions() {
setRadioValue(document.querySelectorAll('input[name="indent_size"]'), parseInt(storage['indent_size'],10));
document.querySelector('#autoparse_js').checked = s2b(storage['autoparse_js']);
document.querySelector('#enable_button').checked = s2b(storage['enable_button']);
document.querySelector('#preserve_newlines').checked = s2b(storage['preserve_newlines']);
document.querySelector('#keep_array_indentation').checked = s2b(storage['keep_array_indentation']);
document.querySelector('#braces_on_own_line').checked = s2b(storage['braces_on_own_line']);
document.querySelector('#detect_packers').checked = s2b(storage['detect_packers']);
document.querySelector('#debug_output').checked = s2b(storage['debug_output']);
document.querySelector('#enable_coloring').checked = s2b(storage['enable_coloring']);
}
function saveOptions() {
var options = getOptions();
storage['autoparse_js'] = options.autoparse_js;
storage['enable_button'] = options.enable_button;
storage['indent_size'] = options.indent_size;
storage['preserve_newlines'] = options.preserve_newlines;
storage['keep_array_indentation'] = options.keep_array_indentation;
storage['detect_packers'] = options.detect_packers;
storage['braces_on_own_line'] = options.braces_on_own_line;
var indent_char = (options.indent_size == 1) ? '\t' : ' ';
storage['indent_char'] = indent_char;
storage['debug_output'] = options.debug_output;
storage['enable_coloring'] = options.enable_coloring;
}
function getOptions() {
return {
autoparse_js: document.querySelector('#autoparse_js').checked,
enable_button: document.querySelector('#enable_button').checked,
indent_size: document.querySelector('input[name="indent_size"]:checked').value,
preserve_newlines: document.querySelector('#preserve_newlines').checked,
keep_array_indentation: document.querySelector('#keep_array_indentation').checked,
detect_packers: document.querySelector('#detect_packers').checked,
braces_on_own_line: document.querySelector('#braces_on_own_line').checked,
debug_output: document.querySelector('#debug_output').checked,
enable_coloring: document.querySelector('#enable_coloring').checked,
};
}
function optionChange() { saveOptions(); }
setOptions();
var inputs = document.querySelectorAll('input,select');
for (var i=0, e; e=inputs[i]; i++) e.addEventListener('change', optionChange, false);
},false);
</script>
</head>
<body>
<header>
<img src='icons/icon.png'>
<h1 id='widget_name'>Readable JavaScript</h1>
</header>
<section>
<h3 id='label_preferences'>Preferences</h3>
<fieldset>
<input type='checkbox' id='enable_button'/>
<label for='enable_button' id='enable_button_label'>Toolbar button (browser restart needed)</label>
<br/>
<input type='checkbox' id='autoparse_js'/>
<label for='autoparse_js' id='autoparse_js_label'>Disable confirmation popup for files (auto-parse)</label>
<br/><br/>
<fieldset id='indent_size'><legend id='indent_size_label'>Indentation:</legend>
<input type='radio' value='1' name='indent_size' id='indent_size_tab'>
<label for='indent_size_tab' id='indent_size_tab_label'>tab character</label><br />
<input type='radio' value='2' name='indent_size' id='indent_size_two'>
<label for='indent_size_two' id='indent_size_two_label'>2 spaces</label><br />
<input type='radio' value='3' name='indent_size' id='indent_size_three'>
<label for='indent_size_three' id='indent_size_three_label'>3 spaces</label><br />
<input type='radio' value='4' name='indent_size' id='indent_size_four'>
<label for='indent_size_four' id='indent_size_four_label'>4 spaces</label><br />
<input type='radio' value='8' name='indent_size' id='indent_size_eight'>
<label for='indent_size_eight' id='indent_size_eight_label'>8 spaces</label><br />
</fieldset>
<br/>
<input type='checkbox' id='braces_on_own_line'/>
<label for='braces_on_own_line' id='braces_on_own_line_label'>Braces on own line</label>
<br/>
<input type='checkbox' id='preserve_newlines'/>
<label for='preserve_newlines' id='preserve_newlines_label'>Preserve empty lines</label>
<br/>
<input type='checkbox' id='detect_packers'/>
<label for='detect_packers' id='detect_packers_label'>Detect packers</label>
<br/>
<input type='checkbox' id='keep_array_indentation'/>
<label for='keep_array_indentation_label' id='keep_array_indentation_label'>Keep array indentation</label>
<br/>
<input type='checkbox' id='enable_coloring'/>
<label for='enable_coloring' id='enable_coloring_label'>Syntax highlighting (very slow)</label>
<br/>
<input type='checkbox' id='debug_output'/>
<label for='debug_output' id='debug_output_label'>Debug output</label>
</fieldset>
<br /><p></p>
</section>
<footer>
<p id='footer_text'>Powered by the Opera Browser</p>
</footer>
</body>
</html>