mkws.registerWidgetType('Targets', function() {
+ if (!this.config.show_switch) return;
var that = this;
var M = mkws.M;
- $(this.node).html('\
-<div class="mkwsBytarget mkwsTeam_' + this.team.name() + '">\
-No information available yet.\
-</div>');
- $(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 ='<table><thead><tr>' +
for (var i = 0; i < data.length; i++) {
table += "<tr><td>" + data[i].id +
- "</td><td>" + data[i].hits +
- "</td><td>" + data[i].diagnostic +
- "</td><td>" + data[i].records +
- "</td><td>" + data[i].state + "</td></tr>";
+ "</td><td>" + data[i].hits +
+ "</td><td>" + data[i].diagnostic +
+ "</td><td>" + data[i].records +
+ "</td><td>" + data[i].state + "</td></tr>";
}
table += '</tbody></table>';
- var subnode = $(that.node).children('.mkwsBytarget');
- subnode.html(table);
+ that.node.html(table);
});
});
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>' +
- ' -- ' +
- '<span class="records">' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + '</span>');
+ that.node.html(' -- ' +
+ '<span class="mkwsClientCount">' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '</span>' +
+ ' -- ' +
+ M('Retrieved records') + ': ' + data.records + '/' + data.hits);
});
});
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 = '<div style="float: right">' + M('Displaying') + ': '
- + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) +
- ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': '
- + data.total + ')</div>';
+ + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) +
+ ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': '
+ + data.total + ')</div>';
//client indexes pages from 1 but pz2 from 0
var onsides = 6;
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 = '<span class="mkwsPrev"><< ' + M('Prev') + '</span> | ';
if (currentPage > 1)
- prev = '<a href="#" class="mkwsPrev" onclick="mkws.pagerPrev(\'' + teamName + '\');">'
- +'<< ' + M('Prev') + '</a> | ';
+ prev = '<a href="#" class="mkwsPrev" onclick="mkws.pagerPrev(\'' + teamName + '\');">'
+ +'<< ' + M('Prev') + '</a> | ';
var middle = '';
for(var i = firstClkbl; i <= lastClkbl; i++) {
- var numLabel = i;
- if(i == currentPage)
- numLabel = '<span class="mkwsSelected">' + i + '</span>';
+ var numLabel = i;
+ if(i == currentPage)
+ numLabel = '<span class="mkwsCurrentPage">' + i + '</span>';
- middle += '<a href="#" onclick="mkws.showPage(\'' + teamName + '\', ' + i + ')"> '
- + numLabel + ' </a>';
+ middle += '<a href="#" onclick="mkws.showPage(\'' + teamName + '\', ' + i + ')"> '
+ + numLabel + ' </a>';
}
var next = ' | <span class="mkwsNext">' + M('Next') + ' >></span>';
if (pages - currentPage > 0)
- next = ' | <a href="#" class="mkwsNext" onclick="mkws.pagerNext(\'' + teamName + '\')">'
- + M('Next') + ' >></a>';
+ next = ' | <a href="#" class="mkwsNext" onclick="mkws.pagerNext(\'' + teamName + '\')">'
+ + M('Next') + ' >></a>';
var predots = '';
if (firstClkbl > 1)
- predots = '...';
+ predots = '...';
var postdots = '';
if (lastClkbl < pages)
- postdots = '...';
+ postdots = '...';
s += '<div style="float: clear">'
- + prev + predots + middle + postdots + next + '</div>';
+ + prev + predots + middle + postdots + next + '</div>';
return s;
}
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.
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");
filters.visitTargets(function(id, name) {
if (text) text += " | ";
- text += M('source') + ': <a class="crossout" href="#" onclick="mkws.delimitTarget(\'' + teamName +
- "', '" + id + "'" + ');return false;">' + name + '</a>';
+ text += M('source') + ': <a class="mkwsRemovable" href="#" onclick="mkws.delimitTarget(\'' + teamName +
+ "', '" + id + "'" + ');return false;">' + name + '</a>';
});
filters.visitFields(function(field, value) {
if (text) text += " | ";
- text += M(field) + ': <a class="crossout" href="#" onclick="mkws.delimitQuery(\'' + teamName +
- "', '" + field + "', '" + value + "'" +
- ');return false;">' + value + '</a>';
+ text += M(field) + ': <a class="mkwsRemovable" href="#" onclick="mkws.delimitQuery(\'' + teamName +
+ "', '" + field + "', '" + value + "'" +
+ ');return false;">' + value + '</a>';
});
- $(that.node).html(text);
+ that.node.html(text);
});
});
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();
}
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();
}
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('\
<a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
| \
</span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
var tname = this.team.name();
var M = mkws.M;
- $(this.node).html('\
+ this.node.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') + '" />\
mkws.registerWidgetType('SearchForm', function() {
- var team = this.team;
- $(this.node).submit(function() {
+ var team = this.team;
+ this.node.submit(function() {
var val = team.widget('Query').value();
team.newSearch(val);
return false;
mkws.registerWidgetType('Results', function() {
var tname = this.team.name();
- $(this.node).html('\
+ this.node.html('\
<table width="100%" border="0" cellpadding="6" cellspacing="0">\
<tr>\
<td class="mkwsTermlists-Container-wide mkwsTeam_' + tname + '" width="250" valign="top">\
var that = this;
var M = mkws.M;
- var s = '<form name="mkwsSelect" class="mkwsSelect mkwsTeam_' + tname + '" action="" >';
+ var s = '<form>';
if (this.config.show_sort) {
s += M('Sort by') + ' ' + mkwsHtmlSort() + ' ';
}
}
s += '</form>';
- $(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 = '<select class="mkwsSort mkwsTeam_' + tname + '">';
for(var i = 0; i < that.config.sort_options.length; i++) {
sort_html += '<option value="' + key + '"';
if (order == key || order == val) {
- sort_html += ' selected="selected"';
+ sort_html += ' selected="selected"';
}
sort_html += '>' + M(val) + '</option>';
}
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++) {
perpage_html += '<option value="' + key + '"';
if (key == perpage) {
- perpage_html += ' selected="selected"';
+ perpage_html += ' selected="selected"';
}
perpage_html += '>' + key + '</option>';
}
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 = "";
}
}
- $(this.node).html(data);
+ this.node.html(data);
widget.hideWhenNarrow(this);
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.node.appendTo(container.node);
+ }
+});
+
+
+// This widget has no functionality of its own, but its configuration
+// is copied up into its team, allowing it to affect other widgets in
+// the team.
+//
+mkws.registerWidgetType('Config', function() {
+ var c = this.config;
+ for (var name in c) {
+ if (c.hasOwnProperty(name)) {
+ this.team.config()[name] = c[name];
+ this.log(this + " copied property " + name + "='" + c[name] + "' up to team");
+ }
}
});
mkws.registerWidgetType('Button', function() {});
mkws.registerWidgetType('Popup', function() {});
-// Not sure whether the following should have functionality:
-// Select HTMLFormElement
-// *-Container-wide HTMLTableCellElement
-// *-Container-narrow HTMLDivElement
-// Bytarget HTMLDivElement
+