<commit_before>highlightNode = (element, key) ->
  highlightNone(element)
  d3.select(element).selectAll('g.node').classed('common', (other) -> other.name is key)

  $('#technologies .technology').each (idx, element) ->
    if $(element).data('node') is key
      $(element).addClass('common')

highlightNone = (element, key) ->
  d3.select(element).selectAll('g.node').classed(common: false)
  $('#technologies .technology').removeClass('common')

showTopology = (url, element) ->
  [width, height] = [920, 400]

  d3.json url, (error, json) ->
    $('.loading', element).detach()

    if error
      errData = JSON.parse(error.responseText)
      errEl   = $('<div class="error"></div>')

      errEl.append($('<span class="message"></span>').text(errData['error']))

      if errData.hasOwnProperty('message')
        errEl.append($('<pre class="detail"></pre>').text(errData['message']))

      $(element).append(errEl)

      return false

    tree     = d3.layout.tree().size([width, height - 40])
    diagonal = d3.svg.diagonal().projection((d) -> [d.x, d.y])
    root     = json.graph[0]

    # Stop the top level from being too far separated from each other, leading
    # to very wide diagrams.
    tree.separation (a, b) -> 1

    svg = d3.select(element)
      .append('svg')
        .attr('width', width)
        .attr('height', height)
      .append('g')
        .attr("transform", "translate(0,5)")

    nodes = tree.nodes(json.graph[0])
    links = tree.links(nodes)

    # Draw links.

    link = svg
      .selectAll('path.link')
        .data(links)
      .enter().append('path')
        .attr('class', 'link')
        .attr('d', diagonal)

    # Draw nodes.

    node = svg
      .selectAll('g.node')
      .data(nodes)
      .enter().append('g')
      .classed('node', true)
      .attr('transform', (data) -> "translate(#{ data.x }, #{ data.y })")

    node.on('mouseover', (d) -> highlightNode(element, d.name))
    node.on('mouseout', -> highlightNone(element))

    # Draw a rectangle around each node.

    node.append('rect')
      .attr('width', 130).attr('height', 25)
      .attr('rx', 5).attr('ry', 5) # Rounded corners
      .attr('x', -65).attr('y')    # Relative x/y coords

    # Add labels.

    node.append('text')
      .attr('dx', 0).attr('dy', 17) # Relative x/y coords.
      .attr('text-anchor', 'middle')
      .text((data) ->
        if data.load
          "#{ data.name } (#{ data.load })"
        else
          data.name
      )

createEditor = (textarea) ->
  id = textarea.attr('id')

  textarea.hide()
  textarea.data('editor', true)

  textarea.after($("""
    <div class="editor-wrap"><pre id='#{ id }_editor'></pre></div>
  """))

  editor = ace.edit("#{ id }_editor")
  editor.getSession().setValue(textarea.text())
  editor.getSession().setMode('ace/mode/yaml')
  editor.setTheme('ace/theme/github')
  editor.setHighlightActiveLine(false)<commit_msg>Show load value in the diagram when load is zero<commit_after>highlightNode = (element, key) ->
  highlightNone(element)
  d3.select(element).selectAll('g.node').classed('common', (other) -> other.name is key)

  $('#technologies .technology').each (idx, element) ->
    if $(element).data('node') is key
      $(element).addClass('common')

highlightNone = (element, key) ->
  d3.select(element).selectAll('g.node').classed(common: false)
  $('#technologies .technology').removeClass('common')

showTopology = (url, element) ->
  [width, height] = [920, 400]

  d3.json url, (error, json) ->
    $('.loading', element).detach()

    if error
      errData = JSON.parse(error.responseText)
      errEl   = $('<div class="error"></div>')

      errEl.append($('<span class="message"></span>').text(errData['error']))

      if errData.hasOwnProperty('message')
        errEl.append($('<pre class="detail"></pre>').text(errData['message']))

      $(element).append(errEl)

      return false

    tree     = d3.layout.tree().size([width, height - 40])
    diagonal = d3.svg.diagonal().projection((d) -> [d.x, d.y])
    root     = json.graph[0]

    # Stop the top level from being too far separated from each other, leading
    # to very wide diagrams.
    tree.separation (a, b) -> 1

    svg = d3.select(element)
      .append('svg')
        .attr('width', width)
        .attr('height', height)
      .append('g')
        .attr("transform", "translate(0,5)")

    nodes = tree.nodes(json.graph[0])
    links = tree.links(nodes)

    # Draw links.

    link = svg
      .selectAll('path.link')
        .data(links)
      .enter().append('path')
        .attr('class', 'link')
        .attr('d', diagonal)

    # Draw nodes.

    node = svg
      .selectAll('g.node')
      .data(nodes)
      .enter().append('g')
      .classed('node', true)
      .attr('transform', (data) -> "translate(#{ data.x }, #{ data.y })")

    node.on('mouseover', (d) -> highlightNode(element, d.name))
    node.on('mouseout', -> highlightNone(element))

    # Draw a rectangle around each node.

    node.append('rect')
      .attr('width', 130).attr('height', 25)
      .attr('rx', 5).attr('ry', 5) # Rounded corners
      .attr('x', -65).attr('y')    # Relative x/y coords

    # Add labels.

    node.append('text')
      .attr('dx', 0).attr('dy', 17) # Relative x/y coords.
      .attr('text-anchor', 'middle')
      .text((data) ->
        if data.load?
          "#{ data.name } (#{ data.load })"
        else
          data.name
      )

createEditor = (textarea) ->
  id = textarea.attr('id')

  textarea.hide()
  textarea.data('editor', true)

  textarea.after($("""
    <div class="editor-wrap"><pre id='#{ id }_editor'></pre></div>
  """))

  editor = ace.edit("#{ id }_editor")
  editor.getSession().setValue(textarea.text())
  editor.getSession().setMode('ace/mode/yaml')
  editor.setTheme('ace/theme/github')
  editor.setHighlightActiveLine(false)
{'fraction_non_alphanumeric': 0.1996236743072186, 'fraction_numerical': 0.010605542251111872, 'mean_word_length': 2.831585845347313, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 49, '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': '1554074', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1895, 'n_words': 386}