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
 
73
 
74
         <br class="clear" />
74
         <br class="clear" />
75
       </form>
75
       </form>
76
-    <section>
76
+    </section>
77
   </body>
77
   </body>
78
 </html>
78
 </html>

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

25
   if (need > 0) { s = new Array(need+1).join(chr) + s; }
25
   if (need > 0) { s = new Array(need+1).join(chr) + s; }
26
   return s;
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
  * selectField.addOptions takes an array or keyed object
34
  * selectField.addOptions takes an array or keyed object
226
         case config_file:
218
         case config_file:
227
           if (has_boards) {
219
           if (has_boards) {
228
             $config.text(txt);
220
             $config.text(txt);
229
-            total_config_lines = txt.split(/\r?\n|\r/).length;
221
+            total_config_lines = txt.lineCount();
230
             this.initThermistorsFromText(txt);
222
             this.initThermistorsFromText(txt);
231
             this.purgeDefineInfo(false);
223
             this.purgeDefineInfo(false);
232
             this.refreshConfigForm();
224
             this.refreshConfigForm();
240
         case config_adv_file:
232
         case config_adv_file:
241
           if (has_config) {
233
           if (has_config) {
242
             $config_adv.text(txt);
234
             $config_adv.text(txt);
243
-            total_config_adv_lines = txt.split(/\r?\n|\r/).length;
235
+            total_config_adv_lines = txt.lineCount();
244
             this.purgeDefineInfo(true);
236
             this.purgeDefineInfo(true);
245
             this.refreshConfigForm();
237
             this.refreshConfigForm();
246
             this.setMessage(config_adv_file+' loaded successfully.');
238
             this.setMessage(config_adv_file+' loaded successfully.');
635
      */
627
      */
636
     getLineInText: function(line, txt) {
628
     getLineInText: function(line, txt) {
637
       var pos = txt.indexOf(line);
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
     log: function(o,l) {
633
     log: function(o,l) {

Loading…
Cancel
Save