{% sw_extends '@Storefront/storefront/base.html.twig' %}
{% block base_flashbags %}
{{ parent() }}
<div class="flashbags container netzp-voucherlink-message">
</div>
<script>
if(window.location.hash) {
var params = window.location.hash.substr(1).split('#');
var type = "info";
var msg = "";
// ?#msg=Message+1@info###Message+2@success###Message+3@error
if(params[0] !== "") {
var messageParts = params[0].split("=");
if(messageParts[0] == "msg") {
var page = document.getElementsByClassName("netzp-voucherlink-message")[0];
if (page) {
var s = messageParts[1],
p = s.indexOf('&'); // strip additional parameters (affiliate codes etc.)
if(p >= 0) {
s = s.substring(0, p);
}
var messages = s.split("@@@");
messages.reverse().forEach(function (msg, index) {
var parts = msg.split('@');
var msg = parts[0], type = 'info';
if (parts.length > 1) {
type = parts[1]
}
msg = decodeURI(msg);
msg = strip_tags(msg, '<b><i>');
var html = '';
html += '<div class="alert alert-' + type + '">';
html += '<div class="alert-content-container">' + decodeURI(msg) + '</div>';
html += '</div>';
var msgDom = document.createElement("div");
msgDom.innerHTML = html;
page.insertBefore(msgDom.childNodes[0], page.childNodes[0]);
});
}
document.body.classList.add("is--netzp-voucher-msg");
}
}
}
function strip_tags(input, allowed) {
allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('')
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi
return input.replace(tags, function ($0, $1) {
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''
})
}
</script>
{% endblock %}