Browse Source

Close section tag, add String.prototype.lineCount

Scott Lahteine 10 years ago
parent
commit
12a3975341
2 changed files with 8 additions and 16 deletions
  1. 1
    1
      Marlin/configurator/index.html
  2. 7
    15
      Marlin/configurator/js/configurator.js

+ 1
- 1
Marlin/configurator/index.html View File

@@ -73,6 +73,6 @@
73 73
 
74 74
         <br class="clear" />
75 75
       </form>
76
-    <section>
76
+    </section>
77 77
   </body>
78 78
 </html>

+ 7
- 15
Marlin/configurator/js/configurator.js View File

@@ -25,18 +25,10 @@ String.prototype.lpad = function(len, chr) {
25 25
   if (need > 0) { s = new Array(need+1).join(chr) + s; }
26 26
   return s;
27 27
 };
28
-
29
-String.prototype.prePad = function(len, chr) {
30
-  return len ? this.lpad(len, chr) : this;
31
-};
32
-
33
-String.prototype.zeroPad = function(len) {
34
-  return len ? this.prePad(len, '0') : this;
35
-};
36
-
37
-String.prototype.regEsc = function() {
38
-  return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
39
-}
28
+String.prototype.prePad = function(len, chr) { return len ? this.lpad(len, chr) : this; };
29
+String.prototype.zeroPad = function(len)     { return this.prePad(len, '0'); };
30
+String.prototype.regEsc = function()         { return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); }
31
+String.prototype.lineCount = function()      { return this.split(/\r?\n|\r/).length; };
40 32
 
41 33
 /**
42 34
  * selectField.addOptions takes an array or keyed object
@@ -226,7 +218,7 @@ var configuratorApp = (function(){
226 218
         case config_file:
227 219
           if (has_boards) {
228 220
             $config.text(txt);
229
-            total_config_lines = txt.split(/\r?\n|\r/).length;
221
+            total_config_lines = txt.lineCount();
230 222
             this.initThermistorsFromText(txt);
231 223
             this.purgeDefineInfo(false);
232 224
             this.refreshConfigForm();
@@ -240,7 +232,7 @@ var configuratorApp = (function(){
240 232
         case config_adv_file:
241 233
           if (has_config) {
242 234
             $config_adv.text(txt);
243
-            total_config_adv_lines = txt.split(/\r?\n|\r/).length;
235
+            total_config_adv_lines = txt.lineCount();
244 236
             this.purgeDefineInfo(true);
245 237
             this.refreshConfigForm();
246 238
             this.setMessage(config_adv_file+' loaded successfully.');
@@ -635,7 +627,7 @@ var configuratorApp = (function(){
635 627
      */
636 628
     getLineInText: function(line, txt) {
637 629
       var pos = txt.indexOf(line);
638
-      return (pos < 0) ? pos : txt.substr(0, pos).replace(/[^\n]+/g, '').length;
630
+      return (pos < 0) ? pos : txt.substr(0, pos).lineCount();
639 631
     },
640 632
 
641 633
     log: function(o,l) {

Loading…
Cancel
Save