// Set up namespace and some state.
var mkws = {
+ authenticated: false,
filters: [],
};
loadTemplate("Summary");
}
- if (mkws.templateSummary) {
- hit._id = "mkwsRec_" + hit.recid;
- hit._onclick = "mkws.showDetails(this.id);return false;"
- return mkws.templateSummary(hit);
- } else {
- var html = [];
- html.push('<a href="#" id="mkwsRec_'+hit.recid
- +'" onclick="mkws.showDetails(this.id);return false;"><b>'
- + hit["md-title"] +' </b></a>');
- if (hit["md-title-remainder"] !== undefined) {
- html.push('<span>' + hit["md-title-remainder"] + ' </span>');
- }
- if (hit["md-title-responsibility"] !== undefined) {
- html.push('<span><i>'+hit["md-title-responsibility"]+'</i></span>');
- }
- return html.join('');
- }
+ hit._id = "mkwsRec_" + hit.recid;
+ hit._onclick = "mkws.showDetails(this.id);return false;"
+ return mkws.templateSummary(hit);
}
}
var termlist = document.getElementById("mkwsTermlists");
- replaceHtml(termlist, acc.join(''));
+ if (termlist)
+ replaceHtml(termlist, acc.join(''));
}
function add_single_facet(acc, caption, data, max, pzIndex) {
// when search button pressed
function onFormSubmitEventHandler()
{
+ newSearch(document.mkwsSearchForm.mkwsQuery.value);
+ return false;
+}
+
+function newSearch(query)
+{
+ if (!mkws.authenticated) {
+ alert("searching before authentication");
+ return;
+ }
+
+ mkws.filters = []
+ redraw_navi();
resetPage();
loadSelect();
- triggerSearch();
+ triggerSearch(query);
mkws.switchView('records'); // In case it's configured to start off as hidden
submitted = true;
- return false;
}
function onSelectDdChange()
totalRec = 0;
}
-function triggerSearch ()
+function triggerSearch (query)
{
var pp2filter = "";
var pp2limit = "";
+ // Re-use previous query if a new one is not specified
+ if (query) {
+ mkws.query = query;
+ }
+
for (var i in mkws.filters) {
var filter = mkws.filters[i];
if (filter.id) {
}
}
- debug("triggerSearch: filters = " + JSON.stringify(mkws.filters) + ", pp2filter = " + pp2filter + ", pp2limit = " + pp2limit);
- my_paz.search(document.mkwsSearchForm.mkwsQuery.value, recPerPage, curSort, pp2filter, undefined, { limit: pp2limit });
+ debug("triggerSearch(" + mkws.query + "): filters = " + JSON.stringify(mkws.filters) + ", pp2filter = " + pp2filter + ", pp2limit = " + pp2limit);
+ my_paz.search(mkws.query, recPerPage, curSort, pp2filter, undefined, { limit: pp2limit });
}
function loadSelect ()
</tr>\
</table>\
';
+ } else if (name === "Summary") {
+ return '\
+ <a href="#" id="{{_id}}" onclick="{{_onclick}}">\
+ <b>{{md-title}}</b>\
+ </a>\
+ {{#if md-title-remainder}}\
+ <span>{{md-title-remainder}}</span>\
+ {{/if}}\
+ {{#if md-title-responsibility}}\
+ <span><i>{{md-title-responsibility}}</i></span>\
+ {{/if}}\
+';
}
var s = "There is no default '" + name +"' template!";
}
}
+
+function run_auto_searches() {
+ var node = $('#mkwsRecords');
+ if (node.attr('autosearch')) {
+ var query = node.attr('autosearch');
+ var sort = node.attr('sort');
+ debug("running auto search: '" + query + "' sorted by '" + sort + "'");
+ // ### currently ignoring sort
+ newSearch(query);
+ }
+}
+
+
function mkws_set_lang() {
var lang = $.parseQuerystring().lang || mkws_config.lang;
if (!lang || !mkws.locale_lang[lang]) {
}
debug("Service proxy auth successfully done");
- mkws.service_proxy_auth = true;
+ mkws.authenticated = true;
+ run_auto_searches();
});
}