{% if filetype == 'Text' %} {% ifnotequal file_content None %} $('#file-view').html('
{{ err }}
').addClass('file-view-tip'); {% endif %} $('#file-op').removeClass('hide'); {% endif %} {% if filetype == 'Image' %} $('#file-view').html('在线查看:请使用firefox, chrome 或 IE 9。
').addClass('file-view-tip'); } else { $('#file-view').html(''); } $('#file-op').removeClass('hide'); {% endif %} {% if filetype == 'Document' %} var uuid = '', obj_id = ''; function create_session() { $.ajax({ url: '{{ SITE_ROOT }}crocodoc/session/?uuid=' + uuid, cache: false, contentType: 'application/json; charset=utf-8', success: function(data) { if (data.length > 0) { $('#file-view').html('').attr('class', ''); } }, error: function(xhr, ajaxOptions, thrownError) { var jsonVal = jQuery.parseJSON(xhr.responseText); $('#file-view').html('' + jsonVal[0]['error'] + '
'); } }); } function check_status () { $.ajax({ url: '{{ SITE_ROOT }}crocodoc/status/?uuids='+ uuid + '&obj_id=' + obj_id, cache: false, contentType: 'application/json; charset=utf-8', success: function(data) { if (data.length > 0) { var status = data[0]['status']; if (status == 'QUEUED') { $('#file-view').html('' + '文档转换任务正在排队,请稍后...' + '
'); setTimeout(check_status, 1000); } else if (status == 'PROCESSING') { $('#file-view').html('' + '文档正在转换,请稍候...' + '
'); setTimeout(check_status, 1000); } else { $('#file-view').html('' + '文档转换成功。正在打开...' + '
'); create_session(); } } }, error: function(xhr, ajaxOptions, thrownError) { var jsonVal = jQuery.parseJSON(xhr.responseText); $('#file-view').html('' + jsonVal[0]['error'] + '
'); } }); } if (!$.browser.mozilla && !$.browser.safari) { $('#file-view').html('在线查看:请使用firefox 或 chrome。
').addClass('file-view-tip'); } else { $.ajax({ url: '{{ SITE_ROOT }}crocodoc/upload/?raw_path={{ raw_path|urlencode }}', cache: false, contentType: 'application/json; charset=utf-8', success: function(data) { if (data.length > 0) { uuid = data[0]['uuid']; obj_id = data[0]['obj_id']; $('#file-view').html('文档内容读取成功,开始转换...
').addClass('file-view-tip'); check_status(); } }, error: function(xhr, ajaxOptions, thrownError) { var jsonVal = jQuery.parseJSON(xhr.responseText); $('#file-view').html('' + jsonVal[0]['error'] + '
').addClass('file-view-tip'); } }); } $('#file-op').removeClass('hide'); {% endif %} {% if filetype == 'PDF' %} $('#view-original').addClass('hide'); if (!$.browser.mozilla && !$.browser.safari) { $('#file-view').html('在线查看:请使用firefox 或 chrome。
').addClass('file-view-tip'); } else { PDFJS.workerSrc = '{{MEDIA_URL}}js/pdf.js'; $('#file-view').html('{{ err }}
').addClass('file-view-tip'); {% endif %} $('#file-op').removeClass('hide'); {% endif %} {% if filetype == 'Unknown' %} $('#file-view').html('该类型文件无法在线查看。
').addClass('file-view-tip'); $('#file-op').removeClass('hide'); {% endif %}