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
5dcbe387
Commit
5dcbe387
authored
Dec 11, 2013
by
csillag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DTM to 7b12a39f (master branch).
parent
324ef5e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
dom_text_mapper.coffee
h/lib/dom_text_mapper.coffee
+13
-2
page_text_mapper_core.coffee
h/lib/page_text_mapper_core.coffee
+1
-0
No files found.
h/lib/dom_text_mapper.coffee
View file @
5dcbe387
...
...
@@ -250,8 +250,12 @@ class window.DomTextMapper
# Get the context that encompasses the given charRange
# in the rendered text of the document
getContextForCharRange
:
(
start
,
end
)
->
if
start
<
0
throw
Error
"Negative range start is invalid!"
if
end
>
@
_corpus
.
length
throw
Error
"Range end is after the end of corpus!"
prefixStart
=
Math
.
max
0
,
start
-
CONTEXT_LEN
prefix
=
@
_corpus
[
prefixStart
..
start
-
1
]
prefix
=
if
prefixStart
then
@
_corpus
[
prefixStart
..
start
-
1
]
else
""
suffix
=
@
_corpus
[
end
..
end
+
CONTEXT_LEN
-
1
]
[
prefix
.
trim
(),
suffix
.
trim
()]
...
...
@@ -371,9 +375,13 @@ class window.DomTextMapper
timestamp
:
->
new
Date
().
getTime
()
stringStartsWith
:
(
string
,
prefix
)
->
unless
prefix
throw
Error
"Requires a non-empty prefix!"
string
[
0
..
prefix
.
length
-
1
]
is
prefix
stringEndsWith
:
(
string
,
suffix
)
->
unless
suffix
throw
Error
"Requires a non-empty suffix!"
string
[
string
.
length
-
suffix
.
length
..
string
.
length
]
is
suffix
parentPath
:
(
path
)
->
path
.
substr
0
,
path
.
lastIndexOf
"/"
...
...
@@ -469,7 +477,10 @@ class window.DomTextMapper
throw
new
Error
"Selection already saved!"
sel
=
@
rootWin
.
getSelection
()
# @log "Saving selection: " + sel.rangeCount + " ranges."
@
savedSelection
=
(
sel
.
getRangeAt
i
)
for
i
in
[
0
...
sel
.
rangeCount
]
@
savedSelection
=
unless
sel
.
rangeCount
[]
else
(
sel
.
getRangeAt
i
)
for
i
in
[
0
...
sel
.
rangeCount
]
switch
sel
.
rangeCount
when
0
then
@
savedSelection
?=
[]
when
1
then
@
savedSelection
=
[
@
savedSelection
]
...
...
h/lib/page_text_mapper_core.coffee
View file @
5dcbe387
...
...
@@ -54,6 +54,7 @@ class window.PageTextMapperCore
# Update the mappings for a given page
_updateMap
:
(
info
)
->
#console.log "Updating mappings for page #" + info.index
info
.
domMapper
.
documentChanged
()
info
.
domMapper
.
scan
()
# Delete the mappings for a given page
...
...
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