<!doctype html>
{% load i18n staticfiles %}
<html>
<head>
    <title>{{doc_title}}</title>
    <link rel="shortcut icon" href="{{ MEDIA_URL }}{{ favicon_path }}" />
    <meta charset="utf-8">
    <!-- Enable IE Standards mode -->
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type="text/css">
        html,
        body {
            margin: 0;
            padding: 0;
            height:100%;
            overflow:hidden;
        }
        #office_frame {
            display: block;
            width:100%;
            height: 100%;
            border: none;
            margin: 0;
        }
        .hide {
            display:none;
        }
    </style>
</head>
<body>

<form id="office_form" name="office_form" target="office_frame" action="{{action_url}}" method="post">
    <input name="access_token" value="{{access_token}}" type="hidden"/>
    <input name="access_token_ttl" value="{{access_token_ttl}}" type="hidden"/>
</form>

<iframe id="office_frame" name="office_frame" class="hide" allowfullscreen ></iframe>

<script type="text/javascript">
var SEAFILE_GLOBAL = {
    csrfCookieName: '{{ CSRF_COOKIE_NAME }}'
};
</script>
<script type="text/javascript" src="{% static "scripts/lib/jquery.min.js" %}"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/jq.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/base.js?t=1536127546642"></script>
<script type="text/javascript">
    document.getElementById('office_form').submit();
    document.getElementById('office_frame').className = '';

    {% if can_edit %}
    var interval;
    var refreshLock = function() {
        $.ajax({
            url: '{% url "api-v2.1-file-view" repo_id %}' + '?p={{path|urlencode}}',
            type: 'PUT',
            dataType: 'json',
            data: {
                'operation': 'refresh-lock'
            },
            cache: false,
            beforeSend: prepareCSRFToken,
            success: function(data) {
            },
            error: function(xhr) {
                if (xhr.responseText) {
                    feedback(JSON.parse(xhr.responseText).error_msg, 'error');
                } else {
                    feedback("{% trans "Failed. Please check the network." %}", 'error');
                }
                clearInterval(interval);
            }
        });
    };
    interval = setInterval(refreshLock, 60 * 1000);
    {% endif %}
</script>
{% if enable_watermark %}
<script type="text/javascript" src="{{ MEDIA_URL }}js/watermark.js"></script>
<script type="text/javascript">{% include "snippets/add_watermark.html" %}</script>
{% endif %}
</body>
</html>
