<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>API: editor-plugin GroupUtils.js (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
<link rel="stylesheet" type="text/css" href="assets/api.css" />
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h1><a href="http://neyric.github.com/wireit" title="WireItLibrary">WireItLibrary</a></h1>
<h3>editor-plugin <span class="subtitle">0.6.0</span></h3>
<a href="./index.html" title="WireItLibrary">WireItLibrary</a>
> <a href="./module_editor-plugin.html" title="editor-plugin">editor-plugin</a>
> GroupUtils.js (source view)
<form onsubmit="return false">
<div id="propertysearch">
Search: <input autocomplete="off" id="searchinput" />
<div id="searchresults">
</div>
</div>
</form>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
<fieldset>
<legend>Filters</legend>
<span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
<span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
<span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
</fieldset>
</form>
<div id="srcout">
<style>
#doc3 .classopts { display:none; }
</style>
<div class="highlight"><pre><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">util</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="o">,</span><span class="nx">lang</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">Event</span> <span class="o">=</span> <span class="nx">util</span><span class="p">.</span><span class="nx">Event</span><span class="o">,</span> <span class="nx">Dom</span> <span class="o">=</span> <span class="nx">util</span><span class="p">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="nx">Connect</span> <span class="o">=</span> <span class="nx">util</span><span class="p">.</span><span class="nx">Connect</span><span class="o">,</span><span class="nx">JSON</span> <span class="o">=</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">JSON</span><span class="o">,</span><span class="nx">widget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">widget</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Contains utility functions to do with groups (also one or two more general ones)</span>
<span class="c"> * @class GroupUtils</span>
<span class="c"> * @namespace WireIt</span>
<span class="c"> */</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span> <span class="o">=</span> <span class="p">{</span>
<span class="c">/**</span>
<span class="c"> * Applys the given function to all containers in the group.</span>
<span class="c"> * @method applyToContainers</span>
<span class="c"> * @param {WireIt.Group} group The group object to work with</span>
<span class="c"> * @param {boolean} deep Whether to recurse down into sub groups applying to their containers as well</span>
<span class="c"> * @param {Function} func The function to apply (takes 1 arg, the container)</span>
<span class="c"> * @param {Object} context The context to call the function with</span>
<span class="c"> */</span>
<span class="nx">applyToContainers</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">deep</span><span class="o">,</span> <span class="nx">func</span><span class="o">,</span> <span class="nx">context</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">context</span><span class="p">))</span>
<span class="nx">context</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="nx">func</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">context</span><span class="o">,</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">);</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="nx">func</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">context</span><span class="o">,</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">container</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">deep</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">applyToContainers</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">gI</span><span class="p">].</span><span class="nx">group</span><span class="o">,</span> <span class="nx">deep</span><span class="o">,</span> <span class="nx">func</span><span class="o">,</span> <span class="nx">context</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Gives the argument back or a default if the argument is not a value</span>
<span class="c"> * @param {any} The argument to check</span>
<span class="c"> * @param {any} The default value</span>
<span class="c"> * @return {any} The argument if it is a value or the default</span>
<span class="c"> */</span>
<span class="nx">valueOr</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">arg</span><span class="o">,</span> <span class="nx">def</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">return</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">arg</span><span class="p">)</span> <span class="o">?</span> <span class="nx">arg</span> <span class="o">:</span> <span class="nx">def</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Removes the group's containers and sub groups from the layer</span>
<span class="c"> * @param {WireIt.Group} The group to remove</span>
<span class="c"> * @param {WireIt.Layer} The layer to remove them from</span>
<span class="c"> */</span>
<span class="nx">removeGroupFromLayer</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">layer</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">group</span><span class="p">.</span><span class="nx">collapsing</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="nx">layer</span><span class="p">.</span><span class="nx">removeContainer</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">);</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="nx">layer</span><span class="p">.</span><span class="nx">removeContainer</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">removeGroupFromLayer</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="o">,</span> <span class="nx">layer</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">group</span><span class="p">.</span><span class="nx">collapsing</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Gets the outer most group (e.g. if this group is inside another one it gives you that one (or its parent group if it has one etc etc))</span>
<span class="c"> * @param {WireIt.Group} The group to get the outer group for</span>
<span class="c"> * @param {Function} Optional callback function for each group found (including the given one)</span>
<span class="c"> * @return {WireIt.Group} The outermost group</span>
<span class="c"> */</span>
<span class="nx">getOuterGroup</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">groupCallback</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">last</span> <span class="o">=</span> <span class="nx">group</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">current</span> <span class="o">=</span> <span class="nx">last</span><span class="o">;</span>
<span class="k">do</span>
<span class="p">{</span>
<span class="nx">last</span> <span class="o">=</span> <span class="nx">current</span><span class="o">;</span>
<span class="nx">current</span> <span class="o">=</span> <span class="nx">current</span><span class="p">.</span><span class="nx">group</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">groupCallback</span><span class="p">))</span>
<span class="nx">groupCallback</span><span class="p">(</span><span class="nx">last</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">while</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">current</span><span class="p">))</span>
<span class="k">return</span> <span class="nx">last</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Adds all(recurses down) the containers in a group to the given array</span>
<span class="c"> * @param {WireIt.Group} The group to get the containers from</span>
<span class="c"> * @param {Array} The array to add all the containers to</span>
<span class="c"> */</span>
<span class="nx">addAllContainers</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="nx">containers</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">);</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="nx">containers</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">container</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">addAllContainers</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">gI</span><span class="p">].</span><span class="nx">group</span><span class="o">,</span> <span class="nx">containers</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Removes direct references to group and container objects (replaces with an index), is applied recursively to sub groups</span>
<span class="c"> * @param {WiteIt.Group} group The group to serialise</span>
<span class="c"> * @param {Array} containers The array of containers from the group (for generating indexes)</span>
<span class="c"> * @return {Object} The seriliased group</span>
<span class="c"> */</span>
<span class="nx">serialiseGroup</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">sGroup</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">sGroup</span><span class="p">.</span><span class="nx">properties</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">sGroup</span><span class="p">.</span><span class="nx">properties</span><span class="o">,</span> <span class="nx">group</span><span class="p">.</span><span class="nx">properties</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">sGroup</span><span class="p">.</span><span class="nx">groupContainer</span> <span class="o">=</span> <span class="nx">containers</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="nx">sGroup</span><span class="p">.</span><span class="nx">containers</span> <span class="o">=</span> <span class="p">[]</span>
<span class="nx">sGroup</span><span class="p">.</span><span class="nx">groups</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="nx">sGroup</span><span class="p">.</span><span class="nx">containers</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span><span class="s2">"container"</span> <span class="o">:</span> <span class="nx">containers</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">container</span><span class="p">)</span><span class="o">,</span> <span class="s2">"overrides"</span> <span class="o">:</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">overrides</span><span class="p">})</span> <span class="c">//TODO: check if index is -1?</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">gI</span><span class="p">];</span>
<span class="nx">sGroup</span><span class="p">.</span><span class="nx">groups</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span><span class="s2">"group"</span> <span class="o">:</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">serialiseGroup</span><span class="p">(</span><span class="nx">g</span><span class="p">.</span><span class="nx">group</span><span class="o">,</span> <span class="nx">containers</span><span class="p">)</span><span class="o">,</span> <span class="s2">"overrides"</span> <span class="o">:</span> <span class="nx">g</span><span class="p">.</span><span class="nx">overrides</span><span class="p">});</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">sGroup</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Get the configuration to pass to a group container</span>
<span class="c"> * @param {WireIt.Group} group The group to get the config for</span>
<span class="c"> * @param {object} map Optional The group's map (obtained by WireIt.GroupUtils.getMap(group))</span>
<span class="c"> * @return {object} The collapsed config</span>
<span class="c"> */</span>
<span class="nx">getCollapsedConfig</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">map</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">map</span><span class="p">))</span>
<span class="nx">map</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getMap</span><span class="p">(</span><span class="nx">group</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">fieldConfigs</span> <span class="o">=</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">terminalConfigs</span> <span class="o">=</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">generateExternal</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ftMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">ftMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">ftMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fMap</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">fMap</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fc</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">fc</span><span class="o">,</span> <span class="nx">fMap</span><span class="p">.</span><span class="nx">fieldConfig</span><span class="p">);</span>
<span class="nx">fc</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">fMap</span><span class="p">.</span><span class="nx">externalName</span><span class="o">;</span>
<span class="nx">fc</span><span class="p">.</span><span class="kd">label</span> <span class="o">=</span> <span class="nx">fMap</span><span class="p">.</span><span class="nx">externalName</span><span class="o">;</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">fc</span><span class="o">,</span> <span class="nx">fMap</span><span class="p">.</span><span class="nx">fieldConfig</span><span class="p">)</span>
<span class="nx">fieldConfigs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">fc</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">tMap</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">tMap</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">tc</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">tc</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">tMap</span><span class="p">.</span><span class="nx">externalName</span><span class="o">;</span>
<span class="nx">tc</span><span class="p">.</span><span class="nx">side</span> <span class="o">=</span> <span class="nx">tMap</span><span class="p">.</span><span class="nx">side</span><span class="o">;</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">tc</span><span class="o">,</span> <span class="nx">tMap</span><span class="p">.</span><span class="nx">terminalConfig</span><span class="p">);</span>
<span class="nx">terminalConfigs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">tc</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">map</span><span class="p">.</span><span class="nx">groupContainerMap</span><span class="p">))</span>
<span class="nx">generateExternal</span><span class="p">([</span><span class="nx">map</span><span class="p">.</span><span class="nx">groupContainerMap</span><span class="p">])</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="nx">generateExternal</span><span class="p">(</span><span class="nx">map</span><span class="p">.</span><span class="nx">containerMap</span><span class="p">);</span>
<span class="nx">generateExternal</span><span class="p">(</span><span class="nx">map</span><span class="p">.</span><span class="nx">groupMap</span><span class="p">);</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">center</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">workOutCenter</span><span class="p">(</span><span class="nx">group</span><span class="p">);</span>
<span class="k">return</span> <span class="p">{</span> <span class="s2">"fields"</span> <span class="o">:</span> <span class="nx">fieldConfigs</span><span class="o">,</span> <span class="s2">"terminals"</span> <span class="o">:</span> <span class="nx">terminalConfigs</span><span class="o">,</span> <span class="s2">"position"</span> <span class="o">:</span> <span class="nx">center</span><span class="o">,</span> <span class="s2">"center"</span> <span class="o">:</span> <span class="nx">center</span><span class="p">};</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Works out the center point of a group</span>
<span class="c"> * @param {WireIt.Group} group The group to get the center of</span>
<span class="c"> * @return {Array} the x, y position of the center</span>
<span class="c"> */</span>
<span class="nx">workOutCenter</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">bounds</span> <span class="o">=</span> <span class="p">{};</span>
<span class="kd">var</span> <span class="nx">setBound</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">position</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">left</span><span class="o">,</span> <span class="nx">top</span><span class="o">;</span>
<span class="nx">left</span> <span class="o">=</span> <span class="nx">position</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="nx">top</span> <span class="o">=</span> <span class="nx">position</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="k">if</span> <span class="p">((</span><span class="k">typeof</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"left"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"undefined"</span><span class="p">)</span> <span class="o">||</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"left"</span><span class="p">]</span> <span class="o">></span> <span class="nx">left</span><span class="p">)</span>
<span class="nx">bounds</span><span class="p">[</span><span class="s2">"left"</span><span class="p">]</span> <span class="o">=</span> <span class="nx">left</span><span class="o">;</span>
<span class="k">if</span> <span class="p">((</span><span class="k">typeof</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"right"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"undefined"</span><span class="p">)</span> <span class="o">||</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"right"</span><span class="p">]</span> <span class="o"><</span> <span class="nx">left</span><span class="p">)</span>
<span class="nx">bounds</span><span class="p">[</span><span class="s2">"right"</span><span class="p">]</span> <span class="o">=</span> <span class="nx">left</span><span class="o">;</span>
<span class="k">if</span> <span class="p">((</span><span class="k">typeof</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"top"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"undefined"</span><span class="p">)</span> <span class="o">||</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"top"</span><span class="p">]</span> <span class="o">></span> <span class="nx">top</span><span class="p">)</span>
<span class="nx">bounds</span><span class="p">[</span><span class="s2">"top"</span><span class="p">]</span> <span class="o">=</span> <span class="nx">top</span><span class="o">;</span>
<span class="k">if</span> <span class="p">((</span><span class="k">typeof</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"bottom"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"undefined"</span><span class="p">)</span> <span class="o">||</span> <span class="nx">bounds</span><span class="p">[</span><span class="s2">"bottom"</span><span class="p">]</span> <span class="o"><</span> <span class="nx">top</span><span class="p">)</span>
<span class="nx">bounds</span><span class="p">[</span><span class="s2">"bottom"</span><span class="p">]</span> <span class="o">=</span> <span class="nx">top</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">setBound</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">getConfig</span><span class="p">().</span><span class="nx">position</span><span class="p">)</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">container</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">getConfig</span><span class="p">();</span>
<span class="nx">setBound</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">position</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">gI</span><span class="p">].</span><span class="nx">group</span><span class="o">;</span>
<span class="nx">setBound</span><span class="p">(</span><span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">workOutCenter</span><span class="p">(</span><span class="nx">g</span><span class="p">));</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">[</span>
<span class="p">((</span><span class="nx">bounds</span><span class="p">.</span><span class="nx">right</span> <span class="o">+</span> <span class="nx">bounds</span><span class="p">.</span><span class="nx">left</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span><span class="o">,</span>
<span class="p">((</span><span class="nx">bounds</span><span class="p">.</span><span class="nx">top</span> <span class="o">+</span> <span class="nx">bounds</span><span class="p">.</span><span class="nx">bottom</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
<span class="p">];</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">getExternalToInternalMap</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">map</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">containerMap</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"fields"</span> <span class="o">:</span> <span class="p">{}</span><span class="o">,</span> <span class="s2">"terminals"</span> <span class="o">:</span> <span class="p">{}};</span>
<span class="kd">var</span> <span class="nx">groupMap</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"fields"</span> <span class="o">:</span> <span class="p">{}</span><span class="o">,</span> <span class="s2">"terminals"</span> <span class="o">:</span> <span class="p">{}};</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">map</span><span class="p">.</span><span class="nx">containerMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">map</span><span class="p">.</span><span class="nx">containerMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span><span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="nx">containerMap</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"containerId"</span> <span class="o">:</span> <span class="nx">cI</span><span class="o">,</span> <span class="s2">"name"</span> <span class="o">:</span> <span class="nx">fName</span><span class="p">}</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span><span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="nx">containerMap</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">t</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"containerId"</span> <span class="o">:</span> <span class="nx">cI</span><span class="o">,</span> <span class="s2">"name"</span> <span class="o">:</span> <span class="nx">tName</span><span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">map</span><span class="p">.</span><span class="nx">groupMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">map</span><span class="p">.</span><span class="nx">groupMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span><span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="nx">groupMap</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"containerId"</span> <span class="o">:</span> <span class="nx">cI</span><span class="o">,</span> <span class="s2">"name"</span> <span class="o">:</span> <span class="nx">fName</span><span class="p">}</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span><span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="nx">groupMap</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">t</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"containerId"</span> <span class="o">:</span> <span class="nx">cI</span><span class="o">,</span> <span class="s2">"name"</span> <span class="o">:</span> <span class="nx">tName</span><span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">{</span><span class="s2">"containerMap"</span> <span class="o">:</span> <span class="nx">containerMap</span><span class="o">,</span> <span class="s2">"groupMap"</span> <span class="o">:</span> <span class="nx">groupMap</span><span class="p">};</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * Set the override options for the group (e.g. rename fields)</span>
<span class="c"> * Currently sets all overrides not just the ones that are actually changed by the user</span>
<span class="c"> * @method getOverridesFromUI</span>
<span class="c"> */</span>
<span class="nx">getOverridesFromUI</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">containerUIMap</span><span class="o">,</span> <span class="nx">groupUIMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">containerOverrides</span> <span class="o">=</span> <span class="p">[];</span>
<span class="nx">groupOverrides</span> <span class="o">=</span> <span class="p">[];</span>
<span class="c">//for the moment set all overrides</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">containerUIMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">containerUIMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">]</span>
<span class="kd">var</span> <span class="nx">overrides</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"fields"</span> <span class="o">:</span> <span class="p">{}</span><span class="o">,</span> <span class="s2">"terminals"</span> <span class="o">:</span> <span class="p">{}};</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="nx">f</span><span class="p">.</span><span class="nx">visible</span><span class="p">.</span><span class="nx">checked</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">rename</span> <span class="o">=</span> <span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">.</span><span class="nx">value</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">rename</span><span class="p">.</span><span class="nx">length</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">rename</span> <span class="o">=</span> <span class="nx">rename</span><span class="o">;</span>
<span class="nx">overrides</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">visible</span><span class="p">.</span><span class="nx">checked</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">rename</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">externalName</span><span class="p">.</span><span class="nx">value</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">rename</span><span class="p">.</span><span class="nx">length</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">rename</span> <span class="o">=</span> <span class="nx">rename</span><span class="o">;</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">side</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">side</span><span class="p">.</span><span class="nx">value</span><span class="o">;</span>
<span class="nx">overrides</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">containerOverrides</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">overrides</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">groupUIMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="nx">groupUIMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">]</span>
<span class="kd">var</span> <span class="nx">overrides</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"fields"</span> <span class="o">:</span> <span class="p">{}</span><span class="o">,</span> <span class="s2">"terminals"</span> <span class="o">:</span> <span class="p">{}};</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fName</span> <span class="k">in</span> <span class="nx">g</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">g</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="nx">f</span><span class="p">.</span><span class="nx">visible</span><span class="p">.</span><span class="nx">checked</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">rename</span> <span class="o">=</span> <span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">.</span><span class="nx">value</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">rename</span><span class="p">.</span><span class="nx">length</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">rename</span> <span class="o">=</span> <span class="nx">rename</span><span class="o">;</span>
<span class="nx">overrides</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tName</span> <span class="k">in</span> <span class="nx">g</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">g</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">visible</span><span class="p">.</span><span class="nx">checked</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">rename</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">externalName</span><span class="p">.</span><span class="nx">value</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">rename</span><span class="p">.</span><span class="nx">length</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">rename</span> <span class="o">=</span> <span class="nx">rename</span><span class="o">;</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">side</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">side</span><span class="p">.</span><span class="nx">value</span><span class="o">;</span>
<span class="nx">overrides</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">{</span><span class="s2">"containerOverrides"</span> <span class="o">:</span> <span class="nx">containerOverrides</span><span class="o">,</span> <span class="s2">"groupOverrides"</span> <span class="o">:</span> <span class="nx">groupOverrides</span><span class="p">};</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">getMap</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="p">)</span>
<span class="p">{</span>
<span class="c">//assume no group container case</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">map</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"fields"</span> <span class="o">:</span> <span class="p">[]</span><span class="o">,</span> <span class="s2">"terminals"</span> <span class="o">:</span> <span class="p">[]};</span>
<span class="kd">var</span> <span class="nx">inGroup</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">container</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">return</span> <span class="nx">container</span> <span class="o">==</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="o">;</span>
<span class="p">};</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputConfigs</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fConfig</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputConfigs</span><span class="p">[</span><span class="nx">fI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">fCopy</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">fCopy</span><span class="o">,</span> <span class="nx">fConfig</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">fMap</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"fieldConfig"</span> <span class="o">:</span> <span class="nx">fCopy</span><span class="p">};</span>
<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isFieldExternal</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputs</span><span class="p">[</span><span class="nx">fI</span><span class="p">]</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">fMap</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="nx">fConfig</span><span class="p">.</span><span class="nx">name</span><span class="o">;</span>
<span class="nx">fMap</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">fields</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">fMap</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">tConfig</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">tMap</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"terminalConfig"</span> <span class="o">:</span> <span class="nx">tConfig</span><span class="p">};</span>
<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isTerminalExternal</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tI</span><span class="p">]</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">tMap</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">tMap</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="nx">tConfig</span><span class="p">.</span><span class="nx">name</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">terminals</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">tMap</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">{</span> <span class="s2">"groupContainerMap"</span> <span class="o">:</span> <span class="nx">map</span> <span class="p">};</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">usedNames</span> <span class="o">=</span> <span class="p">{</span><span class="nx">terminals</span> <span class="o">:</span> <span class="p">{}</span><span class="o">,</span> <span class="nx">fields</span> <span class="o">:</span> <span class="p">{}};</span>
<span class="kd">var</span> <span class="nx">containerMap</span> <span class="o">=</span> <span class="p">{};</span>
<span class="kd">var</span> <span class="nx">groupMap</span> <span class="o">=</span> <span class="p">{};</span>
<span class="k">this</span><span class="p">.</span><span class="nx">generateFieldMap</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">containerMap</span><span class="o">,</span> <span class="nx">groupMap</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">generateTerminalMap</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">containerMap</span><span class="o">,</span> <span class="nx">groupMap</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">generateDefaultFieldNames</span><span class="p">(</span><span class="nx">containerMap</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">generateDefaultFieldNames</span><span class="p">(</span><span class="nx">groupMap</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">generateDefaultTerminalNames</span><span class="p">(</span><span class="nx">containerMap</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">generateDefaultTerminalNames</span><span class="p">(</span><span class="nx">groupMap</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">);</span>
<span class="k">return</span> <span class="p">{</span> <span class="s2">"containerMap"</span> <span class="o">:</span> <span class="nx">containerMap</span><span class="o">,</span> <span class="s2">"groupMap"</span> <span class="o">:</span> <span class="nx">groupMap</span> <span class="p">};</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateDefaultTerminalNames</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">map</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">map</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">map</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">visible</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">externalName</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">t</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">generateFreshName</span><span class="p">(</span><span class="nx">tName</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">.</span><span class="nx">terminals</span><span class="p">);</span>
<span class="nx">usedNames</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">t</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateDefaultFieldNames</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">map</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">map</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">map</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fName</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fName</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">visible</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">))</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">fieldConfig</span><span class="p">.</span><span class="nx">wirable</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">mergedUsedNames</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">mergedUsedNames</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">.</span><span class="nx">fields</span><span class="p">);</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">mergedUsedNames</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">.</span><span class="nx">terminals</span><span class="p">);</span>
<span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">generateFreshName</span><span class="p">(</span><span class="nx">fName</span><span class="o">,</span> <span class="nx">mergedUsedNames</span><span class="p">);</span>
<span class="nx">usedNames</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">usedNames</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">generateFreshName</span><span class="p">(</span><span class="nx">fName</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">.</span><span class="nx">fields</span><span class="p">);</span>
<span class="nx">usedNames</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">f</span><span class="p">.</span><span class="nx">externalName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateTerminalMap</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">containerMap</span><span class="o">,</span> <span class="nx">groupMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">mergeTerminalOverrides</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">terminalConfigs</span><span class="o">,</span> <span class="nx">overrides</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">forceVisible</span><span class="o">,</span> <span class="nx">terminalMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">terminalConfigs</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">terminalConfigs</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">name</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">name</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nx">overrides</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">map</span> <span class="o">=</span> <span class="p">{</span><span class="nx">terminalConfig</span> <span class="o">:</span> <span class="nx">t</span><span class="p">};</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">o</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">))</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">usedNames</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">]))</span>
<span class="k">throw</span> <span class="p">{</span><span class="s2">"type"</span> <span class="o">:</span> <span class="s2">"MappingError"</span><span class="o">,</span> <span class="s2">"message"</span> <span class="o">:</span> <span class="s2">"Two identical terminal names specified ("</span> <span class="o">+</span> <span class="nx">o</span><span class="p">.</span><span class="nx">rename</span> <span class="o">+</span> <span class="s2">")"</span><span class="p">}</span>
<span class="nx">usedNames</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">side</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">side</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">forceVisible</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">forceVisible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">terminalMap</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">map</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="kd">var</span> <span class="nx">allContainers</span> <span class="o">=</span> <span class="p">[];</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">addAllContainers</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">allContainers</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">inGroup</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">container</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">allContainers</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">container</span> <span class="o">==</span> <span class="nx">allContainers</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="c">//TODO: doesn't take into account expanded but in group containers?</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="p">};</span>
<span class="c">//Get default maps (with overrides)</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">co</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">co</span><span class="p">.</span><span class="nx">container</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">os</span> <span class="o">=</span> <span class="nx">co</span><span class="p">.</span><span class="nx">overrides</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">cm</span> <span class="o">=</span> <span class="p">{};</span>
<span class="kd">var</span> <span class="nx">terminalConfigs</span> <span class="o">=</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">c</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span> <span class="o">?</span> <span class="nx">c</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">terminals</span> <span class="o">:</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">forceVisible</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">terminal</span><span class="o">;</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">==</span> <span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">terminal</span> <span class="o">=</span> <span class="nx">t</span><span class="o">;</span>
<span class="k">break</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">self</span><span class="p">.</span><span class="nx">isTerminalExternal</span><span class="p">(</span><span class="nx">terminal</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">mergeTerminalOverrides</span><span class="p">(</span><span class="nx">terminalConfigs</span><span class="o">,</span> <span class="nx">os</span><span class="p">.</span><span class="nx">terminals</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">forceVisible</span><span class="o">,</span> <span class="nx">cm</span><span class="o">,</span> <span class="nx">c</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">title</span><span class="p">);</span>
<span class="nx">containerMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">terminals</span> <span class="o">=</span> <span class="nx">cm</span><span class="o">;</span>
<span class="p">}</span>
<span class="c">//Get default maps (with overrides)</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">go</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">gI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="nx">go</span><span class="p">.</span><span class="nx">group</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">os</span> <span class="o">=</span> <span class="nx">go</span><span class="p">.</span><span class="nx">overrides</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">gm</span> <span class="o">=</span> <span class="p">{};</span>
<span class="kd">var</span> <span class="nx">map</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getMap</span><span class="p">(</span><span class="nx">g</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">terminalConfigs</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getCollapsedConfig</span><span class="p">(</span><span class="nx">g</span><span class="o">,</span> <span class="nx">map</span><span class="p">).</span><span class="nx">terminals</span><span class="c">//TODO: inefficient </span>
<span class="kd">var</span> <span class="nx">forceVisible</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">g</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">forceVisible</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">terminal</span><span class="o">;</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">g</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">g</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">==</span> <span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">terminal</span> <span class="o">=</span> <span class="nx">t</span><span class="o">;</span>
<span class="k">break</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">self</span><span class="p">.</span><span class="nx">isTerminalExternal</span><span class="p">(</span><span class="nx">terminal</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">externalToInternalMap</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getExternalToInternalMap</span><span class="p">(</span><span class="nx">map</span><span class="p">);</span>
<span class="nx">forceVisible</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tName</span> <span class="k">in</span> <span class="nx">externalToInternalMap</span><span class="p">.</span><span class="nx">containerMap</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">tMap</span> <span class="o">=</span> <span class="nx">externalToInternalMap</span><span class="p">.</span><span class="nx">containerMap</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tName</span><span class="p">]</span>
<span class="kd">var</span> <span class="nx">terminal</span><span class="o">;</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">g</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">tMap</span><span class="p">.</span><span class="nx">containerId</span><span class="p">].</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">g</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">tMap</span><span class="p">.</span><span class="nx">containerId</span><span class="p">].</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">==</span> <span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">terminal</span> <span class="o">=</span> <span class="nx">t</span><span class="o">;</span>
<span class="k">break</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">isTerminalExternal</span><span class="p">(</span><span class="nx">terminal</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">))</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nx">mergeTerminalOverrides</span><span class="p">(</span><span class="nx">terminalConfigs</span><span class="o">,</span> <span class="nx">os</span><span class="p">.</span><span class="nx">terminals</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">forceVisible</span><span class="o">,</span> <span class="nx">gm</span><span class="p">);</span>
<span class="nx">groupMap</span><span class="p">[</span><span class="nx">gI</span><span class="p">].</span><span class="nx">terminals</span> <span class="o">=</span> <span class="nx">gm</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">isFieldExternal</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">f</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">f</span><span class="p">))</span>
<span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">isTerminalExternal</span><span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">terminal</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">isTerminalExternal</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">terminal</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">terminal</span><span class="p">))</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">wI</span> <span class="k">in</span> <span class="nx">terminal</span><span class="p">.</span><span class="nx">wires</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">terminal</span><span class="p">.</span><span class="nx">wires</span><span class="p">[</span><span class="nx">wI</span><span class="p">];</span>
<span class="k">if</span> <span class="p">((</span><span class="nx">w</span><span class="p">.</span><span class="nx">terminal1</span> <span class="o">!=</span> <span class="nx">terminal</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">inGroup</span><span class="p">(</span><span class="nx">w</span><span class="p">.</span><span class="nx">terminal1</span><span class="p">.</span><span class="nx">container</span><span class="p">))</span> <span class="o">||</span>
<span class="p">(</span><span class="nx">w</span><span class="p">.</span><span class="nx">terminal2</span> <span class="o">!=</span> <span class="nx">terminal</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">inGroup</span><span class="p">(</span><span class="nx">w</span><span class="p">.</span><span class="nx">terminal2</span><span class="p">.</span><span class="nx">container</span><span class="p">)))</span>
<span class="p">{</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateFieldMap</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">containerMap</span><span class="o">,</span> <span class="nx">groupMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">allContainers</span> <span class="o">=</span> <span class="p">[];</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">addAllContainers</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">allContainers</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">inGroup</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">container</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">allContainers</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">container</span> <span class="o">==</span> <span class="nx">allContainers</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="p">};</span>
<span class="c">//Get default maps (with overrides)</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">co</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">co</span><span class="p">.</span><span class="nx">container</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">os</span> <span class="o">=</span> <span class="nx">co</span><span class="p">.</span><span class="nx">overrides</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">cm</span> <span class="o">=</span> <span class="p">{};</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">c</span><span class="p">.</span><span class="nx">form</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fieldConfigs</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputConfigs</span>
<span class="kd">var</span> <span class="nx">forceVisible</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">return</span> <span class="nx">self</span><span class="p">.</span><span class="nx">isFieldExternal</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">self</span><span class="o">,</span> <span class="nx">c</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputsNames</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">this</span><span class="p">.</span><span class="nx">mergeFieldOverrides</span><span class="p">(</span><span class="nx">fieldConfigs</span><span class="o">,</span> <span class="nx">os</span><span class="p">.</span><span class="nx">fields</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">forceVisible</span><span class="o">,</span> <span class="nx">cm</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">containerMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">]</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">containerMap</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">fields</span> <span class="o">=</span> <span class="nx">cm</span><span class="o">;</span>
<span class="p">}</span>
<span class="c">//Get default maps (with overrides)</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">go</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">gI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="nx">go</span><span class="p">.</span><span class="nx">group</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">os</span> <span class="o">=</span> <span class="nx">go</span><span class="p">.</span><span class="nx">overrides</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">gm</span> <span class="o">=</span> <span class="p">{};</span>
<span class="kd">var</span> <span class="nx">map</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getMap</span><span class="p">(</span><span class="nx">g</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">fieldConfigs</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getCollapsedConfig</span><span class="p">(</span><span class="nx">g</span><span class="o">,</span> <span class="nx">map</span><span class="p">).</span><span class="nx">fields</span><span class="c">//TODO: inefficient since we throw away terminal results then get them again</span>
<span class="kd">var</span> <span class="nx">forceVisible</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">g</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">forceVisible</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">return</span> <span class="nx">self</span><span class="p">.</span><span class="nx">isFieldExternal</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">self</span><span class="o">,</span> <span class="nx">g</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputsNames</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">forceVisible2</span><span class="o">;</span>
<span class="nx">forceVisible2</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">group</span><span class="o">,</span> <span class="nx">map</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">map</span><span class="p">))</span>
<span class="nx">map</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getMap</span><span class="p">(</span><span class="nx">group</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">externalToInternalMap</span> <span class="o">=</span> <span class="nx">WireIt</span><span class="p">.</span><span class="nx">GroupUtils</span><span class="p">.</span><span class="nx">getExternalToInternalMap</span><span class="p">(</span><span class="nx">map</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">fMap</span> <span class="o">=</span> <span class="nx">externalToInternalMap</span><span class="p">.</span><span class="nx">containerMap</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">fMap</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">fMap</span><span class="p">.</span><span class="nx">containerId</span><span class="p">].</span><span class="nx">container</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputsNames</span><span class="p">[</span><span class="nx">fMap</span><span class="p">.</span><span class="nx">name</span><span class="p">]</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">isFieldExternal</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">self</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">inGroup</span><span class="p">))</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fMap</span> <span class="o">=</span> <span class="nx">externalToInternalMap</span><span class="p">.</span><span class="nx">groupMap</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">fMap</span><span class="p">))</span>
<span class="k">return</span> <span class="nx">forceVisible2</span><span class="p">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">fMap</span><span class="p">.</span><span class="nx">containerId</span><span class="p">].</span><span class="nx">group</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">forceVisible</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">forceVisible2</span><span class="p">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">g</span><span class="o">,</span> <span class="nx">map</span><span class="p">);</span> <span class="p">};</span>
<span class="p">}</span>
<span class="k">this</span><span class="p">.</span><span class="nx">mergeFieldOverrides</span><span class="p">(</span><span class="nx">fieldConfigs</span><span class="o">,</span> <span class="nx">os</span><span class="p">.</span><span class="nx">fields</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">forceVisible</span><span class="o">,</span> <span class="nx">gm</span><span class="p">);</span>
<span class="nx">groupMap</span><span class="p">[</span><span class="nx">gI</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">groupMap</span><span class="p">[</span><span class="nx">gI</span><span class="p">].</span><span class="nx">fields</span> <span class="o">=</span> <span class="nx">gm</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateFreshName</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">used</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">return</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">usedNames</span><span class="p">[</span><span class="nx">name</span><span class="p">]);</span>
<span class="p">};</span>
<span class="kd">var</span> <span class="nx">freshName</span> <span class="o">=</span> <span class="nx">name</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">used</span><span class="p">(</span><span class="nx">freshName</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">1</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">current</span> <span class="o">=</span> <span class="nx">freshName</span><span class="o">;</span>
<span class="k">do</span>
<span class="p">{</span>
<span class="nx">freshName</span> <span class="o">=</span> <span class="nx">current</span> <span class="o">+</span> <span class="nx">i</span><span class="o">;</span>
<span class="nx">i</span><span class="o">++;</span>
<span class="p">}</span>
<span class="k">while</span><span class="p">(</span><span class="nx">used</span><span class="p">(</span><span class="nx">freshName</span><span class="p">))</span>
<span class="p">}</span>
<span class="nx">usedNames</span><span class="p">[</span><span class="nx">freshName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">return</span> <span class="nx">freshName</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">mergeFieldOverrides</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">fieldConfigs</span><span class="o">,</span> <span class="nx">overrides</span><span class="o">,</span> <span class="nx">usedNames</span><span class="o">,</span> <span class="nx">forceVisible</span><span class="o">,</span> <span class="nx">fieldMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fI</span> <span class="k">in</span> <span class="nx">fieldConfigs</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">fieldConfigs</span><span class="p">[</span><span class="nx">fI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">name</span> <span class="o">=</span> <span class="nx">f</span><span class="p">.</span><span class="nx">name</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nx">overrides</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">map</span> <span class="o">=</span> <span class="p">{</span><span class="nx">fieldConfig</span> <span class="o">:</span> <span class="nx">f</span><span class="p">};</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">o</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">))</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">usedNames</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">]))</span>
<span class="k">throw</span> <span class="p">{</span><span class="s2">"type"</span> <span class="o">:</span> <span class="s2">"MappingError"</span><span class="o">,</span> <span class="s2">"message"</span> <span class="o">:</span> <span class="s2">"Two identical field names specified ("</span> <span class="o">+</span> <span class="nx">o</span><span class="p">.</span><span class="nx">rename</span> <span class="o">+</span> <span class="s2">")"</span><span class="p">}</span>
<span class="nx">usedNames</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">wirable</span><span class="p">)</span>
<span class="nx">usedNames</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">forceVisible</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">visible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">map</span><span class="p">.</span><span class="nx">forceVisible</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">fieldMap</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">map</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateFields</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">fieldConfigs</span><span class="o">,</span> <span class="nx">overrides</span><span class="o">,</span> <span class="nx">external</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fields</span> <span class="o">=</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">neededFields</span> <span class="o">=</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">terminalNamesUsed</span> <span class="o">=</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">usedNames</span> <span class="o">=</span> <span class="p">{};</span>
<span class="kd">var</span> <span class="nx">addFieldToUsed</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">fieldConfig</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">usedNames</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">fieldConfig</span><span class="p">.</span><span class="nx">wirable</span><span class="p">)</span>
<span class="nx">terminalNamesUsed</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">mI</span> <span class="k">in</span> <span class="nx">fieldConfigs</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="nx">fieldConfigs</span><span class="p">[</span><span class="nx">mI</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fI</span> <span class="k">in</span> <span class="nx">m</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">m</span><span class="p">[</span><span class="nx">fI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">str</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">String</span><span class="p">(</span><span class="nx">mI</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">str2</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">String</span><span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">name</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">str3</span> <span class="o">=</span> <span class="nx">str</span> <span class="o">+</span> <span class="nx">str2</span> <span class="o">+</span> <span class="s1">''</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nx">overrides</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">str3</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">e</span> <span class="o">=</span> <span class="nx">external</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">str3</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">needNames</span> <span class="o">=</span> <span class="p">{};</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">o</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">field</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">field</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="p">{</span><span class="s2">"label"</span> <span class="o">:</span> <span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="o">,</span> <span class="s2">"name"</span> <span class="o">:</span> <span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">});</span>
<span class="nx">fields</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span> <span class="nx">field</span> <span class="p">);</span>
<span class="nx">addFieldToUsed</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="o">,</span> <span class="nx">f</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="nx">neededFields</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">f</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span>
<span class="nx">neededFields</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">f</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fI</span> <span class="k">in</span> <span class="nx">neededFields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">neededFields</span><span class="p">[</span><span class="nx">fI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">freshName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">generateNextName</span><span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">name</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">);</span>
<span class="nx">addFieldToUsed</span><span class="p">(</span><span class="nx">freshName</span><span class="o">,</span> <span class="nx">f</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">field</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">field</span><span class="o">,</span> <span class="nx">f</span><span class="p">);</span>
<span class="nx">field</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">freshName</span><span class="o">;</span>
<span class="nx">fields</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span> <span class="nx">field</span> <span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">"fields"</span> <span class="o">:</span> <span class="nx">fields</span><span class="o">,</span>
<span class="s2">"usedTerminalNames"</span> <span class="o">:</span> <span class="nx">terminalNamesUsed</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateTerminals</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">terminalConfigs</span><span class="o">,</span> <span class="nx">overrides</span><span class="o">,</span> <span class="nx">external</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">terminals</span> <span class="o">=</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">visibleTerminals</span> <span class="o">=</span> <span class="p">[];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">mI</span> <span class="k">in</span> <span class="nx">terminalConfigs</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="nx">terminalConfigs</span><span class="p">[</span><span class="nx">mI</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">m</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">m</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nx">overrides</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">mI</span> <span class="o">+</span> <span class="nx">t</span><span class="p">.</span><span class="nx">name</span><span class="p">]</span>
<span class="kd">var</span> <span class="nx">e</span> <span class="o">=</span> <span class="nx">external</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">mI</span> <span class="o">+</span> <span class="nx">t</span><span class="p">.</span><span class="nx">name</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">o</span><span class="p">.</span><span class="nx">visible</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">terminal</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">terminal</span><span class="o">,</span> <span class="nx">t</span><span class="p">);</span>
<span class="nx">terminal</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="o">;</span>
<span class="c">//TODO: check if name already used?</span>
<span class="nx">usedNames</span><span class="p">[</span><span class="nx">o</span><span class="p">.</span><span class="nx">rename</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">terminals</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">terminal</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="nx">visibleTerminals</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">t</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span>
<span class="nx">visibleTerminals</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">t</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">visibleTerminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">visibleTerminals</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">freshName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">generateNextName</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">name</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">);</span>
<span class="nx">usedNames</span><span class="p">[</span><span class="nx">freshName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">terminal</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">terminal</span><span class="o">,</span> <span class="nx">t</span><span class="p">);</span>
<span class="nx">terminal</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">freshName</span><span class="o">;</span>
<span class="nx">terminals</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">terminal</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">terminals</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">generateNextName</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">usedNames</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">used</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">return</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">usedNames</span><span class="p">[</span><span class="nx">name</span><span class="p">]);</span>
<span class="p">};</span>
<span class="kd">var</span> <span class="nx">freshName</span> <span class="o">=</span> <span class="nx">name</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">used</span><span class="p">(</span><span class="nx">freshName</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">1</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">current</span> <span class="o">=</span> <span class="nx">freshName</span><span class="o">;</span>
<span class="k">do</span>
<span class="p">{</span>
<span class="nx">freshName</span> <span class="o">=</span> <span class="nx">current</span> <span class="o">+</span> <span class="nx">i</span><span class="o">;</span>
<span class="nx">i</span><span class="o">++;</span>
<span class="p">}</span>
<span class="k">while</span><span class="p">(</span><span class="nx">used</span><span class="p">(</span><span class="nx">freshName</span><span class="p">))</span>
<span class="p">}</span>
<span class="nx">usedNames</span><span class="p">[</span><span class="nx">freshName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="k">return</span> <span class="nx">freshName</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">getExternalTerminalName</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="o">,</span> <span class="nx">moduleId</span><span class="o">,</span> <span class="nx">fieldConfigs</span><span class="o">,</span> <span class="nx">terminalConfigs</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">mI</span> <span class="k">in</span> <span class="nx">terminalMap</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="nx">terminalMap</span><span class="p">[</span><span class="nx">mI</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">name</span> <span class="o">==</span> <span class="nx">internalTerminal</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">&&</span>
<span class="nx">m</span><span class="p">.</span><span class="nx">moduleId</span> <span class="o">==</span> <span class="nx">internalModuleId</span><span class="p">)</span>
<span class="k">return</span> <span class="nx">mI</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">throw</span> <span class="p">{</span><span class="s2">"type"</span> <span class="o">:</span> <span class="s2">"MappingError"</span><span class="o">,</span> <span class="s2">"message"</span> <span class="o">:</span> <span class="s2">"Couldn't find internal terminal's external name"</span><span class="p">};</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">fieldConfigsFromModules</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">modules</span><span class="o">,</span> <span class="nx">getBaseConfig</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="p">{};</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">mI</span> <span class="k">in</span> <span class="nx">modules</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="nx">modules</span><span class="p">[</span><span class="nx">mI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">fullConfig</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">fullConfig</span><span class="o">,</span> <span class="nx">m</span><span class="p">.</span><span class="nx">config</span><span class="p">);</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">fullConfig</span><span class="o">,</span> <span class="nx">getBaseConfig</span><span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">name</span><span class="p">))</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">fullConfig</span><span class="p">.</span><span class="nx">fields</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fields</span> <span class="o">=</span> <span class="p">[];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fI</span> <span class="k">in</span> <span class="nx">fullConfig</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">fullConfig</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">fI</span><span class="p">];</span>
<span class="nx">fields</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">f</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">config</span><span class="p">[</span><span class="nx">mI</span><span class="p">]</span> <span class="o">=</span> <span class="nx">fields</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">config</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">fieldConfigsFromContainers</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="p">{};</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">c</span><span class="p">.</span><span class="nx">form</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">fields</span> <span class="o">=</span> <span class="p">[];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">fI</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputConfigs</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">inputConfigs</span><span class="p">[</span><span class="nx">fI</span><span class="p">];</span>
<span class="nx">fields</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">f</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">config</span><span class="p">[</span><span class="nx">cI</span><span class="p">]</span> <span class="o">=</span> <span class="nx">fields</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">config</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">terminalConfigsFromModules</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">modules</span><span class="o">,</span> <span class="nx">getBaseConfig</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="p">{};</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">mI</span> <span class="k">in</span> <span class="nx">modules</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="nx">modules</span><span class="p">[</span><span class="nx">mI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">fullConfig</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">fullConfig</span><span class="o">,</span> <span class="nx">m</span><span class="p">.</span><span class="nx">config</span><span class="p">);</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">fullConfig</span><span class="o">,</span> <span class="nx">getBaseConfig</span><span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">name</span><span class="p">))</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">fullConfig</span><span class="p">.</span><span class="nx">terminals</span><span class="p">))</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">terminals</span> <span class="o">=</span> <span class="p">[];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">tI</span> <span class="k">in</span> <span class="nx">fullConfig</span><span class="p">.</span><span class="nx">terminals</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">fullConfig</span><span class="p">.</span><span class="nx">terminals</span><span class="p">[</span><span class="nx">tI</span><span class="p">];</span>
<span class="nx">terminals</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">t</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">config</span><span class="p">[</span><span class="nx">mI</span><span class="p">]</span> <span class="o">=</span> <span class="nx">terminals</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">config</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">getInternalModuleConfig</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">containers</span><span class="o">,</span> <span class="nx">center</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">modules</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">mConfig</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">getConfig</span><span class="p">();</span>
<span class="nx">mConfig</span><span class="p">.</span><span class="nx">position</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nx">mConfig</span><span class="p">.</span><span class="nx">position</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="nx">center</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="nx">mConfig</span><span class="p">.</span><span class="nx">position</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nx">mConfig</span><span class="p">.</span><span class="nx">position</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="nx">center</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="c">//Add container to group</span>
<span class="nx">modules</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span> <span class="p">{</span><span class="nx">name</span><span class="o">:</span> <span class="nx">c</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">title</span><span class="o">,</span> <span class="nx">value</span><span class="o">:</span> <span class="nx">c</span><span class="p">.</span><span class="nx">getValue</span><span class="p">()</span><span class="o">,</span> <span class="nx">config</span><span class="o">:</span> <span class="nx">mConfig</span><span class="p">});</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">modules</span><span class="o">;</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">getWireConfig</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">getInternalContainerId</span><span class="o">,</span> <span class="nx">getExternalTerminalName</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">externalWires</span> <span class="o">=</span> <span class="p">[];</span>
<span class="kd">var</span> <span class="nx">internalWires</span> <span class="o">=</span> <span class="p">[];</span>
<span class="k">this</span><span class="p">.</span><span class="nx">addWireConfig</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">getInternalContainerId</span><span class="o">,</span> <span class="nx">getExternalTerminalName</span><span class="o">,</span> <span class="nx">externalWires</span><span class="o">,</span> <span class="nx">internalWires</span><span class="p">);</span>
<span class="k">return</span> <span class="p">{</span><span class="s2">"external"</span> <span class="o">:</span> <span class="nx">externalWires</span><span class="o">,</span> <span class="s2">"internal"</span> <span class="o">:</span> <span class="nx">internalWires</span><span class="p">};</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">addWireConfig</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">group</span><span class="o">,</span> <span class="nx">getInternalContainerId</span><span class="o">,</span> <span class="nx">getExternalTerminalName</span><span class="o">,</span> <span class="nx">externalWires</span><span class="o">,</span> <span class="nx">internalWires</span><span class="o">,</span> <span class="nx">groupIndex</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">pushUniqueWireConfig</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">wires</span><span class="o">,</span> <span class="nx">newWire</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">foundWire</span><span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="kd">var</span> <span class="nx">wire</span><span class="o">;</span>
<span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">w</span> <span class="k">in</span> <span class="nx">wires</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">wire</span><span class="o">=</span> <span class="nx">wires</span><span class="p">[</span><span class="nx">w</span><span class="p">];</span>
<span class="k">if</span><span class="p">(</span> <span class="nx">wire</span><span class="p">.</span><span class="nx">src</span><span class="p">.</span><span class="nx">moduleId</span> <span class="o">==</span> <span class="nx">newWire</span><span class="p">.</span><span class="nx">src</span><span class="p">.</span><span class="nx">moduleId</span> <span class="o">&&</span>
<span class="nx">wire</span><span class="p">.</span><span class="nx">tgt</span><span class="p">.</span><span class="nx">moduleId</span> <span class="o">==</span> <span class="nx">newWire</span><span class="p">.</span><span class="nx">tgt</span><span class="p">.</span><span class="nx">moduleId</span> <span class="o">&&</span>
<span class="nx">wire</span><span class="p">.</span><span class="nx">src</span><span class="p">.</span><span class="nx">terminal</span> <span class="o">==</span> <span class="nx">newWire</span><span class="p">.</span><span class="nx">src</span><span class="p">.</span><span class="nx">terminal</span> <span class="o">&&</span>
<span class="nx">wire</span><span class="p">.</span><span class="nx">tgt</span><span class="p">.</span><span class="nx">terminal</span> <span class="o">==</span> <span class="nx">newWire</span><span class="p">.</span><span class="nx">tgt</span><span class="p">.</span><span class="nx">terminal</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">foundWire</span><span class="o">=</span><span class="kc">true</span><span class="o">;</span>
<span class="k">break</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">foundWire</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">wires</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">newWire</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="kd">var</span> <span class="nx">addWiresForContainer</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">c</span><span class="o">,</span> <span class="nx">getExternalName</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">wI</span> <span class="k">in</span> <span class="nx">c</span><span class="p">.</span><span class="nx">wires</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">c</span><span class="p">.</span><span class="nx">wires</span><span class="p">[</span><span class="nx">wI</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">srcIndex</span> <span class="o">=</span> <span class="nx">getInternalContainerId</span><span class="p">(</span><span class="nx">w</span><span class="p">.</span><span class="nx">terminal1</span><span class="p">.</span><span class="nx">container</span><span class="p">)</span>
<span class="kd">var</span> <span class="nx">tgtIndex</span> <span class="o">=</span> <span class="nx">getInternalContainerId</span><span class="p">(</span><span class="nx">w</span><span class="p">.</span><span class="nx">terminal2</span><span class="p">.</span><span class="nx">container</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">srcIndex</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span> <span class="o">&&</span> <span class="nx">tgtIndex</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">pushUniqueWireConfig</span><span class="p">(</span><span class="nx">internalWires</span><span class="o">,</span><span class="p">{</span>
<span class="nx">src</span><span class="o">:</span> <span class="p">{</span><span class="nx">moduleId</span><span class="o">:</span> <span class="nx">srcIndex</span><span class="o">,</span> <span class="nx">terminal</span><span class="o">:</span> <span class="nx">w</span><span class="p">.</span><span class="nx">terminal1</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span><span class="p">}</span><span class="o">,</span>
<span class="nx">tgt</span><span class="o">:</span> <span class="p">{</span><span class="nx">moduleId</span><span class="o">:</span> <span class="nx">tgtIndex</span><span class="o">,</span> <span class="nx">terminal</span><span class="o">:</span> <span class="nx">w</span><span class="p">.</span><span class="nx">terminal2</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span><span class="p">}</span>
<span class="p">});</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="p">{};</span>
<span class="kd">var</span> <span class="nx">et</span><span class="o">,</span> <span class="nx">gt</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">srcIndex</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">ret</span><span class="p">.</span><span class="nx">groupIsSource</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="nx">et</span> <span class="o">=</span> <span class="nx">w</span><span class="p">.</span><span class="nx">terminal1</span><span class="o">;</span>
<span class="nx">gt</span> <span class="o">=</span> <span class="nx">w</span><span class="p">.</span><span class="nx">terminal2</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="nx">ret</span><span class="p">.</span><span class="nx">groupIsSource</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="nx">et</span> <span class="o">=</span> <span class="nx">w</span><span class="p">.</span><span class="nx">terminal2</span>
<span class="nx">gt</span> <span class="o">=</span> <span class="nx">w</span><span class="p">.</span><span class="nx">terminal1</span><span class="o">;</span>
<span class="p">}</span>
<span class="nx">ret</span><span class="p">.</span><span class="nx">externalName</span> <span class="o">=</span> <span class="nx">getExternalName</span><span class="p">(</span><span class="nx">gt</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span><span class="p">);</span>
<span class="nx">ret</span><span class="p">.</span><span class="nx">groupTerminal</span> <span class="o">=</span> <span class="nx">gt</span><span class="o">;</span>
<span class="nx">ret</span><span class="p">.</span><span class="nx">externalTerminal</span> <span class="o">=</span> <span class="nx">et</span><span class="o">;</span>
<span class="nx">externalWires</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ret</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">groupIndex</span><span class="p">))</span>
<span class="nx">groupIndex</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="p">))</span>
<span class="p">{</span>
<span class="nx">addWiresForContainer</span><span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">groupContainer</span><span class="o">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">getExternalTerminalName</span><span class="p">(</span><span class="s2">"group"</span><span class="o">,</span> <span class="nx">groupIndex</span><span class="o">,</span> <span class="nx">name</span><span class="p">);</span> <span class="p">});</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">cI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">containers</span><span class="p">[</span><span class="nx">cI</span><span class="p">].</span><span class="nx">container</span><span class="o">;</span>
<span class="nx">addWiresForContainer</span><span class="p">(</span><span class="nx">c</span><span class="o">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">getExternalTerminalName</span><span class="p">(</span><span class="s2">"container"</span><span class="o">,</span> <span class="nx">cI</span><span class="o">,</span> <span class="nx">name</span><span class="p">);</span> <span class="p">});</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">gI</span> <span class="k">in</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">gI</span><span class="p">].</span><span class="nx">group</span><span class="o">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">addWireConfig</span><span class="p">(</span><span class="nx">g</span><span class="o">,</span> <span class="nx">getInternalContainerId</span><span class="o">,</span> <span class="nx">getExternalTerminalName</span><span class="o">,</span> <span class="nx">externalWires</span><span class="o">,</span> <span class="nx">internalWires</span><span class="o">,</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">gI</span><span class="p">)</span><span class="o">+</span><span class="nx">groupIndex</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="nx">firstTestSucess</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">anarray</span><span class="o">,</span> <span class="nx">atest</span><span class="p">)</span>
<span class="p">{</span>
<span class="kd">var</span> <span class="nx">index</span><span class="o">;</span>
<span class="k">for</span> <span class="p">(</span><span class="nx">index</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="nx">index</span> <span class="o"><</span> <span class="nx">anarray</span><span class="p">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">index</span><span class="o">++</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">atest</span><span class="p">(</span><span class="nx">anarray</span><span class="p">[</span><span class="nx">index</span><span class="p">]))</span>
<span class="k">return</span> <span class="nx">index</span><span class="o">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">})();</span>
</pre></div>
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div id="moduleList" class="module">
<h4>Modules</h4>
<ul class="content">
<li class=""><a href="module_animations-plugin.html" title="animations-plugin">animations-plugin</a></li>
<li class=""><a href="module_composable-plugin.html" title="composable-plugin">composable-plugin</a></li>
<li class="selected"><a href="module_editor-plugin.html" title="editor-plugin">editor-plugin</a></li>
<li class=""><a href="module_inputex-plugin.html" title="inputex-plugin">inputex-plugin</a></li>
<li class=""><a href="module_layout-plugin.html" title="layout-plugin">layout-plugin</a></li>
<li class=""><a href="module_wireit.html" title="WireIt">WireIt</a></li>
</ul>
</div>
<div id="classList" class="module">
<h4>Classes</h4>
<ul class="content">
<li class=""><a href="WireIt.BaseEditor.html" title="WireIt.BaseEditor">WireIt.BaseEditor</a></li>
<li class=""><a href="WireIt.FormContainer.html" title="WireIt.FormContainer">WireIt.FormContainer</a></li>
<li class=""><a href="WireIt.Group.html" title="WireIt.Group">WireIt.Group</a></li>
<li class=""><a href="WireIt.Grouper.html" title="WireIt.Grouper">WireIt.Grouper</a></li>
<li class=""><a href="WireIt.GroupUtils.html" title="WireIt.GroupUtils">WireIt.GroupUtils</a></li>
<li class=""><a href="WireIt.ModuleProxy.html" title="WireIt.ModuleProxy">WireIt.ModuleProxy</a></li>
<li class=""><a href="WireIt.RubberBand.html" title="WireIt.RubberBand">WireIt.RubberBand</a></li>
<li class=""><a href="WireIt.WiringEditor.html" title="WireIt.WiringEditor">WireIt.WiringEditor</a></li>
<li class=""><a href="WireIt.WiringEditor.adapters.Ajax.html" title="WireIt.WiringEditor.adapters.Ajax">WireIt.WiringEditor.adapters.Ajax</a></li>
<li class=""><a href="WireIt.WiringEditor.adapters.Gears.html" title="WireIt.WiringEditor.adapters.Gears">WireIt.WiringEditor.adapters.Gears</a></li>
<li class=""><a href="WireIt.WiringEditor.adapters.JsonRpc.html" title="WireIt.WiringEditor.adapters.JsonRpc">WireIt.WiringEditor.adapters.JsonRpc</a></li>
</ul>
</div>
<div id="fileList" class="module">
<h4>Files</h4>
<ul class="content">
<li class=""><a href="ajax.js.html" title="ajax.js">ajax.js</a></li>
<li class=""><a href="FormContainer.js.html" title="FormContainer.js">FormContainer.js</a></li>
<li class=""><a href="gears.js.html" title="gears.js">gears.js</a></li>
<li class=""><a href="Group.js.html" title="Group.js">Group.js</a></li>
<li class=""><a href="Grouper.js.html" title="Grouper.js">Grouper.js</a></li>
<li class=""><a href="GroupFormContainer.js.html" title="GroupFormContainer.js">GroupFormContainer.js</a></li>
<li class="selected"><a href="GroupUtils.js.html" title="GroupUtils.js">GroupUtils.js</a></li>
<li class=""><a href="json-rpc.js.html" title="json-rpc.js">json-rpc.js</a></li>
<li class=""><a href="ModuleProxy.js.html" title="ModuleProxy.js">ModuleProxy.js</a></li>
<li class=""><a href="rest-json.js.html" title="rest-json.js">rest-json.js</a></li>
<li class=""><a href="RubberBand.js.html" title="RubberBand.js">RubberBand.js</a></li>
<li class=""><a href="WiringEditor.js.html" title="WiringEditor.js">WiringEditor.js</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright © 2010 Eric Abouaf All rights reserved.
</div>
</div>
<script type="text/javascript">
var ALL_YUI_PROPS = [{"url": "WireIt.WiringEditor.html#property_adapters", "access": "", "host": "WireIt.WiringEditor", "type": "property", "name": "adapters"}, {"url": "WireIt.GroupUtils.html#method_addAllContainers", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "addAllContainers"}, {"url": "WireIt.Grouper.html#method_addContainer", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "addContainer"}, {"url": "WireIt.Grouper.html#method_addGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "addGroup"}, {"url": "WireIt.WiringEditor.html#method_addModule", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "addModule"}, {"url": "WireIt.WiringEditor.html#method_addModuleToList", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "addModuleToList"}, {"url": "WireIt.BaseEditor.html#method_alert", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "alert"}, {"url": "WireIt.BaseEditor.html#property_alertPanel", "access": "", "host": "WireIt.BaseEditor", "type": "property", "name": "alertPanel"}, {"url": "WireIt.GroupUtils.html#method_applyToContainers", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "applyToContainers"}, {"url": "WireIt.WiringEditor.html#method_buildModulesList", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "buildModulesList"}, {"url": "WireIt.WiringEditor.html#method_checkAutoLoad", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "checkAutoLoad"}, {"url": "WireIt.FormContainer.html#property_collapsible", "access": "", "host": "WireIt.FormContainer", "type": "property", "name": "collapsible"}, {"url": "WireIt.WiringEditor.adapters.Ajax.html#property_config", "access": "", "host": "WireIt.WiringEditor.adapters.Ajax", "type": "property", "name": "config"}, {"url": "WireIt.RubberBand.html#property_defaultDelay", "access": "", "host": "WireIt.RubberBand", "type": "property", "name": "defaultDelay"}, {"url": "WireIt.BaseEditor.html#property_defaultOptions", "access": "", "host": "WireIt.BaseEditor", "type": "property", "name": "defaultOptions"}, {"url": "WireIt.WiringEditor.adapters.Ajax.html#method_deleteWiring", "access": "", "host": "WireIt.WiringEditor.adapters.Ajax", "type": "method", "name": "deleteWiring"}, {"url": "WireIt.Grouper.html#method_deselectGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "deselectGroup"}, {"url": "WireIt.BaseEditor.html#property_el", "access": "", "host": "WireIt.BaseEditor", "type": "property", "name": "el"}, {"url": "WireIt.ModuleProxy.html#method_endDrag", "access": "", "host": "WireIt.ModuleProxy", "type": "method", "name": "endDrag"}, {"url": "WireIt.FormContainer.html#property_fields", "access": "", "host": "WireIt.FormContainer", "type": "property", "name": "fields"}, {"url": "WireIt.RubberBand.html#method_finish", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "finish"}, {"url": "WireIt.GroupUtils.html#method_getCollapsedConfig", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "getCollapsedConfig"}, {"url": "WireIt.Grouper.html#method_getContainerCorners", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "getContainerCorners"}, {"url": "WireIt.GroupUtils.html#method_getOuterGroup", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "getOuterGroup"}, {"url": "WireIt.GroupUtils.html#method_getOverridesFromUI", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "getOverridesFromUI"}, {"url": "WireIt.WiringEditor.html#method_getPipeByName", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "getPipeByName"}, {"url": "WireIt.WiringEditor.html#method_getValue", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "getValue"}, {"url": "WireIt.FormContainer.html#method_getValue", "access": "", "host": "WireIt.FormContainer", "type": "method", "name": "getValue"}, {"url": "WireIt.Grouper.html#method_groupCollapse", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "groupCollapse"}, {"url": "WireIt.BaseEditor.html#property_helpPanel", "access": "", "host": "WireIt.BaseEditor", "type": "property", "name": "helpPanel"}, {"url": "WireIt.RubberBand.html#method_hide", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "hide"}, {"url": "WireIt.Grouper.html#method_hideGroupConfigure", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "hideGroupConfigure"}, {"url": "WireIt.WiringEditor.adapters.Ajax.html#method_init", "access": "", "host": "WireIt.WiringEditor.adapters.Ajax", "type": "method", "name": "init"}, {"url": "WireIt.WiringEditor.html#method_inputFilterTimer", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "inputFilterTimer"}, {"url": "WireIt.BaseEditor.html#method_isSaved", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "isSaved"}, {"url": "WireIt.WiringEditor.html#property_layer", "access": "", "host": "WireIt.WiringEditor", "type": "property", "name": "layer"}, {"url": "WireIt.RubberBand.html#method_layerMouseDown", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "layerMouseDown"}, {"url": "WireIt.BaseEditor.html#property_layout", "access": "", "host": "WireIt.BaseEditor", "type": "property", "name": "layout"}, {"url": "WireIt.FormContainer.html#property_legend", "access": "", "host": "WireIt.FormContainer", "type": "property", "name": "legend"}, {"url": "WireIt.WiringEditor.adapters.Ajax.html#method_listWirings", "access": "", "host": "WireIt.WiringEditor.adapters.Ajax", "type": "method", "name": "listWirings"}, {"url": "WireIt.WiringEditor.html#method_load", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "load"}, {"url": "WireIt.WiringEditor.html#method_loadPipe", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "loadPipe"}, {"url": "WireIt.Grouper.html#method_makeGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "makeGroup"}, {"url": "WireIt.BaseEditor.html#method_markSaved", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "markSaved"}, {"url": "WireIt.BaseEditor.html#method_markUnsaved", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "markUnsaved"}, {"url": "WireIt.WiringEditor.html#property_modulesByName", "access": "", "host": "WireIt.WiringEditor", "type": "property", "name": "modulesByName"}, {"url": "WireIt.RubberBand.html#method_nextPoint", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "nextPoint"}, {"url": "WireIt.WiringEditor.html#method_onDelete", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "onDelete"}, {"url": "WireIt.ModuleProxy.html#method_onDragDrop", "access": "", "host": "WireIt.ModuleProxy", "type": "method", "name": "onDragDrop"}, {"url": "WireIt.BaseEditor.html#method_onHelp", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "onHelp"}, {"url": "WireIt.WiringEditor.html#method_onLoadSuccess", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "onLoadSuccess"}, {"url": "WireIt.WiringEditor.html#method_onNew", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "onNew"}, {"url": "WireIt.BaseEditor.html#method_onSave", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "onSave"}, {"url": "WireIt.BaseEditor.html#property_options", "access": "", "host": "WireIt.BaseEditor", "type": "property", "name": "options"}, {"url": "WireIt.RubberBand.html#method_pointIsInside", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "pointIsInside"}, {"url": "WireIt.Grouper.html#method_removeContainer", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "removeContainer"}, {"url": "WireIt.Grouper.html#method_removeGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "removeGroup"}, {"url": "WireIt.GroupUtils.html#method_removeGroupFromLayer", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "removeGroupFromLayer"}, {"url": "WireIt.BaseEditor.html#method_render", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "render"}, {"url": "WireIt.WiringEditor.html#method_render", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "render"}, {"url": "WireIt.FormContainer.html#method_render", "access": "", "host": "WireIt.FormContainer", "type": "method", "name": "render"}, {"url": "WireIt.BaseEditor.html#method_renderAlertPanel", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "renderAlertPanel"}, {"url": "WireIt.BaseEditor.html#method_renderButtons", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "renderButtons"}, {"url": "WireIt.FormContainer.html#method_renderForm", "access": "", "host": "WireIt.FormContainer", "type": "method", "name": "renderForm"}, {"url": "WireIt.BaseEditor.html#method_renderHelpPanel", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "renderHelpPanel"}, {"url": "WireIt.WiringEditor.html#method_renderLoadPanel", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "renderLoadPanel"}, {"url": "WireIt.WiringEditor.html#method_renderModulesAccordion", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "renderModulesAccordion"}, {"url": "WireIt.BaseEditor.html#method_renderPropertiesAccordion", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "renderPropertiesAccordion"}, {"url": "WireIt.BaseEditor.html#method_renderPropertiesForm", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "renderPropertiesForm"}, {"url": "WireIt.BaseEditor.html#method_renderSavedStatus", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "renderSavedStatus"}, {"url": "WireIt.WiringEditor.adapters.JsonRpc.html#property_RestJSON", "access": "", "host": "WireIt.WiringEditor.adapters.JsonRpc", "type": "property", "name": "RestJSON"}, {"url": "WireIt.Grouper.html#method_rubberbandSelect", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "rubberbandSelect"}, {"url": "WireIt.BaseEditor.html#method_save", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "save"}, {"url": "WireIt.WiringEditor.html#method_save", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "save"}, {"url": "WireIt.WiringEditor.html#method_saveModuleFailure", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "saveModuleFailure"}, {"url": "WireIt.WiringEditor.html#method_saveModuleSuccess", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "saveModuleSuccess"}, {"url": "WireIt.WiringEditor.adapters.Ajax.html#method_saveWiring", "access": "", "host": "WireIt.WiringEditor.adapters.Ajax", "type": "method", "name": "saveWiring"}, {"url": "WireIt.RubberBand.html#method_scroll", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "scroll"}, {"url": "WireIt.Grouper.html#method_selectGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "selectGroup"}, {"url": "WireIt.WiringEditor.adapters.Ajax.html#method__sendRequest", "access": "", "host": "WireIt.WiringEditor.adapters.Ajax", "type": "method", "name": "_sendRequest"}, {"url": "WireIt.GroupUtils.html#method_serialiseGroup", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "serialiseGroup"}, {"url": "WireIt.Grouper.html#method_setDisplay", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "setDisplay"}, {"url": "WireIt.Grouper.html#method_setGroupOptions", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "setGroupOptions"}, {"url": "WireIt.BaseEditor.html#method_setOptions", "access": "", "host": "WireIt.BaseEditor", "type": "method", "name": "setOptions"}, {"url": "WireIt.WiringEditor.html#method_setOptions", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "setOptions"}, {"url": "WireIt.FormContainer.html#method_setOptions", "access": "", "host": "WireIt.FormContainer", "type": "method", "name": "setOptions"}, {"url": "WireIt.Grouper.html#method_setSelectedGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "setSelectedGroup"}, {"url": "WireIt.Grouper.html#method_setupSelectedGroups", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "setupSelectedGroups"}, {"url": "WireIt.Grouper.html#method_setupWidget", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "setupWidget"}, {"url": "WireIt.FormContainer.html#method_setValue", "access": "", "host": "WireIt.FormContainer", "type": "method", "name": "setValue"}, {"url": "WireIt.RubberBand.html#method_show", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "show"}, {"url": "WireIt.Grouper.html#method_showGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "showGroup"}, {"url": "WireIt.Grouper.html#method_showGroupConfigure", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "showGroupConfigure"}, {"url": "WireIt.RubberBand.html#method_start", "access": "", "host": "WireIt.RubberBand", "type": "method", "name": "start"}, {"url": "WireIt.ModuleProxy.html#method_startDrag", "access": "", "host": "WireIt.ModuleProxy", "type": "method", "name": "startDrag"}, {"url": "WireIt.Grouper.html#method_toggle", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "toggle"}, {"url": "WireIt.Grouper.html#method_unGroup", "access": "", "host": "WireIt.Grouper", "type": "method", "name": "unGroup"}, {"url": "WireIt.WiringEditor.html#method_updateLoadPanelList", "access": "", "host": "WireIt.WiringEditor", "type": "method", "name": "updateLoadPanelList"}, {"url": "WireIt.GroupUtils.html#method_valueOr", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "valueOr"}, {"url": "WireIt.GroupUtils.html#method_workOutCenter", "access": "", "host": "WireIt.GroupUtils", "type": "method", "name": "workOutCenter"}, {"url": "WireIt.FormContainer.html#property_xtype", "access": "", "host": "WireIt.FormContainer", "type": "property", "name": "xtype"}];
</script>
</body>
</html>