Commit 218666b6 authored by csillag's avatar csillag

- Upgraded tp latest version of dom-text-*

- Followed API changes
- Added some more error handling
parent d87b94bf
......@@ -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: {}
......
/*
** 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-02 22:47:44Z
** Built at: 2013-03-03 01:56:48Z
*/
(function() {
......@@ -785,8 +785,8 @@
Annotator.prototype.getContextQuoteSelectorFromRange = function(range) {
var endOffset, prefix, quote, selector, startOffset, suffix, _ref2;
startOffset = (this.domMapper.getMappingsForNode(range.start)).start;
endOffset = (this.domMapper.getMappingsForNode(range.end)).end;
startOffset = (this.domMapper.getInfoForNode(range.start)).start;
endOffset = (this.domMapper.getInfoForNode(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.getMappingsForNode(range.start)).start;
endOffset = (this.domMapper.getMappingsForNode(range.end)).end;
startOffset = (this.domMapper.getInfoForNode(range.start)).start;
endOffset = (this.domMapper.getInfoForNode(range.end)).end;
return selector = {
source: this.getHref(),
type: "position",
......
This diff is collapsed.
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment