X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=experiments%2Fspclient%2Fmkws.js;h=97138ced13c21402acc19bfb6c5d4368ffbf66f1;hb=548622e76659b11cdaba69a5b8dd3b4b0c0842ac;hp=6bc3a30790c8cb148932221fa555eaec69f8c942;hpb=3c47d3fe9fecf21d12f38f6dda73c1b7e5ff2c49;p=mkws-moved-to-github.git
diff --git a/experiments/spclient/mkws.js b/experiments/spclient/mkws.js
index 6bc3a30..97138ce 100644
--- a/experiments/spclient/mkws.js
+++ b/experiments/spclient/mkws.js
@@ -164,36 +164,34 @@ function my_onterm(data) {
var termlists = [];
termlists.push('
' + M('Termlists') + '
');
- termlists.push('');
- termlists.push('
' + M('Sources') + '
');
- for (var i = 0; i < data.xtargets.length && i < SourceMax; i++ ) {
- termlists.push('
' + data.xtargets[i].name
- + ' (' + data.xtargets[i].freq + ')');
- }
- termlists.push('
');
+ add_single_facet(termlists, "Sources", data.xtargets, SourceMax, null);
+ add_single_facet(termlists, "Subjects", data.subject, SubjectMax, "su");
+ add_single_facet(termlists, "Authors", data.author, AuthorMax, "au");
- termlists.push('');
- termlists.push('
' + M('Subjects') + '
');
- for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
- termlists.push('
' + data.subject[i].name + ' ('
- + data.subject[i].freq + ')');
- }
- termlists.push('
');
+ var termlist = document.getElementById("termlist");
+ replaceHtml(termlist, termlists.join(''));
+}
+function add_single_facet(termlists, caption, data, max, cclIndex) {
termlists.push('');
- termlists.push('
' + M('Authors') + '
');
- for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
- termlists.push('
'
- + data.author[i].name
- + ' ('
- + data.author[i].freq
- + ')');
+ termlists.push('
' + M(caption) + '
');
+ for (var i = 0; i < data.length && i < max; i++ ) {
+ termlists.push('
'
+ + data[i].name
+ + ' ('
+ + data[i].freq
+ + ')');
}
termlists.push('
');
-
- var termlist = document.getElementById("termlist");
- replaceHtml(termlist, termlists.join(''));
}
function my_onrecord(data) {
@@ -442,30 +440,39 @@ function renderDetails(data, marker)
{
var details = '';
if (marker) details += ''+ marker + ' |
';
- if (data["md-title"] != undefined) {
- details += '' + M('Title') + ' | : '+data["md-title"];
- if (data["md-title-remainder"] !== undefined) {
- details += ' : ' + data["md-title-remainder"] + ' ';
- }
- if (data["md-title-responsibility"] !== undefined) {
- details += ' '+ data["md-title-responsibility"] +'';
- }
- details += ' |
';
- }
- if (data["md-date"] != undefined)
- details += '' + M('Date') + ' | : ' + data["md-date"] + ' |
';
- if (data["md-author"] != undefined)
- details += '' + M('Author') + ' | : ' + data["md-author"] + ' |
';
- if (data["md-electronic-url"] != undefined)
- details += 'URL | : ' + data["md-electronic-url"] + '' + ' |
';
- if (data["location"][0]["md-subject"] != undefined)
- details += '' + M('Subject') + ' | : ' + data["location"][0]["md-subject"] + ' |
';
- if (data["location"][0]["@name"] != undefined)
- details += '' + M('Location') + ' | : ' + data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")" + ' |
';
+
+ 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"]);
+ details += renderField("Location", data["location"][0]["@name"], data["location"][0]["@id"]);
details += '
';
+
return details;
}
+function renderField(caption, data, data2, data3) {
+ if (data === undefined) {
+ return "";
+ }
+
+ if (caption == "URL") {
+ data = '' + data + '';
+ }
+
+ if (data2 != undefined) {
+ data = data + " (" + data2 + ")";
+ }
+
+ if (data3 != undefined) {
+ data = data + " " + data3 + "";
+ }
+
+ return '' + M(caption) + ' | ' + data + ' |
';
+}
+
+
/*
* All the HTML stuff to render the search forms and
* result pages.
@@ -684,7 +691,7 @@ function mkws_html_lang(mkws_config) {
data += ' | ';
if (lang == l) {
- data += l;
+ data += ' ' + l + ' ';
} else {
data += ' ' + l + ' '
}