<div class="twelve columns">
    <style>
        .alert-partial.partial:hover {
            cursor: pointer;   
        }
        .close-icon {
            float: right;
            color: black;
            padding-right: 5px;
        }
    </style>
    <div class="alert-partial partial" id="{{ partial_item.name }}" style="display:none">
        <div class="alert-msg" style="display:inline-block"></div>
        <a class="alert-partial close-icon" style="display:inline-block" ></a>
   </div>
</div>

<script type="text/javascript">
    $(function () {
               
        var alertWrapper = $('#{{ partial_item.name }}');
        var alertElement =  $('#{{ partial_item.name }} > .alert-msg')[0];
        var alertCloseElement = $('#{{ partial_item.name }} > a')[0];

        var streamConfig = {
            record_type: {{ partial_item.record_type|tojson|safe }},
            start_key: {{ partial_item.start_key|tojson|safe }},
            key_field: {{ partial_item.key_field|tojson|safe }},
            count: {{ partial_item.count|tojson|safe }},
            end_key: {{ partial_item.end_key|tojson|safe }},
            return_children: {{ partial_item.return_children|tojson|safe }},
            stream_tag: {{ partial_item.stream_tag|tojson|safe }},
            force: {{ partial_item.force|tojson|safe }}
        };

        var alertStream = new Stream(socket, streamConfig, (data) => {
            if ('alert' in data) {
                alertElement.innerHTML = data['alert']
                alertCloseElement.innerHTML = "[ ✕ ]"; 
                $(alertWrapper).show();
            } 
            if ('alertcolor' in data) {
                $(alertWrapper).css({"background-color": data['alertcolor']})
            } 
        }); 
        
        alertStream.startStream();

    });
</script>