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
IRMA
Github mirrors
angrygames
Commits
7d93ba37
Commit
7d93ba37
authored
Oct 12, 2020
by
Ivar Derksen
Browse files
Updated irma-frontend version
parent
da6e3030
Pipeline
#45868
passed with stage
in 7 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
js/irma.js
View file @
7d93ba37
This diff is collapsed.
Click to expand it.
js/main.js
View file @
7d93ba37
(
function
(
$
)
{
"
use strict
"
// Mobile Nav toggle
$
(
'
.menu-toggle > a
'
).
on
(
'
click
'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
'
#responsive-nav
'
).
toggleClass
(
'
active
'
);
})
// Fix cart dropdown from closing
$
(
'
.cart-dropdown
'
).
on
(
'
click
'
,
function
(
e
)
{
e
.
stopPropagation
();
});
/////////////////////////////////////////
// Products Slick
$
(
'
.products-slick
'
).
each
(
function
()
{
var
$this
=
$
(
this
),
$nav
=
$this
.
attr
(
'
data-nav
'
);
$this
.
slick
({
slidesToShow
:
4
,
slidesToScroll
:
1
,
autoplay
:
true
,
infinite
:
true
,
speed
:
300
,
dots
:
false
,
arrows
:
true
,
appendArrows
:
$nav
?
$nav
:
false
,
responsive
:
[{
breakpoint
:
991
,
settings
:
{
slidesToShow
:
2
,
slidesToScroll
:
1
,
}
},
{
breakpoint
:
480
,
settings
:
{
slidesToShow
:
1
,
slidesToScroll
:
1
,
}
},
]
});
});
// Product Main img Slick
$
(
'
#product-main-img
'
).
slick
({
infinite
:
true
,
speed
:
300
,
dots
:
false
,
arrows
:
true
,
fade
:
true
,
asNavFor
:
'
#product-imgs
'
,
});
// Product imgs Slick
$
(
'
#product-imgs
'
).
slick
({
slidesToShow
:
3
,
slidesToScroll
:
1
,
arrows
:
true
,
centerMode
:
true
,
focusOnSelect
:
true
,
centerPadding
:
0
,
vertical
:
true
,
asNavFor
:
'
#product-main-img
'
,
responsive
:
[{
breakpoint
:
991
,
settings
:
{
vertical
:
false
,
arrows
:
false
,
dots
:
true
,
}
},
]
});
// Product img zoom
var
zoomMainProduct
=
document
.
getElementById
(
'
product-main-img
'
);
if
(
zoomMainProduct
)
{
$
(
'
#product-main-img .product-preview
'
).
zoom
();
}
// Go to age verification page
$
(
'
.add-to-cart-btn
'
).
on
(
'
click
'
,
function
(
element
)
{
sessionStorage
.
setItem
(
'
minage
'
,
element
.
currentTarget
.
getAttribute
(
'
data-minage
'
));
sessionStorage
.
setItem
(
'
productname
'
,
element
.
currentTarget
.
getAttribute
(
'
data-productname
'
));
sessionStorage
.
setItem
(
'
productid
'
,
element
.
currentTarget
.
id
);
window
.
location
.
href
=
'
cart.html
'
;
});
// If no product is chosen yet, return to the index page.
if
(
location
.
pathname
.
includes
(
'
cart.html
'
)
&&
!
sessionStorage
.
getItem
(
'
productid
'
))
location
.
href
=
'
index.html
'
;
// Age verification with IRMA
if
(
window
.
irma
)
{
console
.
log
(
"
Age verification started
"
);
irma
.
new
({
element
:
'
#irma-web-element
'
,
session
:
{
url
:
''
,
start
:
{
url
:
o
=>
`start_session.php?type=`
+
sessionStorage
.
getItem
(
'
minage
'
)
+
'
plus
'
,
body
:
null
,
headers
:
[],
method
:
'
GET
'
,
},
result
:
{
url
:
(
o
,
{
sessionPtr
,
sessionToken
})
=>
`
${
sessionPtr
.
u
.
split
(
'
/irma
'
)[
0
]}
/session/
${
sessionToken
}
/result`
,
}
},
translations
:
{
'
success
'
:
'
Gegevens ontvangen.
'
},
});
let
success
=
function
(
data
)
{
console
.
log
(
"
Session successful!
"
);
console
.
log
(
"
Result:
"
,
data
);
// Continue to order page if user is 18+
if
(
data
.
disclosed
[
0
][
0
].
rawvalue
.
toLowerCase
()
===
'
yes
'
)
{
setTimeout
(()
=>
{
$
(
'
#phase-agecheck
'
).
hide
();
$
(
'
#phase-finished
'
).
show
();
$
(
'
#breadcrumb
'
).
show
();
$
(
'
html
'
).
scrollTop
(
0
);
},
1000
);
}
else
{
$
(
'
#snackbar-content
'
).
html
(
'
U hebt niet de juiste leeftijd om dit artikel te mogen bestellen.
'
);
$
(
'
#snackbar
'
).
addClass
(
'
show
'
);
}
};
let
error
=
function
(
data
)
{
console
.
log
(
"
Session failed!
"
);
console
.
log
(
"
Error data:
"
,
data
);
$
(
'
#snackbar-content
'
).
html
(
'
Er is een fout opgetreden bij de leeftijdsverificatie via IRMA.
'
);
$
(
'
#snackbar
'
).
addClass
(
'
show
'
);
};
irma
.
start
().
then
(
success
,
error
);
}
})(
jQuery
);
(
function
(
$
)
{
"
use strict
"
// Mobile Nav toggle
$
(
'
.menu-toggle > a
'
).
on
(
'
click
'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
'
#responsive-nav
'
).
toggleClass
(
'
active
'
);
})
// Fix cart dropdown from closing
$
(
'
.cart-dropdown
'
).
on
(
'
click
'
,
function
(
e
)
{
e
.
stopPropagation
();
});
/////////////////////////////////////////
// Products Slick
$
(
'
.products-slick
'
).
each
(
function
()
{
var
$this
=
$
(
this
),
$nav
=
$this
.
attr
(
'
data-nav
'
);
$this
.
slick
({
slidesToShow
:
4
,
slidesToScroll
:
1
,
autoplay
:
true
,
infinite
:
true
,
speed
:
300
,
dots
:
false
,
arrows
:
true
,
appendArrows
:
$nav
?
$nav
:
false
,
responsive
:
[{
breakpoint
:
991
,
settings
:
{
slidesToShow
:
2
,
slidesToScroll
:
1
,
}
},
{
breakpoint
:
480
,
settings
:
{
slidesToShow
:
1
,
slidesToScroll
:
1
,
}
},
]
});
});
// Product Main img Slick
$
(
'
#product-main-img
'
).
slick
({
infinite
:
true
,
speed
:
300
,
dots
:
false
,
arrows
:
true
,
fade
:
true
,
asNavFor
:
'
#product-imgs
'
,
});
// Product imgs Slick
$
(
'
#product-imgs
'
).
slick
({
slidesToShow
:
3
,
slidesToScroll
:
1
,
arrows
:
true
,
centerMode
:
true
,
focusOnSelect
:
true
,
centerPadding
:
0
,
vertical
:
true
,
asNavFor
:
'
#product-main-img
'
,
responsive
:
[{
breakpoint
:
991
,
settings
:
{
vertical
:
false
,
arrows
:
false
,
dots
:
true
,
}
},
]
});
// Product img zoom
var
zoomMainProduct
=
document
.
getElementById
(
'
product-main-img
'
);
if
(
zoomMainProduct
)
{
$
(
'
#product-main-img .product-preview
'
).
zoom
();
}
// Go to age verification page
$
(
'
.add-to-cart-btn
'
).
on
(
'
click
'
,
function
(
element
)
{
sessionStorage
.
setItem
(
'
minage
'
,
element
.
currentTarget
.
getAttribute
(
'
data-minage
'
));
sessionStorage
.
setItem
(
'
productname
'
,
element
.
currentTarget
.
getAttribute
(
'
data-productname
'
));
sessionStorage
.
setItem
(
'
productid
'
,
element
.
currentTarget
.
id
);
window
.
location
.
href
=
'
cart.html
'
;
});
// If no product is chosen yet, return to the index page.
if
(
location
.
pathname
.
includes
(
'
cart.html
'
)
&&
!
sessionStorage
.
getItem
(
'
productid
'
))
location
.
href
=
'
index.html
'
;
// Age verification with IRMA
if
(
window
.
irma
)
{
console
.
log
(
"
Age verification started
"
);
irma
.
newWeb
({
element
:
'
#irma-web-element
'
,
session
:
{
url
:
''
,
start
:
{
url
:
o
=>
`start_session.php?type=`
+
sessionStorage
.
getItem
(
'
minage
'
)
+
'
plus
'
,
},
result
:
{
url
:
(
o
,
{
sessionPtr
,
sessionToken
})
=>
`
${
sessionPtr
.
u
.
split
(
'
/irma
'
)[
0
]}
/session/
${
sessionToken
}
/result`
,
}
},
translations
:
{
'
success
'
:
'
Gegevens ontvangen.
'
},
});
let
success
=
function
(
data
)
{
console
.
log
(
"
Session successful!
"
);
console
.
log
(
"
Result:
"
,
data
);
// Continue to order page if user is 18+
if
(
data
.
disclosed
[
0
][
0
].
rawvalue
.
toLowerCase
()
===
'
yes
'
)
{
setTimeout
(()
=>
{
$
(
'
#phase-agecheck
'
).
hide
();
$
(
'
#phase-finished
'
).
show
();
$
(
'
#breadcrumb
'
).
show
();
$
(
'
html
'
).
scrollTop
(
0
);
},
1000
);
}
else
{
$
(
'
#snackbar-content
'
).
html
(
'
U hebt niet de juiste leeftijd om dit artikel te mogen bestellen.
'
);
$
(
'
#snackbar
'
).
addClass
(
'
show
'
);
}
};
let
error
=
function
(
data
)
{
console
.
log
(
"
Session failed!
"
);
console
.
log
(
"
Error data:
"
,
data
);
$
(
'
#snackbar-content
'
).
html
(
'
Er is een fout opgetreden bij de leeftijdsverificatie via IRMA.
'
);
$
(
'
#snackbar
'
).
addClass
(
'
show
'
);
};
irma
.
start
().
then
(
success
,
error
);
}
})(
jQuery
);
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