/* Project specific Javascript goes here. */

function getColorId(color) {
    if (color == 'both') { return 0; }
    else if (color == 'ladl') { return 1; }
    else if (color == 'lvf') { return 2; }
    else if (color == 'dicovalence') { return 3; }
    else { return 4; }
}

function sortUL(list) {
    list.children(".comma_hack").remove();
    list.children("li").sort(function(a, b) {
        var idA = getColorId($(a).attr('class'));
        var idB = getColorId($(b).attr('class'));

        var upA = $(a).text();
        var upB = $(b).text();
        var cmpText = (upA < upB) ? -1 : (upA > upB) ? 1 : 0;
        return (idA < idB) ? -1 : (idA > idB) ? 1 : cmpText;
    }).appendTo(list);
    span = $('<span />').addClass('comma_hack').text(', ');
    list.find('li').after(span);
}

function toggleHighlightMembers() {
    var origins = $(this).data('origin').split(',');
    $('.verbnet_members li').each(function() {
        if (origins.indexOf($(this).text()) != -1) {
            $(this).toggleClass('hover');
        }
    });
}

function toggleHighlightCandidates() {
    var origin = $(this).text();
    $(this).parent().parent().find('.evaluate li').each(function() {
        if ($(this).data('origin').split(',').indexOf(origin) != -1) {
            $(this).toggleClass('hover');
        }
    });
}

function toggleHideShow(e) {
    e.preventDefault();
    $(this).parent().find('li[class="unknown"]').toggle();
    $(this).parent().find('li[class="dicovalence"]').toggle();
    $(this).text($(this).text() == '[+]' ? '[-]' : '[+]');
}


$(document).ready(function() {
    // "Evaluate" a word: set it as valid or not
    /*
    $('.evaluate li').click(function() {
        // Retrieve the word, its status, and the other list
        var word = $(this);
        var wanted = word.parent().hasClass('valid') ? 'invalid': 'valid';
        var other_list = $(this).parent().parent().find('.'+wanted);

        // Move the word to the other list and append a space
        word.hide()
        sortUL(word.parent());

        other_list.append(word);
        span = $('<span />').addClass('comma_hack').text(', ');
        other_list.append(span);
        sortUL(other_list);

        word.fadeIn('slow');
    });
    */

    // Show relation between verbs and origin
    $('.evaluate li').hover(toggleHighlightMembers, toggleHighlightMembers);
    $('.verbnet_members li').hover(toggleHighlightCandidates, toggleHighlightCandidates);

    var showLink = $('<a/>').text('[+]').prop('href', '#').click(toggleHideShow);
    $('.evaluate').append(showLink);
});



@@ -39,16 +39,58 @@
 re. */%0A%0A
+/* Validating/refusing translations */%0A/*%0A
 function
@@ -826,24 +826,56 @@
 er(span);%0A%7D%0A
+*/%0A%0A/* Highlight translations */
 %0Afunction to
@@ -1107,32 +1107,56 @@
    %7D%0A    %7D);%0A%7D%0A%0A
+/* Highlight origins */%0A
 function toggleH
@@ -1410,24 +1410,58 @@
 %0A    %7D);%0A%7D%0A%0A
+/* Hide dark/gray translations */%0A
 function tog
@@ -2576,24 +2576,72 @@
 ndidates);%0A%0A
+    // Show/hide verbs that are not interesting%0A
     var show
@@ -2751,10 +2751,126 @@
 k);%0A
+%0A    $('.edit').each(function() %7B%0A        $(this).editable('edit/ladl/', %7B%22edited%22: $(this).prev(%22a%22)%5B0%5D%7D);%0A    %7D);%0A%0A
 %7D);%0A%0A
-%0A

Comment out unneeded validation functionality + comments