From: Wolfram Schneider Date: Wed, 28 Aug 2013 15:23:19 +0000 (+0200) Subject: refactor to use single object mkws, part of jQuery rewrite MKWS-24 X-Git-Tag: 0.9.1~202^2~37 X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=commitdiff_plain;h=8259da8a123505e6e13532297ed87e7ceecb4f3b;p=mkws-moved-to-github.git refactor to use single object mkws, part of jQuery rewrite MKWS-24 --- diff --git a/test/spec/mkws-config.js b/test/spec/mkws-config.js index 8cf22e2..f005ad8 100644 --- a/test/spec/mkws-config.js +++ b/test/spec/mkws-config.js @@ -31,11 +31,11 @@ describe("Check mkws_config object", function () { describe("Check pazpar2 config", function () { it("pazpar2path is a path or an full URL", function () { - expect(pazpar2path).toMatch(/^(\/|http:\/\/)/) + expect(mkws.pazpar2path).toMatch(/^(\/|http:\/\/)/) }); it("usesessions false", function () { - expect(usesessions).toBe(false); + expect(mkws.usesessions).toBe(false); }); it("my_paz is defined", function () { diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index b0d6715..5db8b45 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -3,6 +3,15 @@ "use strict"; // HTML5: disable for debug >= 2 +// Set up namespace and some state. +var mkws = {}; + +if (!mkws_config) + var mkws_config = {}; // for the guys who forgot to define mkws_config... + +// Wrapper for jQuery +(function ($) { + /* * global config object: mkws_config * @@ -10,23 +19,14 @@ * including this JS file */ -// Set up namespace and some state. -var mkws = {}; - if (typeof mkws_config.use_service_proxy === 'undefined') mkws_config.use_service_proxy = true; var pazpar2_url = mkws_config.pazpar2_url ? mkws_config.pazpar2_url : "/pazpar2/search.pz2"; var service_proxy_url = mkws_config.service_proxy_url ? mkws_config.service_proxy_url : "http://mkws.indexdata.com/service-proxy/"; -var pazpar2path = mkws_config.use_service_proxy ? service_proxy_url : pazpar2_url; -var usesessions = mkws_config.use_service_proxy ? false : true; - -// Wrapper for jQuery -(function ($) { - -if (!mkws_config) - var mkws_config = {}; // for the guys who forgot to define mkws_config... +mkws.pazpar2path = mkws_config.use_service_proxy ? service_proxy_url : pazpar2_url; +mkws.usesessions = mkws_config.use_service_proxy ? false : true; mkws.locale_lang = { "de": { @@ -112,13 +112,13 @@ for (var key in mkws_config) { // autoInit is set to true on default var my_paz = new pz2( { "onshow": my_onshow, "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way - "pazpar2path": pazpar2path, + "pazpar2path": mkws.pazpar2path, "oninit": my_oninit, "onstat": my_onstat, "onterm": my_onterm, "termlist": "xtargets,subject,author", "onbytarget": my_onbytarget, - "usesessions" : usesessions, + "usesessions" : mkws.usesessions, "showResponseType": '', // or "json" (for debugging?) "onrecord": my_onrecord } );