X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=7df143ab0957dd76a566aadd6bcd665f64663000;hb=428b73f9bb4591271adcb81062ae611231450091;hp=b30b38007c43814a1e51a2f2184732441b0896bc;hpb=857d9397ed4c8bee8e96747e4619297bcaff9c87;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index b30b380..7df143a 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -14,6 +14,8 @@ var mkws = { log_level: 1, // Will be overridden from mkws_config, but // initial value allows jQuery popup to use logging. teams: {}, + widgetType2function: {}, + locale_lang: { "de": { "Authors": "Autoren", @@ -84,7 +86,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; @@ -100,10 +102,20 @@ if (mkws_config == null || typeof mkws_config != 'object') { } console.log(string); } - var log = mkws.log; + mkws.log = log; + + + mkws.registerWidgetType = function(name, fn) { + mkws.widgetType2function[name] = fn; + log("registered widget-type '" + name + "'"); + } + + mkws.promotionFunction = function(name) { + return mkws.widgetType2function[name]; + } - 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) { @@ -161,6 +173,10 @@ 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. Apart from mkws.log, they are the ONLY public UI to + // this module. mkws.switchView = function(tname, view) { mkws.teams[tname].switchView(view); } @@ -272,7 +288,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; } @@ -293,7 +309,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) { @@ -353,7 +368,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 + "'"); @@ -365,7 +380,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); });