var html = [];
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
- html.push('<div class="record" id="mkwsRecdiv_'+hit.recid+'" >'
- +'<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>');
- }
- if (hit.recid == curDetRecId) {
+ html.push('<div class="record" id="mkwsRecdiv_' + hit.recid + '" >',
+ renderSummary(hit),
+ '</div>');
+ if (hit.recid == curDetRecId) {
html.push(renderDetails(curDetRecData));
- }
- html.push('</div>');
+ }
}
replaceHtml(results, html.join(''));
}
+
+function renderSummary(hit)
+{
+ if (mkws.templateSummary === undefined) {
+ loadTemplate("Summary");
+ }
+
+ hit._id = "mkwsRec_" + hit.recid;
+ hit._onclick = "mkws.showDetails(this.id);return false;"
+ return mkws.templateSummary(hit);
+}
+
+
function my_onstat(data) {
var stat = document.getElementById("mkwsStat");
if (stat == null)
loadTemplate("Record");
}
- var details;
- if (mkws.templateRecord) {
- var template = mkws.templateRecord;
- details = template(data);
- } else {
- details = defaultRenderDetails(data, marker);
- }
-
+ var template = mkws.templateRecord;
+ var details = template(data);
return '<div class="details" id="mkwsDet_' + data.recid + '">' + details + '</div>';
}
}
-function defaultRenderDetails(data, marker)
-{
- var details = '<table>';
- if (marker) details += '<tr><td colspan="2">'+ marker + '</td></tr>';
-
- var locations = [];
- for (var i in data.location) {
- locations.push(data.location[i]['@name']);
- }
-
- details += renderField("Title", data["md-title"], data["md-title-remainder"], data["md-title-responsibility"]);
- details += renderField("Date", data["md-date"]);
- details += renderField("Author", data["md-author"]);
- details += renderField("URL", data["md-electronic-url"]);
- details += renderField("Subject", data["location"][0]["md-subject"]);
- if (locations.length == 0) {
- details += '<tr><td colspan="2">No locations for record!</td></tr>';
- } else {
- details += renderField("Location" + (locations.length == 1 ? "" : "s"), locations);
- }
- details += '</table>';
- return details;
-}
-
-
-function renderField(caption, data, data2, data3) {
- if (data === undefined) {
- return "";
- }
-
- var res = "";
- for (var i = 0; i < data.length; i++) {
- var s = data[i];
- if (i > 0)
- res += ", ";
-
- if (caption == "URL")
- s = '<a href="' + s + '" target="_blank">' + s + '</a>';
-
- res += s
- }
-
- if (data2 != undefined) {
- res = res + " (" + data2 + ")";
- }
-
- if (data3 != undefined) {
- res = res + " <i>" + data3 + "</i>";
- }
-
- return '<tr><th>' + M(caption) + '</th><td>' + res + '</td></tr>';
-}
-
-
/*
* All the HTML stuff to render the search forms and
* result pages.