Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws
authorMike Taylor <mike@indexdata.com>
Fri, 24 Jan 2014 13:52:16 +0000 (13:52 +0000)
committerMike Taylor <mike@indexdata.com>
Fri, 24 Jan 2014 13:52:16 +0000 (13:52 +0000)
test/spec/mkws-pazpar2.js
tools/htdocs/mkws.js

index cce9148..e52e0f8 100644 (file)
@@ -208,10 +208,17 @@ describe("Check Termlist", function () {
     it("limit search to first author", function () {
         var hits_all_targets = get_hit_counter();
         var author_number = 2; // 2=first author
-        var author_name = $("div#mkwsFacetAuthors div.term:nth-child(" + author_number + ") a").text();
-        // do not click on author with numbers, e.g.: Bower, James M. Beeman, David, 1938-
-        if (author_name.match(/[0-9].+[0-9]/)) {
-            author_number++;
+        // do not click on author with numbers, e.g.: "Bower, James M. Beeman, David, 1938-"
+        // do not click on author names without a comma, e.g.: "Joe Barbara"
+        var terms = $("div#mkwsFacetAuthors div.term a");
+        for (var i = 0; i < terms.length; i++) {
+            var term = terms[i].text;
+            if (term.match(/[0-9].+[0-9]/i) || !term.match(/,/)) {
+                debug("ignore author facet: " + term);
+                author_number++;
+            } else {
+                break;
+            }
         }
 
         var click = $("div#mkwsFacetAuthors div.term:nth-child(" + author_number + ") a").trigger("click");
@@ -232,10 +239,15 @@ describe("Check Termlist", function () {
     it("limit search to first source", function () {
         var hits_all_targets = get_hit_counter();
         var source_number = 2; // 2=first source
-        var source_name = $("div#mkwsFacetSources div.term:nth-child(" + source_number + ") a").text();
         // do not click on wikipedia link - no author or subject facets possible
-        if (source_name.match(/wikipedia/i)) {
-            source_number++;
+        var terms = $("div#mkwsFacetSources div.term a");
+        for (var i = 0; i < terms.length; i++) {
+            if (terms[i].text.match(/wikipedia/i)) {
+                debug("ignore source facet: " + terms[i].text);
+                source_number++;
+            } else {
+                break;
+            }
         }
 
         var click = $("div#mkwsFacetSources div.term:nth-child(" + source_number + ") a").trigger("click");
index 9f98f32..68892ea 100644 (file)
@@ -1283,8 +1283,12 @@ function _mkws_jquery_plugin ($) {
 // wrapper to call _make_mkws_team() after page load
 (function (j) {
     function log(s) {
-       if (console && console.log) console.log(s);
+        if (typeof console === "undefined" || typeof console.log === "undefined") { /* ARGH!!! old IE */
+            return;
+        }
+       console.log(s);
     }
+
     // enable before page load, so we could call it before mkws() runs
     _mkws_jquery_plugin(j);