Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
histhub
geolinker-widget
Commits
2a936820
Commit
2a936820
authored
Jul 09, 2019
by
Tobias Steiner
Browse files
Hide the widget if we do not have any links
parent
f925c2f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
examlpe/index.html
View file @
2a936820
...
...
@@ -22,12 +22,15 @@
<histhub-widget
endpoint=
"//api.orgalinker.histhub.ch/v1/sameas/"
resolver=
"resolvermanual"
location=
"https://dodis.ch/R20"
>
<h3
slot=
"title"
>
Example 2: Links from orgalinker dodis: Lombard, Odier
&
Cie
</h3>
</histhub-widget>
<histhub-widget
endpoint=
"//api.geolinker.histhub.ch/v1/sameas/"
resolver=
"resolverneo4j"
location=
"https://dodis.ch/G82"
>
<histhub-widget
endpoint=
"//api.geolinker.histhub.ch/v1
-1
/sameas/"
resolver=
"resolverneo4j"
location=
"https://dodis.ch/G82"
>
<h3
slot=
"title"
>
Example 3: Links (sameas) from geolinker dodis: Diedenhofen
</h3>
</histhub-widget>
<histhub-widget
endpoint=
"//api.geolinker.histhub.ch/v1/similarto/"
resolver=
"resolverelasticsearch"
location=
"https://dodis.ch/G82"
>
<histhub-widget
endpoint=
"//api.geolinker.histhub.ch/v1
-1
/similarto/"
resolver=
"resolverelasticsearch"
location=
"https://dodis.ch/G82"
>
<h3
slot=
"title"
>
Example 4: Links (similarto) from geolinker dodis: Diedenhofen
</h3>
</histhub-widget>
<histhub-widget
endpoint=
"//api.geolinker.histhub.ch/v1-1/sameas/"
resolver=
"resolverneo4j"
location=
"https://dodis.ch/G82000000000000"
>
<h3
slot=
"title"
>
Example 5: No links (sameas) from geolinker
</h3>
</histhub-widget>
</div>
</body>
</html>
src/histhub-widget.js
View file @
2a936820
...
...
@@ -119,28 +119,34 @@
if
(
this
.
loading
)
{
this
.
_linksSlot
.
innerHTML
=
`Loading data...`
;
}
else
{
// small util to build the links
const
buildLinks
=
()
=>
this
.
links
.
map
((
link
)
=>
{
let
anchor
=
null
;
let
href
=
null
;
// check f we get an array or an object
if
(
typeof
link
===
"
object
"
)
{
const
provider
=
Object
.
keys
(
link
)[
0
];
// often we do not have information about the provider
if
(
typeof
provider
===
"
string
"
&&
provider
!==
""
)
{
anchor
=
provider
;
if
(
this
.
links
.
length
===
0
)
{
// hide if there is no data
this
.
_linksSlot
.
style
.
display
=
'
none
'
;
this
.
_titleSlot
.
style
.
display
=
'
none
'
;
}
else
{
// small util to build the links
const
buildLinks
=
()
=>
this
.
links
.
map
((
link
)
=>
{
let
anchor
=
null
;
let
href
=
null
;
// check f we get an array (v1) or an object (v1.1)
if
(
typeof
link
===
"
object
"
)
{
const
provider
=
Object
.
keys
(
link
)[
0
];
// often we do not have information about the provider
if
(
typeof
provider
===
"
string
"
&&
provider
!==
""
)
{
anchor
=
provider
;
}
else
{
anchor
=
link
[
provider
];
}
href
=
link
[
provider
];
}
else
{
anchor
=
link
[
provider
];
href
=
link
;
anchor
=
link
;
}
href
=
link
[
provider
];
}
else
{
href
=
link
;
anchor
=
link
;
}
// build the list
return
`<li><a href="
${
href
}
">
${
anchor
}
</a></li>`
;
});
this
.
_linksSlot
.
innerHTML
=
`<ul>
${
buildLinks
().
join
(
""
)}
</ul>`
;
// build the list
return
`<li><a href="
${
href
}
">
${
anchor
}
</a></li>`
;
});
this
.
_linksSlot
.
innerHTML
=
`<ul>
${
buildLinks
().
join
(
""
)}
</ul>`
;
}
}
}
}
...
...
Write
Preview
Supports
Markdown
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