custom/static-plugins/netzpvoucherlink6/src/Resources/views/storefront/base.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/base.html.twig' %}
  2. {% block base_flashbags %}
  3.     {{ parent() }}
  4.    <div class="flashbags container netzp-voucherlink-message">
  5.    </div>
  6.    <script>
  7.        if(window.location.hash) {
  8.            var params = window.location.hash.substr(1).split('#');
  9.            var type = "info";
  10.            var msg = "";
  11.            // ?#msg=Message+1@info###Message+2@success###Message+3@error
  12.            if(params[0] !== "") {
  13.                var messageParts = params[0].split("=");
  14.                if(messageParts[0] == "msg") {
  15.                    var page = document.getElementsByClassName("netzp-voucherlink-message")[0];
  16.                    if (page) {
  17.                        var s = messageParts[1],
  18.                            p = s.indexOf('&'); // strip additional parameters (affiliate codes etc.)
  19.                        if(p >= 0) {
  20.                            s = s.substring(0, p);
  21.                        }
  22.                        var messages = s.split("@@@");
  23.                        messages.reverse().forEach(function (msg, index) {
  24.                            var parts = msg.split('@');
  25.                            var msg = parts[0], type = 'info';
  26.                            if (parts.length > 1) {
  27.                                type = parts[1]
  28.                            }
  29.                            msg = decodeURI(msg);
  30.                            msg = strip_tags(msg, '<b><i>');
  31.                            var html = '';
  32.                            html += '<div class="alert alert-' + type + '">';
  33.                            html += '<div class="alert-content-container">' + decodeURI(msg) + '</div>';
  34.                            html += '</div>';
  35.                            var msgDom = document.createElement("div");
  36.                            msgDom.innerHTML = html;
  37.                            page.insertBefore(msgDom.childNodes[0], page.childNodes[0]);
  38.                        });
  39.                    }
  40.                    document.body.classList.add("is--netzp-voucher-msg");
  41.                }
  42.            }
  43.        }
  44.        function strip_tags(input, allowed) {
  45.            allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('')
  46.            var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi
  47.            return input.replace(tags, function ($0, $1) {
  48.                return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''
  49.            })
  50.        }
  51.    </script>
  52. {% endblock %}