view wordstream/templates/index.html @ 1:af19f44024d3

scroll to bottom
author k0s <k0scist@gmail.com>
date Fri, 01 Jan 2010 20:01:02 -0500
parents 8af3412e907a
children ffe01043ecea
line wrap: on
line source

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
<head>
<title>wordstream</title>
<script src="${link('jquery.js')}"></script>
<script type="text/javascript">
$(document).ready(function(){

$('#stream').keyup(function(event) {

if (event.keyCode == 13) {

var text = $('#stream').val();
var lines = text.split('\n');
var lastline = lines[lines.length - 2];
var words = lastline.split(" ");
var lastword = words[words.length - 1];

if (lastword.length)  {
$.get(lastword, function(data) {
if (data.length) { 
var t = $('#stream');
t.val(text + data + '\n'); 
$('#stream').animate({scrollTop: t.height()});
}
});
}

if (words.length &gt; 1) {
path = words.join('/');
$.post(path);
}

}

});

$('#stream').focus();

});
</script>
</head>
<body>
<textarea id="stream" rows="25"></textarea>
</body>
</html>