<commit_before>import Vue from 'vue'
import qs from 'querystring'

new Vue({
  el: '#preview',
  data: {
    output: '',
    outputEl: null
  },
  mounted() {
    this.outputEl = this.$el.querySelector('output')
    const body = qs.parse(location.search.substr(1))
    const headers = new Headers()
    headers.append('Content-Type', 'application/json')
    fetch(location.pathname, {
      method: 'POST',
      headers,
      body: JSON.stringify(body),
      credentials: 'include'
    }).then(res => {
      const ct = res.headers.get('content-type')
      if(ct && ct.indexOf('application/json') !== -1) {
        return this.json(res)
      } else {
        return this.octet(res)
      }
    })
  },
  methods: {
    scroll() {
      this.outputEl.scrollTop = this.outputEl.scrollHeight
    },
    json(res) {
      return res.json().then(({ url }) => {
        location.href = url
      })
    },
    octet(res) {
      this.output = ''
      const reader = res.body.getReader()
      const decoder = new TextDecoder('utf-8')
      let text
      const processResult = result => {
        if(result.done) {
          this.scroll()
          const lines = text.split('\n')
          const url = lines[lines.length - 1]
          if(url.startsWith('http')) {
            setTimeout(() => location.href = url, 2000)
          } else {
            // error
          }<commit_msg>Improve debug mode<commit_after>import Vue from 'vue'
import qs from 'querystring'

const debug = process.env.NODE_ENV !== 'production'

new Vue({
  el: '#preview',
  data: {
    output: '',
    outputEl: null
  },
  mounted() {
    this.outputEl = this.$el.querySelector('output')
    const body = qs.parse(location.search.substr(1))
    const headers = new Headers()
    headers.append('Content-Type', 'application/json')
    fetch(location.pathname, {
      method: 'POST',
      headers,
      body: JSON.stringify(body),
      credentials: 'include'
    }).then(res => {
      const ct = res.headers.get('content-type')
      if(ct && ct.indexOf('application/json') !== -1) {
        return this.json(res)
      } else {
        return this.octet(res)
      }
    })
  },
  methods: {
    scroll() {
      this.outputEl.scrollTop = this.outputEl.scrollHeight
    },
    json(res) {
      return res.json().then(({ url }) => {
        location.href = url
      })
    },
    octet(res) {
      this.output = ''
      const reader = res.body.getReader()
      const decoder = new TextDecoder('utf-8')
      let text
      const processResult = result => {
        if(result.done) {
          this.scroll()
          const lines = text.split('\n')
          const url = lines[lines.length - 1]
          if(url.startsWith('http') && !debug) {
            setTimeout(() => location.href = url, 2000)
          } else {
            // error or development mode
          }
{'fraction_non_alphanumeric': 0.15231092436974789, 'fraction_numerical': 0.0056022408963585435, 'mean_word_length': 2.062165058949625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2594609', 'n_tokens_mistral': 894, 'n_tokens_neox': 883, 'n_words': 186}