diff --git a/lib/client/dom.js b/lib/client/dom.js index 1a5001f1..b2c83d2b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1193,9 +1193,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; function selectByPattern(msg, files) { - var allMsg = 'Specify file type for ' + msg + ' selection', + var n, + allMsg = 'Specify file type for ' + msg + ' selection', i = 0, - n = files && files.length, arr = [], type, matches = 0, @@ -1219,38 +1219,28 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; type = Util.replaceStr(type, '?', '.?\\'); type += '$'; /* search to end of line */ - do { - if (shouldSel) - current = files[i++]; - else - /* selected files will decrement in - * they own way - */ - current = files[i]; - - if (current) { - name = DOM.getCurrentName(current); + n = files && files.length; + for (i = 0; i < n; i++) { + current = files[i]; + name = DOM.getCurrentName(current); - if (name !== '..') { - isMatch = name.match(new RegExp(type)); + if (name !== '..') { + isMatch = name.match(new RegExp(type)); + + if (isMatch) { + ++matches; - if (isMatch) { - ++matches; - - isSelected = DOM.isSelected(current); - - if (shouldSel) - isSelected = !isSelected; - - if (isSelected) - DOM.toggleSelectedFile(current); - } else if (!shouldSel) - ++i; - } - + isSelected = DOM.isSelected(current); + + if (shouldSel) + isSelected = !isSelected; + + if (isSelected) + DOM.toggleSelectedFile(current); + } else if (!shouldSel) + ++i; } - - } while (current); + } if (!matches) Dialog.alert('No matches found!');