function save_entry(left, right){
$('dl').append("
"+left+""+right+"");
}
function li2span(){
$('.words li').each(function(){
var stuff = $(this).text();
$(this).html('');
$(this).append(""+stuff+"");
})
}
function tokenize(text){
puncre = /([?!.]+)/;
return text.split(puncre);
}
function adjust_font_size(){
var ratio = $('#left').children().length / $('#right').children().length
if (ratio < 1) ratio = 1/ratio;
ratio = ratio * 100;
//console.log('ratio is: ' + tenths(ratio));
$('#left').css('fontSize', Math.round(ratio) - Math.round(ratio) % 10 + '%')
}
/*
function tokenize_source(button){
button.click(function(){
var text = $('#original').val();
var sentences = tokenize('?!.\n', text);
listize(sentences);
})
}
outline again
//when the user clicks the button
//get words from the text in the box
get_words()
// put the words
// on the left,
put_words(left);
// or on the right
put_words(right);
*/
function check_state(){
// both empty
// left empty
if ($('#source ul.words li' ).length > 0 &&
$('#target ul.words li' ).length == 0)
{ return '#target'; }
else
{ return '#source'; }
}
function handle_click(button){}
/*
console.log(typeof button);
button.click()(function(){
var destination = check_state();
console.log(destination);
var words = get_words();
put_words(destination);
})
}
*/
function get_words(){};
function put_words(){};
$(function(){
adjust_font_size();
li2span();
$('textarea#paste').val('').autogrow().focus();
$('span').hover(
function(){$(this).addClass('active')},
function(){$(this).removeClass('active')}
)
handle_click($('#tokenize'));
$('#left span').toggle(
function(){
$('#left span').removeClass('chosen');
$(this).addClass('chosen');
},
function(){$(this).removeClass('chosen')}
)
$('#right span').click(
function(){
$('#right span.chosen').removeClass('chosen');
$(this).addClass('chosen');
if ($('#left .chosen') && $('#right .chosen') ){
save_entry(
$('#left .chosen').text(),
$('#right .chosen').text()
);
}
$('#left .chosen').removeClass('chosen').addClass('already');
$('#right .chosen').removeClass('chosen').addClass('already');
},
function(){$(this).removeClass('chosen')}
)
})