{% load staticfiles %}

<div id="{{ id }}"{% if origin != 'unknown' %} style="background: #fafafa; padding: 15px; display: table; border: 1px solid #dadada; text-align: center; width: 100%; height: 150px;">
    <div style="display: table-cell; vertical-align: middle; width: 100%; height: 100%%;">
        <img src="{% static 'img/loading.png' %}" width="48">
    </div>{% else %}><p><a href="{{ url }}" target="_blank">{{ url }}</a></p>{% endif %}

    <script>
        var url = '{{ OBJECT_URL }}?url=' + encodeURIComponent('{{ url|escapejs }}');
        var scriptTag = document.createElement('script');

        window['cb_{{ id }}'] = function(e) {
            if(e.html) {
                document.getElementById('{{ id }}').style = {};
                document.getElementById('{{ id }}').innerHTML = e.html;
            }
        };

        scriptTag.src = url + '&callback=cb_{{ id }}';
        document.getElementsByTagName('head')[0].appendChild(scriptTag);
    </script>
</div>
