mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-21 04:31:05 -05:00
first commit
This commit is contained in:
39
main.js
Normal file
39
main.js
Normal file
@@ -0,0 +1,39 @@
|
||||
function grep(query) {
|
||||
|
||||
$.getJSON("/u/" + NAME + "/grep.php?q=" + query + "&jsoncallback=?", function(data) {
|
||||
var results = "<p>Searched for: " + query + "</p><ol>";
|
||||
for (i in data) {
|
||||
tweet = data[i].split('|');
|
||||
if (tweet.length > 2) {
|
||||
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet[2] + "</a></li>"; // With datetime
|
||||
} else {
|
||||
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet[1] + "</a></li>"; // Old style
|
||||
}
|
||||
}
|
||||
$('#results').prepend(results + "</ol>");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
NAME = window.location.pathname.split('/')[2];
|
||||
|
||||
$("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("<a href=\"" + NAME + "\.txt\">" + NAME + " simple text backup file</a>");
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user