X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=11a48894406c83006dd8af6188d8f68c75f54362;hb=fea2b711c389ba5f31aed757622fe268b7084768;hp=01f82c80e6b2c3a5a0b49535886086447e81f188;hpb=6048ca4e831ca2b9153ba1f363c76f745db3b0c3;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index 01f82c8..11a4889 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -144,13 +144,25 @@ mkws.setMkwsConfig = function(overrides) { dummy: "dummy" }; - mkws.config = Object.create(config_default); + mkws.config = mkws.objectInheritingFrom(config_default); for (var k in overrides) { mkws.config[k] = overrides[k]; } }; +// This code is from Douglas Crockford's article "Prototypal Inheritance in JavaScript" +// http://javascript.crockford.com/prototypal.html +// mkws.objectInheritingFrom behaves the same as Object.create, +// but since the latter is not available in IE8 we can't use it. +// +mkws.objectInheritingFrom = function(o) { + function F() {} + F.prototype = o; + return new F(); +} + + // The following functions are dispatchers for team methods that // are called from the UI using a team-name rather than implicit // context. @@ -170,6 +182,10 @@ mkws.limitQuery = function(tname, field, value) { mkws.teams[tname].limitQuery(field, value); }; +mkws.limitCategory = function(tname, id) { + mkws.teams[tname].limitCategory(id); +}; + mkws.delimitTarget = function(tname, id) { mkws.teams[tname].delimitTarget(id); }; @@ -217,6 +233,8 @@ mkws.pagerNext = function(tname) { type = cname.replace(/^mkws/, ''); } } + + if (!teamName) teamName = "AUTO"; callback.call(node, teamName, type); } @@ -285,8 +303,10 @@ mkws.pagerNext = function(tname) { log("Service proxy auth successfully done"); mkws.authenticated = true; var authName = $(data).find("displayName").text(); + // You'd think there would be a better way to do this: + var realm = $(data).find("realm:not(realmAttributes realm)").text(); for (var teamName in mkws.teams) { - mkws.teams[teamName].queue("authenticated").publish(authName); + mkws.teams[teamName].queue("authenticated").publish(authName, realm); } runAutoSearches(); @@ -357,15 +377,6 @@ mkws.pagerNext = function(tname) { } } - // 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(); @@ -385,11 +396,22 @@ mkws.pagerNext = function(tname) { handleNodeWithTeam(this, function(tname, type) { var myTeam = mkws.teams[tname]; var myWidget = widget(j, myTeam, type, this); + myTeam.addWidget(myWidget); }); }); var now = $.now(); log("Walking MKWS nodes took " + (now-then) + " ms"); +// for (var tName in mkws.teams) { +// var myTeam = mkws.teams[tName] +// var types = myTeam.widgetTypes(); +// log("TEAM '" + tName + "' = " + myTeam + " has widget types " + types); +// for (var i = 0; i < types.length; i++) { +// var type = types[i]; +// log(" has widget of type '" + type + "': " + myTeam.widget(type)); +// } +// } + if (mkws.config.use_service_proxy) { authenticateSession(mkws.config.service_proxy_auth, mkws.config.service_proxy_auth_domain,