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() {
query = this.value;
// Still a bug dispite FALLBACK in Appcache whereby Safari on Iphone gives an error message
//window.location.search = query; // Triggers Reload the page to get source for: http://greptweet/u/kaihendry/?food
window.location.hash = query;
grep(query);
});
if (window.location.search) {
searchquery = window.decodeURIComponent(window.location.search.substr(1));
if (window.location.search || window.location.hash) {
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);
grep(searchquery);
}