mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-20 12:11:05 -05:00
Use grep.php if there is no Application cache or it's slowly syncing
TODO: Make URL ?queries work offline!
This commit is contained in:
@@ -66,6 +66,7 @@ fi
|
||||
cd u/$id
|
||||
|
||||
ln -sf ../../index.html || true
|
||||
ln -sf ../../grep.php || true
|
||||
|
||||
if echo $id | grep -q -v '_' # Underscores in domain names is a no no
|
||||
then
|
||||
|
||||
17
main.js
17
main.js
@@ -1,5 +1,4 @@
|
||||
var l = []; // avoid expensive $.get for local searches
|
||||
|
||||
function search(query, lines) {
|
||||
var results = "<p class=\"label\">Searched for: " + query + "</p><ol>";
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
@@ -22,6 +21,10 @@ function search(query, lines) {
|
||||
|
||||
function grep(query) {
|
||||
|
||||
if (typeof applicationCache !== 'undefined' && applicationCache.status == 1) {
|
||||
|
||||
// If we have a cache, lets do this locally
|
||||
console.log("Using applicationCache");
|
||||
if (l.length > 0) {
|
||||
search(query, l);
|
||||
} else {
|
||||
@@ -31,6 +34,18 @@ function grep(query) {
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Client doesn't support appcache or it's not in sync, so lets search on the server
|
||||
console.log("Using grep.php");
|
||||
$.getJSON("/u/" + NAME + "/grep.php?jsoncallback=?", {
|
||||
q: query
|
||||
},
|
||||
function(data) {
|
||||
search(query, data);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
Reference in New Issue
Block a user