From: Mike Taylor Date: Fri, 28 Feb 2014 10:30:50 +0000 (+0000) Subject: handle_node_with_team() now passes widget-type as well as class to callback. X-Git-Tag: 1.0.0~1384^2~9 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=6085e5b0540822d0901ed3378582f2f80df5127c;p=mkws-moved-to-github.git handle_node_with_team() now passes widget-type as well as class to callback. widget() factory method accepts `type' argument. widget() factory method logs object creation. --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 7c11d11..bcd33db 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -172,13 +172,15 @@ if (mkws_config == null || typeof mkws_config != 'object') { // Factory function for widget objects. -function widget($, team, node) { +function widget($, team, type, node) { var that = { team: team, + type: type, node: node }; - // ### More to do here, surely + // ### More to do here, surely: e.g. wiring into the team + mkws.debug("made widget(team=" + team + ", type=" + type + ", node=" + node); return that; } @@ -1240,14 +1242,17 @@ function team($, teamName) { mkws.handle_node_with_team = function(node, callback) { var classes = node.className; var list = classes.split(/\s+/) - var tname; + var tname, type; + for (var i = 0; i < list.length; i++) { var cname = list[i]; if (cname.match(/^mkwsTeam_/)) { tname = cname.replace(/^mkwsTeam_/, ''); + } else if (cname.match(/^mkws/)) { + type = cname.replace(/^mkws/, ''); } } - callback.call(this, tname); + callback.call(this, tname, type); } @@ -1441,13 +1446,13 @@ function team($, teamName) { // the mkwsTeam_* class. Make all team objects. var then = $.now(); $('[class^="mkws"],[class*=" mkws"]').each(function () { - mkws.handle_node_with_team(this, function(tname) { + mkws.handle_node_with_team(this, function(tname, type) { if (!mkws.teams[tname]) { mkws.teams[tname] = team(j, tname); debug("Made MKWS team '" + tname + "'"); } - var myTeam = mkws.teams[tname] - var myWidget = widget(j, myTeam, this) + var myTeam = mkws.teams[tname]; + var myWidget = widget(j, myTeam, type, this); }); }); var now = $.now();