Styles for record-detail HTML.
[mkws-moved-to-github.git] / experiments / spclient / mkws.js
index fb40b8f..d52ffb1 100644 (file)
@@ -164,7 +164,7 @@ function my_onterm(data) {
     var termlists = [];
     termlists.push('<div class="title">' + M('Termlists') + '</div>');
 
-    termlists.push('<div class="termlist">');
+    termlists.push('<div class="facet">');
     termlists.push('<div class="termtitle">' + M('Sources') + '</div>');
     for (var i = 0; i < data.xtargets.length && i < SourceMax; i++ ) {
         termlists.push('<a href="#" target_id='+data.xtargets[i].id
@@ -173,16 +173,16 @@ function my_onterm(data) {
     }
     termlists.push('</div>');
 
-    termlists.push('<div class="termlist">');
-    termlists.push('<hr/><div class="termtitle">' + M('Subjects') + '</div>');
+    termlists.push('<div class="facet">');
+    termlists.push('<div class="termtitle">' + M('Subjects') + '</div>');
     for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
         termlists.push('<a href="#" onclick="limitQuery(\'su\', this.firstChild.nodeValue);return false;">' + data.subject[i].name + '</a><span>  ('
               + data.subject[i].freq + ')</span><br/>');
     }
     termlists.push('</div>');
 
-    termlists.push('<div class="termlist">');
-    termlists.push('<hr/><div class="termtitle">' + M('Authors') + '</div>');
+    termlists.push('<div class="facet">');
+    termlists.push('<div class="termtitle">' + M('Authors') + '</div>');
     for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
         termlists.push('<a href="#" onclick="limitQuery(\'au\', this.firstChild.nodeValue);return false;">'
                             + data.author[i].name
@@ -442,30 +442,39 @@ function renderDetails(data, marker)
 {
     var details = '<div class="details" id="det_'+data.recid+'"><table>';
     if (marker) details += '<tr><td>'+ marker + '</td></tr>';
-    if (data["md-title"] != undefined) {
-        details += '<tr><td><b>' + M('Title') + '</b></td><td><b>:</b> '+data["md-title"];
-       if (data["md-title-remainder"] !== undefined) {
-             details += ' : <span>' + data["md-title-remainder"] + ' </span>';
-       }
-       if (data["md-title-responsibility"] !== undefined) {
-             details += ' <span><i>'+ data["md-title-responsibility"] +'</i></span>';
-       }
-         details += '</td></tr>';
-    }
-    if (data["md-date"] != undefined)
-        details += '<tr><td><b>' + M('Date') + '</b></td><td><b>:</b> ' + data["md-date"] + '</td></tr>';
-    if (data["md-author"] != undefined)
-        details += '<tr><td><b>' + M('Author') + '</b></td><td><b>:</b> ' + data["md-author"] + '</td></tr>';
-    if (data["md-electronic-url"] != undefined)
-        details += '<tr><td><b>URL</b></td><td><b>:</b> <a href="' + data["md-electronic-url"] + '" target="_blank">' + data["md-electronic-url"] + '</a>' + '</td></tr>';
-    if (data["location"][0]["md-subject"] != undefined)
-        details += '<tr><td><b>' + M('Subject') + '</b></td><td><b>:</b> ' + data["location"][0]["md-subject"] + '</td></tr>';
-    if (data["location"][0]["@name"] != undefined)
-        details += '<tr><td><b>' + M('Location') + '</b></td><td><b>:</b> ' + data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")" + '</td></tr>';
+
+    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 += '</table></div>';
+
     return details;
 }
 
+function renderField(caption, data, data2, data3) {
+    if (data === undefined) {
+       return "";
+    }
+
+    if (caption == "URL") {
+       data = '<a href="' + data + '" target="_blank">' + data + '</a>';
+    }
+
+    if (data2 != undefined) {
+       data = data + " (" + data2 + ")";
+    }
+
+    if (data3 != undefined) {
+       data = data + " <i>" + data3 + "</i>";
+    }
+
+    return '<tr><th>' + M(caption) + '</th><td>' + data + '</td></tr>';
+}
+
+
 /*
  * All the HTML stuff to render the search forms and
  * result pages.
@@ -530,7 +539,7 @@ function mkws_html_all(config) {
           <td valign="top">\
             <div id="ranking">\
               <form name="select" id="select" action="" >\
-        ' + M('Sort by') + mkws_html_sort(config) + '\
+        ' + M('Sort by') + ' ' + mkws_html_sort(config) + '\
         ' + M('and show') + ' ' + mkws_html_perpage(config) + '\
         ' + M('per page') + '.\
        </form>\