Much better encapsulation for mkws.showDetails().
authorMike Taylor <mike@indexdata.com>
Thu, 30 Jan 2014 11:35:23 +0000 (11:35 +0000)
committerMike Taylor <mike@indexdata.com>
Thu, 30 Jan 2014 11:35:23 +0000 (11:35 +0000)
This is now a single-line function that invokes the same-named
member function on the appropriate team object. That member
function now does all the actual work, and can access member
variables without explicit leading "team.". We no longer need
the encapsulation-violation team.m_paz reference.

tools/htdocs/mkws.js

index 98fc11c..d4e8166 100644 (file)
@@ -230,7 +230,6 @@ function _make_mkws_team($, teamName) {
                      "usesessions" : mkws_config.use_service_proxy ? false : true,
                      "showResponseType": '', // or "json" (for debugging?)
                      "onrecord": my_onrecord });
-    that.m_paz = m_paz; // For access from non-member functions like mkws.showDetails
 
     if (!isNaN(parseInt(mkws_config.perpage_default))) {
        m_recPerPage = parseInt(mkws_config.perpage_default);
@@ -730,7 +729,7 @@ function _make_mkws_team($, teamName) {
 
 
     // detailed record drawing
-    mkws.showDetails = function (prefixRecId, tname) {
+    that.showDetails = function (prefixRecId) {
        var recId = prefixRecId.replace('mkwsRec_', '');
        var oldRecId = m_curDetRecId;
        m_curDetRecId = recId;
@@ -748,9 +747,7 @@ function _make_mkws_team($, teamName) {
             return;
        }
        // request the record
-       var team = mkws.teams[tname];
-       if (!team) alert("no team '" + tname + "'");
-       team.m_paz.record(recId);
+       m_paz.record(recId);
     }
 
 
@@ -1351,6 +1348,11 @@ function _mkws_jquery_plugin ($) {
     }
 
 
+    mkws.showDetails = function (prefixRecId, tname) {
+       mkws.teams[tname].showDetails(prefixRecId);
+    }
+
+
     function default_mkws_config() {
        /* default mkws config */
        var config_default = {