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
f9421db9
Commit
f9421db9
authored
May 28, 2013
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade annotator to 1.2.6-dev-d2ea449
parent
0c3a527d
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
215 additions
and
113 deletions
+215
-113
services.coffee
h/js/services.coffee
+1
-0
annotator.auth.js
h/lib/annotator.auth.js
+2
-2
annotator.js
h/lib/annotator.js
+173
-95
annotator.permissions.js
h/lib/annotator.permissions.js
+2
-2
annotator.store.js
h/lib/annotator.store.js
+22
-4
dom_text_mapper.coffee
h/lib/dom_text_mapper.coffee
+13
-5
dom_text_matcher.coffee
h/lib/dom_text_matcher.coffee
+2
-5
No files found.
h/js/services.coffee
View file @
f9421db9
...
...
@@ -4,6 +4,7 @@ class Hypothesis extends Annotator
# Plugin configuration
options
:
noMatching
:
true
Discovery
:
{}
Heatmap
:
{}
Permissions
:
...
...
h/lib/annotator.auth.js
View file @
f9421db9
/*
** Annotator 1.2.6-dev-
8daf38c
** Annotator 1.2.6-dev-
d2ea449
** 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-05-
17 21:32:3
0Z
** Built at: 2013-05-
24 21:48:0
0Z
*/
...
...
h/lib/annotator.js
View file @
f9421db9
This diff is collapsed.
Click to expand it.
h/lib/annotator.permissions.js
View file @
f9421db9
/*
** Annotator 1.2.6-dev-
8daf38c
** Annotator 1.2.6-dev-
d2ea449
** 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-05-
17 21:32:32
Z
** Built at: 2013-05-
24 21:48:00
Z
*/
...
...
h/lib/annotator.store.js
View file @
f9421db9
/*
** Annotator 1.2.6-dev-
8daf38c
** Annotator 1.2.6-dev-
d2ea449
** 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-05-
17 21:32:33
Z
** Built at: 2013-05-
24 21:48:01
Z
*/
...
...
@@ -124,11 +124,29 @@
};
Store
.
prototype
.
_onLoadAnnotations
=
function
(
data
)
{
var
a
,
annotation
,
annotationMap
,
newData
,
_i
,
_j
,
_len
,
_len1
,
_ref
;
if
(
data
==
null
)
{
data
=
[];
}
this
.
annotations
=
this
.
annotations
.
concat
(
data
);
return
this
.
annotator
.
loadAnnotations
(
data
.
slice
());
annotationMap
=
{};
_ref
=
this
.
annotations
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
a
=
_ref
[
_i
];
annotationMap
[
a
.
id
]
=
a
;
}
newData
=
[];
for
(
_j
=
0
,
_len1
=
data
.
length
;
_j
<
_len1
;
_j
++
)
{
a
=
data
[
_j
];
if
(
annotationMap
[
a
.
id
])
{
annotation
=
annotationMap
[
a
.
id
];
this
.
updateAnnotation
(
annotation
,
a
);
}
else
{
newData
.
push
(
a
);
}
}
this
.
annotations
=
this
.
annotations
.
concat
(
newData
);
return
this
.
annotator
.
loadAnnotations
(
newData
.
slice
());
};
Store
.
prototype
.
loadAnnotationsFromSearch
=
function
(
searchOptions
)
{
...
...
h/lib/dom_text_mapper.coffee
View file @
f9421db9
...
...
@@ -11,7 +11,7 @@ class window.DomTextMapper
if
@
instances
.
length
is
0
then
return
# dm = @instances[0]
# console.log "Node @ " + (dm.getPathTo node) + " has changed: " + reason
for
instance
in
@
instances
for
instance
in
@
instances
when
instance
.
rootNode
.
contains
(
node
)
instance
.
performUpdateOnNode
node
null
...
...
@@ -42,7 +42,7 @@ class window.DomTextMapper
throw
new
Error
"Can't find iframe with specified ID!"
@
rootWin
=
iframe
.
contentWindow
unless
@
rootWin
?
throw
new
Error
"Can't access contents of the spe
f
ified iframe!"
throw
new
Error
"Can't access contents of the spe
c
ified iframe!"
@
rootNode
=
@
rootWin
.
document
@
pathStartNode
=
@
getBody
()
...
...
@@ -87,6 +87,10 @@ class window.DomTextMapper
# console.log "We have a valid DOM structure cache."
return
@
path
unless
@
pathStartNode
.
ownerDocument
.
body
.
contains
@
pathStartNode
# We cannot map nodes that are not attached.
return
@
path
# console.log "No valid cache, will have to do a scan."
startTime
=
@
timestamp
()
@
saveSelection
()
...
...
@@ -195,7 +199,10 @@ class window.DomTextMapper
result
# Return info for a given node in the DOM
getInfoForNode
:
(
node
)
->
@
getInfoForPath
@
getPathTo
node
getInfoForNode
:
(
node
)
->
unless
node
?
throw
new
Error
"Called getInfoForNode(node) with null node!"
@
getInfoForPath
@
getPathTo
node
# Get the matching DOM elements for a given set of charRanges
# (Calles getMappingsForCharRange for each element in the givenl ist)
...
...
@@ -384,6 +391,8 @@ class window.DomTextMapper
getPathTo
:
(
node
)
->
xpath
=
''
;
while
node
!=
@
rootNode
unless
node
?
throw
new
Error
"Called getPathTo on a node which was not a descendant of @rootNode. "
+
@
rootNode
xpath
=
(
@
getPathSegment
node
)
+
'/'
+
xpath
node
=
node
.
parentNode
xpath
=
(
if
@
rootNode
.
ownerDocument
?
then
'./'
else
'/'
)
+
xpath
...
...
@@ -612,8 +621,7 @@ class window.DomTextMapper
# Returns:
# the first character offset position in the content of this node's
# parent node that is not accounted for by this node
collectPositions
:
(
node
,
path
,
parentContent
=
null
,
parentIndex
=
0
,
index
=
0
)
->
collectPositions
:
(
node
,
path
,
parentContent
=
null
,
parentIndex
=
0
,
index
=
0
)
->
# console.log "Scanning path " + path
# content = @getNodeContent node, false
...
...
h/lib/dom_text_matcher.coffee
View file @
f9421db9
...
...
@@ -110,8 +110,7 @@ class window.DomTextMatcher
#
# For the details about the returned data structure,
# see the documentation of the search() method.
searchFuzzy
:
(
pattern
,
pos
,
caseSensitive
=
false
,
path
=
null
,
options
=
{})
->
searchFuzzy
:
(
pattern
,
pos
,
caseSensitive
=
false
,
path
=
null
,
options
=
{})
->
@
ensureDMP
()
@
dmp
.
setMatchDistance
options
.
matchDistance
?
1000
@
dmp
.
setMatchThreshold
options
.
matchThreshold
?
0.5
...
...
@@ -122,9 +121,7 @@ class window.DomTextMatcher
# Used to even out some browser differences.
normalizeString
:
(
string
)
->
string
.
replace
/\s{2,}/g
,
" "
searchFuzzyWithContext
:
(
prefix
,
suffix
,
pattern
,
expectedStart
=
null
,
expectedEnd
=
null
,
caseSensitive
=
false
,
path
=
null
,
options
=
{})
->
searchFuzzyWithContext
:
(
prefix
,
suffix
,
pattern
,
expectedStart
=
null
,
expectedEnd
=
null
,
caseSensitive
=
false
,
path
=
null
,
options
=
{})
->
@
ensureDMP
()
# No context, to joy
...
...
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