Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws
authorJason Skomorowski <jason@indexdata.com>
Fri, 16 May 2014 05:00:11 +0000 (01:00 -0400)
committerJason Skomorowski <jason@indexdata.com>
Fri, 16 May 2014 05:00:11 +0000 (01:00 -0400)
16 files changed:
doc/README.markdown
doc/whitepaper.markdown
examples/htdocs/jasmine-popup.html
examples/htdocs/mike.html
src/mkws-core.js
src/mkws-filter.js
src/mkws-jquery.js
src/mkws-team.js
src/mkws-widget-authname.js
src/mkws-widget-builder.js
src/mkws-widget-categories.js
src/mkws-widget-log.js
src/mkws-widget-main.js
src/mkws-widget-termlists.js
src/mkws-widget.js
test/spec/mkws-pazpar2.js

index 49d415d..667cf4f 100644 (file)
@@ -75,6 +75,7 @@ possible options:
         show_lang: true,            /* true, false: show/hide language menu */
         show_sort: true,            /* true, false: show/hide sort menu */
         show_perpage: true,         /* true, false: show/hide perpage menu */
+        show_switch: true,          /* true, false: show/hide switch menu */
         lang_options: ["en", "de", "da"],
                                     /* display languages links for given languages, [] for all */
         facets: ["xtargets", "subject", "author"],
index 74a3234..55c56ec 100644 (file)
@@ -394,6 +394,9 @@ show_perpage              bool    true      Indicates whether or not to display
 
 show_sort                 bool    true      Indicates whether or not to display the sort menu.
 
+show_switch               bool    true      Indicates whether or not to display the switch menu, for switching between showing
+                                            retrieved records and target information.
+
 sort_default              string  relevance The label of the default sort criterion to use. Must be one of those in the `sort`
                                             array.
 
@@ -405,8 +408,8 @@ use_service_proxy         bool    true      If true, then a Service Proxy is use
                                             Pazpar2.
 ---
 
-Perhaps we should get rid of the `show_lang`, `show_perpage` and
-`show_sort` configuration items, and simply display the relevant menus
+Perhaps we should get rid of the `show_lang`, `show_perpage`,
+`show_sort` and `show_switch` configuration items, and simply display the relevant menus
 only when their containers are provided -- e.g. an `mkwsLang` element
 for the language menu. But for now we retain these, as an easier route
 to lightly customise the display than my changing providing a full HTML
index 44d981e..f00cd84 100644 (file)
@@ -26,6 +26,7 @@
     <script type="text/javascript" src="src/mkws-widget-record.js"></script>
     <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
     <script type="text/javascript" src="src/mkws-jquery.js"></script>
+    <script type="text/javascript">$ = undefined;</script>
 
     <link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-1.3.1/jasmine_favicon.png">
     <link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-1.3.1/jasmine.css">
index fdda334..477be88 100644 (file)
@@ -28,6 +28,7 @@
     <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
     <script type="text/javascript" src="src/mkws-jquery.js"></script>
     <script type="text/javascript" src="mkws-widget-reference.js"></script>
+    <script type="text/javascript">$ = undefined;</script>
   </head>
 <!--
   <body>
@@ -35,6 +36,7 @@
   </body>
 -->
   <body>
+    <script type="text/javascript">$ = undefined;</script>
     <div class="mkwsSwitch"></div>
     <div class="mkwsLang"></div>
     <div class="mkwsSearch-Container-wide"><div class="mkwsSearch"></div></div>
     <div class="mkwsBuilder"></div>
     <div class="mkwsSearch-Container-narrow"></div>
     <script type="text/javascript">$ = undefined;</script>
+    <div class="mkwsMOTD">
+      <p>
+       <b>Welcome to the MasterKey Widget Set demo.</b>
+      </p>
+      <p>
+       Enter a search above to begin, or
+       <a href="http://mkws.indexdata.com/"
+          >Visit the MKWS home page to find out more</a>.
+      </p>
+    </div>
   </body>
 </html>
