Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions NinjaKit.safariextension/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,30 @@ function init(){
FontList();
}

initializeOption('tabsize', 'tabSize', 1);
initializeOption('braces-on-own-line', 'bracesOnOwnLine', true);
initializeOption('preserve-newlines', 'preserveNewlines', true);
initializeOption('detect-packers', 'detectPackers', false);
initializeOption('keep-array-indentation', 'keepArrayIndentation', false);

function initializeOption(id, optionKey, defaultValue) {
var currentValue, key,
element = document.getElementById(id);
if (element.tagName == "INPUT" && element.type == "checkbox") {
currentValue = Config.options[optionKey] === undefined ? defaultValue : Config.options[optionKey];
key = "checked";
element.checked = currentValue ? true : false;
} else {
currentValue = +Config.options[optionKey] || defaultValue;
key = "value";
element.value = currentValue;
}
element.onclick = function() {
Config.options[optionKey] = element[key];
localStorage.Config = JSON.stringify(Config);
}
}

var add = document.getElementById('add_script');
var add_script = function(){
var styl = {
Expand Down
6 changes: 3 additions & 3 deletions NinjaKit.safariextension/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ <h2>beautify options</h2>
<ul>
<li>
<select name="tabsize" id="tabsize">
<option value="1" selected="selected">indent with a tab character</option>
<option value="1">indent with a tab character</option>
<option value="2">indent with 2 spaces</option>
<option value="3">indent with 3 spaces</option>
<option value="4">indent with 4 spaces</option>
<option value="8">indent with 8 spaces</option>
</select>
</li>
<li><input type="checkbox" id="braces-on-own-line" checked="checked"><label for="braces-on-own-line"> Braces on own line</label></li>
<li><input type="checkbox" id="preserve-newlines" checked="checked"><label for="preserve-newlines"> Preserve empty lines?</label></li>
<li><input type="checkbox" id="braces-on-own-line"><label for="braces-on-own-line"> Braces on own line</label></li>
<li><input type="checkbox" id="preserve-newlines"><label for="preserve-newlines"> Preserve empty lines?</label></li>
<li><input type="checkbox" id="detect-packers"><label for="detect-packers"> Detect packers?</label></li>
<li><input type="checkbox" id="keep-array-indentation"><label for="keep-array-indentation"> Keep array indentation?</label></li>
<li> Font size: <span id="currentFontSize">12</span><br> 8<input type="range" id="fontSize" value="12" step="1" min="8" max="40">40</li>
Expand Down