mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-20 12:11:05 -05:00
Actually seems to work
This commit is contained in:
11
greptweet.appcache
Normal file
11
greptweet.appcache
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
CACHE MANIFEST
|
||||||
|
CACHE:
|
||||||
|
index.html
|
||||||
|
tweets.txt
|
||||||
|
/main.js
|
||||||
|
/bootstrap/docs/assets/css/bootstrap.css
|
||||||
|
/bootstrap/docs/assets/img/glyphicons-halflings.png
|
||||||
|
/style.css
|
||||||
|
/jquery-1.7.2.min.js
|
||||||
|
NETWORK:
|
||||||
|
grep.php
|
||||||
4
jquery-1.7.2.min.js
vendored
Normal file
4
jquery-1.7.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
58
main.js
58
main.js
@@ -1,3 +1,30 @@
|
|||||||
|
var l = []; // avoid expensive $.get
|
||||||
|
function search(query, lines) {
|
||||||
|
var results = "<p class=\"label\">Searched for: " + query + "</p><ol>";
|
||||||
|
for (var i = 0; i < lines.length; i++) {
|
||||||
|
tweet = lines[i].split('|');
|
||||||
|
var re = new RegExp(query, 'i');
|
||||||
|
|
||||||
|
switch (tweet.length)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
if (tweet[2].match(re)) {
|
||||||
|
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(2) + "</a></li>";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (tweet[1].match(re)) {
|
||||||
|
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(1) + "</a></li>";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('ODD: ' + tweet);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$('#results').prepend(results + "</ol>");
|
||||||
|
}
|
||||||
|
|
||||||
function grep(query) {
|
function grep(query) {
|
||||||
|
|
||||||
if (navigator.onLine) {
|
if (navigator.onLine) {
|
||||||
@@ -6,37 +33,21 @@ function grep(query) {
|
|||||||
q: query
|
q: query
|
||||||
},
|
},
|
||||||
function(data) {
|
function(data) {
|
||||||
var results = "<p class=\"label\">Searched for: " + query + "</p><ol>";
|
console.log("from grep.php: " + data);
|
||||||
for (var i in data) {
|
search(query, data);
|
||||||
tweet = data[i].split('|');
|
|
||||||
if (tweet.length > 2) {
|
|
||||||
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(2) + "</a></li>"; // With datetime
|
|
||||||
} else {
|
|
||||||
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(1) + "</a></li>"; // Old style
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('#results').prepend(results + "</ol>");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (! lines) {
|
if (l.length > 0) {
|
||||||
|
search(query, l);
|
||||||
|
} else {
|
||||||
$.get('tweets.txt', function(data) {
|
$.get('tweets.txt', function(data) {
|
||||||
lines = data.split("\n");
|
l = data.split("\n");
|
||||||
|
search(query, l);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = "<p class=\"label\">Searched for: " + query + "</p><ol>";
|
|
||||||
for (var i = 0; i < lines.length - 1; i++) {
|
|
||||||
tweet = lines[i].split('|');
|
|
||||||
var re = new RegExp(query, 'i');
|
|
||||||
if (tweet[2].match(re)) {
|
|
||||||
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(2) + "</a></li>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('#results').prepend(results + "</ol>");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +58,7 @@ if (! lines) {
|
|||||||
|
|
||||||
$("input[type=search]").change(function() {
|
$("input[type=search]").change(function() {
|
||||||
query = this.value;
|
query = this.value;
|
||||||
|
// TODO: APPCACHE BUG
|
||||||
// window.location.search = query; // Triggers Reload the page to get source for: http://greptweet/u/kaihendry/?food
|
// window.location.search = query; // Triggers Reload the page to get source for: http://greptweet/u/kaihendry/?food
|
||||||
grep(query);
|
grep(query);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user