index c7c2863..0af84a9 100644 (file)
@@ -10,6 +10,7 @@
 // authentication, and a hash of team objects, indexed by team-name.
 //
 var mkws = {
+  $: $, // Our own local copy of the jQuery object
   authenticated: false,
   log_level: 1, // Will be overridden from mkws.config, but
                 // initial value allows jQuery popup to use logging.
@@ -147,7 +148,8 @@ mkws.setMkwsConfig = function(overrides) {
     query_width: 50,
     show_lang: true,    /* show/hide language menu */
     show_sort: true,    /* show/hide sort menu */
-    show_perpage: true,         /* show/hide perpage menu */
+    show_perpage: true, /* show/hide perpage menu */
+    show_switch: true,  /* show/hide switch menu */
     lang_options: [],   /* display languages links for given languages, [] for all */
     facets: ["xtargets", "subject", "author"], /* display facets, in this order, [] for none */
     responsive_design_width: undefined, /* a page with less pixel width considered as narrow */
@@ -308,10 +310,9 @@ mkws.pagerNext = function(tname) {
 };
 
 
-// wrapper to call team() after page load
-(function(j) {
+// wrapper to provide local copy of the jQuery object.
+(function($) {
   var log = mkws.log;
-  var $ = j; // XXX
 
   function handleNodeWithTeam(node, callback) {
     // First branch for DOM objects; second branch for jQuery objects
@@ -363,11 +364,11 @@ mkws.pagerNext = function(tname) {
           var w1 = team.widget(t + "-Container-" + from);
           var w2 = team.widget(t + "-Container-" + to);
           if (w1) {
-            $(w1.node).hide();
+            w1.node.hide();
           }
           if (w2) {
-            $(w2.node).show();
-            $(w.node).appendTo($(w2.node));
+            w2.node.show();
+            w.node.appendTo(w2.node);
           }
         });
         team.queue("resize-" + to).publish();
@@ -382,7 +383,7 @@ mkws.pagerNext = function(tname) {
    * for the site.
    */
   function authenticateSession(auth_url, auth_domain, pp2_url) {
-    log("Run service proxy auth URL: " + auth_url);
+    log("service proxy authentication on URL: " + auth_url);
 
     if (!auth_domain) {
       auth_domain = pp2_url.replace(/^(https?:)?\/\/(.*?)\/.*/, '$2');
@@ -405,7 +406,7 @@ mkws.pagerNext = function(tname) {
         return;
       }
 
-      log("Service proxy auth successfully done");
+      log("service proxy authentication successful");
       mkws.authenticated = true;
       var authName = $(data).find("displayName").text();
       // You'd think there would be a better way to do this:
@@ -440,14 +441,16 @@ mkws.pagerNext = function(tname) {
       return '[class^="mkws"],[class*=" mkws"]';
     } else {
       // This is the new version, which works by looking up the
-      // specific classes of all registered widget types. Because all
-      // it requires jQuery to do is some hash lookups in pre-built
-      // tables, it should be very fast; but it silently ignores
-      // widgets of unregistered types.
+      // specific classes of all registered widget types and their
+      // resize containers. Because all it requires jQuery to do is
+      // some hash lookups in pre-built tables, it should be very
+      // fast; but it silently ignores widgets of unregistered types.
       var s = "";
       for (var type in mkws.widgetType2function) {
        if (s) s += ',';
        s += '.mkws' + type;
+       s += ',.mkws' + type + "-Container-wide";
+       s += ',.mkws' + type + "-Container-narrow";
       }
       return s;
     }
@@ -459,12 +462,12 @@ mkws.pagerNext = function(tname) {
       handleNodeWithTeam(this, function(tname, type) {
         var myTeam = mkws.teams[tname];
         if (!myTeam) {
-          myTeam = mkws.teams[tname] = team(j, tname);
-          log("Made MKWS team '" + tname + "'");
+          myTeam = mkws.teams[tname] = team($, tname);
+          log("made MKWS team '" + tname + "'");
         }
 
         var oldHTML = this.innerHTML;
-        var myWidget = widget(j, myTeam, type, this);
+        var myWidget = widget($, myTeam, type, this);
         myTeam.addWidget(myWidget);
         var newHTML = this.innerHTML;
         if (newHTML !== oldHTML) {
@@ -494,7 +497,7 @@ mkws.pagerNext = function(tname) {
           var lang = key.replace(/^language_/, "");
           // Copy custom languages into list
           mkws.locale_lang[lang] = mkws.config[key];
-          log("Added locally configured language '" + lang + "'");
+          log("added locally configured language '" + lang + "'");
         }
       }
     }
@@ -506,17 +509,17 @@ mkws.pagerNext = function(tname) {
       mkws.config.lang = lang;
     }
 
-    log("Locale language: " + (mkws.config.lang ? mkws.config.lang : "none"));
+    log("using language: " + (mkws.config.lang ? mkws.config.lang : "none"));
 
     if (mkws.config.query_width < 5 || mkws.config.query_width > 150) {
-      log("Reset query width: " + mkws.config.query_width);
+      log("reset query width to " + mkws.config.query_width);
       mkws.config.query_width = 50;
     }
 
     // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp"
     if (mkws.config.pazpar2_url.match(/^\/\//)) {
       mkws.config.pazpar2_url = document.location.protocol + mkws.config.pazpar2_url;
-      log("adjust protocol independent links: " + mkws.config.pazpar2_url);
+      log("adjusted protocol independent link to " + mkws.config.pazpar2_url);
     }
 
     if (mkws.config.responsive_design_width) {
@@ -545,12 +548,12 @@ mkws.pagerNext = function(tname) {
     makeWidgetsWithin(1, $(rootsel));
     var now = $.now();
 
-    log("Walking MKWS nodes took " + (now-then) + " ms");
+    log("walking MKWS nodes took " + (now-then) + " ms");
 
     /*
       for (var tName in mkws.teams) {
       var myTeam = mkws.teams[tName]
-      log("TEAM '" + tName + "' = " + myTeam + " ...");
+      log("team '" + tName + "' = " + myTeam + " ...");
       myTeam.visitWidgets(function(t, w) {
       log("  has widget of type '" + t + "': " + w);
       });
index b8780da..22aeb20 100644 (file)
@@ -6,7 +6,7 @@ function filterSet(team) {
   var that = {};
 
   that.toJSON = function() {
-    return $.toJSON(m_list);
+    return mkws.$.toJSON(m_list);
   };
 
   that.add = function(filter) {
@@ -45,9 +45,9 @@ function filterSet(team) {
     for (var i in m_list) {
       var filter = m_list[i];
       if (matchFn(filter)) {
-        m_team.log("removeMatching() removing filter " + $.toJSON(filter));
+        m_team.log("removeMatching: removing filter " + mkws.$.toJSON(filter));
       } else {
-        m_team.log("removeMatching() keeping filter " + $.toJSON(filter));
+        m_team.log("removeMatching: keeping filter " + mkws.$.toJSON(filter));
         newList.push(filter);
       }
     }
index 90e43e4..73bd406 100644 (file)
@@ -11,7 +11,7 @@
  */
 function _mkws_jquery_plugin($) {
   function debug(string) {
-    mkws.log("jquery.pazpar2: " + string);
+    mkws.log("jQuery.pazpar2: " + string);
   }
 
   function init_popup(obj) {
index 9a012d3..8523ec7 100644 (file)
@@ -83,12 +83,11 @@ function team($, teamName) {
   that.log = log;
 
 
-  log("start running MKWS");
+  log("making new widget team");
 
   m_sortOrder = m_config.sort_default;
   m_perpage = m_config.perpage_default;
 
-  log("Create main pz2 object");
   // create a parameters array and pass it to the pz2's constructor
   // then register the form submit event with the pz2.search function
   // autoInit is set to true on default
@@ -104,6 +103,7 @@ function team($, teamName) {
                     "showtime": 500,            //each timer (show, stat, term, bytarget) can be specified this way
                     "termlist": m_config.facets.join(',')
                   });
+  log("created main pz2 object");
 
   // pz2.js event handlers:
   function onInit() {
@@ -113,7 +113,7 @@ function team($, teamName) {
   }
 
   function onBytarget(data) {
-    log("target");
+    log("bytarget");
     queue("targets").publish(data);
   }
 
@@ -360,7 +360,7 @@ function team($, teamName) {
 
   function widgetNode(type) {
     var w = that.widget(type);
-    return w ? $(w.node) : undefined;
+    return w ? w.node : undefined;
   }
 
   function renderDetails(data, marker) {
@@ -411,10 +411,8 @@ function team($, teamName) {
   that.addWidget = function(w) {
     if (m_widgets[w.type] === undefined) {
       m_widgets[w.type] = [ w ];
-      log("Added '" + w.type + "' widget to team '" + m_teamName + "'");
     } else {
       m_widgets[w.type].push(w);
-      log("Added '" + w.type + "' widget #" + m_widgets[w.type].length + "' to team '" + m_teamName + "'");
     }
   }
 
index 02cce99..b1e0b1f 100644 (file)
@@ -2,6 +2,6 @@ mkws.registerWidgetType('Authname', function() {
   var that = this;
 
   this.team.queue("authenticated").subscribe(function(authName) {
-    $(that.node).html(authName);
+    that.node.html(authName);
   });
 });
index 22f016d..60ee37b 100644 (file)
@@ -2,11 +2,11 @@ mkws.registerWidgetType('Builder', function() {
   var that = this;
   var team = this.team;
 
-  this.button = $('<button/>', {
+  this.button = mkws.$('<button/>', {
     type: 'button',
     text: this.config.text || "Build!"
   });
-  $(this.node).append(this.button);
+  this.node.append(this.button);
   this.button.click(function() {
     var   query = team.widget('Query').value();
     var    sort = team.widget('Sort').value();
@@ -24,6 +24,6 @@ mkws.registerWidgetType('Builder', function() {
 mkws.registerWidgetType('ConsoleBuilder', function() {
   mkws.promotionFunction('Builder').call(this);
   this.callback = function(s) {
-    console.log("Generated widget: " + s);
+    console.log("generated widget: " + s);
   }
 });
index aa25653..a11e522 100644 (file)
@@ -29,7 +29,7 @@ mkws.registerWidgetType('Categories', function() {
         text.push("<option value='", id, "'>", name, "</option>");
       });
       text.push("</select>");
-      $(that.node).html(text.join(''));
+      that.node.html(text.join(''));
     });
   });
 });
index 828ac48..4ea6cd8 100644 (file)
@@ -2,6 +2,6 @@ mkws.registerWidgetType('Log', function() {
   var that = this;
 
   this.team.queue("log").subscribe(function(teamName, timestamp, message) {
-    $(that.node).append(teamName + ": " + timestamp + message + "<br/>");
+    that.node.append(teamName + ": " + timestamp + message + "<br/>");
   });
 });
index c3eac87..161f61f 100644 (file)
@@ -4,11 +4,12 @@
 
 
 mkws.registerWidgetType('Targets', function() {
+  if (!this.config.show_switch) return;
   var that = this;
   var M = mkws.M;
 
-  $(this.node).html('No information available yet.');
-  $(this.node).css("display", "none");
+  this.node.html('No information available yet.');
+  this.node.css("display", "none");
 
   this.team.queue("targets").subscribe(function(data) {
     var table ='<table><thead><tr>' +
@@ -28,7 +29,7 @@ mkws.registerWidgetType('Targets', function() {
     }
 
     table += '</tbody></table>';
-    $(that.node).html(table);
+    that.node.html(table);
   });
 });
 
@@ -38,9 +39,7 @@ mkws.registerWidgetType('Stat', function() {
   var M = mkws.M;
 
   this.team.queue("stat").subscribe(function(data) {
-    if (that.node.length === 0)  alert("huh?!");
-
-    $(that.node).html(' -- ' +
+    that.node.html(' -- ' +
                       '<span class="mkwsClientCount">' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '</span>' +
                       ' -- ' +
                       M('Retrieved records') + ': ' + data.records + '/' + data.hits);
@@ -53,7 +52,7 @@ mkws.registerWidgetType('Pager', function() {
   var M = mkws.M;
 
   this.team.queue("pager").subscribe(function(data) {
-    $(that.node).html(drawPager(data))
+    that.node.html(drawPager(data))
 
     function drawPager(data) {
       var teamName = that.team.name();
@@ -131,7 +130,7 @@ mkws.registerWidgetType('Records', function() {
           html.push(team.renderDetails(team.currentRecordData()));
       }
     }
-    $(that.node).html(html.join(''));
+    that.node.html(html.join(''));
 
     function renderSummary(hit) {
       var template = team.loadTemplate(that.config.template || "Summary");
@@ -167,7 +166,7 @@ mkws.registerWidgetType('Navi', function() {
         ');return false;">' + value + '</a>';
     });
 
-    $(that.node).html(text);
+    that.node.html(text);
   });
 });
 
@@ -178,8 +177,8 @@ mkws.registerWidgetType('Navi', function() {
 mkws.registerWidgetType('Sort', function() {
   var that = this;
 
-  $(this.node).change(function() {
-    that.team.set_sortOrder($(that.node).val());
+  this.node.change(function() {
+    that.team.set_sortOrder(that.node.val());
     if (that.team.submitted()) {
       that.team.reShow();
     }
@@ -191,8 +190,8 @@ mkws.registerWidgetType('Sort', function() {
 mkws.registerWidgetType('Perpage', function() {
   var that = this;
 
-  $(this.node).change(function() {
-    that.team.set_perpage($(that.node).val());
+  this.node.change(function() {
+    that.team.set_perpage(that.node.val());
     if (that.team.submitted()) {
       that.team.reShow();
     }
@@ -205,14 +204,15 @@ mkws.registerWidgetType('Done', function() {
   var that = this;
 
   this.team.queue("complete").subscribe(function(n) {
-    $(that.node).html("Search complete: found " + n + " records");
+    that.node.html("Search complete: found " + n + " records");
   });
 });
 
 
 mkws.registerWidgetType('Switch', function() {
+  if (!this.config.show_switch) return;
   var tname = this.team.name();
-  $(this.node).html('\
+  this.node.html('\
 <a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
 | \
 </span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
@@ -224,7 +224,7 @@ mkws.registerWidgetType('Search', function() {
   var tname = this.team.name();
   var M = mkws.M;
 
-  $(this.node).html('\
+  this.node.html('\
 <form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
   <input class="mkwsQuery mkwsTeam_' + tname + '" type="text" size="' + this.config.query_width + '" />\
   <input class="mkwsButton mkwsTeam_' + tname + '" type="submit" value="' + M('Search') + '" />\
@@ -234,7 +234,7 @@ mkws.registerWidgetType('Search', function() {
 
 mkws.registerWidgetType('SearchForm', function() {
   var team = this.team;
-  $(this.node).submit(function() {
+  this.node.submit(function() {
     var val = team.widget('Query').value();
     team.newSearch(val);
     return false;
@@ -245,7 +245,7 @@ mkws.registerWidgetType('SearchForm', function() {
 mkws.registerWidgetType('Results', function() {
   var tname = this.team.name();
 
-  $(this.node).html('\
+  this.node.html('\
 <table width="100%" border="0" cellpadding="6" cellspacing="0">\
   <tr>\
     <td class="mkwsTermlists-Container-wide mkwsTeam_' + tname + '" width="250" valign="top">\
@@ -283,13 +283,13 @@ mkws.registerWidgetType('Ranking', function() {
   }
   s += '</form>';
 
-  $(this.node).html(s);
+  this.node.html(s);
 
 
   function mkwsHtmlSort() {
     var order = that.team.sortOrder();
 
-    that.log("HTML sort, sortOrder = '" + order + "'");
+    that.log("making sort HTML, sortOrder = '" + order + "'");
     var sort_html = '<select class="mkwsSort mkwsTeam_' + tname + '">';
 
     for(var i = 0; i < that.config.sort_options.length; i++) {
@@ -311,7 +311,7 @@ mkws.registerWidgetType('Ranking', function() {
   function mkwsHtmlPerpage() {
     var perpage = that.team.perpage();
 
-    that.log("HTML perpage, perpage = " + perpage);
+    that.log("making perpage HTML, perpage = " + perpage);
     var perpage_html = '<select class="mkwsPerpage mkwsTeam_' + tname + '">';
 
     for(var i = 0; i < that.config.perpage_options.length; i++) {
@@ -355,7 +355,7 @@ mkws.registerWidgetType('Lang', function() {
   if (lang_options.length == 0 || toBeIncluded[lang_default])
     list.push(lang_default);
 
-  this.log("Language menu for: " + list.join(", "));
+  this.log("language menu: " + list.join(", "));
 
   /* the HTML part */
   var data = "";
@@ -371,7 +371,7 @@ mkws.registerWidgetType('Lang', function() {
     }
   }
 
-  $(this.node).html(data);
+  this.node.html(data);
   widget.hideWhenNarrow(this);
 
 
@@ -400,7 +400,7 @@ mkws.registerWidgetType('MOTD', function() {
   var container = this.team.widget('MOTDContainer');
   if (container) {
     // Move the MOTD from the provided element down into the container
-    $(this.node).appendTo(container.node);
+    this.node.appendTo(container.node);
   }
 });
 
index b282614..addfd94 100644 (file)
@@ -2,11 +2,11 @@ mkws.registerWidgetType('Termlists', function() {
   var that = this;
 
   // Initially hide the termlists; display when we get results
-  $(document).ready(function() {
-    $(that.node).hide();
+  mkws.$(document).ready(function() {
+    that.node.hide();
   });
   this.team.queue("termlists").subscribe(function(data) {
-    $(that.node).show();
+    that.node.show();
   });
 
   var acc = [];
@@ -15,7 +15,7 @@ mkws.registerWidgetType('Termlists', function() {
   for (var i = 0; i < facets.length; i++) {
     acc.push('<div class="mkwsFacet mkwsTeam_', this.team.name(), '" data-mkws-facet="', facets[i], '">', '</div>');
   }
-  $(this.node).html(acc.join(''));
+  this.node.html(acc.join(''));
 
   widget.autosearch(this);
 });
@@ -63,6 +63,6 @@ mkws.registerWidgetType('Facet', function() {
       acc.push('</div>');
     }
 
-    $(that.node).html(acc.join(''));
+    that.node.html(acc.join(''));
   });
 });
index 464d2b4..a0a5795 100644 (file)
@@ -9,7 +9,7 @@ function widget($, team, type, node) {
   var that = {
     team: team,
     type: type,
-    node: node,
+    node: $(node),
     config: mkws.objectInheritingFrom(team.config())
   };
 
@@ -44,10 +44,10 @@ function widget($, team, type, node) {
     } else if (a.name.match (/^data-mkws-/)) {
       var name = a.name.replace(/^data-mkws-/, '')
       that.config[name] = a.value;
-      log(node + ": set data-mkws attribute " + name + "='" + a.value + "'");
+      log(that + ": set data-mkws attribute " + name + "='" + a.value + "'");
     } else if (!ignoreAttrs[a.name]) {
       that.config[a.name] = a.value;
-      log(node + ": set regular attribute " + a.name + "='" + a.value + "'");
+      log(that + ": set regular attribute " + a.name + "='" + a.value + "'");
     }
   }
 
@@ -121,10 +121,10 @@ widget.autosearch = function(widget) {
 // Utility function for all widgets that want to hide in narrow windows
 widget.hideWhenNarrow = function(widget) {
   widget.team.queue("resize-narrow").subscribe(function(n) {
-    $(widget.node).hide();
+    widget.node.hide();
   });
   widget.team.queue("resize-wide").subscribe(function(n) {
-    $(widget.node).show();
+    widget.node.show();
   });
 };
 
index 21d0ea3..466d9de 100644 (file)
@@ -53,9 +53,9 @@ function init_jasmine_config() {
 
 var get_hit_counter = function () {
         // not yet here
-        if ($(".mkwsPager").length == 0) return -1;
+        if (mkws.$(".mkwsPager").length == 0) return -1;
 
-        var found = $(".mkwsPager").text();
+        var found = mkws.$(".mkwsPager").text();
         var re = /\([A-Za-z]+:\s+([0-9]+)\)/;
         re.exec(found);
         var hits = -1;
@@ -91,14 +91,14 @@ xdescribe("Check MOTD before search", function () {
     // Note that the testMOTD is a regular div, and uses #testMOTD,
     // since the automagic class-making does not apply to it.
     it("MOTD is hidden", function () {
-        expect($(".mkwsMOTD").length).toBe(1);
-        expect($("#testMOTD").length).toBe(1);
-        expect($("#testMOTD").text()).toMatch("^ *$");
+        expect(mkws.$(".mkwsMOTD").length).toBe(1);
+        expect(mkws.$("#testMOTD").length).toBe(1);
+        expect(mkws.$("#testMOTD").text()).toMatch("^ *$");
     });
 
     it("mkwsMOTDContainer has received the text", function () {
-        expect($(".mkwsMOTDContainer").length).toBe(1);
-        expect($(".mkwsMOTDContainer").text()).toMatch(/MOTD/);
+        expect(mkws.$(".mkwsMOTDContainer").length).toBe(1);
+        expect(mkws.$(".mkwsMOTDContainer").text()).toMatch(/MOTD/);
     });
 });
 
@@ -108,18 +108,18 @@ describe("Check pazpar2 search", function () {
     });
 
     it("validate HTML id's", function () {
-        expect($("input.mkwsQuery").length).toBe(1);
-        expect($("input.mkwsButton").length).toBe(1);
+        expect(mkws.$("input.mkwsQuery").length).toBe(1);
+        expect(mkws.$("input.mkwsButton").length).toBe(1);
 
-        expect($(".mkwsNext").length).not.toBe(1);
-        expect($(".mkwsPrev").length).not.toBe(1);
+        expect(mkws.$(".mkwsNext").length).not.toBe(1);
+        expect(mkws.$(".mkwsPrev").length).not.toBe(1);
     });
 
     it("run search query", function () {
         var search_query = jasmine_config.search_query; // short hit counter with some paging
-        $("input.mkwsQuery").val(search_query);
+        mkws.$("input.mkwsQuery").val(search_query);
         debug("set search query: " + search_query)
-        expect($("input.mkwsQuery").val()).toMatch("^" + search_query + "$");
+        expect(mkws.$("input.mkwsQuery").val()).toMatch("^" + search_query + "$");
 
         if (mkws.config.use_service_proxy) {
             // wait for service proxy auth
@@ -132,7 +132,7 @@ describe("Check pazpar2 search", function () {
 
         runs(function () {
             debug("Click on submit button");
-            $("input.mkwsButton").trigger("click");
+            mkws.$("input.mkwsButton").trigger("click");
         })
     });
 });
@@ -143,10 +143,10 @@ describe("Check MOTD after search", function () {
             return;
         }
 
-        expect($(".mkwsMOTD").length).toBe(1);
-        expect($(".mkwsMOTD").is(":hidden")).toBe(true);
-        debug("motd t=" + $(".mkwsMOTD").text());
-        debug("motd v=" + $(".mkwsMOTD").is(":visible"));
+        expect(mkws.$(".mkwsMOTD").length).toBe(1);
+        expect(mkws.$(".mkwsMOTD").is(":hidden")).toBe(true);
+        debug("motd t=" + mkws.$(".mkwsMOTD").text());
+        debug("motd v=" + mkws.$(".mkwsMOTD").is(":visible"));
     });
 });
 
@@ -159,17 +159,17 @@ describe("Check MOTD after search", function () {
 describe("Check pazpar2 navigation", function () {
     // Asynchronous part
     it("check running search next/prev", function () {
-        expect($(".mkwsPager").length).toBe(1);
+        expect(mkws.$(".mkwsPager").length).toBe(1);
 
         function my_click(id, time) {
             setTimeout(function () {
                 debug("trigger click on id: " + id);
-                $(id).trigger("click");
+                mkws.$(id).trigger("click");
             }, time * jasmine_config.second);
         }
 
         waitsFor(function () {
-            return $("div.mkwsPager div:nth-child(2) a").length >= 2 ? true : false;
+            return mkws.$("div.mkwsPager div:nth-child(2) a").length >= 2 ? true : false;
         }, "Expect next link 2", 10 * jasmine_config.second);
 
         runs(function () {
@@ -178,7 +178,7 @@ describe("Check pazpar2 navigation", function () {
         });
 
         waitsFor(function () {
-            return $("div.mkwsPager div:nth-child(2) a").length >= 3 ? true : false;
+            return mkws.$("div.mkwsPager div:nth-child(2) a").length >= 3 ? true : false;
         }, "Expect next link 3", 5 * jasmine_config.second);
 
         runs(function () {
@@ -202,7 +202,7 @@ describe("Check pazpar2 hit counter", function () {
 
         runs(function () {
             debug("mkws pager found records: '" + hits + "'");
-            expect($(".mkwsPager").length).toBe(1);
+            expect(mkws.$(".mkwsPager").length).toBe(1);
             expect(hits).toBeGreaterThan(expected_hits);
         });
     });
@@ -210,33 +210,33 @@ describe("Check pazpar2 hit counter", function () {
 
 describe("Check Termlist", function () {
     it("found Termlist", function () {
-        var termlist = $("div.mkwsTermlists");
+        var termlist = mkws.$("div.mkwsTermlists");
         debug("Termlist success: " + termlist.length);
         expect(termlist.length).toBe(1);
 
         waitsFor(function () {
-            return $("div.mkwsFacet[data-mkws-facet='xtargets']").length == 1 ? true : false;
+            return mkws.$("div.mkwsFacet[data-mkws-facet='xtargets']").length == 1 ? true : false;
         }, "check for facet sources", 4 * jasmine_config.second);
 
         // everything displayed?
         runs(function () {
-            var sources = $("div.mkwsFacet[data-mkws-facet='xtargets']");
+            var sources = mkws.$("div.mkwsFacet[data-mkws-facet='xtargets']");
             debug("Termlist sources success: " + sources.length);
             expect(sources.length).toBe(1);
 
-            var subjects = $("div.mkwsFacet[data-mkws-facet='subject']");
+            var subjects = mkws.$("div.mkwsFacet[data-mkws-facet='subject']");
             expect(subjects.length).toBe(1);
 
-            var authors = $("div.mkwsFacet[data-mkws-facet='author']");
+            var authors = mkws.$("div.mkwsFacet[data-mkws-facet='author']");
             expect(authors.length).toBe(1);
         });
 
         waitsFor(function () {
-            return $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm").length >= 2 ? true : false;
+            return mkws.$("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm").length >= 2 ? true : false;
         }, "At least one author link displayed", 4 * jasmine_config.second);
 
         runs(function () {
-            expect($("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm").length).toBeGreaterThan(1);
+            expect(mkws.$("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm").length).toBeGreaterThan(1);
         });
     });
 });
@@ -254,9 +254,9 @@ describe("Check Author Facets", function () {
         // do not click on author names without a comma, e.g.: "Joe Barbara"
         // because searching on such authors won't find anything.
         runs(function () {
-            var terms = $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm a");
+            var terms = mkws.$("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm a");
             for (var i = 0; i < terms.length; i++) {
-                var term = $(terms[i]).text();
+                var term = mkws.$(terms[i]).text();
                 if (term.match(/[0-9].+[0-9]/i) || !term.match(/,/)) {
                     debug("ignore author facet: " + term);
                     author_number++;
@@ -264,13 +264,13 @@ describe("Check Author Facets", function () {
                     break;
                 }
             }
-            if ($("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").text().length == 0) {
+            if (mkws.$("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").text().length == 0) {
                 debug("No good authors found. Not clicking on the bad ones");
                 return;
             }
 
-            debug("Clicking on author (" + author_number + ") " + $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").text());
-            $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").trigger("click");
+            debug("Clicking on author (" + author_number + ") " + mkws.$("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").text());
+            mkws.$("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").trigger("click");
         });
 
         waitsFor(function () {
@@ -288,13 +288,13 @@ describe("Check Author Facets", function () {
 describe("Check active clients author", function () {
     it("check for active clients after limited author search", function () {
         waitsFor(function () {
-            var clients = $("div.mkwsStat span.mkwsClientCount");
+            var clients = mkws.$("div.mkwsStat span.mkwsClientCount");
             // debug("clients: " + clients.text());
             return clients.length == 1 && clients.text().match("/[1-9]+[0-9]*$");
         }, "wait for Active clients: x/y", 5.5 * jasmine_config.second);
 
         runs(function () {
-            var clients = $("div.mkwsStat span.mkwsClientCount");
+            var clients = mkws.$("div.mkwsStat span.mkwsClientCount");
             debug("span.mkwsClientCount: " + clients.text());
             expect(clients.text()).toMatch("/[1-9]+[0-9]*$");
 
@@ -318,15 +318,15 @@ describe("Check Source Facets", function () {
 
         // wait for a visible source link in facets
         waitsFor(function () {
-            var terms = $(link);
+            var terms = mkws.$(link);
             return terms && terms.length > 0;
         }, "wait for source facets after author search", 5 * jasmine_config.second);
 
 
         runs(function () {
-            var terms = $(link);
+            var terms = mkws.$(link);
             for (var i = 0; i < terms.length; i++) {
-                var term = $(terms[i]).text();
+                var term = mkws.$(terms[i]).text();
                 debug("check for good source: " + term);
 
                 if (term.match(/wikipedia/i)) {
@@ -338,22 +338,22 @@ describe("Check Source Facets", function () {
             }
             debug("Source counter: " + terms.length + ", select: " + (source_number - 1));
 
-            if ($("div.mkwsFacet[data-mkws-facet='xtargets'] div.mkwsTerm:nth-child(" + source_number + ") a").text().length == 0) {
+            if (mkws.$("div.mkwsFacet[data-mkws-facet='xtargets'] div.mkwsTerm:nth-child(" + source_number + ") a").text().length == 0) {
                 debug("No good source found. Not clicking on the bad ones");
                 return;
             }
 
             debug("click on source link nth-child(): " + source_number);
-            $("div.mkwsFacet[data-mkws-facet='xtargets'] div.mkwsTerm:nth-child(" + source_number + ") a").trigger("click");
+            mkws.$("div.mkwsFacet[data-mkws-facet='xtargets'] div.mkwsTerm:nth-child(" + source_number + ") a").trigger("click");
 
-            $(".mkwsPager").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
+            mkws.$(".mkwsPager").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
                 waitcount++;
                 debug("DOM wait for stat: " + waitcount);
             });
         });
 
         waitsFor(function () {
-            if ($("div.mkwsNavi").length && $("div.mkwsNavi").text().match(/(Source|datenquelle|kilder): /i)) {
+            if (mkws.$("div.mkwsNavi").length && mkws.$("div.mkwsNavi").text().match(/(Source|datenquelle|kilder): /i)) {
                 return true;
             } else {
                 return false;
@@ -374,7 +374,7 @@ describe("Check Source Facets", function () {
             expect(hits_all_targets).not.toBeLessThan(hits_single_target);
             jasmine_status.source_click = 1;
 
-            $(".mkwsPager").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
+            mkws.$(".mkwsPager").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
         });
     });
 });
@@ -388,13 +388,13 @@ describe("Check record list", function () {
         }
 
         waitsFor(function () {
-            var clients = $("div.mkwsStat span.mkwsClientCount");
+            var clients = mkws.$("div.mkwsStat span.mkwsClientCount");
             //debug("clients: " + clients.text());
             return clients.length == 1 && clients.text().match("/1$");
         }, "wait for Active clients: x/1", 5 * jasmine_config.second);
 
         runs(function () {
-            var clients = $("div.mkwsStat span.mkwsClientCount");
+            var clients = mkws.$("div.mkwsStat span.mkwsClientCount");
             debug("span.mkwsClientCount: " + clients.text());
             expect(clients.text()).toMatch("/1$");
         });
@@ -405,11 +405,11 @@ describe("Check record list", function () {
 
         waitsFor(function () {
             // remove + insert node: must be at least 2
-            return $(linkaddr).length > 0;
+            return mkws.$(linkaddr).length > 0;
         }, "wait until we see a new record", 2.5 * jasmine_config.second);
 
         runs(function () {
-            expect($(linkaddr).length).toBeGreaterThan(0);
+            expect(mkws.$(linkaddr).length).toBeGreaterThan(0);
         });
     });
 });
@@ -417,20 +417,20 @@ describe("Check record list", function () {
 describe("Show record", function () {
     var record_number = 1; // the Nth record in hit list
     it("show record author", function () {
-        var click = $("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") a").trigger("click");
+        var click = mkws.$("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") a").trigger("click");
         debug("show record click is success: " + click.length);
         expect(click.length).toBe(1);
 
         // wait until the record pops up
         waitsFor(function () {
-            var show = $("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") > div.mkwsDetails");
-            //debug("poprecord: " + (show ? show.length : -1) + " " + $("div.mkwsRecords div.mkwsSummary").text());
+            var show = mkws.$("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") > div.mkwsDetails");
+            //debug("poprecord: " + (show ? show.length : -1) + " " + mkws.$("div.mkwsRecords div.mkwsSummary").text());
             return show != null && show.length ? true : false;
         }, "wait some miliseconds to show up a record", 2 * jasmine_config.second);
 
         runs(function () {
             debug("show record pop up");
-            expect($("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div")).not.toBe(null);
+            expect(mkws.$("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div")).not.toBe(null);
         });
     });
 
@@ -440,11 +440,11 @@ describe("Show record", function () {
             return;
         }
 
-        var urls = $("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div table tbody tr td a");
+        var urls = mkws.$("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div table tbody tr td a");
         debug("number of extracted URL from record: " + urls.length);
         // expect(urls.length).toBeGreaterThan(0); // LoC has records without links
         for (var i = 0; i < urls.length; i++) {
-            var url = $(urls[i]);
+            var url = mkws.$(urls[i]);
             debug("URL: " + url.attr('href') + " text: " + url.text());
 
             expect(url.attr('href')).not.toBe(null);
@@ -456,18 +456,18 @@ describe("Show record", function () {
 
 describe("Check switch menu Records/Targets", function () {
     it("check mkwsSwitch", function () {
-        expect($("div.mkwsSwitch").length).toBe(1);
+        expect(mkws.$("div.mkwsSwitch").length).toBe(1);
 
         // expect 2 clickable links
-        expect($("div.mkwsSwitch a").length).toBe(2);
+        expect(mkws.$("div.mkwsSwitch a").length).toBe(2);
     });
 
     it("switch to target view", function () {
-        $("div.mkwsSwitch").children('a').eq(1).trigger("click");
+        mkws.$("div.mkwsSwitch").children('a').eq(1).trigger("click");
 
         // now the target table must be visible
-        expect($("div.mkwsTargets").is(":visible")).toBe(true);
-        expect($("div.mkwsRecords").is(":visible")).toBe(false);
+        expect(mkws.$("div.mkwsTargets").is(":visible")).toBe(true);
+        expect(mkws.$("div.mkwsRecords").is(":visible")).toBe(false);
 
         // wait a half second, to show the target view
         var time = (new Date).getTime();
@@ -477,16 +477,16 @@ describe("Check switch menu Records/Targets", function () {
 
         // look for table header
         runs(function () {
-            expect($("div.mkwsTargets").html()).toMatch(/Target ID/);
+            expect(mkws.$("div.mkwsTargets").html()).toMatch(/Target ID/);
         });
     });
 
     it("switch back to record view", function () {
-        $("div.mkwsSwitch").children('a').eq(0).trigger("click");
+        mkws.$("div.mkwsSwitch").children('a').eq(0).trigger("click");
 
         // now the target table must be visible
-        expect($("div.mkwsTargets").is(":visible")).toBe(false);
-        expect($("div.mkwsRecords").is(":visible")).toBe(true);
+        expect(mkws.$("div.mkwsTargets").is(":visible")).toBe(false);
+        expect(mkws.$("div.mkwsRecords").is(":visible")).toBe(true);
     });
 });
 
@@ -504,7 +504,7 @@ describe("Check status client counter", function () {
         }
 
         waitsFor(function () {
-            var clients = $("div.mkwsStat span.mkwsClientCount");
+            var clients = mkws.$("div.mkwsStat span.mkwsClientCount");
             debug("clients: " + clients.text());
             if (clients.length == 1 && clients.text().match("0/1$")) {
                 return true;
@@ -514,7 +514,7 @@ describe("Check status client counter", function () {
         }, "wait for Active clients: 0/1", 4 * jasmine_config.second);
 
         runs(function () {
-            var clients = $("div.mkwsStat span.mkwsClientCount");
+            var clients = mkws.$("div.mkwsStat span.mkwsClientCount");
             debug("span.mkwsClientCount: " + clients.text());
             expect(clients.text()).toMatch("0/1$");
         });