Commits

Anonymous committed bc3353e

Add example configurations to demo.

  • Participants
  • Parent commits cc4d661

Comments (0)

Files changed (2)

File demo/circute.html

 <button id="step">Step</button>
 Speed: <input id="speed" type="range" min="0" max="200" value="0" />
 
+<span id="select_source_container">
+  <select id="select_source">
+    <option>(select one...)</option>
+    <option>and</option>
+    <option>gated</option>
+    <option>or</option>
+    <option>osc</option>
+    <option>smallosc</option>
+    <option>sr</option>
+    <option>store_hmm</option>
+    <option>xor</option>
+    <option>xor2</option>
+  </select>
+</span>
+
 <textarea id="input" rows="10">
    =========
    =       =
 
 <pre id="output"></pre>
 
+<div id="and" style="display: none;"
+>                 =
+                 =
+   #######==     =     =========
+   #       =     =     =       =
+ ==N==     =   ==N==   =     ==N==
+ =   =     =   =   =   =     =   =
+ =====     =   =====   =     =====
+   =       =     =     =       =
+   ==============N==============
+
+   =========
+   =       =
+ ==N==     =
+ =   =     =
+ =====     =
+   =       =
+   =========</div>
+
+
+<div id="gated" style="display: none;"
+>  ####
+  #  #
+ =N###
+ =   #
+ =  ###
+ =  # #
+ =  #N#
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =   =
+ =
+ ===============================================================#
+</div>
+
+
+<div id="or" style="display: none;"
+>                  =
+                  =
+   #######==   ===N===   =========
+   #       =   =     =   =       =
+ ==N==     = ==N== ==N== =     ==N==
+ =   =     = =   = =   = =     =   =
+ =====     = ===== ===== =     =====
+   =       =   =     =   =       =
+   =============     =============
+</div>
+
+
+<div id="osc" style="display: none;"
+>   =========
+   =       =
+ ==N==     =
+ =   =     =
+ =====     =
+   =       =
+   =========</div>
+
+
+<div id="smallosc" style="display: none;"
+> ============================================================================
+ =
+=N#
+==
+</div>
+
+
+<div id="sr" style="display: none;"
+>
+  #      #
+  #      #
+  #      #
+  #####  #####
+  #   #  #   #
+ =N## # =N## #
+ =  # # =  # #
+ = =N## = =N##
+ = =    = =
+ = =    = =
+ = =    = =
+ = = #  = =
+ # = =  = #
+ # = =  = #
+ # = =  = #
+ # = =  = #
+ # = =  = #
+ # = =  = #
+ # = =  = #
+ # = =  = #
+ # ====== #
+</div>
+
+
+<div id="store_hmm" style="display: none;"
+>
+
+   ==========
+   =   =    =
+  #N# ===   =
+  # # = =   =
+  ### =N=   =
+   #   #   #N#
+   #####   # #
+           ###
+            #
+           =N=
+           = =
+           === ==#
+            =  =
+            ====</div>
+
+
+<div id="xor" style="display: none;"
+>
+
+                  ==========================
+                  =                        =
+        ====   ###N###   ====              =
+        =  =   #     #   =  =              =
+       =N= =  =N=   =N=  = =N=             =
+       = = =  = =   = =  = = =       ##N====
+       === =  ===   ===  = ===       # =
+        =  =   =     =   =  =        # =======================
+        ========     ========        #
+               =     =               #
+               =     =               #
+               =     =               #
+               =     =               #
+               =     =               #
+               =     =               #
+               ===N===               #
+                  #                  #
+                  #                  #
+                  ####################</div>
+
+
+<div id="xor2" style="display: none;"
+>
+
+                  ==========================
+                  =                        =
+        ====   ###N###   ====              =
+        =  =   #     #   =  =              =
+       =N= =  =N=   =N=  = =N=             =
+       = = =  = =   = =  = = =       ##N====
+       === =  ===   ===  = ===       # =
+        =  =   =     =   =  =        # =======================
+        ====   =     =   ====        #
+           =   =     =   =           #
+          ===  =     =  ===          #
+          = =  =     =  = =          #
+          ===  =     =  =N=          #
+           =   =     =   =           #
+           =====     =====           #
+               ===N===               #
+                  #                  #
+                  #                  #
+                  ####################</div>
+
+
 </body>
 <script src="yoob/controller.js"></script>
 <script src="yoob/playfield.js"></script>
     'step': 'step',
     'load': 'load',
     'edit': 'edit',
+    'speed': 'speed',
+    'select': 'select_source',
     'source': 'input',
-    'display': 'output',
-    'speed': 'speed'
+    'display': 'output'
   });
   
   c.click_load();

File demo/yoob/controller.js

     this.speed = undefined;
     this.controls = {};
 
-    var makeOnClick = function(controller, key) {
-        if (controller['click_' + key] !== undefined)
+    this.makeEventHandler = function(control, key) {
+        if (this['click_' + key] !== undefined) {
             key = 'click_' + key;
-        return function(e) { controller[key](); }
+        }
+        var self = this;
+        return function(e) {
+          self[key](control); 
+        };
     };
 
     /*
      */
     this.connect = function(dict) {
         var self = this;
-        var keys = ["start", "stop", "step", "load", "edit"];
+        var keys = ["start", "stop", "step", "load", "edit", "select"];
         for (var i in keys) {
             var key = keys[i];
             var value = dict[key];
                 value = document.getElementById(value);
             }
             if (value !== undefined) {
-                value.onclick = makeOnClick(this, key);
+                if (key === 'select') {
+                    value.onchange = this.makeEventHandler(value, key);
+                } else {
+                    value.onclick = this.makeEventHandler(value, key);
+                }
                 this.controls[key] = value;
             }
         }
         if (this.source) this.source.style.display = "block";
     };
 
+    this.click_select = function(control) {
+        this.stop();
+        var source = document.getElementById(
+          control.options[control.selectedIndex].value
+        );
+        var text = source.innerHTML;
+        text = text.replace(/\&lt;/g, '<');
+        text = text.replace(/\&gt;/g, '>');
+        text = text.replace(/\&amp;/g, '&');
+        if (this.source) this.source.value = text;
+        this.load(text);
+    };
+
     this.start = function() {
         if (this.intervalId !== undefined)
             return;