<commit_before>'use strict';

var $$ = React.createElement;
var _ = require("substance/helpers");
var Panel = require("substance-ui/panel");
var Interview = require("../../interview");
var exporter = new Interview.HtmlExporter();
// Abstract class!

class InfoPanel extends Panel {

  // Event handlers
  // -----------------

  handleClick(e) {
    console.log('meh');

    e.preventDefault();
    // var commentId = e.currentTarget.dataset.id;

    // this.context.app.replaceState({
    //   contextId: "show-comment",
    //   commentId: commentId
    // });
  }

  render() {
    var doc = this.props.doc;
    var metadata = doc.getDocumentMeta();
    var photo = this._renderPhoto(metadata);

    return $$("div", {className: "panel info-panel-component"},
      $$('div', {className: 'panel-content'},
        photo,
        $$('div', {className: 'abstract', ref: 'abstract'}),
        $$('div', {className: 'biography', ref: 'biography'},
          $$('span', {className: 'section-title', id: 'biography'}, i18n.t('metadata.interviewee_bio'))
        )
      )
    );
  }

  _renderPhoto(metadata) {
    var filename = metadata.interviewee_photo;
    if(!filename) return '';
    var path = window.mediaServer + '/photos/' + filename;
    return $$('div', {className: 'photo'},
      $$('img', {src: path})
    );
  }

  _renderContent() {
    var doc = this.props.doc;
    var abstract_prop, bio_prop;
    var storage = window.storage || window.localStorage;
    var locale = storage.getItem('locale') || "ru";
    if(locale == "ru") {
      abstract_prop = "abstract";
      bio_prop = "interviewee_bio";
    } else if (locale == "en") {
      abstract_prop = "abstract_en";
      bio_prop = "interviewee_bio_en";
    } else if (locale == "de") {
      abstract_prop = "abstract_de";
      bio_prop = "interviewee_bio_de";
    }
    var $abstract = exporter.convertProperty(doc, ['document', abstract_prop]);
    var $bio = exporter.convertProperty(doc, ['document', bio_prop]);
    var splitted_abstract = $abstract.text().split('\n');
    var teaser_abstract = splitted_abstract.shift();
    var $teaser_abstract = $("<span/>", { class: "teaser" }).append(teaser_abstract);
    var complete_abstract = splitted_abstract.join('\n');
    var $complete_abstract = $("<span/>", { class: "complete", dangerouslySetInnerHTML: {__html: '<p>' + complete_abstract.split('\n').join('</p><p>') + '</p>' } });
    var $more = $("<span/>", { class: "more", text: i18n.t('metadata.show_more')});
    $more.click(function(){
      var $complete = $(this).siblings('.complete');
      var $teaser = $(this).siblings('.teaser');
      var isFullText = $complete.is(':visible');
      if(isFullText) {
        $complete.hide();
        $teaser.css('display', 'inline');
        $(this).text(i18n.t('metadata.show_more'));
      } else {
        $complete.show();<commit_msg>Html abstract.<commit_after>'use strict';

var $$ = React.createElement;
var _ = require("substance/helpers");
var Panel = require("substance-ui/panel");
var Interview = require("../../interview");
var exporter = new Interview.HtmlExporter();
// Abstract class!

class InfoPanel extends Panel {

  // Event handlers
  // -----------------

  handleClick(e) {
    console.log('meh');

    e.preventDefault();
    // var commentId = e.currentTarget.dataset.id;

    // this.context.app.replaceState({
    //   contextId: "show-comment",
    //   commentId: commentId
    // });
  }

  render() {
    var doc = this.props.doc;
    var metadata = doc.getDocumentMeta();
    var photo = this._renderPhoto(metadata);

    return $$("div", {className: "panel info-panel-component"},
      $$('div', {className: 'panel-content'},
        photo,
        $$('div', {className: 'abstract', ref: 'abstract'}),
        $$('div', {className: 'biography', ref: 'biography'},
          $$('span', {className: 'section-title', id: 'biography'}, i18n.t('metadata.interviewee_bio'))
        )
      )
    );
  }

  _renderPhoto(metadata) {
    var filename = metadata.interviewee_photo;
    if(!filename) return '';
    var path = window.mediaServer + '/photos/' + filename;
    return $$('div', {className: 'photo'},
      $$('img', {src: path})
    );
  }

  _renderContent() {
    var doc = this.props.doc;
    var abstract_prop, bio_prop;
    var storage = window.storage || window.localStorage;
    var locale = storage.getItem('locale') || "ru";
    if(locale == "ru") {
      abstract_prop = "abstract";
      bio_prop = "interviewee_bio";
    } else if (locale == "en") {
      abstract_prop = "abstract_en";
      bio_prop = "interviewee_bio_en";
    } else if (locale == "de") {
      abstract_prop = "abstract_de";
      bio_prop = "interviewee_bio_de";
    }
    var $abstract = exporter.convertProperty(doc, ['document', abstract_prop]);
    var $bio = exporter.convertProperty(doc, ['document', bio_prop]);
    var splitted_abstract = $abstract.text().split('\n');
    var teaser_abstract = splitted_abstract.shift();
    var $teaser_abstract = $("<span/>", { class: "teaser" }).append(teaser_abstract);
    var complete_abstract = splitted_abstract.join('\n');
    var $complete_abstract = $$('div', { 
      className: "complete", 
      dangerouslySetInnerHTML: {
        __html: '<p>' + complete_abstract.split('\n').join('</p><p>') + '</p>' 
      } 
    });
    var $more = $("<span/>", { class: "more", text: i18n.t('metadata.show_more')});
    $more.click(function(){
      var $complete = $(this).siblings('.complete');
      var $teaser = $(this).siblings('.teaser');
      var isFullText = $complete.is(':visible');
      if(isFullText) {
        $complete.hide();
        $teaser.css('display', 'inline');
        $(this).text(i18n.t('metadata.show_more'));
      } else {
        $complete.show();
{'fraction_non_alphanumeric': 0.19314048155205266, 'fraction_numerical': 0.0020786419539234368, 'mean_word_length': 3.069062720225511, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4417077', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1818, 'n_words': 368}