diff --git a/src/logtail.html b/src/logtail.html
index 9e55894..82ef5cc 100644
--- a/src/logtail.html
+++ b/src/logtail.html
@@ -193,7 +193,56 @@
Message Logtail
}).show();
}
- $('#filter').keyup(filter);
+ function getParameterByName(name, url) {
+ // derived from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
+ if (!url) {
+ url = window.location.href;
+ }
+ name = name.replace(/[\[\]]/g, "\\$&");
+ var regex = new RegExp("[#&]" + name + "(=([^]*)|&|#|$)"),
+ results = regex.exec(url);
+ if (!results) return null;
+ if (!results[2]) return '';
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
+ }
+
+ function UpdateQueryString(key, value, url) {
+ // derived from http://stackoverflow.com/questions/5999118/add-or-update-query-string-parameter
+ if (!url) url = window.location.href;
+ var re = new RegExp("([#&])" + key + "=.*?(&|#|$)(.*)", "gi"),
+ hash;
+
+ if (re.test(url)) {
+ if (typeof value !== 'undefined' && value !== null)
+ return url.replace(re, '$1' + key + "=" + value + '$2$3');
+ else {
+ hash = url.split('#');
+ url = hash[0].replace(re, '$1$3').replace(/(&|\?#)$/, '');
+ if (typeof hash[1] !== 'undefined' && hash[1] !== null)
+ url += '#' + hash[1];
+ return url;
+ }
+ }
+ else {
+ if (typeof value !== 'undefined' && value !== null) {
+ var separator = url.indexOf('#') !== -1 ? '&' : '#';
+ hash = url.split('#');
+ url = hash[0] + separator + key + '=' + value;
+ if (typeof hash[1] !== 'undefined' && hash[1] !== null)
+ url += '#' + hash[1];
+ return url;
+ }
+ else
+ return url;
+ }
+ }
+
+ $('#filter').keyup(function() {
+ window.location.href = UpdateQueryString('filter', escapeRegExp($('#filter').val()));
+ filter();
+ });
+
+ $('#filter').val(getParameterByName('filter'));