From: Mike Taylor Date: Tue, 15 Apr 2014 17:00:44 +0000 (+0100) Subject: Add function widgetNode, a simpler and more efficient alternative to X-Git-Tag: 1.0.0~939 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=b682bc773466148ddeb0ee88be0177702612da6b;p=mkws-moved-to-github.git Add function widgetNode, a simpler and more efficient alternative to findnode for most though not all purposes. widgetNode('Records') is equivalent to findnode('.mkwsRecords') but works by reference to the team's registered set of widgets. This is presently used in just one place, as proof of concept. Many more to follow, so that uses of findnode should become very rare. --- diff --git a/src/mkws-team.js b/src/mkws-team.js index 0ddc962..126f534 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -332,7 +332,7 @@ function team($, teamName) { // switching view between targets and records function switchView(view) { - var targets = findnode('.mkwsTargets'); + var targets = widgetNode('Targets'); var results = findnode('.mkwsResults,.mkwsRecords'); var blanket = findnode('.mkwsBlanket'); var motd = findnode('.mkwsMOTD'); @@ -620,6 +620,13 @@ function team($, teamName) { that.findnode = findnode; + // This much simpler and more efficient function should be usable + // in place of most uses of findnode. + function widgetNode(type) { + var w = that.widget(type); + return w ? $(w.node) : undefined; + } + function renderDetails(data, marker) { var template = loadTemplate("Record"); var details = template(data);