diff options
-rw-r--r-- | fractiform.js | 8 | ||||
-rw-r--r-- | index.html | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/fractiform.js b/fractiform.js index 79085ec..578e0fb 100644 --- a/fractiform.js +++ b/fractiform.js @@ -36,6 +36,7 @@ let widget_choices; let widget_search; let widgets_container; let display_output; +let code_input; let display_output_span = null; let auto_update = true; @@ -1244,7 +1245,7 @@ function import_widgets_from_local_storage() { function export_widgets_to_local_storage() { let widget_str = export_widgets(); - console.log('save', widget_str); + code_input.value = widget_str; localStorage.setItem('widgets', widget_str); } @@ -1311,6 +1312,7 @@ function startup() { widget_choices = document.getElementById('widget-choices'); widget_search = document.getElementById('widget-search'); widgets_container = document.getElementById('widgets-container'); + code_input = document.getElementById('code'); ui_div.style.flexBasis = ui_div.offsetWidth + "px"; // convert to px // drag to resize ui @@ -1335,6 +1337,10 @@ function startup() { e.preventDefault(); }); + document.getElementById('code-form').addEventListener('submit', function (e) { + import_widgets(code_input.value); + }); + gl = canvas.getContext('webgl'); if (gl === null) { // support for very-old-but-not-ancient browsers @@ -101,7 +101,7 @@ button { height: 2.0em; } - input { + input[type=text], input[type=number] { height: 1.5em; font-size: inherit; } @@ -196,6 +196,10 @@ </p> </noscript> <div id="ui"> + <form action="#" method="dialog" id="code-form"> + <input type="text" placeholder="Code" id="code"> + <input type="submit" value="✓"> + </form> Add <input type="text" id="widget-search" placeholder="Search"> <div id="widget-choices"></div> <div id="widgets-container"></div> |