Move invocation of run_auto_searches() from when DOM is ready to when
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index b5c1b34..ff67799 100644 (file)
@@ -5,6 +5,7 @@
 
 // Set up namespace and some state.
 var mkws = {
+    authenticated: false,
     filters: [],
 };
 
@@ -260,7 +261,6 @@ function my_onshow(data) {
 
     // navi
     var results = document.getElementById("mkwsRecords");
-    debug("my_onshow(" + JSON.stringify(data) + ")");
 
     var html = [];
     for (var i = 0; i < data.hits.length; i++) {
@@ -416,6 +416,11 @@ function onFormSubmitEventHandler()
 
 function newSearch(query)
 {
+    if (!mkws.authenticated) {
+       alert("searching before authentication");
+       return;
+    }
+
     mkws.filters = []
     redraw_navi();
     resetPage();
@@ -1009,7 +1014,8 @@ function mkws_service_proxy_auth(auth_url, auth_domain) {
        }
 
        debug("Service proxy auth successfully done");
-       mkws.service_proxy_auth = true;
+       mkws.authenticated = true;
+       run_auto_searches();
     });
 }
 
@@ -1247,8 +1253,6 @@ $(document).ready(function() {
        mkws_config.error = e.message;
        // alert(e.message);
     }
-
-    run_auto_searches();
 });
 
 })(jQuery);