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
c4dea460
Commit
c4dea460
authored
Jun 30, 2016
by
Alice Wyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor domainAndTitle into smaller pieces
parent
dc00cf4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
annotation-metadata.js
h/static/scripts/annotation-metadata.js
+22
-7
No files found.
h/static/scripts/annotation-metadata.js
View file @
c4dea460
...
@@ -37,8 +37,15 @@ function documentMetadata(annotation) {
...
@@ -37,8 +37,15 @@ function documentMetadata(annotation) {
* card.
* card.
*/
*/
function
domainAndTitle
(
annotation
)
{
function
domainAndTitle
(
annotation
)
{
var
document
=
documentMetadata
(
annotation
);
return
{
var
titleLink
=
document
.
uri
;
domain
:
domainTextFromAnnotation
(
annotation
),
titleText
:
titleTextFromAnnotation
(
annotation
),
titleLink
:
titleLinkFromAnnotation
(
annotation
),
};
}
function
titleLinkFromAnnotation
(
annotation
)
{
var
titleLink
=
annotation
.
uri
;
if
(
titleLink
&&
!
(
titleLink
.
indexOf
(
'http://'
)
===
0
||
titleLink
.
indexOf
(
'https://'
)
===
0
))
{
if
(
titleLink
&&
!
(
titleLink
.
indexOf
(
'http://'
)
===
0
||
titleLink
.
indexOf
(
'https://'
)
===
0
))
{
// We only link to http(s) URLs.
// We only link to http(s) URLs.
...
@@ -49,6 +56,12 @@ function domainAndTitle(annotation) {
...
@@ -49,6 +56,12 @@ function domainAndTitle(annotation) {
titleLink
=
annotation
.
links
.
incontext
;
titleLink
=
annotation
.
links
.
incontext
;
}
}
return
titleLink
;
}
function
domainTextFromAnnotation
(
annotation
)
{
var
document
=
documentMetadata
(
annotation
);
var
domainText
=
''
;
var
domainText
=
''
;
if
(
document
.
uri
&&
document
.
uri
.
indexOf
(
'file://'
)
===
0
&&
document
.
title
)
{
if
(
document
.
uri
&&
document
.
uri
.
indexOf
(
'file://'
)
===
0
&&
document
.
title
)
{
var
parts
=
document
.
uri
.
split
(
'/'
);
var
parts
=
document
.
uri
.
split
(
'/'
);
...
@@ -60,16 +73,18 @@ function domainAndTitle(annotation) {
...
@@ -60,16 +73,18 @@ function domainAndTitle(annotation) {
domainText
=
document
.
domain
;
domainText
=
document
.
domain
;
}
}
return
domainText
;
}
function
titleTextFromAnnotation
(
annotation
)
{
var
document
=
documentMetadata
(
annotation
);
var
titleText
=
document
.
title
;
var
titleText
=
document
.
title
;
if
(
titleText
.
length
>
30
)
{
if
(
titleText
.
length
>
30
)
{
titleText
=
titleText
.
slice
(
0
,
30
)
+
'…'
;
titleText
=
titleText
.
slice
(
0
,
30
)
+
'…'
;
}
}
return
{
return
titleText
;
domain
:
domainText
,
titleText
:
titleText
,
titleLink
:
titleLink
,
};
}
}
/** Return `true` if the given annotation is a reply, `false` otherwise. */
/** Return `true` if the given annotation is a reply, `false` otherwise. */
...
...
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