Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cloogle.org
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cloogle
cloogle.org
Commits
f4fdd124
Verified
Commit
f4fdd124
authored
Jan 26, 2019
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow selection of multiple lines in the library browser
parent
9d3600c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
24 deletions
+86
-24
frontend/src/view.css
frontend/src/view.css
+16
-1
frontend/src/view.js
frontend/src/view.js
+70
-23
No files found.
frontend/src/view.css
View file @
f4fdd124
...
@@ -18,6 +18,10 @@ table.source-code {
...
@@ -18,6 +18,10 @@ table.source-code {
white-space
:
pre
;
white-space
:
pre
;
}
}
table
.source-code
tr
td
{
padding
:
0
;
}
table
.source-code
tr
:first-child
td
{
table
.source-code
tr
:first-child
td
{
padding-top
:
1em
;
padding-top
:
1em
;
}
}
...
@@ -48,5 +52,16 @@ table.source-code tr td:last-child {
...
@@ -48,5 +52,16 @@ table.source-code tr td:last-child {
.hll
{
.hll
{
background-color
:
#eef
;
background-color
:
#eef
;
outline
:
1px
solid
#dbdee3
;
}
table
.source-code
tr
.hll-first
{
box-shadow
:
0
-1px
0
#dbdee3
;
}
table
.source-code
tr
.hll-last
{
box-shadow
:
0
1px
0
#dbdee3
;
}
table
.source-code
tr
.hll-first.hll-last
{
box-shadow
:
0
-1px
0
#dbdee3
,
0
1px
0
#dbdee3
;
}
}
frontend/src/view.js
View file @
f4fdd124
...
@@ -22,27 +22,73 @@ function shareButtonClick() {
...
@@ -22,27 +22,73 @@ function shareButtonClick() {
});
});
}
}
function
selectLine
(
n
)
{
function
selectLines
(
n
)
{
browser
.
state
.
line
=
n
;
var
firstline
=
null
;
browser
.
state
.
lines
=
n
;
if
(
!
isNaN
(
n
))
{
var
hll
=
document
.
getElementsByClassName
(
'
hll
'
);
var
hll
=
document
.
getElementsByClassName
(
'
hll
'
);
while
(
hll
.
length
>
0
)
for
(
var
i
=
0
;
i
<
hll
.
length
;
i
++
)
hll
[
0
].
classList
.
remove
(
'
hll
'
,
'
hll-first
'
,
'
hll-last
'
);
hll
[
i
].
classList
.
remove
(
'
hll
'
);
var
linespan
=
document
.
getElementById
(
'
line-
'
+
browser
.
state
.
line
);
if
(
!
isNaN
(
n
))
{
firstline
=
n
;
var
linespan
=
document
.
getElementById
(
'
line-
'
+
n
);
if
(
linespan
!=
null
)
if
(
linespan
!=
null
)
linespan
.
classList
.
add
(
'
hll
'
);
linespan
.
classList
.
add
(
'
hll
'
,
'
hll-first
'
,
'
hll-last
'
);
}
else
if
(
typeof
n
==
'
string
'
)
{
var
match
=
n
.
match
(
/^
(\d
+
)
-
(\d
+
)
$/
);
if
(
match
!=
null
)
{
firstline
=
match
[
1
];
var
first
=
true
;
for
(
var
i
=
firstline
;
i
<
match
[
2
];
i
++
)
{
var
linespan
=
document
.
getElementById
(
'
line-
'
+
i
);
if
(
linespan
!=
null
)
{
linespan
.
classList
.
add
(
'
hll
'
);
if
(
first
)
{
linespan
.
classList
.
add
(
'
hll-first
'
);
first
=
false
;
}
}
}
var
linespan
=
document
.
getElementById
(
'
line-
'
+
match
[
2
]);
if
(
linespan
!=
null
)
linespan
.
classList
.
add
(
'
hll
'
,
'
hll-last
'
);
}
}
}
browser
.
triggerChange
(
false
);
browser
.
triggerChange
(
false
);
return
firstline
;
}
function
selectLinesByEvent
(
e
,
n
)
{
if
(
e
.
shiftKey
)
{
if
(
!
isNaN
(
browser
.
state
.
lines
))
{
if
(
browser
.
state
.
lines
<
n
)
selectLines
(
browser
.
state
.
lines
+
'
-
'
+
n
);
else
selectLines
(
n
+
'
-
'
+
browser
.
state
.
lines
);
return
;
}
else
if
(
typeof
n
==
'
string
'
)
{
var
match
=
n
.
match
(
/^
(\d
+
)
-
(\d
+
)
$/
);
if
(
match
!=
null
)
{
if
(
n
<
match
[
1
])
selectLines
(
n
+
'
-
'
+
match
[
2
]);
else
selectLines
(
match
[
1
]
+
'
-
'
+
n
);
return
;
}
}
}
selectLines
(
n
);
}
}
var
tableLineNo
=
null
;
var
tableLineNo
=
null
;
function
tableHighlightCallback
(
span
,
cls
,
str
)
{
function
tableHighlightCallback
(
span
,
cls
,
str
)
{
var
html
=
''
;
var
html
=
''
;
if
(
tableLineNo
==
null
)
{
if
(
tableLineNo
==
null
)
{
html
=
'
<tr id="line-1"><td onclick="selectLine
(
1);">1</td><td>
'
;
html
=
'
<tr id="line-1"><td onclick="selectLine
sByEvent(event,
1);">1</td><td>
'
;
tableLineNo
=
1
;
tableLineNo
=
1
;
}
}
var
lines
=
str
.
split
(
'
\n
'
);
var
lines
=
str
.
split
(
'
\n
'
);
...
@@ -51,7 +97,7 @@ function tableHighlightCallback(span, cls, str) {
...
@@ -51,7 +97,7 @@ function tableHighlightCallback(span, cls, str) {
html
+=
highlightCallback
(
html
+=
highlightCallback
(
'
<span class="
'
+
cls
+
'
">
'
+
escapeHTML
(
lines
[
i
])
+
'
</span>
'
,
'
<span class="
'
+
cls
+
'
">
'
+
escapeHTML
(
lines
[
i
])
+
'
</span>
'
,
cls
,
lines
[
i
])
+
cls
,
lines
[
i
])
+
'
</td></tr><tr id="line-
'
+
tableLineNo
+
'
"><td onclick="selectLine
(
'
+
tableLineNo
+
'
);">
'
'
</td></tr><tr id="line-
'
+
tableLineNo
+
'
"><td onclick="selectLine
sByEvent(event,
'
+
tableLineNo
+
'
);">
'
+
tableLineNo
+
'
</td><td>
'
;
+
tableLineNo
+
'
</td><td>
'
;
}
}
html
+=
highlightCallback
(
html
+=
highlightCallback
(
...
@@ -69,7 +115,7 @@ window.onload = function() {
...
@@ -69,7 +115,7 @@ window.onload = function() {
browser
=
document
.
getElementsByClassName
(
'
browser
'
)[
0
].
browser
({
browser
=
document
.
getElementsByClassName
(
'
browser
'
)[
0
].
browser
({
newPath
:
function
(
path
)
{
newPath
:
function
(
path
)
{
this
.
state
.
mod
=
path
.
join
(
'
/
'
);
this
.
state
.
mod
=
path
.
join
(
'
/
'
);
this
.
state
.
line
=
null
;
this
.
state
.
line
s
=
null
;
this
.
newState
();
this
.
newState
();
},
},
newHash
:
function
(
hash
)
{
newHash
:
function
(
hash
)
{
...
@@ -77,16 +123,16 @@ window.onload = function() {
...
@@ -77,16 +123,16 @@ window.onload = function() {
var
update
=
this
.
state
.
mod
!=
hashelems
[
0
];
var
update
=
this
.
state
.
mod
!=
hashelems
[
0
];
this
.
state
.
mod
=
hashelems
[
0
];
this
.
state
.
mod
=
hashelems
[
0
];
this
.
state
.
icl
=
false
;
this
.
state
.
icl
=
false
;
this
.
state
.
line
=
null
;
this
.
state
.
line
s
=
null
;
for
(
var
i
=
1
;
i
<
hashelems
.
length
;
i
++
)
{
for
(
var
i
=
1
;
i
<
hashelems
.
length
;
i
++
)
{
if
(
hashelems
[
i
]
==
'
icl
'
)
if
(
hashelems
[
i
]
==
'
icl
'
)
icl
.
checked
=
this
.
state
.
icl
=
true
;
icl
.
checked
=
this
.
state
.
icl
=
true
;
else
if
(
hashelems
[
i
].
substring
(
0
,
5
)
==
'
line=
'
)
else
if
(
hashelems
[
i
].
substring
(
0
,
5
)
==
'
line=
'
)
this
.
state
.
line
=
hashelems
[
i
].
substring
(
5
);
this
.
state
.
line
s
=
hashelems
[
i
].
substring
(
5
);
}
}
if
(
this
.
state
.
line
!=
null
)
if
(
this
.
state
.
line
s
!=
null
)
selectLine
(
this
.
state
.
line
);
selectLine
s
(
this
.
state
.
lines
);
browser
.
openPath
(
this
.
state
.
mod
.
split
(
'
/
'
));
browser
.
openPath
(
this
.
state
.
mod
.
split
(
'
/
'
));
browser
.
triggerChange
(
update
);
browser
.
triggerChange
(
update
);
...
@@ -95,8 +141,8 @@ window.onload = function() {
...
@@ -95,8 +141,8 @@ window.onload = function() {
var
hash
=
this
.
state
.
mod
;
var
hash
=
this
.
state
.
mod
;
if
(
this
.
state
.
icl
)
if
(
this
.
state
.
icl
)
hash
+=
'
;icl
'
;
hash
+=
'
;icl
'
;
if
(
this
.
state
.
line
!=
null
)
if
(
this
.
state
.
line
s
!=
null
)
hash
+=
'
;line=
'
+
this
.
state
.
line
;
hash
+=
'
;line=
'
+
this
.
state
.
line
s
;
browser
.
setHash
(
hash
);
browser
.
setHash
(
hash
);
},
},
...
@@ -104,8 +150,8 @@ window.onload = function() {
...
@@ -104,8 +150,8 @@ window.onload = function() {
var
url
=
'
src.php?mod=
'
+
this
.
state
.
mod
;
var
url
=
'
src.php?mod=
'
+
this
.
state
.
mod
;
if
(
this
.
state
.
icl
)
if
(
this
.
state
.
icl
)
url
+=
'
&icl
'
;
url
+=
'
&icl
'
;
if
(
this
.
state
.
line
!=
null
)
if
(
this
.
state
.
line
s
!=
null
)
url
+=
'
&line=
'
+
this
.
state
.
line
;
url
+=
'
&line=
'
+
this
.
state
.
line
s
;
return
url
;
return
url
;
},
},
viewer
:
viewer
,
viewer
:
viewer
,
...
@@ -115,9 +161,10 @@ window.onload = function() {
...
@@ -115,9 +161,10 @@ window.onload = function() {
highlightClean
(
text
,
tableHighlightCallback
)
+
highlightClean
(
text
,
tableHighlightCallback
)
+
'
</table>
'
;
'
</table>
'
;
viewer
.
scrollLeft
=
0
;
viewer
.
scrollLeft
=
0
;
if
(
state
.
line
!=
null
)
{
if
(
state
.
lines
!=
null
)
{
selectLine
(
state
.
line
);
var
firstline
=
selectLines
(
state
.
lines
);
browser
.
scrollTo
(
document
.
getElementById
(
'
line-
'
+
state
.
line
));
if
(
firstline
!=
null
)
browser
.
scrollTo
(
document
.
getElementById
(
'
line-
'
+
firstline
));
}
else
{
}
else
{
browser
.
scrollTo
();
browser
.
scrollTo
();
}
}
...
@@ -138,7 +185,7 @@ window.onload = function() {
...
@@ -138,7 +185,7 @@ window.onload = function() {
browser
.
state
.
icl
=
icl
.
checked
;
browser
.
state
.
icl
=
icl
.
checked
;
icl
.
onchange
=
function
()
{
icl
.
onchange
=
function
()
{
browser
.
state
.
icl
=
this
.
checked
;
browser
.
state
.
icl
=
this
.
checked
;
browser
.
state
.
line
=
null
;
browser
.
state
.
line
s
=
null
;
browser
.
triggerChange
();
browser
.
triggerChange
();
};
};
...
...
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