Instead of saving authName in the mkws structure, publish it to the
[mkws-moved-to-github.git] / src / mkws-team.js
index 7c4b6b9..872f957 100644 (file)
@@ -28,6 +28,7 @@ function team($, teamName) {
     var m_paz; // will be initialised below
     var m_template = {};
 
+    that.toString = function() { return '[Team ' + teamName + ']'; }
 
     // Accessor methods for individual widgets: readers
     that.name = function() { return m_teamName; }
@@ -76,34 +77,28 @@ function team($, teamName) {
                    });
 
 
-    //
     // pz2.js event handlers:
-    //
     function onInit() {
        log("init");
        m_paz.stat();
        m_paz.bytarget();
     }
 
-
     function onBytarget(data) {
        log("target");
        queue("targets").publish(data);
     }
 
-
     function onStat(data) {
        log("stat");
        queue("stat").publish(data);
     }
 
-
     function onTerm(data) {
        log("term");
        queue("termlists").publish(data);
     }
 
-
     function onShow(data, teamName) {
        log("show");
        m_totalRecordCount = data.merged;
@@ -111,14 +106,12 @@ function team($, teamName) {
        queue("records").publish(data);
     }
 
-
     function onRecord(data, args, teamName) {
        log("record");
        // FIXME: record is async!!
        clearTimeout(m_paz.recordTimer);
-       // ##### restrict to current team
-       var detRecordDiv = document.getElementById(recordDetailsId(data.recid[0]));
-       if (detRecordDiv) {
+       var detRecordDiv = findnode(recordDetailsId(data.recid[0]));
+       if (detRecordDiv.length) {
            // in case on_show was faster to redraw element
            return;
        }
@@ -129,7 +122,7 @@ function team($, teamName) {
     }
 
 
-    // Used by promoteRecords() and onRecord()
+    // Used by the Records widget and onRecord()
     function recordElementId(s) {
        return 'mkwsRec_' + s.replace(/[^a-z0-9]/ig, '_');
     }
@@ -139,7 +132,6 @@ function team($, teamName) {
     function recordDetailsId(s) {
        return 'mkwsDet_' + s.replace(/[^a-z0-9]/ig, '_');
     }
-    that.recordElementId = recordElementId;
 
 
     that.targetFiltered = function(id) {
@@ -632,7 +624,9 @@ function team($, teamName) {
            return s + '.mkwsTeam_' + teamName;
        }).join(',');
 
-       return $(selector);
+       var node = $(selector);
+       //log('findnode(' + selector + ') found ' + node.length + ' nodes');
+       return node;
     }
 
 
@@ -773,20 +767,7 @@ function team($, teamName) {
     }
     that.queue = queue;
 
+    mkwsHtmlAll()
 
-    // main
-    (function() {
-       try {
-           mkwsHtmlAll()
-       }
-
-       catch (e) {
-           mkws_config.error = e.message;
-           // alert(e.message);
-       }
-    })();
-
-    // Bizarrely, 'that' is just an empty hash. All its state is in
-    // the closure variables defined earlier in this function.
     return that;
 };