2014-07-08 04:35:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function outputResults(results, maxResults) {
|
|
|
|
$('#results').empty();
|
|
|
|
$('#count').text(results.length);
|
|
|
|
|
|
|
|
results = results.splice(0, maxResults);
|
|
|
|
|
|
|
|
var template = Handlebars.compile($('#template').html());
|
|
|
|
$('#results').append(template({'results': results}));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAdjust(name, value) {
|
2014-07-28 06:41:14 +00:00
|
|
|
// var wa = window.adjuster;
|
|
|
|
// var wg = window.grapher;
|
2014-07-08 04:35:52 +00:00
|
|
|
|
2014-07-28 06:41:14 +00:00
|
|
|
// wa.searchParams[name] = value;
|
|
|
|
// console.log(wa.searchParams);
|
2014-07-08 04:35:52 +00:00
|
|
|
|
2014-07-28 06:41:14 +00:00
|
|
|
// var hintData = {};
|
|
|
|
// _.each(wg.getColumnNames(), function(name) {
|
|
|
|
// hintData[name] = searchBuildHints(wa.searchParams, wa.minScore, name, wa.searchRange, wa.hintSteps);
|
|
|
|
// });
|
|
|
|
// wg.setColumnHints(hintData);
|
2014-07-08 04:35:52 +00:00
|
|
|
|
2014-07-28 06:41:14 +00:00
|
|
|
// var results = searchData(wa.searchParams, wa.minScore);
|
|
|
|
// outputResults(results, wa.maxResults);
|
2014-07-08 04:35:52 +00:00
|
|
|
}
|
|
|
|
|
2014-07-28 02:52:30 +00:00
|
|
|
function onSearch() {
|
|
|
|
var params = {
|
2014-07-28 06:51:48 +00:00
|
|
|
keyword: $('#keyword').val(),
|
|
|
|
searchRange: { min: -1.0, max: 1.0 },
|
|
|
|
minScore: parseInt($('#minScore').val()),
|
|
|
|
hintSteps: parseInt($('#hintSteps').val()),
|
|
|
|
maxResults: parseInt($('#maxResults').val()),
|
|
|
|
useLocalScale: true,
|
|
|
|
useRelativeScale: true
|
2014-07-08 04:35:52 +00:00
|
|
|
};
|
|
|
|
|
2014-07-28 02:52:30 +00:00
|
|
|
$.getJSON('/node/search', params, function(results) {
|
2014-07-28 06:41:14 +00:00
|
|
|
window.adjuster = {
|
|
|
|
searchParams: results.params,
|
2014-07-28 06:51:48 +00:00
|
|
|
searchRange: params.searchRange,
|
2014-07-28 06:41:14 +00:00
|
|
|
minScore: params.minScore,
|
|
|
|
hintSteps: params.hintSteps,
|
|
|
|
maxResults: params.maxResults
|
|
|
|
};
|
|
|
|
|
|
|
|
window.grapher = new Grapher('grapher', new goog.math.Range(-1.0, 1.0), params.useLocalScale, params.useRelativeScale);
|
|
|
|
window.grapher.setColumns(results.columns);
|
|
|
|
window.grapher.setValueChangedListener(onAdjust);
|
|
|
|
|
2014-07-28 06:51:48 +00:00
|
|
|
outputResults(results.items, params.maxResults);
|
2014-07-28 06:41:14 +00:00
|
|
|
|
|
|
|
$('#query').text(params.keyword);
|
|
|
|
$('#useLocalScale').prop('checked', useLocalScale);
|
|
|
|
$('#useRelativeScale').prop('checked', useRelativeScale);
|
|
|
|
$('#useLocalScale').click(function() {
|
|
|
|
var useLocalScale = $('#useLocalScale').is(':checked');
|
|
|
|
window.grapher.setUseLocalScale(useLocalScale);
|
|
|
|
});
|
|
|
|
$('#useRelativeScale').click(function() {
|
|
|
|
var useRelativeScale = $('#useRelativeScale').is(':checked');
|
|
|
|
window.grapher.setUseRelativeScale(useRelativeScale);
|
|
|
|
});
|
|
|
|
$('#input').fadeOut(function() {
|
|
|
|
$('#output').fadeIn();
|
|
|
|
});
|
2014-07-08 04:35:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2014-07-28 02:52:30 +00:00
|
|
|
$.getJSON('/node/keywords', function(keywords) {
|
2014-07-28 01:57:04 +00:00
|
|
|
for (var i = 0; i < keywords.length; ++i) {
|
2014-07-28 02:52:30 +00:00
|
|
|
$('#keyword').append($('<option></option>', {
|
2014-07-28 01:57:04 +00:00
|
|
|
'value': keywords[i],
|
|
|
|
'text': keywords[i]
|
2014-07-26 06:29:55 +00:00
|
|
|
}));
|
|
|
|
}
|
2014-07-28 01:57:04 +00:00
|
|
|
|
|
|
|
$('#search').prop('disabled', false);
|
2014-07-28 02:52:30 +00:00
|
|
|
$('#search').click(onSearch);
|
2014-07-26 06:02:42 +00:00
|
|
|
});
|
2014-07-08 04:35:52 +00:00
|
|
|
});
|