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
0b75c084
Commit
0b75c084
authored
Feb 26, 2016
by
Nick Stenning
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove leading whitespace from annotation-metadata.js
parent
6e25ab1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
64 deletions
+64
-64
annotation-metadata.js
h/static/scripts/annotation-metadata.js
+64
-64
No files found.
h/static/scripts/annotation-metadata.js
View file @
0b75c084
...
@@ -2,74 +2,74 @@
...
@@ -2,74 +2,74 @@
* Utility functions for querying annotation metadata.
* Utility functions for querying annotation metadata.
*/
*/
/** Extract a URI, domain and title from the given domain model object.
/** Extract a URI, domain and title from the given domain model object.
*
*
* @param {object} annotation An annotation domain model object as received
* @param {object} annotation An annotation domain model object as received
* from the server-side API.
* from the server-side API.
* @returns {object} An object with three properties extracted from the model:
* @returns {object} An object with three properties extracted from the model:
* uri, domain and title.
* uri, domain and title.
*
*
*/
*/
function
extractDocumentMetadata
(
annotation
)
{
function
extractDocumentMetadata
(
annotation
)
{
var
document_
;
var
document_
;
var
uri
=
annotation
.
uri
;
var
uri
=
annotation
.
uri
;
var
domain
=
new
URL
(
uri
).
hostname
;
var
domain
=
new
URL
(
uri
).
hostname
;
if
(
annotation
.
document
)
{
if
(
annotation
.
document
)
{
if
(
uri
.
indexOf
(
'urn'
)
===
0
)
{
if
(
uri
.
indexOf
(
'urn'
)
===
0
)
{
var
i
;
var
i
;
for
(
i
=
0
;
i
<
annotation
.
document
.
link
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
annotation
.
document
.
link
.
length
;
i
++
)
{
var
link
=
annotation
.
document
.
link
[
i
];
var
link
=
annotation
.
document
.
link
[
i
];
if
(
link
.
href
.
indexOf
(
'urn:'
)
===
0
)
{
if
(
link
.
href
.
indexOf
(
'urn:'
)
===
0
)
{
continue
;
continue
;
}
}
uri
=
link
.
href
;
uri
=
link
.
href
;
break
;
break
;
}
}
}
}
var
documentTitle
;
var
documentTitle
;
if
(
Array
.
isArray
(
annotation
.
document
.
title
))
{
if
(
Array
.
isArray
(
annotation
.
document
.
title
))
{
documentTitle
=
annotation
.
document
.
title
[
0
];
documentTitle
=
annotation
.
document
.
title
[
0
];
}
else
{
}
else
{
documentTitle
=
annotation
.
document
.
title
;
documentTitle
=
annotation
.
document
.
title
;
}
}
document_
=
{
document_
=
{
uri
:
uri
,
uri
:
uri
,
domain
:
domain
,
domain
:
domain
,
title
:
documentTitle
||
domain
title
:
documentTitle
||
domain
};
};
}
else
{
}
else
{
document_
=
{
document_
=
{
uri
:
uri
,
uri
:
uri
,
domain
:
domain
,
domain
:
domain
,
title
:
domain
title
:
domain
};
};
}
}
if
(
document_
.
title
.
length
>
30
)
{
if
(
document_
.
title
.
length
>
30
)
{
document_
.
title
=
document_
.
title
.
slice
(
0
,
30
)
+
'…'
;
document_
.
title
=
document_
.
title
.
slice
(
0
,
30
)
+
'…'
;
}
}
return
document_
;
return
document_
;
}
}
/** Return `true` if the given annotation is a reply, `false` otherwise. */
/** Return `true` if the given annotation is a reply, `false` otherwise. */
function
isReply
(
annotation
)
{
function
isReply
(
annotation
)
{
return
(
annotation
.
references
||
[]).
length
>
0
;
return
(
annotation
.
references
||
[]).
length
>
0
;
}
}
/** Return `true` if the given annotation is new, `false` otherwise.
/** Return `true` if the given annotation is new, `false` otherwise.
*
*
* "New" means this annotation has been newly created client-side and not
* "New" means this annotation has been newly created client-side and not
* saved to the server yet.
* saved to the server yet.
*/
*/
function
isNew
(
annotation
)
{
function
isNew
(
annotation
)
{
return
!
annotation
.
id
;
return
!
annotation
.
id
;
}
}
module
.
exports
=
{
module
.
exports
=
{
extractDocumentMetadata
:
extractDocumentMetadata
,
extractDocumentMetadata
:
extractDocumentMetadata
,
isReply
:
isReply
,
isReply
:
isReply
,
isNew
:
isNew
,
isNew
:
isNew
,
};
};
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