From a4b8050d80ad80f5ca58e27dce7c98c451b6a2dd Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 8 May 2014 13:03:15 +0100 Subject: [PATCH] No separate tree-walk to create teams: now they are made as needed during the walk to create widgets. --- src/mkws-core.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/mkws-core.js b/src/mkws-core.js index 87070f8..4c9db87 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -430,8 +430,13 @@ mkws.pagerNext = function(tname) { function makeWidgetsWithin(level, node) { node.find('[class^="mkws"],[class*=" mkws"]').each(function() { handleNodeWithTeam(this, function(tname, type) { - var oldHTML = this.innerHTML; var myTeam = mkws.teams[tname]; + if (!myTeam) { + myTeam = mkws.teams[tname] = team(j, tname); + log("Made MKWS team '" + tname + "'"); + } + + var oldHTML = this.innerHTML; var myWidget = widget(j, myTeam, type, this); myTeam.addWidget(myWidget); var newHTML = this.innerHTML; @@ -508,21 +513,10 @@ mkws.pagerNext = function(tname) { } } - // Find all nodes with an MKWS class, and determine their team from - // the mkwsTeam_* class. Make all team objects. var then = $.now(); - $('[class^="mkws"],[class*=" mkws"]').each(function() { - handleNodeWithTeam(this, function(tname, type) { - if (!mkws.teams[tname]) { - mkws.teams[tname] = team(j, tname); - log("Made MKWS team '" + tname + "'"); - } - }); - }); - makeWidgetsWithin(1, $(':root')); - var now = $.now(); + log("Walking MKWS nodes took " + (now-then) + " ms"); /* -- 1.7.10.4