Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
904810bd
Commit
904810bd
authored
Sep 13, 2021
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `strippedHint` initialization
Combine two separate if blocks into one.
parent
7f4de8c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
+6
-9
pdf.js
src/annotator/anchoring/pdf.js
+6
-9
No files found.
src/annotator/anchoring/pdf.js
View file @
904810bd
...
...
@@ -387,10 +387,12 @@ async function anchorQuote(quoteSelector, positionHint) {
let
bestMatch
;
for
(
let
page
of
pageIndexes
)
{
const
text
=
await
getPageTextContent
(
page
);
const
[
strippedText
,
offsets
]
=
stripSpaces
(
text
);
// Expected offset of quote in current page based on position hint.
let
hint
;
if
(
expectedPageIndex
!==
undefined
)
{
// Determine expected offset of quote in current page based on position hint.
let
strippedHint
;
if
(
expectedPageIndex
!==
undefined
&&
expectedOffsetInPage
!==
undefined
)
{
let
hint
;
if
(
page
<
expectedPageIndex
)
{
hint
=
text
.
length
;
// Prefer matches closer to end of page.
}
else
if
(
page
===
expectedPageIndex
)
{
...
...
@@ -398,13 +400,8 @@ async function anchorQuote(quoteSelector, positionHint) {
}
else
{
hint
=
0
;
// Prefer matches closer to start of page.
}
}
const
[
strippedText
,
offsets
]
=
stripSpaces
(
text
);
// Convert expected offset in original text into offset into stripped text.
let
strippedHint
;
if
(
hint
!==
undefined
)
{
// Convert expected offset in original text into offset into stripped text.
strippedHint
=
0
;
while
(
strippedHint
<
offsets
.
length
&&
offsets
[
strippedHint
]
<
hint
)
{
++
strippedHint
;
...
...
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