| 1 |
<script type="text/javascript"> |
|---|
| 2 |
<!-- |
|---|
| 3 |
function perform_graph_search(string, offset, limit) { |
|---|
| 4 |
$.getJSON('json/graph/search', |
|---|
| 5 |
{ 'q' : string, 'o' : offset, 'l' : limit }, |
|---|
| 6 |
function(r) { |
|---|
| 7 |
var summary = r.count + ' graph' + (r.count == 1 ? '' : 's' ) + ' found for \'' + htmlentities(r.query) + '\''; |
|---|
| 8 |
if(r.error) summary = 'Error: ' + htmlentities(r.error); |
|---|
| 9 |
$("#graphlist > p.graph-search-summary").html(summary).fadeIn('fast'); |
|---|
| 10 |
var c = new Number(r.count); |
|---|
| 11 |
var l = new Number(r.limit); |
|---|
| 12 |
var o = new Number(r.offset); |
|---|
| 13 |
var page = $("#graphlist > p.paginate"); |
|---|
| 14 |
page.html(''); |
|---|
| 15 |
if(c > l) { |
|---|
| 16 |
if(o > 0) { |
|---|
| 17 |
var po = Math.max(o-l, 0); |
|---|
| 18 |
$('<a/>').html( (po+1) + ' - ' + (po+l) ) |
|---|
| 19 |
.click(function() { |
|---|
| 20 |
perform_datapoint_search(string,po,r.limit); |
|---|
| 21 |
return false; |
|---|
| 22 |
}).appendTo(page); |
|---|
| 23 |
} |
|---|
| 24 |
page.append($('<span/>').html((o+1) + '-' + (o+l)).addClass('searchselect')); |
|---|
| 25 |
if(o + l < c) { |
|---|
| 26 |
var po = o + l; |
|---|
| 27 |
$('<a/>').html( (po + 1) + '-' + (po+l) ) |
|---|
| 28 |
.click(function() { |
|---|
| 29 |
perform_datapoint_search(string,po,r.limit); |
|---|
| 30 |
return false; |
|---|
| 31 |
}).appendTo(page); |
|---|
| 32 |
} |
|---|
| 33 |
page.slideDown('fast'); |
|---|
| 34 |
} |
|---|
| 35 |
else page.slideUp('fast'); |
|---|
| 36 |
$("#graph-searchresults > li").remove(); |
|---|
| 37 |
for(var i=0; r.results && i<r.results.length; i++) { |
|---|
| 38 |
var g = r.results[i]; |
|---|
| 39 |
var a = $('<a href="#"/>'); |
|---|
| 40 |
a.html('Edit').addClass('addtows'); |
|---|
| 41 |
a.click( |
|---|
| 42 |
(function(graphid) { |
|---|
| 43 |
return function() { |
|---|
| 44 |
set_current_graph_id(graphid); |
|---|
| 45 |
return false; |
|---|
| 46 |
} |
|---|
| 47 |
})(g.graphid) |
|---|
| 48 |
); |
|---|
| 49 |
var li = $('<li/>').append($('<a/>').html(g.title)) |
|---|
| 50 |
.append($('<ul/>').append($('<li/>').html(g.last_update)) |
|---|
| 51 |
.append($('<li/>').append(a))); |
|---|
| 52 |
$("#graph-searchresults").append(li); |
|---|
| 53 |
} |
|---|
| 54 |
}); |
|---|
| 55 |
} |
|---|
| 56 |
$(document).ready(function(){ |
|---|
| 57 |
$("#graph-searchform").submit(function() { |
|---|
| 58 |
perform_graph_search($("#graph-searchinput").val(), 0, 25); |
|---|
| 59 |
return false; |
|---|
| 60 |
}); |
|---|
| 61 |
}); |
|---|
| 62 |
--> |
|---|
| 63 |
</script> |
|---|
| 64 |
|
|---|
| 65 |
</script> |
|---|
| 66 |
<h4 id="graph-searchterms"></h4> |
|---|
| 67 |
<div id="graph-searchform-container" style="margin:.5em 0 2em 0;padding-bottom:1em;border-bottom: solid 1px #e6e4e5;"> |
|---|
| 68 |
<form id="graph-searchform"> |
|---|
| 69 |
<fieldset> |
|---|
| 70 |
<legend style="display:none;">Search</legend> |
|---|
| 71 |
<label for="keyword" style="display:none;">Keyword</label> <input type="text" id="graph-searchinput" style="width:220px;" /> <input type="submit" value="Search" /> |
|---|
| 72 |
</fieldset> |
|---|
| 73 |
</form> |
|---|
| 74 |
</div> |
|---|
| 75 |
<div id="graphlist"> |
|---|
| 76 |
<p class="graph-search-summary"></p> |
|---|
| 77 |
<ul id="graph-searchresults"> |
|---|
| 78 |
</ul> |
|---|
| 79 |
</div> |
|---|