<commit_before># Copyright 2014 Square Inc.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

$(document).ready ->
  locale_field = $('#locale-field')
  commit_select = $("select[name='commit']")
  article_id = $("input[name='article_id']").val()
  section_select = $("select[name='section_id']")
  translate_link = $("#translate-link")
  gallery_link = $('#gallery-link')
  issues_link = $('#issues-link')

  locale_field.val "<%= @locale.rfc5646 %>"

  translate_link.click () ->
    commit_sha = commit_select.val()
    section_id = section_select.val()
    locale = locale_field.val()
    url = '/locales/' + encodeURIComponent(locale) + '/projects/<%= @project.to_param %>?'
    url += "commit=#{commit_sha}" if commit_sha
    url += "article_id=#{article_id}" if article_id
    url += "&section_id=#{section_id}" if section_id
    window.location = url

  gallery_link.click () ->
    commit_sha = commit_select.val()
    if commit_sha
      window.open "/projects/<%= @project.to_param %>/commits/#{commit_sha}/gallery"
    else
      new Flash('alert').text('Need to select a commit to view screenshots')

  issues_link.click ->
    commit_sha = commit_select.val()
    if commit_sha
      window.open "/projects/<%= @project.to_param %>/commits/#{commit_sha}/issues"
    else
      new Flash('alert').text('Need to select a commit to view issues')

  # TRANSLATION WORKBENCH
  new TranslationWorkbench(
    $(".translation-workbench"),
    "<%= search_translations_url(:target_locales => @locale.rfc5646) %>",
    JSON.parse("<%= escape_javascript @glossary_entries.to_json %>"),
    JSON.parse('<%= escape_javascript @presenter.decorate_translations(@translations) %>'),
    "<%= @presenter.role %>",
    "<%= Shuttle::Configuration.workbench.enable_reasons %>"
  )<commit_msg>Fix translation reason flag.<commit_after># Copyright 2014 Square Inc.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

$(document).ready ->
  locale_field = $('#locale-field')
  commit_select = $("select[name='commit']")
  article_id = $("input[name='article_id']").val()
  section_select = $("select[name='section_id']")
  translate_link = $("#translate-link")
  gallery_link = $('#gallery-link')
  issues_link = $('#issues-link')

  locale_field.val "<%= @locale.rfc5646 %>"

  translate_link.click () ->
    commit_sha = commit_select.val()
    section_id = section_select.val()
    locale = locale_field.val()
    url = '/locales/' + encodeURIComponent(locale) + '/projects/<%= @project.to_param %>?'
    url += "commit=#{commit_sha}" if commit_sha
    url += "article_id=#{article_id}" if article_id
    url += "&section_id=#{section_id}" if section_id
    window.location = url

  gallery_link.click () ->
    commit_sha = commit_select.val()
    if commit_sha
      window.open "/projects/<%= @project.to_param %>/commits/#{commit_sha}/gallery"
    else
      new Flash('alert').text('Need to select a commit to view screenshots')

  issues_link.click ->
    commit_sha = commit_select.val()
    if commit_sha
      window.open "/projects/<%= @project.to_param %>/commits/#{commit_sha}/issues"
    else
      new Flash('alert').text('Need to select a commit to view issues')

  # TRANSLATION WORKBENCH
  new TranslationWorkbench(
    $(".translation-workbench"),
    "<%= search_translations_url(:target_locales => @locale.rfc5646) %>",
    JSON.parse("<%= escape_javascript @glossary_entries.to_json %>"),
    JSON.parse('<%= escape_javascript @presenter.decorate_translations(@translations) %>'),
    "<%= @presenter.role %>",
    JSON.parse("<%= Shuttle::Configuration.workbench.enable_reasons %>")
  )
{'fraction_non_alphanumeric': 0.14540761454076145, 'fraction_numerical': 0.006883200688320069, 'mean_word_length': 3.9892703862660945, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1877137', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1396, 'n_words': 362}