<commit_before>// Documents viewer

'use strict';

var curry              = require('es5-ext/function/#/curry')
  , nextTick           = require('next-tick')
  , _                  = require('mano').i18n.bind('User: Submitted')
  , resolveArchivePath = require('../utils/resolve-document-archive-path')
  , syncHeight         = require('./utils/sync-height')
  , scrollBottom       = require('./utils/scroll-to-bottom')
  , isReadOnlyRender   = require('mano/client/utils/is-read-only-render')
  , docMimeTypes       = require('../utils/microsoft-word-doc-mime-types')
  , includes           = require('es5-ext/array/#/contains')
  , endsWith           = require('es5-ext/string/#/ends-with')
  , db                 = require('mano').db

  , _d = _;

var getFilePreview = function (file) {
	var type = file.type;
	if (includes.call(docMimeTypes, type)) {
		return img({ class: 'submitted-preview-new-word-document', src: '/img/word-doc-icon.png' });
	}
	if (!isReadOnlyRender && (type === 'application/pdf')) {
		return iframe({
			src: url('pdfjs/web/viewer.html?file=') + file.path
		});
	}
	return img({ zoomOnHover: true, src: or(resolve(file._preview, '_url'),
		resolve(file._thumb, '_url')) });
};

module.exports = function (doc, sideContent) {
	var elem, scrollableElem;

	return [h2(doc._label.map(function (label) { return _d(label, doc.getTranslations()); })),
		insert(_if(doc.statusLog.ordered._size,
			section(
				{ class: 'section-primary' },
				h2(_("Documents history")),
				scrollableElem = div(
					{ class: 'submitted-user-history-wrapper' },
					table(
						{ class: 'submitted-user-history' },
						tbody(
							doc.statusLog.ordered,
							function (log) {
								th(log.label);
								td({ class: 'submitted-user-history-time' }, log.time);
								td(log.text && log.text.split('\n').filter(Boolean).map(curry.call(p, 1)));
							}
						)
					)
				)
			))),
		doc.isCertificate ?
				section(
					{ class: 'section-primary' },
					h2(_("Data of certificate")),
					doc.dataForm.constructor !== db.FormSectionBase ?<commit_msg>Use external filePreview utility<commit_after>// Documents viewer

'use strict';

var curry              = require('es5-ext/function/#/curry')
  , nextTick           = require('next-tick')
  , _                  = require('mano').i18n.bind('User: Submitted')
  , resolveArchivePath = require('../utils/resolve-document-archive-path')
  , syncHeight         = require('./utils/sync-height')
  , scrollBottom       = require('./utils/scroll-to-bottom')
  , endsWith           = require('es5-ext/string/#/ends-with')
  , db                 = require('mano').db

  , _d = _

  , getFilePreview = require('./utils/get-file-preview');

module.exports = function (doc, sideContent) {
	var elem, scrollableElem;

	return [h2(doc._label.map(function (label) { return _d(label, doc.getTranslations()); })),
		insert(_if(doc.statusLog.ordered._size,
			section(
				{ class: 'section-primary' },
				h2(_("Documents history")),
				scrollableElem = div(
					{ class: 'submitted-user-history-wrapper' },
					table(
						{ class: 'submitted-user-history' },
						tbody(
							doc.statusLog.ordered,
							function (log) {
								th(log.label);
								td({ class: 'submitted-user-history-time' }, log.time);
								td(log.text && log.text.split('\n').filter(Boolean).map(curry.call(p, 1)));
							}
						)
					)
				)
			))),
		doc.isCertificate ?
				section(
					{ class: 'section-primary' },
					h2(_("Data of certificate")),
					doc.dataForm.constructor !== db.FormSectionBase ?
{'fraction_non_alphanumeric': 0.17529544175576814, 'fraction_numerical': 0.004783342712436691, 'mean_word_length': 2.7186192468619246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '504838', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1145, 'n_words': 185}