<commit_before>###
This file provides a way to let people see what happens
when you create a new "SurveyApp".
###

trimString = (str) -> String(str).replace /^\s+|\s+$/g, ''
trimMultilineString = (str)->
  (trimString(s) for s in str.split("\n") when s.match(/\w/)).join("\n")

sampleForms = {}

@convertToDemoForm = ()->
  $s = $(@)
  csvTxt = trimMultilineString $s.html()
  cobj = csv.sheeted(csvTxt)
  settingsSheet = cobj.sheet "settings"
  uniqueId = $s.attr("id") || _.uniqueId("sampleform")
  try
    _settings = settingsSheet.toObjects()[0]
    formName = _settings.form_title || _settings.form_id
    identifier = _settings.form_id || uniqueId
  catch e
    formName = "untitled form"
    identifier = uniqueId

  button = $ """
  <button data-clicks="launch-builder">
    #{formName}
  </button>
  """
  sampleForms[identifier] = button
  button.click (evt)->
    evt.preventDefault()
    window.location.hash = identifier
    sheetToObjects = (sheetName)->
      if (sht = cobj.sheet sheetName) then sht.toObjects() else []
    $survey = if (sht = cobj.sheet "survey") then sht.toObjects() else []
    $choices = if (sht = cobj.sheet "choices") then sht.toObjects() else []
    if settingsSheet
      $settings = settingsSheet.toObjects()[0]
    else
      $settings = {}

    $("#preview").empty()
    publishCb = ()->
      # called by surveyapp
      window.surveyCsv = @survey.toCSV()
      log "Storing survey csv in 'window.surveyCsv'."
      csv2dom window.surveyCsv, "#preview"

    app = new SurveyApp
      choices: $choices<commit_msg>class name changes for bootstrap<commit_after>###
This file provides a way to let people see what happens
when you create a new "SurveyApp".
###

trimString = (str) -> String(str).replace /^\s+|\s+$/g, ''
trimMultilineString = (str)->
  (trimString(s) for s in str.split("\n") when s.match(/\w/)).join("\n")

sampleForms = {}

@convertToDemoForm = ()->
  $s = $(@)
  csvTxt = trimMultilineString $s.html()
  cobj = csv.sheeted(csvTxt)
  settingsSheet = cobj.sheet "settings"
  uniqueId = $s.attr("id") || _.uniqueId("sampleform")
  try
    _settings = settingsSheet.toObjects()[0]
    formName = _settings.form_title || _settings.form_id
    identifier = _settings.form_id || uniqueId
  catch e
    formName = "untitled form"
    identifier = uniqueId

  button = $ """
  <button data-clicks="launch-builder" type="button" class="btn btn-sm btn-default">
    #{formName}
  </button>
  """
  sampleForms[identifier] = button
  button.click (evt)->
    evt.preventDefault()
    $et = $(evt.target)
    $et.siblings(".btn-primary").removeClass("btn-primary")
    $et.addClass("btn-primary")
    window.location.hash = identifier
    sheetToObjects = (sheetName)->
      if (sht = cobj.sheet sheetName) then sht.toObjects() else []
    $survey = if (sht = cobj.sheet "survey") then sht.toObjects() else []
    $choices = if (sht = cobj.sheet "choices") then sht.toObjects() else []
    if settingsSheet
      $settings = settingsSheet.toObjects()[0]
    else
      $settings = {}

    $("#preview").empty()
    publishCb = ()->
      # called by surveyapp
      window.surveyCsv = @survey.toCSV()
      log "Storing survey csv in 'window.surveyCsv'."
      csv2dom window.surveyCsv, "#preview"

    app = new SurveyApp
      choices: $choices
{'fraction_non_alphanumeric': 0.15685679611650485, 'fraction_numerical': 0.0018203883495145632, 'mean_word_length': 3.304177545691906, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '6700173', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1104, 'n_words': 261}