mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(dom) selectByPatter
This commit is contained in:
parent
26bbb9d944
commit
823c8f3930
1 changed files with 21 additions and 31 deletions
|
|
@ -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!');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue