Cleanup
This commit is contained in:
parent
7401359144
commit
696049aa76
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var app = { };
|
||||||
|
|
||||||
function outputResults(results, maxResults) {
|
function outputResults(results, maxResults) {
|
||||||
$('#results').empty();
|
$('#results').empty();
|
||||||
$('#count').text(results.length);
|
$('#count').text(results.length);
|
||||||
@ -11,18 +13,15 @@ function outputResults(results, maxResults) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onAdjust(name, value) {
|
function onAdjust(name, value) {
|
||||||
var wa = window.adjuster;
|
app.searchParams[name] = value;
|
||||||
var wg = window.grapher;
|
console.log(app.searchParams);
|
||||||
|
|
||||||
wa.searchParams[name] = value;
|
|
||||||
console.log(wa.searchParams);
|
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
searchParams: wa.searchParams,
|
searchParams: app.searchParams,
|
||||||
searchRange: wa.searchRange,
|
searchRange: app.searchRange,
|
||||||
minScore: wa.minScore,
|
minScore: app.minScore,
|
||||||
hintSteps: wa.hintSteps,
|
hintSteps: app.hintSteps,
|
||||||
maxResults: wa.maxResults
|
maxResults: app.maxResults
|
||||||
};
|
};
|
||||||
|
|
||||||
$.getJSON('/node/search', params, function(results) {
|
$.getJSON('/node/search', params, function(results) {
|
||||||
@ -31,7 +30,7 @@ function onAdjust(name, value) {
|
|||||||
hintData[feature] = results.columns[feature].hints;
|
hintData[feature] = results.columns[feature].hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.setColumnHints(hintData);
|
app.grapher.setColumnHints(hintData);
|
||||||
outputResults(results.items, params.maxResults);
|
outputResults(results.items, params.maxResults);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -42,37 +41,33 @@ function onSearch() {
|
|||||||
searchRange: { min: -1.0, max: 1.0 },
|
searchRange: { min: -1.0, max: 1.0 },
|
||||||
minScore: parseInt($('#minScore').val()),
|
minScore: parseInt($('#minScore').val()),
|
||||||
hintSteps: parseInt($('#hintSteps').val()),
|
hintSteps: parseInt($('#hintSteps').val()),
|
||||||
maxResults: parseInt($('#maxResults').val()),
|
maxResults: parseInt($('#maxResults').val())
|
||||||
useLocalScale: true,
|
|
||||||
useRelativeScale: true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$.getJSON('/node/search', params, function(results) {
|
$.getJSON('/node/search', params, function(results) {
|
||||||
window.adjuster = {
|
app.searchParams = results.params;
|
||||||
searchParams: results.params,
|
app.searchRange = params.searchRange;
|
||||||
searchRange: params.searchRange,
|
app.minScore = params.minScore;
|
||||||
minScore: params.minScore,
|
app.hintSteps = params.hintSteps;
|
||||||
hintSteps: params.hintSteps,
|
app.maxResults = params.maxResults;
|
||||||
maxResults: params.maxResults
|
|
||||||
};
|
|
||||||
|
|
||||||
window.grapher = new Grapher('grapher', new goog.math.Range(-1.0, 1.0), params.useLocalScale, params.useRelativeScale);
|
app.grapher = new Grapher('grapher', new goog.math.Range(-1.0, 1.0), true, true);
|
||||||
window.grapher.setColumns(results.columns);
|
app.grapher.setColumns(results.columns);
|
||||||
window.grapher.setValueChangedListener(onAdjust);
|
app.grapher.setValueChangedListener(onAdjust);
|
||||||
|
|
||||||
outputResults(results.items, params.maxResults);
|
outputResults(results.items, params.maxResults);
|
||||||
|
|
||||||
$('#query').text(params.keyword);
|
$('#query').text(params.keyword);
|
||||||
$('#useLocalScale').prop('checked', useLocalScale);
|
|
||||||
$('#useRelativeScale').prop('checked', useRelativeScale);
|
|
||||||
$('#useLocalScale').click(function() {
|
$('#useLocalScale').click(function() {
|
||||||
var useLocalScale = $('#useLocalScale').is(':checked');
|
var useLocalScale = $('#useLocalScale').is(':checked');
|
||||||
window.grapher.setUseLocalScale(useLocalScale);
|
app.grapher.setUseLocalScale(useLocalScale);
|
||||||
});
|
});
|
||||||
$('#useRelativeScale').click(function() {
|
$('#useRelativeScale').click(function() {
|
||||||
var useRelativeScale = $('#useRelativeScale').is(':checked');
|
var useRelativeScale = $('#useRelativeScale').is(':checked');
|
||||||
window.grapher.setUseRelativeScale(useRelativeScale);
|
app.grapher.setUseRelativeScale(useRelativeScale);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#input').fadeOut(function() {
|
$('#input').fadeOut(function() {
|
||||||
$('#output').fadeIn();
|
$('#output').fadeIn();
|
||||||
});
|
});
|
||||||
@ -82,10 +77,8 @@ function onSearch() {
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.getJSON('/node/keywords', function(keywords) {
|
$.getJSON('/node/keywords', function(keywords) {
|
||||||
for (var i = 0; i < keywords.length; ++i) {
|
for (var i = 0; i < keywords.length; ++i) {
|
||||||
$('#keyword').append($('<option></option>', {
|
var properties = { value: keywords[i], text: keywords[i] };
|
||||||
'value': keywords[i],
|
$('#keyword').append($('<option></option>', properties));
|
||||||
'text': keywords[i]
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#search').prop('disabled', false);
|
$('#search').prop('disabled', false);
|
||||||
|
Loading…
Reference in New Issue
Block a user