<commit_before>'use strict'

import m from 'mithril'

import PhotosComponent from './desktop_photos_component'
import InfoComponent from './desktop_info_component'
import ContentComponent from './content_component.js'


//helpers
import dimensionsHelper from '../helpers/screen-dimensions.js'
import DB from '../services/db.js'

//styles
import style from '../../css/desktop-details.scss'

import fab from 'polythene/fab/fab'
import editIcon from 'mmsvg/google/msvg/editor/mode-edit'
import doneIcon from 'mmsvg/google/msvg/action/done'
import clearIcon from 'mmsvg/google/msvg/content/clear'

const closeWritingSection = function() {
  const ctrl = this

  if(ctrl.review().valid()) {
    const review = JSON.stringify(ctrl.review().props())
    const arr = ctrl.indexDBReviews()
    arr.push(JSON.parse(review))
    ctrl.indexDBReviews(arr)
  }
  
  ctrl.review().valid(false)
  ctrl.review().props().author_name('')
  ctrl.review().props().text('')
  ctrl.review().props().time('')
  ctrl.review().props().rating('')

//   console.log(ctrl.review().valid())
//   console.log(ctrl.review().props().author_name())
//   console.log(ctrl.review().props().text())
//   console.log(ctrl.review().props().time())
//   console.log(ctrl.review().props().rating())

  ctrl.writingActive(false)

  m.redraw()  
}

const captureElement = function(namespace, el, init) {
  if(!init) {
    dimensionsHelper.setElement(namespace, el)
    dimensionsHelper.setDimensions(namespace)
  }
}

const handleClearClick = function() {
  const ctrl = this

  ctrl.writingActive(false)
}

const handleWritingFabClick = function(type) {
  const ctrl = this

  // if edit -> do something
  if (type === 'edit') {
    if (dimensionsHelper.isDesktop()) {
      dimensionsHelper.scrollTop('desktop-details-container')  
    }
    ctrl.writingActive(true)<commit_msg>fix: clear button in desktop details view has different fucntion on close<commit_after>'use strict'

import m from 'mithril'

import PhotosComponent from './desktop_photos_component'
import InfoComponent from './desktop_info_component'
import ContentComponent from './content_component.js'


//helpers
import dimensionsHelper from '../helpers/screen-dimensions.js'
import DB from '../services/db.js'

//styles
import style from '../../css/desktop-details.scss'

import fab from 'polythene/fab/fab'
import editIcon from 'mmsvg/google/msvg/editor/mode-edit'
import doneIcon from 'mmsvg/google/msvg/action/done'
import clearIcon from 'mmsvg/google/msvg/content/clear'

const closeWritingSection = function() {
  const ctrl = this

  if(ctrl.review().valid()) {
    const review = JSON.stringify(ctrl.review().props())
    const arr = ctrl.indexDBReviews()
    arr.push(JSON.parse(review))
    ctrl.indexDBReviews(arr)
  }
  
  ctrl.review().valid(false)
  ctrl.review().props().author_name('')
  ctrl.review().props().text('')
  ctrl.review().props().time('')
  ctrl.review().props().rating('')

//   console.log(ctrl.review().valid())
//   console.log(ctrl.review().props().author_name())
//   console.log(ctrl.review().props().text())
//   console.log(ctrl.review().props().time())
//   console.log(ctrl.review().props().rating())

  ctrl.writingActive(false)

  m.redraw()  
}

const captureElement = function(namespace, el, init) {
  if(!init) {
    dimensionsHelper.setElement(namespace, el)
    dimensionsHelper.setDimensions(namespace)
  }
}

const handleClearClick = function() {
  const ctrl = this

  ctrl.closeWritingSection()
}

const handleWritingFabClick = function(type) {
  const ctrl = this

  // if edit -> do something
  if (type === 'edit') {
    if (dimensionsHelper.isDesktop()) {
      dimensionsHelper.scrollTop('desktop-details-container')  
    }
    ctrl.writingActive(true)
{'fraction_non_alphanumeric': 0.15930388219544847, 'fraction_numerical': 0.0, 'mean_word_length': 4.131868131868132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7241135', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1153, 'n_words': 226}