Widget-promotion switch is now driven by a table.
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index b3cd04a..b6f0e0e 100644 (file)
@@ -158,21 +158,22 @@ function widget($, team, type, node) {
 
     var M = mkws.M;
 
-    if (type === 'Targets') {
-       promoteTargets();
-    } else if (type === 'Stat') {
-       promoteStat();
-    } else if (type === 'Termlists') {
-       promoteTermlists();
-    } else if (type === 'Pager') {
-       promotePager();
-    } else if (type === 'Records') {
-       promoteRecords();
+    var type2fn = {
+       Targets: promoteTargets,
+       Stat: promoteStat,
+       Termlists: promoteTermlists,
+       Pager: promotePager,
+       Records: promoteRecords
+    };
+
+    var promote = type2fn[type];
+    if (promote) {
+       promote();
+       team.debug("made " + type + " widget(node=" + node + ")");
     } else {
-       // ### Handle other types here
+       team.debug("made UNENCAPSULATED widget(type=" + type + ", node=" + node + ")");
     }
 
-    team.debug("made widget(type=" + type + ", node=" + node);
     return that;
 
 
@@ -355,7 +356,7 @@ function widget($, team, type, node) {
                // from the team object into this widget.
                if (hit.recid == team.currentRecordId()) {
                    if (team.currentRecordData())
-                       html.push(renderDetails(team.currentRecordData()));
+                       html.push(team.renderDetails(team.currentRecordData()));
                }
            }
            $(node).html(html.join(''));
@@ -1069,6 +1070,7 @@ function team($, teamName) {
        var details = template(data);
        return '<div class="details" id="mkwsDet_' + m_teamName + '_' + data.recid + '">' + details + '</div>';
     }
+    that.renderDetails = renderDetails;
 
 
     function loadTemplate(name)