Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100840085
availabilityline.component.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 3, 04:34
Size
3 KB
Mime Type
text/html
Expires
Wed, Feb 5, 04:34 (2 d)
Engine
blob
Format
Raw Data
Handle
24042813
Attached To
rPRIMOIII Primo_3_package
availabilityline.component.js
View Options
module
.
exports
=
{
bindings
:
{
parentCtrl
:
'<'
},
controllerAs
:
'ctrl'
,
controller
:
[
'$filter'
,
'$http'
,
'userService'
,
function
(
$filter
,
$http
,
userService
)
{
var
vm
=
this
function
parse_doi
(
txt
){
var
re
=
/10\.\d{4,9}\/[-._;()/:A-Z0-9]+/i
;
var
m
=
txt
.
match
(
re
);
if
(
m
){
return
m
[
0
]
}
}
vm
.
is_epfl_IP
=
false
;
var
userIP
=
userService
.
getIP
();
// console.log(userIP);
// Vérification du range EPFL
if
(
userIP
)
{
const
regex
=
/128\.17([89])\.(\d{1,3})\./
;
const
found
=
userIP
.
match
(
regex
);
if
(
found
&&
(
found
[
1
]
==
'8'
||
parseInt
(
found
[
2
])
>=
128
))
{
vm
.
is_epfl_IP
=
true
;
}
}
vm
.
get_doi
=
function
(){
if
(
vm
.
parentCtrl
.
hasOwnProperty
(
'result'
)
&&
vm
.
parentCtrl
.
result
.
hasOwnProperty
(
'pnx'
)){
var
pnx
=
vm
.
parentCtrl
.
result
.
pnx
;
// Recherche dans la section addata
if
(
'addata'
in
pnx
&&
'doi'
in
pnx
.
addata
&&
parse_doi
(
pnx
.
addata
.
doi
[
0
])
&&
pnx
.
control
.
recordtype
[
0
]
===
'article'
)
{
return
parse_doi
(
pnx
.
addata
.
doi
[
0
])
}
// Recherche dans la section display
if
(
'display'
in
pnx
&&
'identifier'
in
pnx
.
display
)
{
for
(
const
identifier
of
pnx
.
display
.
identifier
){
if
(
parse_doi
(
identifier
)){
return
parse_doi
(
identifier
)
}
}
}
}
}
vm
.
check_doi
=
function
(){
if
(
!
vm
.
hasOwnProperty
(
'doi'
)){
if
(
vm
.
parentCtrl
.
hasOwnProperty
(
'result'
)
&&
vm
.
parentCtrl
.
result
.
hasOwnProperty
(
'pnx'
)){
if
(
vm
.
get_doi
()){
vm
.
doi
=
vm
.
get_doi
();
vm
.
set_url_pdf
()
}
else
{
vm
.
doi
=
null
;
}
}
}
if
(
vm
.
hasOwnProperty
(
'pdf_link'
))
{
return
true
}
return
false
}
vm
.
set_url_pdf
=
function
(){
var
url
=
`
https
:
//public-api.thirdiron.com/public/v1/libraries/183/articles/doi/${vm.doi}?access_token=adc54dee-c6a6-4b99-a917-2ed400f1f2d3`;
$http
({
method
:
'GET'
,
url
:
url
}).
then
(
function
successCallback
(
response
)
{
if
(
response
.
status
===
200
)
{
try
{
var
pdf_link
=
response
.
data
.
data
.
fullTextFile
;
}
catch
(
e
){
var
pdf_link
=
''
;
}
if
(
pdf_link
.
length
>
0
)
{
vm
.
pdf_link
=
pdf_link
;
}
}
// console.log(vm.pdf_link);
},
function
(
response
)
{
vm
.
doi
=
null
;
});
}
// console.log(vm);
}],
template
:
`
<
div
><
div
class
=
"pdf_btn"
ng
-
if
=
"ctrl.check_doi() && ctrl.is_epfl_IP"
>
<
a
href
=
"{{ctrl.pdf_link}}"
target
=
"_blank"
><
prm
-
icon
icon
-
type
=
"svg"
svg
-
icon
-
set
=
"primo-ui"
icon
-
definition
=
"pdf"
><
/prm-icon> {{ 'pdfAccess' | customTranslate }}</a></div></div>`
}
Event Timeline
Log In to Comment