From ef18bfdd3f328b30590fc6d64c14557a0b2b5c2a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 5 Feb 2015 07:05:29 -0800 Subject: [PATCH 01/41] An in-place browser-based configurator utility - A web form with fields for configuration values - Reads and parses standard config files - Modifies configurations dynamically in-place --- Marlin/configurator/css/configurator.css | 27 ++ Marlin/configurator/index.html | 52 +++ Marlin/configurator/js/configurator.js | 293 +++++++++++++ Marlin/configurator/js/jcanvas.js | 524 +++++++++++++++++++++++ Marlin/configurator/js/jstepper.js | 220 ++++++++++ 5 files changed, 1116 insertions(+) create mode 100644 Marlin/configurator/css/configurator.css create mode 100644 Marlin/configurator/index.html create mode 100644 Marlin/configurator/js/configurator.js create mode 100644 Marlin/configurator/js/jcanvas.js create mode 100644 Marlin/configurator/js/jstepper.js diff --git a/Marlin/configurator/css/configurator.css b/Marlin/configurator/css/configurator.css new file mode 100644 index 0000000000..9c7b1be0a8 --- /dev/null +++ b/Marlin/configurator/css/configurator.css @@ -0,0 +1,27 @@ +/* configurator.css */ +/* Styles for Marlin Configurator */ + +body { margin: 0; padding: 0; background: #458; color: #FFC; font-family: sans-serif; } +#main { float: left; width: 100%; margin-right: -100%; } +#main { padding: 0 4%; width: 92%; } +#main { font-family: monospace; } +.info { color: #AAF; } +.info span { color: #FFF; } +.info span span { color: #000; font-weight: bold; } +p { width: 80%; color: #FF0; } +#help strong { color: #0DD; } +img { display: none; } +label, input, select, textarea { display: block; float: left; margin: 1px 0; } +label.newline, textarea { clear: both; } +label { width: 130px; height: 1em; padding: 10px 480px 10px 1em; margin-right: -470px; text-align: right; } +input[type="text"], select, .jstepper { margin: 0.75em 0 0; } +input[type="checkbox"], input[type="radio"] { margin: 1em 0 0; } +#config_form { display: block; background: #DDD; padding: 20px; color: #000; } +/*#config_text, #config_adv_text { font-family: "Andale mono", monospace; clear: both; }*/ +#config_text, #config_adv_text { height: 25em; overflow: auto; background-color: #FFF; color: #888; padding: 10px; } +input[type="checkbox"], input[type="radio"].enabler { margin-left: 1em; } +input:disabled { color: #BBB; } +.clear { clear: both; } +h1, h2, h3, h4, h5, h6 { clear: both; } +h2 { margin: 0; padding: 1em 0 0; } +.jstepper { display: block; } diff --git a/Marlin/configurator/index.html b/Marlin/configurator/index.html new file mode 100644 index 0000000000..ea613d0177 --- /dev/null +++ b/Marlin/configurator/index.html @@ -0,0 +1,52 @@ + + + Marlin Configurator + + + + + + + + +
+

Marlin Configurator 0.1a

+

Enter values in the form, get a Marlin configuration.
Will include a drop-down of known configurations.

+ + +
+ + + +
+ + + + + + + + + + + + + + + + + + + +

Marlin/Configuration.h

+

+        

Marlin/Configuration_adv.h

+

+
+        
+
+
+ + diff --git a/Marlin/configurator/js/configurator.js b/Marlin/configurator/js/configurator.js new file mode 100644 index 0000000000..8189b24fa8 --- /dev/null +++ b/Marlin/configurator/js/configurator.js @@ -0,0 +1,293 @@ +/** + * configurator.js + * + * Marlin Configuration Utility + * - Web form for entering configuration options + * - A reprap calculator to calculate movement values + * - Uses HTML5 to generate downloadables in Javascript + * - Reads and parses standard configuration files from local folders + * + * Supporting functions + * - Parser to read Marlin Configuration.h and Configuration_adv.h files + * - Utilities to replace values in configuration files + */ +$(function(){ + +var marlin_config = '..'; + +// Extend String +String.prototype.lpad = function(len, chr) { + if (chr === undefined) { chr = ' '; } + var s = this+'', need = len - s.length; + if (need > 0) { s = new Array(need+1).join(chr) + s; } + return s; +}; + +String.prototype.prePad = function(len, chr) { + return len ? this.lpad(len, chr) : this; +}; + +String.prototype.zeroPad = function(len) { + return len ? this.prePad(len, '0') : this; +}; + +/** + * selectField.addOptions takes an array or keyed object + */ +$.fn.extend({ + addOptions: function(arrObj) { + return this.each(function() { + var sel = $(this); + var isArr = Object.prototype.toString.call(arrObj) == "[object Array]"; + $.each(arrObj, function(k, v) { + sel.append( $('