- // For all MKWS-classed nodes that don't have a team
- // specified, set the team to AUTO.
- $('[class^="mkws"],[class*=" mkws"]').each(function () {
- if (!this.className.match(/mkwsTeam_/)) {
- log("adding AUTO team to node with class '" + this.className + "'");
- $(this).addClass('mkwsTeam_AUTO');
- }
- });
-
- // Find all nodes with an MKWS class, and determine their team from
- // the mkwsTeam_* class. Make all team objects.
- var then = $.now();
- $('[class^="mkws"],[class*=" mkws"]').each(function () {
- handleNodeWithTeam(this, function(tname, type) {
- if (!mkws.teams[tname]) {
- mkws.teams[tname] = team(j, tname);
- log("Made MKWS team '" + tname + "'");
- }
- });
- });
- // Second pass: make the individual widget objects. This has
- // to be done separately, and after the team-creation, since
- // that sometimes makes new widget nodes (e.g. creating
- // mkwsTermlists inside mkwsResults.
- $('[class^="mkws"],[class*=" mkws"]').each(function () {
- handleNodeWithTeam(this, function(tname, type) {
- var myTeam = mkws.teams[tname];
- var myWidget = widget(j, myTeam, type, this);
- });
- });
- var now = $.now();
- log("Walking MKWS nodes took " + (now-then) + " ms");
-
- if (mkws_config.use_service_proxy) {
- authenticateSession(mkws_config.service_proxy_auth,
- mkws_config.service_proxy_auth_domain,
- mkws_config.pazpar2_url);
- } else {
- // raw pp2
- runAutoSearches();
+ if (mkws.config.query_width < 5 || mkws.config.query_width > 150) {
+ log("Reset query width: " + 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);
+ }
+
+ if (mkws.config.responsive_design_width) {
+ // Responsive web design - change layout on the fly based on
+ // current screen width. Required for mobile devices.
+ $(window).resize(resizePage);
+ // initial check after page load
+ $(document).ready(resizePage);
+ }
+
+ // Backwards compatibility: set new magic class names on any
+ // elements that have the old magic IDs.
+ var ids = [ "Switch", "Lang", "Search", "Pager", "Navi",
+ "Results", "Records", "Targets", "Ranking",
+ "Termlists", "Stat", "MOTD" ];
+ for (var i = 0; i < ids.length; i++) {
+ var id = 'mkws' + ids[i];
+ var node = $('#' + id);
+ if (node.attr('id')) {
+ node.addClass(id);
+ log("added magic class to '" + node.attr('id') + "'");
+ }
+ }
+
+ // Find all nodes with an MKWS class, and determine their team from
+ // the mkwsTeam_* class. Make all team objects.
+ var then = $.now();
+ $('[class^="mkws"],[class*=" mkws"]').each(function() {
+ handleNodeWithTeam(this, function(tname, type) {
+ if (!mkws.teams[tname]) {
+ mkws.teams[tname] = team(j, tname);
+ log("Made MKWS team '" + tname + "'");