New widgets Search and SearchForm.
[mkws-moved-to-github.git] / src / mkws-team.js
index a76c65c..d0ebcc5 100644 (file)
@@ -26,7 +26,8 @@ function team($, teamName) {
        "last": $.now()
     };
     var m_paz; // will be initialised below
-    var m_template = {};
+    var m_tempateText = {}; // widgets can register tempates to be compiled
+    var m_template = {}; // compiled templates, from any source
     var m_config = mkws.objectInheritingFrom(mkws.config);
     var m_widgets = {}; // Maps widget-type to object
 
@@ -411,8 +412,6 @@ function team($, teamName) {
         ranking_data += '</form>';
        findnode(".mkwsRanking").html(ranking_data);
 
-       mkwsHtmlSwitch();
-
        findnode('.mkwsSearchForm').submit(function() {
            var val = widgetNode('Query').val();
            newSearch(val);
@@ -548,24 +547,6 @@ function team($, teamName) {
     }
 
 
-    function mkwsHtmlSwitch() {
-       log("HTML switch for team " + m_teamName);
-
-       var node = findnode(".mkwsSwitch");
-       node.append($('<a href="#" onclick="mkws.switchView(\'' + m_teamName + '\', \'records\')">' + M('Records') + '</a>'));
-       node.append($("<span/>", { text: " | " }));
-       node.append($('<a href="#" onclick="mkws.switchView(\'' + m_teamName + '\', \'targets\')">' + M('Targets') + '</a>'));
-
-       log("HTML targets");
-       var node = findnode(".mkwsTargets");
-       node.html('\
-<div class="mkwsBytarget mkwsTeam_' + m_teamName + '">\
-  No information available yet.\
-</div>');
-       node.css("display", "none");
-    }
-
-
     // Translation function. At present, this is properly a
     // global-level function (hence the assignment to mkws.M) but we
     // want to make it per-team so different teams can operate in
@@ -616,6 +597,11 @@ function team($, teamName) {
     that.renderDetails = renderDetails;
 
 
+    that.registerTemplate = function(name, text) {
+        m_tempateText[name] = text;
+    };
+
+
     function loadTemplate(name) {
        var template = m_template[name];
 
@@ -631,6 +617,9 @@ function team($, teamName) {
             }
 
            if (!source) {
+                source = m_tempateText[name];
+            }
+           if (!source) {
                source = defaultTemplate(name);
            }