Final changes to logging text (for now, anyway)
[mkws-moved-to-github.git] / src / mkws-widget-main.js
index 8c1fd97..55d628d 100644 (file)
@@ -4,11 +4,12 @@
 
 
 mkws.registerWidgetType('Targets', function() {
+  if (!this.config.show_switch) return;
   var that = this;
   var M = mkws.M;
 
-  $(this.node).html('No information available yet.');
-  $(this.node).css("display", "none");
+  this.jqnode.html('No information available yet.');
+  this.jqnode.css("display", "none");
 
   this.team.queue("targets").subscribe(function(data) {
     var table ='<table><thead><tr>' +
@@ -28,7 +29,7 @@ mkws.registerWidgetType('Targets', function() {
     }
 
     table += '</tbody></table>';
-    $(that.node).html(table);
+    that.jqnode.html(table);
   });
 });
 
@@ -38,13 +39,10 @@ mkws.registerWidgetType('Stat', function() {
   var M = mkws.M;
 
   this.team.queue("stat").subscribe(function(data) {
-    if (that.node.length === 0)  alert("huh?!");
-
-    $(that.node).html('<span class="head">' + M('Status info') + '</span>' +
-                      ' -- ' +
-                      '<span class="clients">' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '</span>' +
+    that.jqnode.html(' -- ' +
+                      '<span class="mkwsClientCount">' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '</span>' +
                       ' -- ' +
-                      '<span class="records">' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + '</span>');
+                      M('Retrieved records') + ': ' + data.records + '/' + data.hits);
   });
 });
 
@@ -54,7 +52,7 @@ mkws.registerWidgetType('Pager', function() {
   var M = mkws.M;
 
   this.team.queue("pager").subscribe(function(data) {
-    $(that.node).html(drawPager(data))
+    that.jqnode.html(drawPager(data))
 
     function drawPager(data) {
       var teamName = that.team.name();
@@ -123,7 +121,7 @@ mkws.registerWidgetType('Records', function() {
       var hit = data.hits[i];
       that.team.queue("record").publish(hit);
       var divId = team.recordElementId(hit.recid[0]);
-      html.push('<div class="record mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
+      html.push('<div class="mkwsSummary mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
       // ### At some point, we may be able to move the
       // m_currentRecordId and m_currentRecordData members
       // from the team object into this widget.
@@ -132,7 +130,7 @@ mkws.registerWidgetType('Records', function() {
           html.push(team.renderDetails(team.currentRecordData()));
       }
     }
-    $(that.node).html(html.join(''));
+    that.jqnode.html(html.join(''));
 
     function renderSummary(hit) {
       var template = team.loadTemplate(that.config.template || "Summary");
@@ -168,7 +166,7 @@ mkws.registerWidgetType('Navi', function() {
         ');return false;">' + value + '</a>';
     });
 
-    $(that.node).html(text);
+    that.jqnode.html(text);
   });
 });
 
@@ -179,8 +177,8 @@ mkws.registerWidgetType('Navi', function() {
 mkws.registerWidgetType('Sort', function() {
   var that = this;
 
-  $(this.node).change(function() {
-    that.team.set_sortOrder($(that.node).val());
+  this.jqnode.change(function() {
+    that.team.set_sortOrder(that.jqnode.val());
     if (that.team.submitted()) {
       that.team.reShow();
     }
@@ -192,8 +190,8 @@ mkws.registerWidgetType('Sort', function() {
 mkws.registerWidgetType('Perpage', function() {
   var that = this;
 
-  $(this.node).change(function() {
-    that.team.set_perpage($(that.node).val());
+  this.jqnode.change(function() {
+    that.team.set_perpage(that.jqnode.val());
     if (that.team.submitted()) {
       that.team.reShow();
     }
@@ -206,14 +204,15 @@ mkws.registerWidgetType('Done', function() {
   var that = this;
 
   this.team.queue("complete").subscribe(function(n) {
-    $(that.node).html("Search complete: found " + n + " records");
+    that.jqnode.html("Search complete: found " + n + " records");
   });
 });
 
 
 mkws.registerWidgetType('Switch', function() {
+  if (!this.config.show_switch) return;
   var tname = this.team.name();
-  $(this.node).html('\
+  this.jqnode.html('\
 <a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
 | \
 </span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
@@ -225,7 +224,7 @@ mkws.registerWidgetType('Search', function() {
   var tname = this.team.name();
   var M = mkws.M;
 
-  $(this.node).html('\
+  this.jqnode.html('\
 <form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
   <input class="mkwsQuery mkwsTeam_' + tname + '" type="text" size="' + this.config.query_width + '" />\
   <input class="mkwsButton mkwsTeam_' + tname + '" type="submit" value="' + M('Search') + '" />\
@@ -235,7 +234,7 @@ mkws.registerWidgetType('Search', function() {
 
 mkws.registerWidgetType('SearchForm', function() {
   var team = this.team;
-  $(this.node).submit(function() {
+  this.jqnode.submit(function() {
     var val = team.widget('Query').value();
     team.newSearch(val);
     return false;
@@ -246,7 +245,7 @@ mkws.registerWidgetType('SearchForm', function() {
 mkws.registerWidgetType('Results', function() {
   var tname = this.team.name();
 
-  $(this.node).html('\
+  this.jqnode.html('\
 <table width="100%" border="0" cellpadding="6" cellspacing="0">\
   <tr>\
     <td class="mkwsTermlists-Container-wide mkwsTeam_' + tname + '" width="250" valign="top">\
@@ -284,13 +283,13 @@ mkws.registerWidgetType('Ranking', function() {
   }
   s += '</form>';
 
-  $(this.node).html(s);
+  this.jqnode.html(s);
 
 
   function mkwsHtmlSort() {
     var order = that.team.sortOrder();
 
-    that.log("HTML sort, sortOrder = '" + order + "'");
+    that.log("making sort HTML, sortOrder = '" + order + "'");
     var sort_html = '<select class="mkwsSort mkwsTeam_' + tname + '">';
 
     for(var i = 0; i < that.config.sort_options.length; i++) {
@@ -312,7 +311,7 @@ mkws.registerWidgetType('Ranking', function() {
   function mkwsHtmlPerpage() {
     var perpage = that.team.perpage();
 
-    that.log("HTML perpage, perpage = " + perpage);
+    that.log("making perpage HTML, perpage = " + perpage);
     var perpage_html = '<select class="mkwsPerpage mkwsTeam_' + tname + '">';
 
     for(var i = 0; i < that.config.perpage_options.length; i++) {
@@ -356,7 +355,7 @@ mkws.registerWidgetType('Lang', function() {
   if (lang_options.length == 0 || toBeIncluded[lang_default])
     list.push(lang_default);
 
-  this.log("Language menu for: " + list.join(", "));
+  this.log("language menu: " + list.join(", "));
 
   /* the HTML part */
   var data = "";
@@ -372,7 +371,7 @@ mkws.registerWidgetType('Lang', function() {
     }
   }
 
-  $(this.node).html(data);
+  this.jqnode.html(data);
   widget.hideWhenNarrow(this);
 
 
@@ -401,7 +400,7 @@ mkws.registerWidgetType('MOTD', function() {
   var container = this.team.widget('MOTDContainer');
   if (container) {
     // Move the MOTD from the provided element down into the container
-    $(this.node).appendTo(container.node);
+    this.jqnode.appendTo(container.node); // #### can this be container.jqnode
   }
 });