From: Mike Taylor Date: Fri, 28 Feb 2014 16:21:12 +0000 (+0000) Subject: findnode() correctly handles selectors with commas ("or"). X-Git-Tag: 1.0.0~1373 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=912f0c2e3809d91dbbc3872c93367ef178e96965;p=mkws-moved-to-github.git findnode() correctly handles selectors with commas ("or"). It is now used in the case where we have such a thing. --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 710e47f..177aa98 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -275,9 +275,17 @@ function team($, teamName) { // Finds the node of the specified class within the current team + // Multiple OR-clauses separated by commas are handled + // More complex cases may not work + // function findnode(selector, teamName) { teamName = teamName || m_teamName; - return $(selector + '.mkwsTeam_' + teamName); + + selector = selector.split(',').map(function(s) { + return s + '.mkwsTeam_' + teamName; + }).join(','); + + return $(selector); } @@ -752,8 +760,7 @@ function team($, teamName) { // switching view between targets and records that.switchView = function(view) { var targets = findnode('.mkwsTargets'); - // ### Fix next line to use findnode() - var results = $('.mkwsResults.mkwsTeam_' + m_teamName + ',.mkwsRecords.mkwsTeam_' + m_teamName); + var results = findnode('.mkwsResults,.mkwsRecords'); var blanket = findnode('.mkwsBlanket'); var motd = findnode('.mkwsMOTD');