Anonymous avatar Anonymous committed ac65026

point

Comments (0)

Files changed (1)

ThreeWireMatrix/matrix_solver.html

 		}
 		#col_center{
 		    padding:1em;
+		    padding-left: 0;
 		    padding-top:0;
 		    overflow:hidden;
 		}
 		#col_left{
 		    float: left;
 		    width: 300px;
+		    padding:1em;
+		    padding-top:0;
+		}
+		div#panel_load_save textarea {
+			width: 100%;
+			max-width: 100%;
+			min-width: 100%;
+			height: 75px;
 		}
 		div.panel>div.ui-widget-content {
 			min-height: 400px;
 			padding: 0.5em;
 		}
+		div#panel_load_save>div.ui-widget-content {
+			min-height: 100px;
+			padding: 0.5em;
+		}
 		.slider-set div.ui-slider-horizontal {
 		  width: 200px;
 		  display:inline-block
 					$( "#content_holder_pin_forms").on("change keyup input","input",function() {
 						keyValuesChanged();
 					});
+					$( "#btn_load" ).on("click",jsonRestore);
 					keySettingsChanged();
 				});
 				function sliderSlide(event,ui) {
 					$( "#var_col_count" ).val( cols );
           $( "#var_key_count" ).val( rows * cols );
           console.log(rows*cols);
+          $("#content_holder_pin_forms").empty();
           for (var i = 0; i < (rows*cols);i++) {
             console.log(i);
-          	var s = $('<div class="panel_pin_info_form"></div>')
-          	$('<label for="input_key_text_' + i + '">Key</label><input type="text" name="input_key_text_'+i+'" id="input_key_text_'+i+'">').appendTo(s);
-          	$('<label for="input_key_text_' + i + '">Pin R</label><input type="text" name="input_key_text_'+i+'" id="input_key_text_'+i+'">').appendTo(s);
-          	$('<label for="input_key_text_' + i + '">Pin B</label><input type="text" name="input_key_text_'+i+'" id="input_key_text_'+i+'">').appendTo(s);
-          	s.fadeIn("fast").appendTo('#content_holder_pin_forms'); 
+          	var s = $('<div class="panel_pin_info_form" id="panel_pin_info_form_'+i+'"></div>')
+ 	        	$('<label for="input_key_text_' + i + '">Key</label><input type="text" name="input_key_text_'+i+'" id="input_key_text_'+i+'">').appendTo(s);
+   	      	$('<label for="input_pin_r_' + i + '">Pin R</label><input type="text" name="input_pin_r_'+i+'" id="input_pin_r_'+i+'">').appendTo(s);
+     	    	$('<label for="input_pin_b_' + i + '">Pin B</label><input type="text" name="input_pin_b_'+i+'" id="input_pin_b_'+i+'">').appendTo(s);
+      	  	s.fadeIn("fast").appendTo('#content_holder_pin_forms'); 
 		      }
 				}
 				function keyValuesChanged() {
+					jsonSave();
+				}
+				function jsonSave() {
+					var obj = {};
+					obj["rows"] = $( "#slider_row_count" ).slider( "value" );
+					obj["cols"] = $( "#slider_col_count" ).slider( "value" );
+					obj["pins"] = {};
 					$("#content_holder_pin_forms .panel_pin_info_form").each(function() {
-						console.log(this);
+						var key_id = parseInt(this.id.replace("panel_pin_info_form_",""));
+						obj["pins"][key_id] = {};
+						obj["pins"][key_id]["key_text"] = $('#input_key_text_'+key_id,this).val();
+						obj["pins"][key_id]["pin_r"] = $('#input_pin_r_'+key_id,this).val();
+						obj["pins"][key_id]["pin_b"] = $('#input_pin_b_'+key_id,this).val();
 					});
+					$("#textarea_load_save").val(JSON.stringify(obj, undefined, 2));
+				}
+				function jsonRestore() {
+					var obj = JSON.parse($("#textarea_load_save").val());
+					$( "#slider_row_count" ).slider( "value", obj["rows"] );
+					$( "#slider_col_count" ).slider( "value", obj["cols"] );
+					for (var i = 0; i < parseInt(obj["rows"])*parseInt(obj["cols"]);i++) {
+						if(obj["pins"] && obj["pins"][i]) {
+	          	$('#input_key_text_' + i).val(obj["pins"][i]["key_text"]);
+  	 	      	$('#input_pin_r_' + i).val(obj["pins"][i]["pin_r"]);
+   		      	$('#input_pin_b_' + i).val(obj["pins"][i]["pin_b"]);
+   		      }
+		      }
 				}
 		</script>
 	</head>
 				</div>
 			</div>
 			<div id="col_center">
+				<div id="panel_load_save" class="panel ui-widget">
+					<div class="ui-widget-header">Load/Save JSON</div>
+					<div class="ui-widget-content">
+						<textarea name="textarea_load_save" id="textarea_load_save"></textarea><br/>
+						<input type="button" id="btn_load" value="Restore From JSON" />
+					</div>					
+				</div>
 				<div id="panel_display" class="panel ui-widget">
 					<div class="ui-widget-header">Results</div>
 					<div class="ui-widget-content">
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.