"use strict"; // HTML5: disable for debug_level >= 2
-// Set up namespace and some state.
+// Set up global mkws object. Contains a hash of session objects,
+// indexed by windowid.
var mkws = {
- sort: 'relevance',
- authenticated: false,
- filters: []
+ sessions: {}
};
// Define empty mkws_config for simple applications that don't define it.
}
// wrapper for jQuery lib
-function _mkws($) {
- // if (console && console.log) console.log("run _mkws()");
+function _make_mkws_team($) {
+ // if (console && console.log) console.log("run _make_mkws_team()");
// call this function only once
- if (mkws.init) return;
+ if (mkws.init) {
+ alert("_make_mkws_team() called twice: how did that happen?!");
+ return;
+ }
+
+mkws.sort = 'relevance';
+mkws.authenticated = false;
+mkws.filters = [];
mkws.locale_lang = {
"de": {
"Date": "Datum",
"Subject": "Schlagwort",
"Location": "Ort",
- // ### to add: Records, Targets
+ "Records": "Datensätze",
+ "Targets": "Datenbanken",
"dummy": "dummy"
},
"Date": "Dato",
"Subject": "Emneord",
"Location": "Lokation",
- // ### to add: Records, Targets
+ "Records": "Poster",
+ "Targets": "Baser",
"dummy": "dummy"
}
});
+Handlebars.registerHelper('translate', function(s) {
+ debug("translating '" + s + "'");
+ return M(s);
+});
+
+
// We need {{attr '@name'}} because Handlebars can't parse {{@name}}
Handlebars.registerHelper('attr', function(attrName) {
return this[attrName];
}
}
+
mkws.sort = mkws_config.sort_default;
debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to mkws.sort");
var SubjectMax = 10;
var AuthorMax = 10;
+if (!isNaN(parseInt(mkws_config.perpage_default))) {
+ recPerPage = parseInt(mkws_config.perpage_default);
+}
+
//
// pz2.js event handlers:
//
}
}
- debug("triggerSearch(" + mkws.query + "): filters = " + $.toJSON(mkws.filters) + ", pp2filter = " + pp2filter + ", pp2limit = " + pp2limit);
- my_paz.search(mkws.query, recPerPage, mkws.sort, pp2filter, undefined, { limit: pp2limit });
+ var params = {};
+ if (pp2limit) {
+ params.limit = pp2limit;
+ }
+ if (windowid) {
+ params.windowid = windowid;
+ }
+ debug("triggerSearch(" + mkws.query + "): filters = " + $.toJSON(mkws.filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
+
+ my_paz.search(mkws.query, recPerPage, mkws.sort, pp2filter, undefined, params);
}
function loadSelect ()
return '\
<table>\
<tr>\
- <th>Title</th>\
+ <th>{{translate "Title"}}</th>\
<td>\
{{md-title}}\
{{#if md-title-remainder}}\
</tr>\
{{#if md-date}}\
<tr>\
- <th>Date</th>\
+ <th>{{translate "Date"}}</th>\
<td>{{md-date}}</td>\
</tr>\
{{/if}}\
{{#if md-author}}\
<tr>\
- <th>Author</th>\
+ <th>{{translate "Author"}}</th>\
<td>{{md-author}}</td>\
</tr>\
{{/if}}\
{{#if md-electronic-url}}\
<tr>\
- <th>URL</th>\
+ <th>{{translate "URL"}}</th>\
<td>\
{{#each md-electronic-url}}\
<a href="{{this}}">{{this}}</a><br/>\
{{/if}}\
{{#if-any location having="md-subject"}}\
<tr>\
- <th>Subject</th>\
+ <th>{{translate "Subject"}}</th>\
<td>\
{{#first location having="md-subject"}}\
{{#if md-subject}}\
</tr>\
{{/if-any}}\
<tr>\
- <th>Locations</th>\
+ <th>{{translate "Locations"}}</th>\
<td>\
{{#commaList location}}\
{{attr "@name"}}{{/commaList}}\
debug("Run service proxy auth URL: " + auth_url);
if (!auth_domain) {
- auth_domain = pp2_url.replace(/^http:\/\/(.*?)\/.*/, '$1');
+ auth_domain = pp2_url.replace(/^https?:\/\/(.*?)\/.*/, '$1');
debug("guessed auth_domain '" + auth_domain + "' from pp2_url '" + pp2_url + "'");
}
* implement jQuery plugin $.pazpar2({})
*/
function _mkws_jquery_plugin ($) {
- // delayed debug, internal variables are set after dom ready
+ var debug_level = 1;
+
function debug (string) {
- setTimeout(function() { mkws.debug_function(string); }, 500);
+ if (!debug_level)
+ return;
+
+ if (typeof console === "undefined" || typeof console.log === "undefined")
+ return;
+
+ console.log("jquery.pazpar2: " + string);
}
function init_popup(obj) {
// make sure that jquery-ui was loaded afte jQuery core lib, e.g.:
// <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
if (!$.ui) {
- debug("Error: jquery-ui.js is missing, did you included it after jquery core in the HTML file?");
+ debug("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?");
return;
}
});
};
-// wrapper to call _mkws after page load
+// wrapper to call _make_mkws_team() after page load
(function (j) {
// enable before page load, so we could call it before mkws() runs
_mkws_jquery_plugin(j);
$(document).ready(function() {
// if (console && console.log) console.log("on load ready");
- _mkws(j);
+ _make_mkws_team(j);
});
})(jQuery);