mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
- Store web2.0 state in the url bar.
This commit is contained in:
parent
a56a9325e2
commit
c986701c2c
2 changed files with 34 additions and 8 deletions
|
@ -1,23 +1,45 @@
|
|||
(function() {
|
||||
var params = {
|
||||
offset: 0,
|
||||
count: 50
|
||||
};
|
||||
|
||||
var search = function(query) {
|
||||
document.location.hash = query
|
||||
$("#results").load("/search/ajax", { q: query })
|
||||
$("#query").val(query)
|
||||
params.q = query;
|
||||
document.location.hash = JSON.stringify(params);
|
||||
$("#results").load("/search/ajax", params);
|
||||
$("#query").val(params.q);
|
||||
};
|
||||
|
||||
$().ready(function() {
|
||||
if (location.hash.length > 1) {
|
||||
search(location.hash.substring(1));
|
||||
try {
|
||||
params = JSON.parse(location.hash.substring(1));
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
search(params.q);
|
||||
}
|
||||
|
||||
$(window).hashchange(function() {
|
||||
query = location.hash.substring(1)
|
||||
params = JSON.parse(location.hash.substring(1));
|
||||
query = params.q
|
||||
if (query != $("#query").val()) {
|
||||
scroll(0, 0);
|
||||
search(query);
|
||||
}
|
||||
});
|
||||
|
||||
$("a.querychanger").live("click", function() {
|
||||
var href = $(this).attr("href");
|
||||
var re = new RegExp("[&?]q=([^&]+)");
|
||||
var match = re.exec(href);
|
||||
if (match) {
|
||||
search(match[1]);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$("ul.results li.event").live("click", function() {
|
||||
var data = eval($(this).data("full"));
|
||||
|
||||
|
@ -97,11 +119,15 @@
|
|||
var query = $("#query");
|
||||
var newcondition = unescape(field) + ":" + unescape(value);
|
||||
|
||||
var newquery = query.val();
|
||||
if (newquery.length != 0) {
|
||||
newquery += " AND ";
|
||||
}
|
||||
if (ev.shiftKey) {
|
||||
// Shift-click will make a "and not" condition
|
||||
query.val(query.val() + " AND -" + newcondition)
|
||||
query.val(newquery + "-" + newcondition)
|
||||
} else {
|
||||
query.val(query.val() + " AND " + newcondition)
|
||||
query.val(newquery + newcondition)
|
||||
}
|
||||
search(query.val())
|
||||
return false;
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
%li.event{ :"data-full" => hit.to_json }&= hit["_source"]["@message"]
|
||||
- if @hits.length == 0
|
||||
- if !params[:q]
|
||||
No query given. How about <a href="#*">this?</a>
|
||||
No query given. How about <a href="?q=*" class="querychanger">this?</a>
|
||||
- else
|
||||
No results for query '#{params[:q]}'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue