Tatoeba Visual Linker

Put a sentence into your "shopping cart" to easily link it to another sentence later.

// ==UserScript==
// @name           Tatoeba Visual Linker
// @namespace      http://userscripts.org/users/61020
// @description    Put a sentence into your "shopping cart" to easily link it to another sentence later.
// @include        http://*.tatoeba.org/*
// @include        https://*.tatoeba.org/*
// @match          http://*.tatoeba.org/*
// @match          https://*.tatoeba.org/*
// @grant          GM_getValue
// @grant          GM_setValue
// @require        http://code.jquery.com/jquery-latest.min.js
// @version 0.0.1.20150428074750
// ==/UserScript==

  // The Icon graphics included in this script can be found for free at http://www.famfamfam.com/lab/icons/silk/
  console.log('initializing');
  textfield_key = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFZSURBVDjL3ZM9S0JhGIbPH/APBEFQ7Q32gS0tlQ21iDVYJ/qAooaGliYRtKBBimrIwKSkooTGaiitFnvJjzLLPGXZCfVVRMWPo6ZwNzaZmlvDtT1cw831MACYWmD+gYAQglpgCCEoFot/glL6IygrKnwhYl1B6HwWcbepekHUbkCUzKGQIqCWCcQ5S+WC2MMRIlcsCgkjEm4VolYl3vaH4LkwViYImReQjx0iF1QiR7eQuFdC4FXg9H2VjRi5WUfatwzBP4MsPw/hfRQCJ4dD0wWGUopSBDzX4E+nETBPIullIbwMIOtTIPMsh0Mtxt3JbulAuM2WYd+2xCHwOmReZRC8PbCttqed6lbq0rTRA7ZB9muJHyapMxfcQdLVAeGpF/aNzoxO0Th+JqsTXbL1orIpfx5LST68hIy3H7Y1SUo/1jRS1S8QrXjx0dAdvtVK/HtTzYOl7r4BQSM7uFIKnq0AAAAASUVORK5CYII=';
  not_translation = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAACXBIWXMAAA7CAAAOwgEVKEqAAAAKT2lDQ1BQaG90b3Nob3AgSUND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wtNC44NDg0ODUgQyAxMi40ODkzOCwxMS4xNTE1MTUgMC4xODc5ODgyOCwxMS4yMjcxNTQgMCwwIDYuMjE4MzgzOCwxMC4zNDkxOTUgMTIuNDkwMDAyLDYuNzg3ODc4OCAxMi40OTAwMDIsNi43ODc4Nzg4IEwgMTIuNDg5MzgsMS45MzkzOTM5IDIyLjA4ODc0NSw4Ljk2OTY5NyAxMi40ODkzOCwxNiBsIDAsMCB6IG0gMS4wMTk1MzIsLTIuMDA1MDkgMCwtMy43NjM0OTQgYyAwLDAgLTkuNDQ2NDEyLDAuNjk0MDEgLTEyLjI0MzI4NywtNy4xMjAwMjg3IDUuMDI1MjY4NSw3LjgxNDAzODcgMTIuMjQzMjg2LDQuNDAxMTYgMTIuMjQzMjg2LDQuNDAxMTYgbCAxZS02LC0zLjY5MjQ3MTUgNi42OTU4LDUuMTQ5NjIxMiAtNi42OTU4LDUuMDI1MjEzIDAsMCB6IgogICAgICAgaWQ9InBhdGgtMSIKICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICBzdHlsZT0iZmlsbDojZjE1Zjc0IiAvPgogIDwvZGVmcz4KICA8ZwogICAgIGZpbGw9Im5vbmUiCiAgICAgZmlsbC1ydWxlPSJldmVub2RkIgogICAgIGlkPSJtaXUiCiAgICAgc3Ryb2tlPSJub25lIgogICAgIHN0cm9rZS13aWR0aD0iMSI+CiAgICA8dXNlCiAgICAgICBoZWlnaHQ9IjEwMCUiCiAgICAgICB3aWR0aD0iMTAwJSIKICAgICAgIHk9IjAiCiAgICAgICB4PSIwIgogICAgICAgaWQ9IiIKICAgICAgIHhsaW5rOmhyZWY9IiNwYXRoLTEiIC8+CiAgPC9nPgo8L3N2Zz4K';
  default_shopping = {
  };
  default_shopping = JSON.stringify(default_shopping);
  //BEGIN USER STATS
  shopping = GM_getValue('shopping');
  shopping = shopping || default_shopping;
  shopping = JSON.parse(shopping);
  console.log('shopping: ' + JSON.stringify(shopping));
  automatically_numeric = GM_getValue('automatically_numeric');
  automatically_numeric = automatically_numeric || false;
  setup = false;
  if (window.location.href.split('/') [4] == 'user' && window.location.href.split('/') [5] == 'profile' && window.location.href.split('/') [6] == $('.menuSection').attr('href').split('/') [4]) {
    setup = true;
    if ($('.userscriptSettings').is('*')) {
      settings = $('.userscriptSettings');
    } 
    else {
      settings = $('<div class="module profileSummary userscriptSettings"><h2>userscripts</h2></div>');
      $('.profileSummary').after(settings);
    }
    settings.append('<h3>Visual Linker</h3>');
    contentdiv = $('<form id="visuallinker"></form>');
    settings.append(contentdiv);
    contentdiv.append('<table>');
    contentdiv.append('<tr><td><label for="delete" class="field">delete list</label></td><td><input type="button" id="shopping" value="delete list" ' + (shopping == default_shopping ? 'diabled="disabled"' : '') + '"></td></tr>');
    contentdiv.append('</table>');
    $('#shopping').click(function () {
      if (confirm('Really delete the whole shopping cart?')) {
        shopping = JSON.parse(default_shopping);
        GM_setValue('shopping', JSON.stringify(shopping));
        console.log('shopping: ' + JSON.stringify(shopping));
      }
    });
  } 
  else {
    interface_lang = $('#languageSelection option[selected="selected"]').val();
    cart_button_add = $('<a class="audioButton cartButton notincart" style="background-image:url(' + cart_add + ');    background-repeat: no-repeat;background-position: center center; float: right; margin: 0.5em 0 0 0;" title="Add this sentence to the \'shopping cart\'."></a>');
    cart_button_remove = $('<a class="audioButton cartButton    incart" style="background-image:url(' + cart_delete + '); background-repeat: no-repeat;background-position: center center; float: right; margin: 0.5em 0 0 0;" title="Remove this sentence from the \'shopping cart\'."></a>');
    empty_cart_button = $('<li class="option tocart"><a title="Click to remove all items from the whole shopping cart."><img width="16" height="16" src="' + cart_remove + '"></a></li>');
    empty_cart_button.click(function (event) {
      event.preventDefault();
      if (confirm('Really delete the whole shopping cart?')) {
        shopping = JSON.parse(default_shopping);
        GM_setValue('shopping', JSON.stringify(shopping));
        console.log('shopping: ' + JSON.stringify(shopping));
        $('.sentences_set').each(function () {
          showcart($(this));
        });
      }
    });
    $('.sentences_set ul.menu .option.addToList').before(empty_cart_button);
    numeric = $('<li class="option numeric"><a title="Click to toggle sentence number input field. (Double-click to always show the input field.)"><img width="16" height="16" src="' + (automatically_numeric ? textfield_key : textfield_add) + '"></a></li>');
    numeric.click(function (event) {
      if (!$(this).parentsUntil('.sentences_set').parent().find('.cart #cart_0').is('*')) {
        add_numeric = $('<div class="sentence indirectTranslation" id="cart_0"><a class="translationIcon direct" style="background:none !important;" title="Not yet linked to main sentence (click to go to this sentence)"><div style="background:none !important;"></div></a><!-- a style="background-image:url(' + cart_delete + '); background-repeat: no-repeat;background-position: center center;" class="audioButton cartButton" alt="0" title="Remove this sentence from the \'shopping cart\'."></a--><a class="link button" title="Fetch sentence from server by number. Type the sentence\'s number into the textfield and hit the [enter] key."><img src="' + server_connect + '"></a><!--img width="30" height="20" src="http://flags.tatoeba.org/img/flags/unknown.png" class="languageFlag" alt="unknown" title="The language of the sentence cannot be known yet." --><a class="sentenceContent text"><input type="number" min="1" size="10" title="Fetch sentence from server by number. Type the sentence\'s number into the textfield and hit the [enter] key."></a></div>');
        $(add_numeric).find('input').keypress(function (event) {
          if (event.which == 13) {
            event.preventDefault();
            id = $(this).val();
            console.log(id);
            $(add_numeric).find('.link.button img').attr('src', 'http://flags.tatoeba.org/img/loading-small.gif');
            if (typeof (shopping[id]) == 'undefined') {
              imtheget = $.get('http://tatoeba.org/sentences/show/' + id, function (data) {
                if ($(data).find('.sentences_set').is('*')) {
                  console.log(data);
                  lang = $(data).find('.sentences_set .mainSentence .languageFlag').attr('src');
                  cont = $(data).find('.sentences_set .mainSentence .sentenceContent').removeAttr('href').html();
                  audio = $(data).find('.sentences_set .mainSentence .audioButton').attr('href');
                  add_to_cart(id, {
                    lang: lang,
                    cont: cont,
                    audio: audio
                  });
                } 
                else {
                  $(add_numeric).find('.link.button img').attr('src', server_error);
                }
              }
              ).error(function () {
                $(add_numeric).find('.link.button img').attr('src', server_error);
              });
            } 
            else {
              $(add_numeric).find('.link.button img').attr('src', cart_error);
            }
          }
        });
        $(add_numeric).find('.link.button img').click(function () {
          id = $(add_numeric).find('input').val();
          console.log(id);
          $(add_numeric).find('.link.button img').attr('src', 'http://flags.tatoeba.org/img/loading-small.gif');
          if (typeof (shopping[id]) == 'undefined') {
            imtheget = $.get('http://tatoeba.org/sentences/show/' + id, function (data) {
              if ($(data).find('.sentences_set').is('*')) {
                console.log(data);
                lang = $(data).find('.sentences_set .mainSentence .languageFlag').attr('src');
                cont = $(data).find('.sentences_set .mainSentence .sentenceContent').removeAttr('href').html();
                audio = $(data).find('.sentences_set .mainSentence .audioButton').attr('href');
                add_to_cart(id, {
                  lang: lang,
                  cont: cont,
                  audio: audio
                });
              } 
              else {
                $(add_numeric).find('.link.button img').attr('src', server_error);
              }
            }
            ).error(function () {
              $(add_numeric).find('.link.button img').attr('src', server_error);
            });
          } 
          else {
            $(add_numeric).find('.link.button img').attr('src', cart_error);
          }
        });
        $(this).parentsUntil('.sentences_set').parent().find('.cart').append(add_numeric);
      } 
      else {
        $(this).parentsUntil('.sentences_set').parent().find('#cart_0').remove();
      }
      event.preventDefault();
    });
    numeric.dblclick(function (event) {
      event.preventDefault();
      automatically_numeric = !automatically_numeric;
      GM_setValue('automatically_numeric', automatically_numeric);
      console.log('automatically_numeric: ' + automatically_numeric);
      $(numeric).find('img').attr('src', (automatically_numeric ? textfield_key : textfield_add));
      $(this).parentsUntil('.sentences_set').parent().find('#cart_0').remove();
      $(numeric).click();
    });
    $('.sentences_set ul.menu .option.addToList').before(numeric);
    function showcart(sentences_set) {
      if ($(sentences_set).find('.cart').is('*')) {
        cart = $(sentences_set).find('.cart');
        $(cart).empty();
      } 
      else {
        cart = $('<div class="translations cart"></div>').css({
          'border-top': '1px dashed #CCCCCC',
          'margin-top':'10px',
        });
        $(sentences_set).find('.translations').after(cart);
      }
      chief_sentence = $(sentences_set).attr('id').split('_').reverse() [0];
      directs = $(sentences_set).find('.directTranslation').map(function () {
        return $(this).attr('id').split('_') [1];
      });
      indirects = $(sentences_set).find('.indirectTranslation').map(function () {
        return $(this).attr('id').split('_') [1];
      });
      $.each(shopping, function (id, value) {
        lang = shopping[id]['lang'];
        cont = shopping[id]['cont'];
        audio = shopping[id]['audio'];
        isself = (id == chief_sentence);
        isdirect = ($.inArray(id, directs) >= 0 ? true : false);
        isindirect = ($.inArray(id, indirects) >= 0 ? true : false);
        sentence_in_basket = $('<div id="cart_' + id + '" class="sentence' + (isself ? ' mainSentence' : (isdirect ? ' directTranslation' : ' indirectTranslation')) + '"></div>');
        sentence_in_basket.data({
          id: id,
          lang: lang,
          cont: cont,
          audio: audio
        });
        
        if (!isself) {
          sentence_in_basket.append('<a class="translationIcon '+(isdirect ? 'direct' : 'indirect')+'" href="/sentences/show/' + id + '" title="' + (isdirect ? 'Already' : (isindirect ? 'Indirectly' : 'Not yet')) + ' linked to main sentence (click to go to this sentence)"><div '+(!isdirect && !isindirect ? 'style="background:none !important;"' : '')+'></div></a>');
        }
        else{
          sentence_in_basket.append('<a href="/sentences/show/' + id + '" class="infoIcon"><div></div></a>');
        }
        sentence_in_basket.append(cart_button_remove.clone());
        sentence_in_basket.append('<img width="30" height="20" alt="' + lang + '" class="languageFlag" src="' + lang + '">');
        if (!isself) {
          if (!isdirect) {
            sentence_in_basket.append($('<a class="add link button" href="/' + interface_lang + '/links/add/' + chief_sentence + '/' + id + '" title="Link this sentence to the main sentence."><img width="16" height="16" src="http://flags.tatoeba.org/img/link.svg?1421599964"></a>').data('sentenceId', chief_sentence).data('translationId', id));
          } 
          else {
            sentence_in_basket.append($('<a class="delete link button" href="/' + interface_lang + '/links/delete/' + chief_sentence + '/' + id + '" title="Unlink this sentence from the main sentence."><img width="16" height="16" src="http://flags.tatoeba.org/img/unlink.svg?1421599964"></a>').data('sentenceId', chief_sentence).data('translationId', id));
          }
        }
        else{
          
        }
        if (!$(sentences_set).parent().is('.sentenceInList')) {
          audio = audio | false;
          audiotrue = (audio ? audio.split('.').reverse() [0] == 'mp3' : false);
          audioURL = audio+'';
          sentence_in_basket.append('<a onclick="return false;" class="audioButton ' + (audiotrue ? 'audioAvailable' : 'audioUnavailable') + '" href="' + audioURL + '"></a>').click(function () {
            // this is copied from sentences.playaudio.js
            $('#audioPlayer').html('<object data="' + audioURL + '" type="audio/mpeg" data="' + audioURL + '" width="0" height="0">' +
            '<param name="src" value="' + audioURL + '" />' +
            '<object ' +
            'type="application/x-shockwave-flash" ' +
            'data="http://static.tatoeba.org/dewplayer-mini.swf?autostart=1&amp;mp3=' + audioURL + '" ' +
            'width="0" ' +
            'height="0" ' +
            '>' +
            '<param name="movie" value="http://static.tatoeba.org/dewplayer-mini.swf?autostart=1&amp;mp3=' + audioURL + '" />' +
            '</object>' +
            '</object>'
            );
          });
        }
        sentence_in_basket.append($('<a href="/sentences/show/' + id + '" class="sentenceContent"></div>').append($(cont).removeClass('editableSentence')));
        cart.append(sentence_in_basket);
      });
    }
    function add_to_cart(id, object) {
      // reload the shopping cart so we can use it across tabs
      shopping = GM_getValue('shopping');
      shopping = shopping || default_shopping;
      shopping = JSON.parse(shopping);
      shopping[id] = {
        lang: lang,
        cont: cont,
        audio: audio
      };
      GM_setValue('shopping', JSON.stringify(shopping));
      console.log('shopping: ' + JSON.stringify(shopping));
      $('.sentences_set').each(function () {
        showcart($(this));
        if (automatically_numeric) {
          $(this).find('.numeric').click();
        }
      });
    }
    function remove_from_cart(id) {
      // reload the shopping cart so we can use it across tabs
      shopping = GM_getValue('shopping');
      shopping = shopping || default_shopping;
      shopping = JSON.parse(shopping);
      console.log(id);
      delete shopping[id];
      GM_setValue('shopping', JSON.stringify(shopping));
      console.log('shopping: ' + JSON.stringify(shopping));
      $('.sentences_set').each(function () {
        showcart($(this));
        if (automatically_numeric) {
          $(this).find('.numeric').click();
        }
      });
    }
    function refresh_cart() {
      // reload the shopping cart so we can use it across tabs
      compare_shopping = shopping;
      shopping = GM_getValue('shopping');
      shopping = shopping || default_shopping;
      shopping = JSON.parse(shopping);
      if(JSON.stringify(compare_shopping)!=JSON.stringify(shopping)){
        console.log('updating shopping cart');
        $('.sentences_set').each(function () {
          showcart($(this));
          if (automatically_numeric) {
            $(this).find('.numeric').click();
          }
        });  
      } else {
        //console.log('no changes to shopping cart');
      }
    }
    window.onfocus = function(){refresh_cart();};
    $('.sentences_set').each(function () {
      showcart($(this));
      if (automatically_numeric) {
        $(this).find('.numeric').click();
      }
    });
    
    $('.sentences_set .translations:not(.cart) .sentence, .sentences_set > .mainSentence').each(function () {
      id = $(this).find('.languageFlag').attr('id').split('_').reverse() [0];
      lang = $(this).find('.languageFlag').attr('src');
      cont = $(this).find('.sentenceContent').removeAttr('href').html();
      audio = $(this).find('.audioButton').attr('href');
      incart = typeof (shopping[id]) == 'object';
      $(this).data({
        id: id,
        lang: lang,
        cont: cont,
        audio: audio
      });
      $(this).addClass('id' + id);
      $(this).find('.languageFlag').before((incart ? cart_button_remove.clone()  : cart_button_add.clone()));
    });
    $('.sentences_set').on('click', '.cartButton', function (event) {
      data = $(this).parentsUntil('sentence').data();
      id = data['id'];
      lang = data['lang'];
      cont = data['cont'];
      audio = data['audio'];
      incart = typeof (shopping[id]) == 'object';
      if (incart) {
        remove_from_cart(id);
        $('.sentences_set .sentence.id' + id + ' .cartButton').replaceWith(cart_button_add.clone());
      } 
      else {
        add_to_cart(id, {
          lang: lang,
          cont: cont,
          audio: audio
        });
        $('.sentences_set .sentence.id' + id + ' .cartButton').replaceWith(cart_button_remove.clone());
      }
    });
    //Below is an adaption of original code from Tatoeba, as greasemonkey cannot (to my knowledge) interact with the code from the page itself
    /**
		 * Tatoeba Project, free collaborative creation of multilingual corpuses project
		 * Copyright (C) 2011  HO Ngoc Phuong Trang <tranglich@gmail.com>
		 *
		 * This program is free software: you can redistribute it and/or modify
		 * it under the terms of the GNU Affero General Public License as published by
		 * the Free Software Foundation, either version 3 of the License, or
		 * (at your option) any later version.
		 *
		 * This program is distributed in the hope that it will be useful,
		 * but WITHOUT ANY WARRANTY; without even the implied warranty of
		 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
		 * GNU Affero General Public License for more details.
		 *
		 * You should have received a copy of the GNU Affero General Public License
		 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
		 */
    //http://tatoeba.org/js/links.add_and_delete.js
    $('.cart .link').click(function (event) { //modified by Jakob
      event.preventDefault(); //modified by Jakob
      var sentenceId = $(this).data('sentenceId');
      var translationId = $(this).data('translationId');
      var rootUrl = 'http://tatoeba.org/';
      var image = $(this);
      var action = null;
      if ($(this).hasClass('add')) {
        var action = 'add';
        var newAction = 'delete';
        var removeClass = 'indirectTranslation';
        var addClass = 'directTranslation';
        var newType = 'direct';
      } else if ($(this).hasClass('delete')) {
        var action = 'delete';
        var newAction = 'add';
        var removeClass = 'directTranslation';
        var addClass = 'indirectTranslation';
        var newType = 'indirect';
      }
      if (action != null) {
        // Show the loading gif...
        $(this).html('<img src=\'/img/loading-small.gif\' alt=\'loading\'>'
        );
        // Send request...
        $.get(rootUrl + interface_lang + '/links/' + action + '/' + sentenceId + '/' + translationId, function (data) {
          var elementId = '#translation_' + translationId + '_' + sentenceId;
          var cartId = '#cart_' + sentenceId;
          // Update the link or unlink image
          image.html(data);
          image.removeClass(action);
          image.addClass(newAction);
          // update the class of the sentence and the arrow
          $(elementId).removeClass(removeClass);
          $(elementId).addClass(addClass);
          $(elementId + ' .show img').attr('src', '/img/' + newType + '_translation.png'
          );
          $(elementId + ' .link').html(data);
          $(image).parent().removeClass(removeClass);
          $(image).parent().addClass(addClass);
          $(image).parent().find(' .show img').attr('src', '/img/' + newType + '_translation.png'
          );
          $(image).html(data);
        }
        );
      }
    });
  }