Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3b651e48
Commit
3b651e48
authored
Nov 18, 2019
by
Utkarsh Gupta
Committed by
Martin Wortschack
Nov 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove var from project_find_file.js
parent
0e6b59bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
23 deletions
+25
-23
app/assets/javascripts/project_find_file.js
app/assets/javascripts/project_find_file.js
+25
-23
No files found.
app/assets/javascripts/project_find_file.js
View file @
3b651e48
/* eslint-disable func-names,
no-var, consistent-return, one-var, no-cond-assig
n, no-return-assign */
/* eslint-disable func-names,
consistent-retur
n, no-return-assign */
import
$
from
'
jquery
'
;
import
fuzzaldrinPlus
from
'
fuzzaldrin-plus
'
;
...
...
@@ -9,9 +9,12 @@ import sanitize from 'sanitize-html';
// highlight text(awefwbwgtc -> <b>a</b>wefw<b>b</b>wgt<b>c</b> )
const
highlighter
=
function
(
element
,
text
,
matches
)
{
var
j
,
lastIndex
,
len
,
matchIndex
,
matchedChars
,
unmatched
;
lastIndex
=
0
;
matchedChars
=
[];
let
j
=
0
;
let
len
=
0
;
let
lastIndex
=
0
;
let
matchedChars
=
[];
let
matchIndex
=
matches
[
j
];
let
unmatched
=
text
.
substring
(
lastIndex
,
matchIndex
);
for
(
j
=
0
,
len
=
matches
.
length
;
j
<
len
;
j
+=
1
)
{
matchIndex
=
matches
[
j
];
unmatched
=
text
.
substring
(
lastIndex
,
matchIndex
);
...
...
@@ -55,10 +58,10 @@ export default class ProjectFindFile {
'
keyup
'
,
(
function
(
_this
)
{
return
function
(
event
)
{
var
oldValue
,
ref
,
target
,
value
;
target
=
$
(
event
.
target
);
value
=
target
.
val
(
);
oldValue
=
(
ref
=
target
.
data
(
'
oldValue
'
))
!=
null
?
ref
:
''
;
const
target
=
$
(
event
.
target
)
;
const
value
=
target
.
val
(
);
const
ref
=
target
.
data
(
'
oldValue
'
);
const
oldValue
=
ref
!=
null
?
ref
:
''
;
if
(
value
!==
oldValue
)
{
target
.
data
(
'
oldValue
'
,
value
);
_this
.
findFile
();
...
...
@@ -74,9 +77,8 @@ export default class ProjectFindFile {
}
findFile
()
{
var
result
,
searchText
;
searchText
=
sanitize
(
this
.
inputElement
.
val
());
result
=
const
searchText
=
sanitize
(
this
.
inputElement
.
val
());
const
result
=
searchText
.
length
>
0
?
fuzzaldrinPlus
.
filter
(
this
.
filePaths
,
searchText
)
:
this
.
filePaths
;
return
this
.
renderList
(
result
,
searchText
);
// find file
...
...
@@ -101,20 +103,21 @@ export default class ProjectFindFile {
// render result
renderList
(
filePaths
,
searchText
)
{
var
blobItemUrl
,
filePath
,
html
,
i
,
len
,
matches
,
results
;
let
i
=
0
;
let
len
=
0
;
let
matches
=
[];
const
results
=
[];
this
.
element
.
find
(
'
.tree-table > tbody
'
).
empty
();
results
=
[];
for
(
i
=
0
,
len
=
filePaths
.
length
;
i
<
len
;
i
+=
1
)
{
filePath
=
filePaths
[
i
];
const
filePath
=
filePaths
[
i
];
if
(
i
===
20
)
{
break
;
}
if
(
searchText
)
{
matches
=
fuzzaldrinPlus
.
match
(
filePath
,
searchText
);
}
blobItemUrl
=
`
${
this
.
options
.
blobUrlTemplate
}
/
${
encodeURIComponent
(
filePath
)}
`
;
html
=
ProjectFindFile
.
makeHtml
(
filePath
,
matches
,
blobItemUrl
);
const
blobItemUrl
=
`
${
this
.
options
.
blobUrlTemplate
}
/
${
encodeURIComponent
(
filePath
)}
`
;
const
html
=
ProjectFindFile
.
makeHtml
(
filePath
,
matches
,
blobItemUrl
);
results
.
push
(
this
.
element
.
find
(
'
.tree-table > tbody
'
).
append
(
html
));
}
...
...
@@ -125,8 +128,7 @@ export default class ProjectFindFile {
// make tbody row html
static
makeHtml
(
filePath
,
matches
,
blobItemUrl
)
{
var
$tr
;
$tr
=
$
(
const
$tr
=
$
(
"
<tr class='tree-item'><td class='tree-item-file-name link-container'><a><i class='fa fa-file-text-o fa-fw'></i><span class='str-truncated'></span></a></td></tr>
"
,
);
if
(
matches
)
{
...
...
@@ -141,9 +143,9 @@ export default class ProjectFindFile {
}
selectRow
(
type
)
{
var
next
,
rows
,
selectedRow
;
rows
=
this
.
element
.
find
(
'
.files-slider tr.tree-item
'
);
selectedRow
=
this
.
element
.
find
(
'
.files-slider tr.tree-item.selected
'
);
const
rows
=
this
.
element
.
find
(
'
.files-slider tr.tree-item
'
)
;
let
selectedRow
=
this
.
element
.
find
(
'
.files-slider tr.tree-item.selected
'
);
let
next
=
selectedRow
.
prev
(
);
if
(
rows
&&
rows
.
length
>
0
)
{
if
(
selectedRow
&&
selectedRow
.
length
>
0
)
{
if
(
type
===
'
UP
'
)
{
...
...
@@ -175,7 +177,7 @@ export default class ProjectFindFile {
}
goToBlob
()
{
var
$link
=
this
.
element
.
find
(
'
.tree-item.selected .tree-item-file-name a
'
);
const
$link
=
this
.
element
.
find
(
'
.tree-item.selected .tree-item-file-name a
'
);
if
(
$link
.
length
)
{
$link
.
get
(
0
).
click
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment