Sha256: 34b7002672adc689a7e156efd92c09d69e3f1a36154b319a1fa0b77ab0fa51a1

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

$(document).on 'ready page:load', ->
  if document.URL.includes("tolk/locales")
    alert "Double click anywhere to start autotranslating."
    autotranslatingClicked = 0
    $('#container').dblclick ->
      autotranslatingClicked += 1
      to_lang = document.URL.split('/').slice(-1).pop()
      $translation_rows = $('table.translations tbody tr:not(:first-child)')
      for $translation_row in $translation_rows
        original = $translation_row.querySelector('td.original textarea#translations__original_text').innerText
        $translationArea = $translation_row.querySelector('td.translation textarea')
        if $translationArea.innerText == '' && autotranslatingClicked == 1
          translate(original, to_lang, $translationArea)

translate = (original, to, textarea) ->
  $.get '/translate', {original: original, to: to}, ((response) ->
    alert 'udalo sie'
    if response.status == 200
      textarea.innerText = response.translated
  ), 'json'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
autotolk-0.1.0 app/assets/javascripts/locales.js.coffee