X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=e353e6cea7b43e2c3fd6b628dcd9ff0b96dce480;hb=867531e90782b1af6324d9b36449c0e33a2ccced;hp=4870c7c1e4ed23fe1dfe5ac82cb80bfbbcf9925c;hpb=c1e819f7760602c6638547dadcb371f512e3cd0c;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index 4870c7c..e353e6c 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -13,7 +13,6 @@ var mkws = { authenticated: false, log_level: 1, // Will be overridden from mkws_config, but // initial value allows jQuery popup to use logging. - paz: undefined, // will be set up during initialisation teams: {}, locale_lang: { "de": { @@ -85,7 +84,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { // wrapper to call team() after page load (function (j) { - mkws.log = function (string) { + function log(string) { if (!mkws.log_level) return; @@ -101,10 +100,10 @@ if (mkws_config == null || typeof mkws_config != 'object') { } console.log(string); } - var log = mkws.log; + mkws.log = log; - mkws.handleNodeWithTeam = function(node, callback) { + function handleNodeWithTeam(node, callback) { // First branch for DOM objects; second branch for jQuery objects var classes = node.className || node.attr('class'); if (!classes) { @@ -130,7 +129,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { } - mkws.resizePage = function () { + function resizePage() { var list = ["mkwsSwitch", "mkwsLang"]; var width = mkws_config.responsive_design_width; @@ -162,6 +161,9 @@ if (mkws_config == null || typeof mkws_config != 'object') { }; + // The following functions are dispatchers for team methods that + // are called from the UI using a team-name rather than implicit + // context. mkws.switchView = function(tname, view) { mkws.teams[tname].switchView(view); } @@ -199,97 +201,6 @@ if (mkws_config == null || typeof mkws_config != 'object') { } - // This function is taken from a StackOverflow answer - // http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144 - mkws.getParameterByName = function(name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); - return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); - } - - - mkws.defaultTemplate = function(name) - { - if (name === 'Record') { - return '\ -\ - \ - \ - \ - \ - {{#if md-date}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if md-author}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if md-electronic-url}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if-any location having="md-subject"}}\ - \ - \ - \ - \ - {{/if-any}}\ - \ - \ - \ - \ -
{{translate "Title"}}\ - {{md-title}}\ - {{#if md-title-remainder}}\ - ({{md-title-remainder}})\ - {{/if}}\ - {{#if md-title-responsibility}}\ - {{md-title-responsibility}}\ - {{/if}}\ -
{{translate "Date"}}{{md-date}}
{{translate "Author"}}{{md-author}}
{{translate "Links"}}\ - {{#each md-electronic-url}}\ - Link{{index1}}\ - {{/each}}\ -
{{translate "Subject"}}\ - {{#first location having="md-subject"}}\ - {{#if md-subject}}\ - {{#commaList md-subject}}\ - {{this}}{{/commaList}}\ - {{/if}}\ - {{/first}}\ -
{{translate "Locations"}}\ - {{#commaList location}}\ - {{attr "@name"}}{{/commaList}}\ -
\ -'; - } else if (name === "Summary") { - return '\ -\ - {{md-title}}\ -\ -{{#if md-title-remainder}}\ - {{md-title-remainder}}\ -{{/if}}\ -{{#if md-title-responsibility}}\ - {{md-title-responsibility}}\ -{{/if}}\ -'; - } - - var s = "There is no default '" + name +"' template!"; - alert(s); - return s; - } - - function defaultMkwsConfig() { /* default mkws config */ var config_default = { @@ -364,7 +275,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { } var status = $(data).find("status"); if (status.text() != "OK") { - alert("service proxy auth repsonse status: " + status.text() + ", give up!"); + alert("service proxy auth response status: " + status.text() + ", give up!"); return; } @@ -385,7 +296,6 @@ if (mkws_config == null || typeof mkws_config != 'object') { $(document).ready(function() { - log("on load ready"); defaultMkwsConfig(); if (mkws_config.query_width < 5 || mkws_config.query_width > 150) { @@ -407,9 +317,9 @@ if (mkws_config == null || typeof mkws_config != 'object') { 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(function(e) { mkws.resizePage() }); + $(window).resize(resizePage); // initial check after page load - $(document).ready(function() { mkws.resizePage() }); + $(document).ready(resizePage); } // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp" @@ -445,7 +355,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { // the mkwsTeam_* class. Make all team objects. var then = $.now(); $('[class^="mkws"],[class*=" mkws"]').each(function () { - mkws.handleNodeWithTeam(this, function(tname, type) { + handleNodeWithTeam(this, function(tname, type) { if (!mkws.teams[tname]) { mkws.teams[tname] = team(j, tname); log("Made MKWS team '" + tname + "'"); @@ -457,7 +367,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { // that sometimes makes new widget nodes (e.g. creating // mkwsTermlists inside mkwsResults. $('[class^="mkws"],[class*=" mkws"]').each(function () { - mkws.handleNodeWithTeam(this, function(tname, type) { + handleNodeWithTeam(this, function(tname, type) { var myTeam = mkws.teams[tname]; var myWidget = widget(j, myTeam, type, this); });