/** * 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 */ "use strict"; $(function(){ var marlin_config = 'https://api.github.com/repos/MarlinFirmware/Marlin/contents/Marlin'; // Extend builtins 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 this.prePad(len, '0'); }; String.prototype.toHTML = function() { return jQuery('
').text(this).html(); }; String.prototype.regEsc = function() { return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); } String.prototype.lineCount = function() { var len = this.split(/\r?\n|\r/).length; return len > 0 ? len - 1 : 0; }; String.prototype.toLabel = function() { return this.replace(/_/g, ' ').toTitleCase(); } String.prototype.toTitleCase = function() { return this.replace(/([A-Z])(\w+)/gi, function(m,p1,p2) { return p1.toUpperCase() + p2.toLowerCase(); }); } Number.prototype.limit = function(m1, m2) { if (m2 == null) return this > m1 ? m1 : this; return this < m1 ? m1 : this > m2 ? m2 : 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( $('