{% load i18n %} {% if not err %} {% if filetype == 'Text' %} {% ifnotequal file_content None %} var editor = CodeMirror.fromTextArea($('#docu-view')[0], { {% include 'snippets/editor_set_mode.html' %} theme: 'default', indentUnit: 4, {% if fileext != 'txt' and fileext != 'text' %} lineNumbers: true, {% endif %} lineWrapping: true, readOnly: true }); {% endifnotequal %} {% endif %} {% if filetype == 'Image' %} {% include 'snippets/image_file_view_js.html' %} {% endif %} {% if filetype == 'SVG' %} function setFileViewAreaHeight() { var $fileView = $('#file-view'); $fileView.outerHeight($(window).height() - $fileView.offset().top); } setFileViewAreaHeight(); $(window).on('resize', setFileViewAreaHeight); $('#svg-view').prev('.loading-icon').hide(); $('#svg-view').show(); {% endif %} {% if filetype == 'Markdown' %} {% ifnotequal file_content None %} var renderer = new marked.Renderer(); // remove 'id' attribute for headings renderer.heading = function (text, level) { return '' + text + ''; }; marked.setOptions({ renderer: renderer, breaks: true, // keep linebreak smartLists: true, sanitize: true // Ignore any HTML that has been input }); $('#md-view').html(marked('{{ file_content|escapejs }}')).children(':first').css('margin-top', '0'); {% endifnotequal %} {% endif %} {% if filetype == 'Document' %} {% include 'snippets/document_file_viewer.html' %} {% endif %} {% if filetype == 'SpreadSheet' %} {% include 'snippets/spreadsheet_convert_js.html' %} {% endif %} {% if filetype == 'PDF' %} var raw_path = "{{ raw_path|escapejs }}"; {% include 'snippets/pdfjs_file_viewer.html' %} {% endif %} {% if filetype == 'Video' %} $('#file-view').html('
'); videojs.options.flash.swf = "{{MEDIA_URL}}js/video-js.swf"; videojs('sf-video', { 'controls': true, 'autoplay': false, 'preload': 'auto' }); {% endif %} {% if filetype == 'Audio' %} $('#file-view').html('
'); $('audio').mediaelementplayer(/* Options */); {% endif %} {% if filetype == 'Unknown' %} $('#file-view').html('
'); {% endif %} {% endif %}{# 'if not err' ends here. #} {% if filetype == 'Text' or filetype == 'Markdown' %} $('#file-enc').on('change', function() { var file_enc = $(this).val(); var s = location.search; if (s.indexOf('?') == -1) { location.search = '?file_enc=' + file_enc; } else { if (s.indexOf('file_enc') == -1) { location.search += '&file_enc=' + file_enc; } else { var params = s.substr(1).split('&'); var param; for (var i = 0, len = params.length; i < len; i++) { param = params[i].split('='); if (param[0] == 'file_enc') { param[1] = file_enc; params[i] = param.join('='); break; } } location.search = '?' + params.join('&'); } } }) {% endif %}