-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.htm
143 lines (130 loc) · 5.07 KB
/
index.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script type="text/javascript" src="https://www.google.com/jsapi">
</script>
<script type="text/javascript">google.load("visualization", "1", {packages:["corechart"]});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
//solrURL = "http://ammatsun.acis.ufl.edu:5900/solr/lichenssilver/select?q=content%3A*&fq=alaska&wt=json&indent=true&facet=true&facet.field=content&facet.mincount=8";
//var collection = "herbsilver";
var collection = "lichenssilver";
//var collection_field = "content";
var collection_field = "content";
solrURL = "http://ammatsun.acis.ufl.edu:5900/solr/" + collection + "/select?q=" + collection_field + "%3A*&fq=" + $("#fqstring").val() + "&wt=json&indent=true&facet=true&facet.field=content&facet.mincount=" + $("#mincount").val();
//alert (solrURL);
$.getJSON(solrURL,function(result){
var numFound = result.response.numFound;
var facet_counts = result.facet_counts;
var facet_fields = result.facet_counts.facet_fields;
var facet_content = result.facet_counts.facet_fields.content;
var facet_array = new Array();
facet_array.push(['word', 'count']);
var facet_key = "";
var facet_value = "";
var docs = result.docs;
//<li class="list-group-item">Cras justo odio</li>
// Clear params from previous query
$( "#params_div ").empty();
// Display params from current query
$("#params_div").append("<li class='list-group-item'>Found: " + numFound + "</li>");
// Generate facet array
$.each(facet_content, function(i, facet_content_item){
//$("div").append(i + ":" + facet_content_item + " </br>");
if(i % 2 === 0) {
// code to be executed if condition is true
//$("div").append("key: " + facet_content_item + " ");
facet_key = facet_content_item;
}
else {
// code to be executed if condition is false
facet_value = facet_content_item;
facet_array.push([facet_key,facet_value]);
}
});
var data = google.visualization.arrayToDataTable(facet_array);
var options = {
title: 'Token occurrence in dataset.',
legend: { position: 'none' },
};
var chart = new google.visualization.Histogram(document.getElementById('chart_div'));
chart.draw(data, options);
// Remove previous facets from last query
$( "#facet_div ").empty();
// Add facets to facet list
$.each(facet_array, function(i, facet_kv){
//<li class="list-group-item">Facets</li>
$("#facet_div").append("<li class='list-group-item'>" + facet_kv[0] + "<span class='badge'>" + facet_kv[1] + "</span></li>");
});
});
});
});
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">iDigBio Faceted Collection Browser</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div class="page-header">
<h1> </h1>
</div>
<div class="row">
<!-- Parameters and Results -->
<div class="col-sm-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Query</h3>
</div>
<div class="panel-body">
<form>
Search term: <input id="fqstring" type="text" name="fqstring" value="alaska"><br>
Min occurrence count: <input id="mincount" type="text" name="mincount" value="8"><br>
<p><button type="button" class="btn btn-sm btn-default">Get JSON data</button>
</p>
</form>
<div id="params_div">
<li class="list-group-item">Results</li>
</div>
</div>
</div>
<!-- Facet -->
<ul class="list-group">
<div id="facet_div">
<li class="list-group-item">Facets</li>
</div>
</ul>
</div><!-- /.col-sm-4 -->
<div class="col-sm-8">
<div id="docs_div">
<div id="chart_div" style="width: 700px; height: 600px;"></div>
</div>
</div><!-- /.col-sm-8 -->
</div><!-- /.row -->
</div><!-- /.container -->
</body>
</html>