Browse Source

Parse and use dependent groups

- Parse #if, #ifdef, etc. for rules to enable fields
Scott Lahteine 10 years ago
parent
commit
f994729999

+ 4
- 0
Marlin/configurator/css/configurator.css View File

@@ -91,6 +91,8 @@ label {
91 91
 	margin-right: -450px;
92 92
 	text-align: right;
93 93
 	}
94
+label.blocked { color: #AAA; }
95
+
94 96
 input[type="text"], select { margin: 0.75em 0 0; }
95 97
 input[type="checkbox"], input[type="radio"], input[type="file"] { margin: 1em 0 0; }
96 98
 input[type="checkbox"].enabler, input[type="radio"].enabler { margin-left: 1em; }
@@ -308,3 +310,5 @@ a.download-all { margin: 9px 2em 0; color: #449; border-color: #449; }
308 310
 	.disclose { display: none; }
309 311
 
310 312
 }
313
+
314
+/*.blocked { display: none; }*/

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

@@ -26,7 +26,7 @@
26 26
 
27 27
         <div id="tooltip"></div>
28 28
 
29
-        <label>Drop Files Here:</label><input type="file" id="file-upload" />
29
+        <label>Drop Files:</label><input type="file" id="file-upload" />
30 30
         <label id="tipson"><input type="checkbox" checked /> ?</label>
31 31
         <a href="" class="download-all">Download Zip</a>
32 32
 

+ 209
- 67
Marlin/configurator/js/configurator.js View File

@@ -142,8 +142,10 @@ window.configuratorApp = (function(){
142 142
       $tooltip = $('#tooltip'),
143 143
       $cfg = $('#config_text'), $adv = $('#config_adv_text'),
144 144
       $config = $cfg.find('pre'), $config_adv = $adv.find('pre'),
145
+      define_info = {},
145 146
       define_list = [[],[]],
146 147
       define_section = {},
148
+      dependentGroups = {},
147 149
       boards_list = {},
148 150
       therms_list = {},
149 151
       total_config_lines,
@@ -321,7 +323,7 @@ window.configuratorApp = (function(){
321 323
     /**
322 324
      * Init the thermistors array from the Configuration.h file
323 325
      */
324
-    initThermistorsFromText: function(txt) {
326
+    initThermistorList: function(txt) {
325 327
       // Get all the thermistors and save them into an object
326 328
       var r, s, findDef = new RegExp('(//.*\n)+\\s+(#define[ \\t]+TEMP_SENSOR_0)', 'g');
327 329
       r = findDef.exec(txt);
@@ -334,7 +336,7 @@ window.configuratorApp = (function(){
334 336
     /**
335 337
      * Get all the unique define names
336 338
      */
337
-    updateDefinesFromText: function(index, txt) {
339
+    initDefineList: function(index, txt) {
338 340
       var section = 'hidden',
339 341
           leave_out_defines = ['CONFIGURATION_H', 'CONFIGURATION_ADV_H'],
340 342
           define_sect = {},
@@ -343,7 +345,7 @@ window.configuratorApp = (function(){
343 345
         var name = r[2];
344 346
         if (r[1] == '@section')
345 347
           section = name;
346
-        else if ($.inArray(name, leave_out_defines) < 0 && !(name in define_sect))
348
+        else if ($.inArray(name, leave_out_defines) < 0 && !(name in define_section) && !(name in define_sect))
347 349
           define_sect[name] = section;
348 350
       }
349 351
       define_list[index] = Object.keys(define_sect);
@@ -352,21 +354,100 @@ window.configuratorApp = (function(){
352 354
     },
353 355
 
354 356
     /**
357
+     * Get all condition blocks and their line ranges.
358
+     * Conditions may control multiple line-ranges
359
+     * across both config files.
360
+     */
361
+    initDependentGroups: function() {
362
+      var findDef = /^[ \t]*#(ifn?def|if|else|endif)[ \t]*(.*)([ \t]*\/\/[^\n]+)?$/gm,
363
+          leave_out_defines = ['CONFIGURATION_H', 'CONFIGURATION_ADV_H'];
364
+      $.each([$config, $config_adv], function(i, $v) {
365
+        var ifStack = [];
366
+        var r, txt = $v.text();
367
+        while((r = findDef.exec(txt)) !== null) {
368
+          var lineNum = txt.substr(0, r.index).lineCount();
369
+          var code = r[2].replace(/[ \t]*\/\/.*$/, '');
370
+          switch(r[1]) {
371
+            case 'if':
372
+              var code = code
373
+                .replace(/([A-Z][A-Z0-9_]+)/g, 'self.defineValue("$1")')
374
+                .replace(/defined[ \t]*\(?[ \t]*self.defineValue\(("[A-Z][A-Z0-9_]+")\)[ \t]*\)?/g, 'self.defineIsEnabled($1)');
375
+              ifStack.push(['('+code+')', lineNum]);  // #if starts on next line
376
+              self.log("push     if " + code, 4);
377
+              break;
378
+            case 'ifdef':
379
+              if ($.inArray(code, leave_out_defines) < 0) {
380
+                ifStack.push(['self.defineIsEnabled("' + code + '")', lineNum]);
381
+                self.log("push  ifdef " + code, 4);
382
+              }
383
+              else {
384
+                ifStack.push(0);
385
+              }
386
+              break;
387
+            case 'ifndef':
388
+              if ($.inArray(code, leave_out_defines) < 0) {
389
+                ifStack.push(['!self.defineIsEnabled("' + code + '")', lineNum]);
390
+                self.log("push ifndef " + code, 4);
391
+              }
392
+              else {
393
+                ifStack.push(0);
394
+              }
395
+              break;
396
+            case 'else':
397
+            case 'endif':
398
+              var c = ifStack.pop();
399
+              if (c) {
400
+                var cond = c[0], line = c[1];
401
+                self.log("pop " + c[0], 4);
402
+                if (dependentGroups[cond] === undefined) dependentGroups[cond] = [];
403
+                dependentGroups[cond].push({adv:i,start:line,end:lineNum});
404
+                if (r[1] == 'else') {
405
+                  // Reverse the condition
406
+                  cond = (cond.indexOf('!') === 0) ? cond.substr(1) : ('!'+cond);
407
+                  ifStack.push([cond, lineNum]);
408
+                  self.log("push " + cond, 4);
409
+                }
410
+              }
411
+              else {
412
+                if (r[1] == 'else') ifStack.push(0);
413
+              }
414
+              break;
415
+          }
416
+        }
417
+      }); // text blobs loop
418
+    },
419
+
420
+    /**
421
+     * Init all the defineInfo structures after reload
422
+     * The "enabled" field may need an update for newly-loaded dependencies
423
+     */
424
+    initDefineInfo: function() {
425
+      $.each(define_list, function(e,def_list){
426
+        var adv = e == 1;
427
+        $.each(def_list, function(i,name) {
428
+          define_info[name] = self.getDefineInfo(name, adv);
429
+        });
430
+      });
431
+    },
432
+
433
+    /**
355 434
      * Create fields for any defines that have none
356 435
      */
357
-    createFieldsForDefines: function(adv) {
358
-      var e = adv ? 1 : 0, n = 0;
359
-      var fail_list = [];
436
+    createFieldsForDefines: function(e) {
437
+      var n = 0, fail_list = [];
360 438
       $.each(define_list[e], function(i,name) {
361 439
         var section = define_section[name];
362 440
         if (section != 'hidden' && !$('#'+name).length) {
363
-          var inf = self.getDefineInfo(name, adv);
441
+          var inf = define_info[name];
364 442
 
365 443
           if (inf) {
366 444
 
367 445
             var $ff = $('#'+section), $newfield,
446
+                avail = eval(inf.enabled),
368 447
                 $newlabel = $('<label>',{for:name,class:'added'}).text(name.toLabel());
369 448
 
449
+            if (!avail) $newlabel.addClass('blocked');
450
+
370 451
             // if (!(++n % 3))
371 452
               $newlabel.addClass('newline');
372 453
 
@@ -376,7 +457,8 @@ window.configuratorApp = (function(){
376 457
             if (inf.type == 'list') {
377 458
               for (var i=0; i<inf.size; i++) {
378 459
                 var fieldname = i > 0 ? name+'-'+i : name;
379
-                $newfield = $('<input>',{type:'text',size:6,maxlength:10,id:fieldname,name:fieldname,class:'subitem added'}).prop({defineInfo:inf});
460
+                $newfield = $('<input>',{type:'text',size:6,maxlength:10,id:fieldname,name:fieldname,class:'subitem added',disabled:!avail});
461
+                if (!avail) $newfield.addClass('blocked');
380 462
                 $ff.append($newfield);
381 463
               }
382 464
             }
@@ -396,7 +478,8 @@ window.configuratorApp = (function(){
396 478
               else {
397 479
                 $newfield = inf.type == 'switch' ? $('<input>',{type:'checkbox'}) : $('<input>',{type:'text',size:10,maxlength:40});
398 480
               }
399
-              $newfield.attr({id:name,name:name,class:'added'}).prop({defineInfo:inf});
481
+              $newfield.attr({id:name,name:name,class:'added',disabled:!avail});
482
+              if (!avail) $newfield.addClass('blocked');
400 483
               // Add the new field to the form
401 484
               $ff.append($newfield);
402 485
             }
@@ -442,7 +525,7 @@ window.configuratorApp = (function(){
442 525
           if (has_boards) {
443 526
             $config.text(txt);
444 527
             total_config_lines = txt.lineCount();
445
-            // this.initThermistorsFromText(txt);
528
+            // this.initThermistorList(txt);
446 529
             init_index = 0;
447 530
             has_config = true;
448 531
             if (has_config_adv)
@@ -466,19 +549,24 @@ window.configuratorApp = (function(){
466 549
           }
467 550
           break;
468 551
       }
469
-      // When a config file loads defines might change
552
+      // When a config file loads defines need update
470 553
       if (init_index != null) {
471 554
         var adv = init_index == 1;
555
+        // Purge old fields from the form, clear the define list
472 556
         this.purgeAddedFields(init_index);
473
-        this.updateDefinesFromText(init_index, txt);
557
+        // Build the define_list
558
+        this.initDefineList(init_index, txt);
474 559
         // TODO: Find sequential names and group them
475 560
         //       Allows related settings to occupy one line in the form
476 561
           // this.refreshSequentialDefines();
477
-        // TODO: Get dependent groups (#ifdef's) from text
478
-        //       Allows parent to hide/show or disable/enable dependent fields!
479
-          // this.refreshDependentGroups(); // (from all config text)
480
-        this.createFieldsForDefines(adv);
481
-        this.refreshConfigForm(init_index); // TODO: <-- hide dependent fields
562
+        // Build the dependent defines list
563
+        this.initDependentGroups(); // all config text
564
+        // Get define_info for all known defines
565
+        this.initDefineInfo();      // all config text
566
+        // Create new fields
567
+        this.createFieldsForDefines(init_index); // create new fields
568
+        // Init the fields, set values, etc
569
+        this.refreshConfigForm(init_index);
482 570
         this.activateDownloadLink(adv);
483 571
       }
484 572
       this.setMessage(err
@@ -595,25 +683,65 @@ window.configuratorApp = (function(){
595 683
       // Refresh the motherboard menu with new options
596 684
       $('#MOTHERBOARD').html('').addOptions(boards_list);
597 685
 
598
-      // Init all existing fields, getting define info for any that need it
686
+      // Init all existing fields, getting define info for those that need it
599 687
       // refreshing the options and updating their current values
600 688
       $.each(define_list[init_index], function() {
601
-        if ($('#'+this).length)
602
-          self.initField(this,init_index==1);
689
+        if ($('#'+this).length) {
690
+          self.initField(this);
691
+          self.initFieldValue(this);
692
+        }
603 693
         else
604 694
           self.log(this + " is not on the page yet.", 2);
605 695
       });
696
+
697
+      // Set enabled state based on dependencies
698
+      // this.enableForDependentConditions();
699
+    },
700
+
701
+    /**
702
+     * Enable / disable fields based on condition tests
703
+     */
704
+    refreshDependentFields: function() {
705
+      // Simplest way is to go through all define_info
706
+      // and run a test on all fields that have one.
707
+      //
708
+      // Each define_info caches its enable test as code.
709
+      //
710
+      // The fields that act as switches for these dependencies
711
+      // are not currently modified, but they will soon be.
712
+      //
713
+      // Once all conditions have been gathered into define_info
714
+      // the conditions can be scraped for define names.
715
+      //
716
+      // Those named fields will be given a .change action to
717
+      // check and update enabled state for the field.
718
+      //
719
+      $.each(define_list, function(e,def_list){
720
+        $.each(def_list, function() {
721
+          var inf = define_info[this];
722
+          if (inf && inf.enabled != 'true') {
723
+            var $elm = $('#'+this), ena = eval(inf.enabled);
724
+            // Make any switch toggle also
725
+            $('#'+this+'-switch').attr('disabled', !ena);
726
+            var alreadyEnabled = inf.type == 'switch' || self.defineIsEnabled(this);
727
+            $elm.attr('disabled', !(ena && alreadyEnabled));
728
+            ena ? $elm.removeClass('blocked') : $elm.addClass('blocked');
729
+            // Dim label for unavailable element
730
+            var $lbl = $elm.prev('label');
731
+            if ($lbl.length)
732
+              ena ? $lbl.removeClass('blocked') : $lbl.addClass('blocked');
733
+          }
734
+        });
735
+      });
606 736
     },
607 737
 
608 738
     /**
609
-     * Get the defineInfo for a field on the form
610
-     * Make it responsive, add a tooltip
739
+     * Make the field responsive, add optional tooltip, enabler box
611 740
      */
612
-    initField: function(name, adv) {
741
+    initField: function(name) {
613 742
       this.log("initField:"+name,4);
614
-      var $elm = $('#'+name), elm = $elm[0], inf = elm.defineInfo;
615
-      if (inf == null)
616
-        inf = elm.defineInfo = this.getDefineInfo(name, adv);
743
+      var $elm = $('#'+name), inf = define_info[name];
744
+      $elm[0].defineInfo = inf;
617 745
 
618 746
       // Create a tooltip on the label if there is one
619 747
       if (inf.tooltip) {
@@ -672,16 +800,16 @@ window.configuratorApp = (function(){
672 800
             .change(self.handleSwitch)
673 801
         );
674 802
       }
675
-
676
-      // Set the field's initial value from the define
677
-      this.setFieldFromDefine(name);
678 803
     },
679 804
 
680 805
     /**
681 806
      * Handle any value field being changed
682 807
      * this = the field
683 808
      */
684
-    handleChange: function() { self.updateDefineFromField(this.id); },
809
+    handleChange: function() {
810
+      self.updateDefineFromField(this.id);
811
+      self.refreshDependentFields();
812
+    },
685 813
 
686 814
     /**
687 815
      * Handle a switch checkbox being changed
@@ -690,7 +818,7 @@ window.configuratorApp = (function(){
690 818
     handleSwitch: function() {
691 819
       var $elm = $(this),
692 820
           name = $elm[0].id.replace(/-.+/,''),
693
-          inf = $('#'+name)[0].defineInfo,
821
+          inf = define_info[name],
694 822
           on = $elm.prop('checked') || false;
695 823
 
696 824
       self.setDefineEnabled(name, on);
@@ -711,9 +839,10 @@ window.configuratorApp = (function(){
711 839
      */
712 840
     defineValue: function(name) {
713 841
       this.log('defineValue:'+name,4);
714
-      var inf = $('#'+name)[0].defineInfo;
842
+      var inf = define_info[name];
715 843
       if (inf == null) return 'n/a';
716
-      var result = inf.regex.exec($(inf.field).text());
844
+      // var result = inf.regex.exec($(inf.field).text());
845
+      var result = inf.regex.exec(inf.line);
717 846
 
718 847
       this.log(result,2);
719 848
 
@@ -725,13 +854,14 @@ window.configuratorApp = (function(){
725 854
      */
726 855
     defineIsEnabled: function(name) {
727 856
       this.log('defineIsEnabled:'+name,4);
728
-      var inf = $('#'+name)[0].defineInfo;
857
+      var inf = define_info[name];
729 858
       if (inf == null) return false;
730
-      var result = inf.regex.exec($(inf.field).text());
859
+      // var result = inf.regex.exec($(inf.field).text());
860
+      var result = inf.regex.exec(inf.line);
731 861
 
732 862
       this.log(result,2);
733 863
 
734
-      var on = result !== null ? result[1].trim() != '//' : true;
864
+      var on = result[1] != null ? result[1].trim() != '//' : true;
735 865
       this.log(name + ' = ' + on, 2);
736 866
 
737 867
       return on;
@@ -742,7 +872,7 @@ window.configuratorApp = (function(){
742 872
      */
743 873
     setDefineEnabled: function(name, val) {
744 874
       this.log('setDefineEnabled:'+name,4);
745
-      var inf = $('#'+name)[0].defineInfo;
875
+      var inf = define_info[name];
746 876
       if (inf) {
747 877
         var slash = val ? '' : '//';
748 878
         var newline = inf.line
@@ -761,7 +891,7 @@ window.configuratorApp = (function(){
761 891
       // Drop the suffix on sub-fields
762 892
       name = name.replace(/-\d+$/, '');
763 893
 
764
-      var $elm = $('#'+name), inf = $elm[0].defineInfo;
894
+      var $elm = $('#'+name), inf = define_info[name];
765 895
       if (inf == null) return;
766 896
 
767 897
       var isCheck = $elm.attr('type') == 'checkbox',
@@ -797,7 +927,7 @@ window.configuratorApp = (function(){
797 927
      */
798 928
     setDefineLine: function(name, newline) {
799 929
       this.log('setDefineLine:'+name+'\n'+newline,4);
800
-      var inf = $('#'+name)[0].defineInfo;
930
+      var inf = define_info[name];
801 931
       var $c = $(inf.field), txt = $c.text();
802 932
 
803 933
       var hilite_token = '[HIGHLIGHTER-TOKEN]';
@@ -820,7 +950,7 @@ window.configuratorApp = (function(){
820 950
      */
821 951
     scrollToDefine: function(name, always) {
822 952
       this.log('scrollToDefine:'+name,4);
823
-      var inf = $('#'+name)[0].defineInfo, $c = $(inf.field);
953
+      var inf = define_info[name], $c = $(inf.field);
824 954
 
825 955
       // Scroll to the altered text if it isn't visible
826 956
       var halfHeight = $c.height()/2, scrollHeight = $c.prop('scrollHeight'),
@@ -836,14 +966,14 @@ window.configuratorApp = (function(){
836 966
     /**
837 967
      * Set a form field to the current #define value in the config text
838 968
      */
839
-    setFieldFromDefine: function(name) {
840
-      var $elm = $('#'+name), inf = $elm[0].defineInfo,
969
+    initFieldValue: function(name) {
970
+      var $elm = $('#'+name), inf = define_info[name],
841 971
           val = this.defineValue(name);
842 972
 
843
-      this.log('setFieldFromDefine:' + name + ' to ' + val, 2);
973
+      this.log('initFieldValue:' + name + ' to ' + val, 2);
844 974
 
845 975
       // If the item has a checkbox then set enabled state too
846
-      var $cb = $('#'+name+'-switch'), on = true;
976
+      var $cb = $('#'+name+'-switch'), avail = eval(inf.enabled), on = true;
847 977
       if ($cb.length) {
848 978
         on = self.defineIsEnabled(name);
849 979
         $cb.prop('checked', on);
@@ -854,13 +984,19 @@ window.configuratorApp = (function(){
854 984
           var $e = i > 0 ? $('#'+name+'-'+i) : $elm;
855 985
           $e.val(v.trim());
856 986
           $e.attr('disabled', !on);
987
+          avail ? $e.removeClass('blocked') : $e.addClass('blocked');
857 988
         });
858 989
       }
859 990
       else {
860 991
         if (inf.type == 'toggle') val = val == inf.options[1];
861 992
         $elm.attr('type') == 'checkbox' ? $elm.prop('checked', val) : $elm.val(''+val);
862 993
         $elm.attr('disabled', !on); // enable/disable the form field (could also dim it)
994
+        avail ? $elm.removeClass('blocked') : $elm.addClass('blocked');
863 995
       }
996
+
997
+      // set label color
998
+      var $lbl = $elm.prev('label');
999
+      avail ? $lbl.removeClass('blocked') : $lbl.addClass('blocked');
864 1000
     },
865 1001
 
866 1002
     /**
@@ -874,17 +1010,6 @@ window.configuratorApp = (function(){
874 1010
     },
875 1011
 
876 1012
     /**
877
-     * Update #define information for one of the config files
878
-     */
879
-    refreshDefineInfo: function(adv) {
880
-      if (adv === undefined) adv = false;
881
-      $('[name]').each(function() {
882
-        var inf = this.defineInfo;
883
-        if (inf && adv == inf.adv) this.defineInfo = self.getDefineInfo(this.id, adv);
884
-      });
885
-    },
886
-
887
-    /**
888 1013
      * Get information about a #define from configuration file text:
889 1014
      *
890 1015
      *   - Pre-examine the #define for its prefix, value position, suffix, etc.
@@ -909,9 +1034,9 @@ window.configuratorApp = (function(){
909 1034
           val_i:  1,
910 1035
           type:   'switch',
911 1036
           line:   result[0], // whole line
912
-          pre:    result[1] === undefined ? '' : result[1].replace('//',''),
1037
+          pre:    result[1] == null ? '' : result[1].replace('//',''),
913 1038
           define: result[2],
914
-          post:   result[3] === undefined ? '' : result[3]
1039
+          post:   result[3] == null ? '' : result[3]
915 1040
         });
916 1041
         info.regex = new RegExp('([ \\t]*//)?([ \\t]*' + info.define.regEsc() + info.post.regEsc() + ')', 'm');
917 1042
         info.repl =  new RegExp('([ \\t]*)(\/\/)?([ \\t]*' + info.define.regEsc() + info.post.regEsc() + ')', 'm');
@@ -924,10 +1049,10 @@ window.configuratorApp = (function(){
924 1049
           $.extend(info, {
925 1050
             type:   'list',
926 1051
             line:   result[0],
927
-            pre:    result[1] === undefined ? '' : result[1].replace('//',''),
1052
+            pre:    result[1] == null ? '' : result[1].replace('//',''),
928 1053
             define: result[2],
929 1054
             size:   result[3].split(',').length,
930
-            post:   result[4] === undefined ? '' : result[4]
1055
+            post:   result[4] == null ? '' : result[4]
931 1056
           });
932 1057
           info.regex = new RegExp('([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '\{([^\}]*)\}' + info.post.regEsc(), 'm');
933 1058
           info.repl  = new RegExp('(([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '\{)[^\}]*(\}' + info.post.regEsc() + ')', 'm');
@@ -940,9 +1065,9 @@ window.configuratorApp = (function(){
940 1065
             $.extend(info, {
941 1066
               type:   'quoted',
942 1067
               line:   result[0],
943
-              pre:    result[1] === undefined ? '' : result[1].replace('//',''),
1068
+              pre:    result[1] == null ? '' : result[1].replace('//',''),
944 1069
               define: result[2],
945
-              post:   result[4] === undefined ? '' : result[4]
1070
+              post:   result[4] == null ? '' : result[4]
946 1071
             });
947 1072
             info.regex = new RegExp('([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '"([^"]*)"' + info.post.regEsc(), 'm');
948 1073
             info.repl  = new RegExp('(([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '")[^"]*("' + info.post.regEsc() + ')', 'm');
@@ -955,9 +1080,9 @@ window.configuratorApp = (function(){
955 1080
               $.extend(info, {
956 1081
                 type:   'plain',
957 1082
                 line:   result[0],
958
-                pre:    result[1] === undefined ? '' : result[1].replace('//',''),
1083
+                pre:    result[1] == null ? '' : result[1].replace('//',''),
959 1084
                 define: result[2],
960
-                post:   result[4] === undefined ? '' : result[4]
1085
+                post:   result[4] == null ? '' : result[4]
961 1086
               });
962 1087
               if (result[3].match(/false|true/)) {
963 1088
                 info.type = 'toggle';
@@ -1005,19 +1130,36 @@ window.configuratorApp = (function(){
1005 1130
           }
1006 1131
         }
1007 1132
 
1008
-
1009 1133
         // Add .tooltip and .lineNum properties to the info
1010 1134
         findDef = new RegExp('^'+name); // Strip the name from the tooltip
1135
+        var lineNum = this.getLineNumberOfText(info.line, txt);
1136
+
1137
+        // See if this define is enabled conditionally
1138
+        var enable_cond = '';
1139
+        var adv_index = adv ? 1 : 0;
1140
+        $.each(dependentGroups, function(cond,dat){
1141
+          $.each(dat, function(i,o){
1142
+            if (o.adv == adv_index && lineNum > o.start && lineNum < o.end) {
1143
+              // self.log(name + " is in range " + o.start + "-" + o.end, 2);
1144
+              // if this setting is in a range, conditions are added
1145
+              if (enable_cond != '') enable_cond += ' && ';
1146
+              enable_cond += '(' + cond + ')';
1147
+            }
1148
+          });
1149
+        });
1150
+
1011 1151
         $.extend(info, {
1012 1152
           tooltip: '<strong>'+name+'</strong> '+tooltip.trim().replace(findDef,'').toHTML(),
1013
-          lineNum: this.getLineNumberOfText(info.line, txt),
1014
-          switchable: (info.type != 'switch' && info.line.match(/^[ \t]*\/\//)) || false // Disabled? Mark as "switchable"
1153
+          lineNum: lineNum,
1154
+          switchable: (info.type != 'switch' && info.line.match(/^[ \t]*\/\//)) || false, // Disabled? Mark as "switchable"
1155
+          enabled: enable_cond ? enable_cond : 'true'
1015 1156
         });
1157
+
1016 1158
       }
1017 1159
       else
1018 1160
         info = null;
1019 1161
 
1020
-      this.log(info,2);
1162
+      this.log(info, 2);
1021 1163
 
1022 1164
       return info;
1023 1165
     },

Loading…
Cancel
Save