Config option to specify cookie domain for auth
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 6a202f8..4f4cc5c 100644 (file)
@@ -557,16 +557,9 @@ function renderDetails(data, marker)
     var details = '<div class="details" id="mkwsDet_'+data.recid+'"><table>';
     if (marker) details += '<tr><td colspan="2">'+ marker + '</td></tr>';
 
-    var sources = [];
+    var locations = [];
     for (var i in data.location) {
-       sources.push(data.location[i]['@name']);
-    }
-    if (sources.length == 0) {
-       details += '<tr><td colspan="2">No sources for record!</td></tr>';
-    } else if (sources.length == 1) {
-       details += renderField("Source", sources[0]);
-    } else {
-       details += renderField("Sources", sources);
+       locations.push(data.location[i]['@name']);
     }
 
     details += renderField("Title", data["md-title"], data["md-title-remainder"], data["md-title-responsibility"]);
@@ -574,7 +567,11 @@ function renderDetails(data, marker)
     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"]);
+    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></div>';
 
     return details;
@@ -585,26 +582,27 @@ function renderField(caption, data, data2, data3) {
        return "";
     }
 
-    if (caption == "URL") {
-       var tmp = "";
-       for (var i = 0; i < data.length; i++) {
-           var s = data[i];
-           if (i > 0)
-               tmp += ", ";
-           tmp += '<a href="' + s + '" target="_blank">' + s + '</a>';
-       }
-       data = tmp;
+    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) {
-       data = data + " (" + data2 + ")";
+       res = res + " (" + data2 + ")";
     }
 
     if (data3 != undefined) {
-       data = data + " <i>" + data3 + "</i>";
+       res = res + " <i>" + data3 + "</i>";
     }
 
-    return '<tr><th>' + M(caption) + '</th><td>' + data + '</td></tr>';
+    return '<tr><th>' + M(caption) + '</th><td>' + res + '</td></tr>';
 }
 
 
@@ -674,7 +672,8 @@ function mkws_html_all() {
     mkws_html_switch();
 
     if (mkws_config.use_service_proxy)
-       mkws_service_proxy_auth(mkws_config.service_proxy_auth);
+         mkws_service_proxy_auth(mkws_config.service_proxy_auth, 
+          mkws_config.service_proxy_auth_domain);
 
     if (mkws_config.responsive_design_width) {
        // Responsive web design - change layout on the fly based on
@@ -767,13 +766,13 @@ function mkws_html_perpage() {
  * The username/password is configured in the apache config file
  * for the site.
  */
-function mkws_service_proxy_auth(auth_url) {
+function mkws_service_proxy_auth(auth_url, auth_domain) {
     debug("Run service proxy auth URL: " + auth_url);
 
     var request = new pzHttpRequest(auth_url, function(err) {
-       alert("HTTP call for authentication failed: " + err)
-       return;
-    });
+         alert("HTTP call for authentication failed: " + err)
+         return;
+    }, auth_domain);
 
     request.get(null, function(data) {
        if (!$.isXMLDoc(data)) {