+ /* override standard config values by function parameters */
+ for (var k in config_default) {
+ if (typeof mkws_config[k] === 'undefined')
+ mkws_config[k] = config_default[k];
+ //debug("Set config: " + k + ' => ' + mkws_config[k]);
+ }
+ }
+
+
+ /*
+ * Run service-proxy authentication in background (after page load).
+ * The username/password is configured in the apache config file
+ * for the site.
+ */
+ function authenticate_session(auth_url, auth_domain, pp2_url) {
+ console.log("Run service proxy auth URL: " + auth_url);
+
+ if (!auth_domain) {
+ auth_domain = pp2_url.replace(/^(https?:)?\/\/(.*?)\/.*/, '$2');
+ console.log("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;
+ }, auth_domain);
+
+ request.get(null, function(data) {
+ if (!$.isXMLDoc(data)) {
+ alert("service proxy auth response document is not valid XML document, give up!");
+ return;
+ }
+ var status = $(data).find("status");
+ if (status.text() != "OK") {
+ alert("service proxy auth repsonse status: " + status.text() + ", give up!");
+ return;
+ }
+
+ console.log("Service proxy auth successfully done");
+ mkws.authenticated = true;
+ run_auto_searches();
+ });
+ }
+
+
+ function run_auto_searches() {
+ console.log("running auto searches");
+
+ for (var teamName in mkws.teams) {
+ // ### should check mkwsTermlist as well, for facet-only teams
+ var node = $('.mkwsRecords.mkwsTeam_' + teamName);
+ var query = node.attr('autosearch');
+ console.log("teamName '" + teamName + "', node=" + node + ", class='" + node.className + "', query=" + query);
+
+ if (query) {
+ var sort = node.attr('sort');
+ var targets = node.attr('targets');
+ var s = "running auto search: '" + query + "'";
+ if (teamName) s += " [teamName '" + teamName + "']";
+ if (sort) s += " sorted by '" + sort + "'";
+ if (targets) s += " in targets '" + targets + "'";
+ console.log(s);
+ var team = mkws.teams[teamName];
+ console.log($.toJSON(team));
+ team.newSearch(query, sort, targets, teamName);
+ }
+ }
+ }