Persist checkbox state using localStorage
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Mon, 27 Jun 2011 12:02:23 -0600
changeset 322 1d74af5b8d37
parent 321 ecc067a11a03
child 323 31db5f77c92d
Persist checkbox state using localStorage
extramethods.html
--- a/extramethods.html	Mon Jun 27 11:57:43 2011 -0600
+++ b/extramethods.html	Mon Jun 27 12:02:23 2011 -0600
@@ -48,12 +48,22 @@
 // Number of rows to display per entry
 var rowCount;
 
+document.querySelector("#enabled-checkbox").checked = localStorage["extramethods-display-enabled"] != "false";
+document.querySelector("#indeterm-checkbox").checked = localStorage["extramethods-display-indeterm"] != "false";
+document.querySelector("#state-checkbox").checked = localStorage["extramethods-display-state"] != "false";
+document.querySelector("#value-checkbox").checked = localStorage["extramethods-display-value"] != "false";
+
 function updateDisplayedRows() {
 	var enabled = document.querySelector("#enabled-checkbox").checked;
 	var indeterm = document.querySelector("#indeterm-checkbox").checked;
 	var state = document.querySelector("#state-checkbox").checked;
 	var value = document.querySelector("#value-checkbox").checked;
 
+	localStorage["extramethods-display-enabled"] = enabled;
+	localStorage["extramethods-display-indeterm"] = indeterm;
+	localStorage["extramethods-display-state"] = state;
+	localStorage["extramethods-display-value"] = value;
+
 	var numberChecked = Number(enabled) + Number(indeterm) + Number(state) + Number(value);
 	var boxes = document.querySelectorAll("#toolbar input");
 	var hiddenRows = [];