X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=5951c1c140c802f98a2c9d64e2969baf182ae93a;hb=c302068454a4f0a77574eae189b582a01138e763;hp=41201dd87c711660cf37aa3d6e0aeb33dcaa7f0c;hpb=d2b83a91581809fa14754b891a074f102f9f3400;p=mkws-moved-to-github.git
diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js
index 41201dd..5951c1c 100644
--- a/src/mkws-widget-main.js
+++ b/src/mkws-widget-main.js
@@ -4,14 +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.node.html('No information available yet.');
+ this.node.css("display", "none");
this.team.queue("targets").subscribe(function(data) {
var table ='' +
@@ -24,15 +22,14 @@ No information available yet.\
for (var i = 0; i < data.length; i++) {
table += "
" + data[i].id +
- " | " + data[i].hits +
- " | " + data[i].diagnostic +
- " | " + data[i].records +
- " | " + data[i].state + " |
";
+ "" + data[i].hits +
+ " | " + data[i].diagnostic +
+ " | " + data[i].records +
+ " | " + data[i].state + " | ";
}
table += '
';
- var subnode = $(that.node).children('.mkwsBytarget');
- subnode.html(table);
+ that.node.html(table);
});
});
@@ -42,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('' + M('Status info') + '' +
- ' -- ' +
- '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '' +
- ' -- ' +
- '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + '');
+ that.node.html(' -- ' +
+ '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '' +
+ ' -- ' +
+ M('Retrieved records') + ': ' + data.records + '/' + data.hits);
});
});
@@ -58,14 +52,14 @@ mkws.registerWidgetType('Pager', function() {
var M = mkws.M;
this.team.queue("pager").subscribe(function(data) {
- $(that.node).html(drawPager(data))
+ that.node.html(drawPager(data))
function drawPager(data) {
var teamName = that.team.name();
var s = '' + M('Displaying') + ': '
- + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) +
- ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': '
- + data.total + ')
';
+ + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) +
+ ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': '
+ + data.total + ')';
//client indexes pages from 1 but pz2 from 0
var onsides = 6;
@@ -73,43 +67,43 @@ mkws.registerWidgetType('Pager', function() {
var currentPage = that.team.currentPage();
var firstClkbl = (currentPage - onsides > 0)
- ? currentPage - onsides
- : 1;
+ ? currentPage - onsides
+ : 1;
var lastClkbl = firstClkbl + 2*onsides < pages
- ? firstClkbl + 2*onsides
- : pages;
+ ? firstClkbl + 2*onsides
+ : pages;
var prev = '<< ' + M('Prev') + ' | ';
if (currentPage > 1)
- prev = ''
- +'<< ' + M('Prev') + ' | ';
+ prev = ''
+ +'<< ' + M('Prev') + ' | ';
var middle = '';
for(var i = firstClkbl; i <= lastClkbl; i++) {
- var numLabel = i;
- if(i == currentPage)
- numLabel = '' + i + '';
+ var numLabel = i;
+ if(i == currentPage)
+ numLabel = '' + i + '';
- middle += ' '
- + numLabel + ' ';
+ middle += ' '
+ + numLabel + ' ';
}
var next = ' | ' + M('Next') + ' >>';
if (pages - currentPage > 0)
- next = ' | '
- + M('Next') + ' >>';
+ next = ' | '
+ + M('Next') + ' >>';
var predots = '';
if (firstClkbl > 1)
- predots = '...';
+ predots = '...';
var postdots = '';
if (lastClkbl < pages)
- postdots = '...';
+ postdots = '...';
s += ''
- + prev + predots + middle + postdots + next + '
';
+ + prev + predots + middle + postdots + next + '';
return s;
}
@@ -127,16 +121,16 @@ mkws.registerWidgetType('Records', function() {
var hit = data.hits[i];
that.team.queue("record").publish(hit);
var divId = team.recordElementId(hit.recid[0]);
- html.push('', renderSummary(hit), '
');
+ html.push('', renderSummary(hit), '
');
// ### At some point, we may be able to move the
// m_currentRecordId and m_currentRecordData members
// from the team object into this widget.
if (hit.recid == team.currentRecordId()) {
- if (team.currentRecordData())
- html.push(team.renderDetails(team.currentRecordData()));
+ if (team.currentRecordData())
+ html.push(team.renderDetails(team.currentRecordData()));
}
}
- $(that.node).html(html.join(''));
+ that.node.html(html.join(''));
function renderSummary(hit) {
var template = team.loadTemplate(that.config.template || "Summary");
@@ -146,7 +140,7 @@ mkws.registerWidgetType('Records', function() {
}
});
- widget.autosearch(that);
+ that.autosearch();
});
@@ -161,18 +155,18 @@ mkws.registerWidgetType('Navi', function() {
filters.visitTargets(function(id, name) {
if (text) text += " | ";
- text += M('source') + ': ' + name + '';
+ text += M('source') + ': ' + name + '';
});
filters.visitFields(function(field, value) {
if (text) text += " | ";
- text += M(field) + ': ' + value + '';
+ text += M(field) + ': ' + value + '';
});
- $(that.node).html(text);
+ that.node.html(text);
});
});
@@ -183,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.node.change(function() {
+ that.team.set_sortOrder(that.node.val());
if (that.team.submitted()) {
that.team.reShow();
}
@@ -196,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.node.change(function() {
+ that.team.set_perpage(that.node.val());
if (that.team.submitted()) {
that.team.reShow();
}
@@ -210,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.node.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.node.html('\
Records \
| \
Targets');
@@ -229,7 +224,7 @@ mkws.registerWidgetType('Search', function() {
var tname = this.team.name();
var M = mkws.M;
- $(this.node).html('\
+ this.node.html('\
';
- $(this.node).html(s);
+ this.node.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 = '