Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Annotation-System
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Annotation-Pushers
Annotation-System
Commits
6ca14464
Commit
6ca14464
authored
Jun 23, 2018
by
Matt Mascarenhas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test_search_perf'
parents
8c171941
6136a458
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
52 deletions
+51
-52
cinera/cinera_search.js
cinera/cinera_search.js
+51
-52
No files found.
cinera/cinera_search.js
View file @
6ca14464
...
...
@@ -35,7 +35,7 @@ indexSort.addEventListener("click", function(ev) {
var
lastQuery
=
null
;
var
resultsToRender
=
[];
var
resultsIndex
=
0
;
var
resultsMarkerIndex
=
0
;
var
resultsMarkerIndex
=
-
1
;
var
resultsContainer
=
document
.
getElementById
(
"
cineraResults
"
);
var
rendering
=
false
;
...
...
@@ -93,7 +93,7 @@ function runSearch() {
oldResultsContainer
.
parentNode
.
insertBefore
(
resultsContainer
,
oldResultsContainer
);
oldResultsContainer
.
remove
();
resultsIndex
=
0
;
resultsMarkerIndex
=
0
;
resultsMarkerIndex
=
-
1
;
}
lastQuery
=
queryStr
;
resultsToRender
=
[];
...
...
@@ -145,22 +145,29 @@ function runSearch() {
document
.
getElementById
(
"
cineraResultsSummary
"
).
textContent
=
"
Found:
"
+
numEpisodes
+
"
episodes,
"
+
numMarkers
+
"
markers,
"
+
totalTime
+
"
total.
"
;
}
function
renderMatches
(
renderStart
)
{
function
renderResults
()
{
if
(
resultsIndex
<
resultsToRender
.
length
)
{
rendering
=
true
;
var
maxItems
=
10
;
var
numItems
=
0
;
while
(
numItems
<
maxItems
&&
resultsIndex
<
resultsToRender
.
length
)
{
var
query
=
resultsToRender
[
resultsIndex
].
query
;
var
episode
=
resultsToRender
[
resultsIndex
].
episode
;
var
matches
=
resultsToRender
[
resultsIndex
].
matches
;
var
markerList
=
null
;
if
(
resultsMarkerIndex
==
0
)
{
if
(
resultsMarkerIndex
==
-
1
)
{
var
dayContainer
=
dayContainerPrototype
.
cloneNode
(
true
);
var
dayName
=
dayContainer
.
children
[
0
];
markerList
=
dayContainer
.
children
[
1
];
dayName
.
textContent
=
episode
.
day
+
"
:
"
+
episode
.
title
;
resultsContainer
.
appendChild
(
dayContainer
);
resultsMarkerIndex
=
0
;
numItems
++
;
}
else
{
markerList
=
document
.
querySelector
(
"
#cineraResults > .dayContainer:nth-child(
"
+
(
resultsIndex
+
1
)
+
"
) .markerList
"
);
}
do
{
while
(
numItems
<
maxItems
&&
resultsMarkerIndex
<
matches
.
length
)
{
var
match
=
matches
[
resultsMarkerIndex
];
var
marker
=
markerPrototype
.
cloneNode
();
var
playerURLPrefix
=
(
baseURL
?
baseURL
+
"
/
"
:
""
)
+
(
playerLocation
?
playerLocation
+
"
/
"
:
""
);
...
...
@@ -184,24 +191,16 @@ function renderMatches(renderStart) {
marker
.
appendChild
(
document
.
createTextNode
(
text
.
slice
(
cursor
,
text
.
length
)));
}
markerList
.
appendChild
(
marker
);
numItems
++
;
resultsMarkerIndex
++
;
}
while
(
resultsMarkerIndex
<
matches
.
length
&&
performance
.
now
()
-
renderStart
<
1
);
return
resultsMarkerIndex
==
matches
.
length
;
}
}
function
renderResults
()
{
if
(
resultsIndex
<
resultsToRender
.
length
)
{
rendering
=
true
;
var
renderStart
=
performance
.
now
();
while
(
resultsIndex
<
resultsToRender
.
length
&&
performance
.
now
()
-
renderStart
<
1
)
{
var
done
=
renderMatches
(
renderStart
);
if
(
done
)
{
resultsMarkerIndex
=
0
;
if
(
resultsMarkerIndex
==
matches
.
length
)
{
resultsMarkerIndex
=
-
1
;
resultsIndex
++
;
}
}
requestAnimationFrame
(
renderResults
);
setTimeout
(
renderResults
,
0
);
}
else
{
rendering
=
false
;
}
...
...
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