mkws_config.service_proxy_auth_domain no longer need be specified: it
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index d331de5..d3adf6d 100644 (file)
@@ -7,7 +7,7 @@
 var mkws = {
     sort: 'relevance',
     authenticated: false,
-    filters: [],
+    filters: []
 };
 
 /*
@@ -160,6 +160,7 @@ Handlebars.registerHelper('commaList', function(items, options) {
     /* default mkws config */
     var config_default = {
        use_service_proxy: true,
+       pazpar2_url: "http://mkws.indexdata.com/service-proxy/",
        service_proxy_auth: "http://mkws.indexdata.com/service-proxy-auth",
        lang: "",
        sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]],
@@ -220,7 +221,7 @@ for (var key in mkws_config) {
 // autoInit is set to true on default
 var my_paz = new pz2( { "onshow": my_onshow,
                     "showtime": 500,            //each timer (show, stat, term, bytarget) can be specified this way
-                   "pazpar2path": mkws_config.pazpar2_url || "http://mkws.indexdata.com/service-proxy/",
+                    "pazpar2path": mkws_config.pazpar2_url,
                     "oninit": my_oninit,
                     "onstat": my_onstat,
                     "onterm": my_onterm,
@@ -905,7 +906,8 @@ function mkws_html_all() {
 
     if (mkws_config.use_service_proxy)
          mkws_service_proxy_auth(mkws_config.service_proxy_auth,
-          mkws_config.service_proxy_auth_domain);
+                                 mkws_config.service_proxy_auth_domain,
+                                 mkws_config.pazpar2_url);
 
     if (mkws_config.responsive_design_width) {
        // Responsive web design - change layout on the fly based on
@@ -1014,9 +1016,14 @@ function mkws_html_perpage() {
  * The username/password is configured in the apache config file
  * for the site.
  */
-function mkws_service_proxy_auth(auth_url, auth_domain) {
+function mkws_service_proxy_auth(auth_url, auth_domain, pp2_url) {
     debug("Run service proxy auth URL: " + auth_url);
 
+    if (!auth_domain) {
+       auth_domain = pp2_url.replace(/^http:\/\/(.*?)\/.*/, '$1');
+       debug("guessed auth_domain '" + auth_domain + "' from pp2_url '" + pp2_url + "'");
+    }
+
     var request = new pzHttpRequest(auth_url, function(err) {
          alert("HTTP call for authentication failed: " + err)
          return;