function grep(query) { $.getJSON("/u/" + NAME + "/grep.php?q=" + query + "&jsoncallback=?", function(data) { var results = "

Searched for: " + query + "

    "; for (var i in data) { tweet = data[i].split('|'); if (tweet.length > 2) { results += "
  1. " + tweet.slice(2) + "
  2. "; // With datetime } else { results += "
  3. " + tweet.slice(1) + "
  4. "; // Old style } } $('#results').prepend(results + "
"); }); } $(document).ready(function() { NAME = window.location.pathname.split('/')[2]; $("#name").html(NAME); $("input[type=text]").change(function() { query = this.value; window.location.search = query; grep(query); }); if (window.location.search) { searchquery = window.decodeURIComponent(window.location.search.substr(1)); $("input[type=text]").val(searchquery); grep(searchquery); } $("input[type=text]").focus(); $("#source").html('' + NAME + ' simple text backup file'); document.title = "Greptweet " + NAME; });