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; }
});
- //
// 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;
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;
}
}
- // Used by promoteRecords() and onRecord()
+ // Used by the Records widget and onRecord()
function recordElementId(s) {
return 'mkwsRec_' + s.replace(/[^a-z0-9]/ig, '_');
}
function recordDetailsId(s) {
return 'mkwsDet_' + s.replace(/[^a-z0-9]/ig, '_');
}
- that.recordElementId = recordElementId;
that.targetFiltered = function(id) {
}
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
-
-
- // when search button pressed
- function onFormSubmitEventHandler()
- {
- var val = findnode('.mkwsQuery').val();
- newSearch(val);
- return false;
- }
-
-
- // limit by target functions
- that.limitTarget = function (id, name)
+ that.limitTarget = function(id, name)
{
log("limitTarget(id=" + id + ", name=" + name + ")");
m_filters.push({ id: id, name: name });
}
- // limit the query after clicking the facet
- that.limitQuery = function (field, value)
+ that.limitQuery = function(field, value)
{
log("limitQuery(field=" + field + ", value=" + value + ")");
m_filters.push({ field: field, value: value });
}
- that.delimitTarget = function (id)
+ that.delimitTarget = function(id)
{
log("delimitTarget(id=" + id + ")");
var newFilters = [];
}
- that.delimitQuery = function (field, value)
+ that.delimitQuery = function(field, value)
{
log("delimitQuery(field=" + field + ", value=" + value + ")");
var newFilters = [];
}
- that.showPage = function (pageNum)
+ that.showPage = function(pageNum)
{
m_currentPage = pageNum;
m_paz.showPage(m_currentPage - 1);
}
- that.pagerNext = function () {
+ that.pagerNext = function() {
if (m_totalRecordCount - m_perpage*m_currentPage > 0) {
m_paz.showNext();
m_currentPage++;
}
- that.pagerPrev = function () {
+ that.pagerPrev = function() {
if (m_paz.showPrev() != false)
m_currentPage--;
}
}
- function triggerSearch (query, sortOrder, targets)
+ function triggerSearch(query, sortOrder, targets)
{
resetPage();
queue("navi").publish();
// detailed record drawing
- that.showDetails = function (recId) {
+ that.showDetails = function(recId) {
var oldRecordId = m_currentRecordId;
m_currentRecordId = recId;
mkwsHtmlSwitch();
- findnode('.mkwsSearchForm').submit(onFormSubmitEventHandler);
+ findnode('.mkwsSearchForm').submit(function() {
+ var val = findnode('.mkwsQuery').val();
+ newSearch(val);
+ return false;
+ });
// on first page, hide the termlist
$(document).ready(function() { findnode(".mkwsTermlists").hide(); });
return s + '.mkwsTeam_' + teamName;
}).join(',');
- return $(selector);
+ var node = $(selector);
+ //log('findnode(' + selector + ') found ' + node.length + ' nodes');
+ return node;
}
}
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;
};