{% if filetype == 'Text' %} $.ajax({ url: url, dataType: 'json', cache: false, success: function(data) { $('#file-view').html('
' + jsonVal['error'] + '
'); } }); {% endif %} {% if filetype == 'Image' %} $('#file-view').html('在线查看:请使用firefox, chrome 或 IE 9。
'); } else { $('#file-view').html(''); } {% 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(''); } }, 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。
'); } 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('文档内容读取成功,开始转换...
'); check_status(); } }, error: function(xhr, ajaxOptions, thrownError) { var jsonVal = jQuery.parseJSON(xhr.responseText); $('#file-view').html('' + jsonVal[0]['error'] + '
'); } }); } {% endif %} {% if filetype == 'PDF' %} if (!$.browser.mozilla && !$.browser.safari) { $('#file-view').html('在线查看:请使用firefox 或 chrome。
'); } else { PDFJS.workerSrc = '{{MEDIA_URL}}js/pdf.js'; $('#file-view').html('该类型文件无法在线查看。下载
'); {% endif %}