From: Mike Taylor Date: Fri, 21 Mar 2014 16:34:54 +0000 (+0000) Subject: Simplify a lot of code that unnecessarily checks that a jQuery X-Git-Tag: 1.0.0~1281 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=eefc90ceb608fec8b276e06b0218f1e717854159;p=mkws-moved-to-github.git Simplify a lot of code that unnecessarily checks that a jQuery node-set is non-empty before doing something with it. Of course, doing anything to an empty node-set no-ops anyway. --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index edd44cb..1b45c79 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -803,8 +803,7 @@ function team($, teamName) { // .mkwsPager // .mkwsNavi // .mkwsRecords - if (findnode(".mkwsResults").length) { - findnode(".mkwsResults").html('\ + findnode(".mkwsResults").html('\ \ \ \ \
\ @@ -823,42 +822,29 @@ function team($, teamName) {
'); - } - var node = findnode(".mkwsRanking"); - if (node.length) { - var ranking_data = '
'; - if (mkws_config.show_sort) { - ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' '; - } - if (mkws_config.show_perpage) { - ranking_data += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.'; - } - ranking_data += '
'; - - node.html(ranking_data); + var ranking_data = '
'; + if (mkws_config.show_sort) { + ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' '; + } + if (mkws_config.show_perpage) { + ranking_data += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.'; } + ranking_data += '
'; + findnode(".mkwsRanking").html(ranking_data); mkwsHtmlSwitch(); - var node; - node = findnode('.mkwsSearchForm'); - if (node.length) - node.submit(onFormSubmitEventHandler); - node = findnode('.mkwsSort'); - if (node.length) - node.change(onSortChange); - node = findnode('.mkwsPerpage'); - if (node.length) - node.change(onPerpageChange); + findnode('.mkwsSearchForm').submit(onFormSubmitEventHandler); + findnode('.mkwsSort').change(onSortChange); + findnode('.mkwsPerpage').change(onPerpageChange); // on first page, hide the termlist $(document).ready(function() { findnode(".mkwsTermlists").hide(); }); - var motd = findnode(".mkwsMOTD"); var container = findnode(".mkwsMOTDContainer"); - if (motd.length && container.length) { + if (container.length) { // Move the MOTD from the provided element down into the container - motd.appendTo(container); + findnode(".mkwsMOTD").appendTo(container); } }