Using window.location.hash to stop page reload, closes #20

This commit is contained in:
Kai Hendry
2012-08-20 20:46:12 +02:00
parent c502227bf9
commit 0a0d9ab7e8

10
main.js
View File

@@ -55,13 +55,15 @@ $(document).ready(function() {
$("input[type=search]").change(function() { $("input[type=search]").change(function() {
query = this.value; query = this.value;
// Still a bug dispite FALLBACK in Appcache whereby Safari on Iphone gives an error message window.location.hash = query;
//window.location.search = query; // Triggers Reload the page to get source for: http://greptweet/u/kaihendry/?food
grep(query); grep(query);
}); });
if (window.location.search) { if (window.location.search || window.location.hash) {
searchquery = window.decodeURIComponent(window.location.search.substr(1)); if (!window.location.hash) {
window.location.hash = window.location.search.substr(1);
}
searchquery = window.decodeURIComponent(window.location.hash.substr(1));
$("input[type=search]").val(searchquery); $("input[type=search]").val(searchquery);
grep(searchquery); grep(searchquery);
} }