Skip to content

Commit

Permalink
Add two more checkbox options:
Browse files Browse the repository at this point in the history
* Enable double click to edit text area
* Enable keyboard shortcut to edit text area
  • Loading branch information
stsquad authored and Alex Bennee committed Mar 7, 2010
1 parent 2dd16f3 commit 9326e4c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<hr>
Edit Server @ 127.0.0.1:
<input id="port" type="text" name="port"><em>default: <code>9292</code></em><br>
Allow double click on textarea to invoke editor: <input id="dblclick" type="checkbox" name="dblclick"><br>
Enable Alt-E Keyboard shortcut to invoke editor: <input id="keyshort" type="checkbox" name="keyshort"><br>
<div id="status"></div>
<button onclick="save_options()">Save</button>
<hr>
Expand Down
23 changes: 17 additions & 6 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
* and licensed under the GPLv3. See the COPYING file for details
*/

// Saves options to localStorage.

// Snarfed from AdThwart, not sure why checkboxes are so trixy
function loadCheckbox(id, config) {
document.getElementById(id).checked = typeof localStorage[config] == "undefined" ? false : localStorage[config] == "true";
}

function saveCheckbox(id, config) {
localStorage[config] = document.getElementById(id).checked;
}

// Saves options to localStorage
function save_options() {
var port_box = document.getElementById("port");
var port = port_box.value;
localStorage["edit_server_port"] = port;
localStorage["edit_server_port"] = document.getElementById("port").value;
saveCheckbox("dblclick", "enable_dblclick");
saveCheckbox("keyshort", "enable_keys");

// Update status to let user know options were saved.
var status = document.getElementById("status");
Expand All @@ -27,8 +37,9 @@ function restore_options() {
if (!port) {
port = 9292;
}
var port_box = document.getElementById("port");
port_box.value = port;
document.getElementById("port").value = port;
loadCheckbox("dblclick", "enable_dblclick");
loadCheckbox("keyshort", "enable_keys");
}

/* Message handling multiplexer */
Expand Down

0 comments on commit 9326e4c

Please sign in to comment.