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
218666b6
Commit
218666b6
authored
Mar 03, 2013
by
csillag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Upgraded tp latest version of dom-text-*
- Followed API changes - Added some more error handling
parent
d87b94bf
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
203 deletions
+114
-203
host.coffee
h/js/inject/host.coffee
+8
-3
annotator.js
h/lib/annotator.js
+6
-6
dom_text_mapper.coffee
h/lib/dom_text_mapper.coffee
+96
-175
dom_text_matcher.coffee
h/lib/dom_text_matcher.coffee
+4
-19
No files found.
h/js/inject/host.coffee
View file @
218666b6
...
...
@@ -147,9 +147,14 @@ class Annotator.Host extends Annotator
$
(
'html, body'
).
stop
().
animate
{
scrollTop
:
y
},
600
scanDocument
:
(
reason
=
"something happened"
)
=>
console
.
log
"Analyzing host frame, because "
+
reason
+
"..."
scanTime
=
@
domMatcher
.
prepareSearch
null
,
true
console
.
log
"Traversal+scan took "
+
scanTime
+
" ms."
try
console
.
log
"Analyzing host frame, because "
+
reason
+
"..."
r
=
@
domMatcher
.
scan
()
scanTime
=
r
.
time
console
.
log
"Traversal+scan took "
+
scanTime
+
" ms."
catch
e
console
.
log
e
.
message
console
.
log
e
.
stack
remote
:
publish
:
{}
...
...
h/lib/annotator.js
View file @
218666b6
/*
** Annotator 1.2.5-dev-
02598fb
** Annotator 1.2.5-dev-
4109850
** https://github.com/okfn/annotator/
**
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2013-03-0
2 22:47:44
Z
** Built at: 2013-03-0
3 01:56:48
Z
*/
(
function
()
{
...
...
@@ -785,8 +785,8 @@
Annotator
.
prototype
.
getContextQuoteSelectorFromRange
=
function
(
range
)
{
var
endOffset
,
prefix
,
quote
,
selector
,
startOffset
,
suffix
,
_ref2
;
startOffset
=
(
this
.
domMapper
.
get
Mappings
ForNode
(
range
.
start
)).
start
;
endOffset
=
(
this
.
domMapper
.
get
Mappings
ForNode
(
range
.
end
)).
end
;
startOffset
=
(
this
.
domMapper
.
get
Info
ForNode
(
range
.
start
)).
start
;
endOffset
=
(
this
.
domMapper
.
get
Info
ForNode
(
range
.
end
)).
end
;
quote
=
this
.
domMapper
.
getContentForRange
(
startOffset
,
endOffset
);
_ref2
=
this
.
domMapper
.
getContextForRange
(
startOffset
,
endOffset
),
prefix
=
_ref2
[
0
],
suffix
=
_ref2
[
1
];
return
selector
=
{
...
...
@@ -800,8 +800,8 @@
Annotator
.
prototype
.
getPositionSelectorFromRange
=
function
(
range
)
{
var
endOffset
,
selector
,
startOffset
;
startOffset
=
(
this
.
domMapper
.
get
Mappings
ForNode
(
range
.
start
)).
start
;
endOffset
=
(
this
.
domMapper
.
get
Mappings
ForNode
(
range
.
end
)).
end
;
startOffset
=
(
this
.
domMapper
.
get
Info
ForNode
(
range
.
start
)).
start
;
endOffset
=
(
this
.
domMapper
.
get
Info
ForNode
(
range
.
end
)).
end
;
return
selector
=
{
source
:
this
.
getHref
(),
type
:
"position"
,
...
...
h/lib/dom_text_mapper.coffee
View file @
218666b6
This diff is collapsed.
Click to expand it.
h/lib/dom_text_matcher.coffee
View file @
218666b6
...
...
@@ -2,12 +2,6 @@ class window.DomTextMatcher
# ===== Public methods =======
# Switch the library into "serializable-only" mode.
# If set to true, all public API calls will be restricted to return
# strictly serializable data structures.
# (References to DOM objects will be omitted.)
restrictToSerializable
:
(
value
=
true
)
->
@
mapper
.
restrictToSerializable
value
# Consider only the sub-tree beginning with the given node.
#
# This will be the root node to use for all operations.
...
...
@@ -45,24 +39,15 @@ class window.DomTextMatcher
# node: reference to the DOM node
# content: the text content of the node, as rendered by the browser
# length: the length of the next content
getAllPaths
:
->
scan
:
->
t0
=
@
timestamp
()
paths
=
@
mapper
.
getAllPaths
()
data
=
@
mapper
.
scan
()
t1
=
@
timestamp
()
return
time
:
t1
-
t0
,
paths
:
paths
return
time
:
t1
-
t0
,
data
:
data
# Return the default path
getDefaultPath
:
->
@
mapper
.
getDefaultPath
()
# Prepare for searching the specified path
#
# Returns the time (in ms) it took the scan the specified path
prepareSearch
:
(
path
)
->
t0
=
@
timestamp
()
@
mapper
.
scan
path
t1
=
@
timestamp
()
t1
-
t0
# Search for text using exact string matching
#
# Parameters:
...
...
@@ -162,7 +147,7 @@ class window.DomTextMatcher
# Do some preparation, if required
t0
=
@
timestamp
()
#
if
path
?
then
@
prepareSearch
path
if
path
?
then
@
scan
()
t1
=
@
timestamp
()
# Check preparations
...
...
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