var m_paz; // will be initialised below
var m_template = {};
- that.toString = function() { return '[Team ' + teamName + ']'; }
+ that.toString = function() { return '[Team ' + teamName + ']'; };
// Accessor methods for individual widgets: readers
- that.name = function() { return m_teamName; }
- that.submitted = function() { return m_submitted; }
- that.perpage = function() { return m_perpage; }
- that.totalRecordCount = function() { return m_totalRecordCount; }
- that.currentPage = function() { return m_currentPage; }
- that.currentRecordId = function() { return m_currentRecordId; }
- that.currentRecordData = function() { return m_currentRecordData; }
- that.filters = function() { return m_filters; }
+ that.name = function() { return m_teamName; };
+ that.submitted = function() { return m_submitted; };
+ that.perpage = function() { return m_perpage; };
+ that.totalRecordCount = function() { return m_totalRecordCount; };
+ that.currentPage = function() { return m_currentPage; };
+ that.currentRecordId = function() { return m_currentRecordId; };
+ that.currentRecordData = function() { return m_currentRecordData; };
+ that.filters = function() { return m_filters; };
// Accessor methods for individual widgets: writers
that.set_sortOrder = function(val) { m_sortOrder = val };
function log(s) {
var now = $.now();
- var timestamp = ((now - m_logTime.start)/1000).toFixed(3) + " (+" + ((now - m_logTime.last)/1000).toFixed(3) + ") "
+ var timestamp = (((now - m_logTime.start)/1000).toFixed(3) + " (+" +
+ ((now - m_logTime.last)/1000).toFixed(3) + ") ");
m_logTime.last = now;
-
mkws.log(m_teamName + ": " + timestamp + s);
}
that.log = log;
}
}
return false;
- }
+ };
that.limitTarget = function(id, name)
m_filters.push({ id: id, name: name });
triggerSearch();
return false;
- }
+ };
that.limitQuery = function(field, value)
m_filters.push({ field: field, value: value });
triggerSearch();
return false;
- }
+ };
that.delimitTarget = function(id)
{
log("delimitTarget(id=" + id + ")");
- var newFilters = [];
- for (var i in m_filters) {
- var filter = m_filters[i];
- if (filter.id) {
- log("delimitTarget() removing filter " + $.toJSON(filter));
- } else {
- log("delimitTarget() keeping filter " + $.toJSON(filter));
- newFilters.push(filter);
- }
- }
- m_filters = newFilters;
-
+ removeMatchingFilters(function(f) { return f.id });
triggerSearch();
return false;
- }
+ };
that.delimitQuery = function(field, value)
{
log("delimitQuery(field=" + field + ", value=" + value + ")");
+ removeMatchingFilters(function(f) { return f.field && field == f.field && value == f.value });
+ triggerSearch();
+ return false;
+ };
+
+
+ function removeMatchingFilters(matchFn) {
var newFilters = [];
for (var i in m_filters) {
var filter = m_filters[i];
- if (filter.field &&
- field == filter.field &&
- value == filter.value) {
- log("delimitQuery() removing filter " + $.toJSON(filter));
+ if (matchFn(filter)) {
+ log("removeMatchingFilters() removing filter " + $.toJSON(filter));
} else {
- log("delimitQuery() keeping filter " + $.toJSON(filter));
+ log("removeMatchingFilters() keeping filter " + $.toJSON(filter));
newFilters.push(filter);
}
}
m_filters = newFilters;
-
- triggerSearch();
- return false;
}
{
m_currentPage = pageNum;
m_paz.showPage(m_currentPage - 1);
- }
+ };
that.pagerNext = function() {
m_paz.showNext();
m_currentPage++;
}
- }
+ };
that.pagerPrev = function() {
if (m_paz.showPrev() != false)
m_currentPage--;
- }
+ };
that.reShow = function() {
m_paz.show(0, m_perpage, m_sortOrder);
- }
+ };
function resetPage()
params.limit = pp2limit;
}
- log("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
+ log("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filters) + ", " +
+ "pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
// We can use: params.torusquery = "udb=NAME"
// Note: that won't work when running against raw pazpar2
// request the record
log("showDetails() requesting record '" + recId + "'");
m_paz.record(recId);
- }
+ };
/*
log(s);
newSearch(query, sortOrder, targets);
- }
+ };
// This function is taken from a StackOverflow answer
{
var template = loadTemplate("Record");
var details = template(data);
- return '<div class="details mkwsTeam_' + m_teamName + '" id="' + recordDetailsId(data.recid[0]) + '">' + details + '</div>';
+ return '<div class="details mkwsTeam_' + m_teamName + '" ' +
+ 'id="' + recordDetailsId(data.recid[0]) + '">' + details + '</div>';
}
that.renderDetails = renderDetails;
};
}
return queues[id];
- }
+ };
that.queue = queue;
mkwsHtmlAll()