Cleanup
This commit is contained in:
parent
fc865ea2f8
commit
926cd27136
@ -1,95 +1,96 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var app = { };
|
|
||||||
|
|
||||||
|
(function(hscd) {
|
||||||
|
var ctx = {};
|
||||||
|
|
||||||
function outputResults(results, maxResults) {
|
function onAdjust(name, value) {
|
||||||
$('#results').empty();
|
ctx.searchParams[name] = value;
|
||||||
$('#count').text(results.length);
|
|
||||||
|
|
||||||
results = results.splice(0, maxResults);
|
var params = {
|
||||||
|
searchParams: ctx.searchParams,
|
||||||
|
searchRange: ctx.searchRange,
|
||||||
|
minScore: ctx.minScore,
|
||||||
|
hintSteps: ctx.hintSteps,
|
||||||
|
maxResults: ctx.maxResults
|
||||||
|
};
|
||||||
|
|
||||||
var template = Handlebars.compile($('#template').html());
|
$.getJSON('/node/search', params, function(results) {
|
||||||
$('#results').append(template({'results': results}));
|
var hintData = {};
|
||||||
}
|
for (var feature in results.columns) {
|
||||||
|
hintData[feature] = results.columns[feature].hints;
|
||||||
function onAdjust(name, value) {
|
|
||||||
app.searchParams[name] = value;
|
|
||||||
console.log(app.searchParams);
|
|
||||||
|
|
||||||
var params = {
|
|
||||||
searchParams: app.searchParams,
|
|
||||||
searchRange: app.searchRange,
|
|
||||||
minScore: app.minScore,
|
|
||||||
hintSteps: app.hintSteps,
|
|
||||||
maxResults: app.maxResults
|
|
||||||
};
|
|
||||||
|
|
||||||
$.getJSON('/node/search', params, function(results) {
|
|
||||||
var hintData = { };
|
|
||||||
for (var feature in results.columns) {
|
|
||||||
hintData[feature] = results.columns[feature].hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
app.grapher.setColumnHints(hintData);
|
|
||||||
outputResults(results.items, params.maxResults);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSearch() {
|
|
||||||
var params = {
|
|
||||||
keyword: $('#keyword').val(),
|
|
||||||
searchRange: { min: -1.0, max: 1.0 },
|
|
||||||
minScore: parseInt($('#minScore').val()),
|
|
||||||
hintSteps: parseInt($('#hintSteps').val()),
|
|
||||||
maxResults: parseInt($('#maxResults').val())
|
|
||||||
};
|
|
||||||
|
|
||||||
$.getJSON('/node/search', params, function(results) {
|
|
||||||
app.searchParams = results.params;
|
|
||||||
app.searchRange = params.searchRange;
|
|
||||||
app.minScore = params.minScore;
|
|
||||||
app.hintSteps = params.hintSteps;
|
|
||||||
app.maxResults = params.maxResults;
|
|
||||||
|
|
||||||
app.grapher = new Grapher('grapher', app.searchRange, true, true);
|
|
||||||
app.grapher.setColumns(results.columns);
|
|
||||||
app.grapher.setValueChangedListener(onAdjust);
|
|
||||||
|
|
||||||
outputResults(results.items, params.maxResults);
|
|
||||||
|
|
||||||
$('#query').text(params.keyword);
|
|
||||||
$('#useLocalScale').click(function() {
|
|
||||||
var useLocalScale = $('#useLocalScale').is(':checked');
|
|
||||||
app.grapher.setUseLocalScale(useLocalScale);
|
|
||||||
});
|
|
||||||
$('#useRelativeScale').click(function() {
|
|
||||||
var useRelativeScale = $('#useRelativeScale').is(':checked');
|
|
||||||
app.grapher.setUseRelativeScale(useRelativeScale);
|
|
||||||
});
|
|
||||||
$('#input').fadeOut(function() {
|
|
||||||
$('#output').fadeIn();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
$.getJSON('/node/keywords', function(keywords) {
|
|
||||||
for (var i = 0; i < keywords.length; ++i) {
|
|
||||||
var properties = { value: keywords[i], text: keywords[i] };
|
|
||||||
$('#keyword').append($('<option></option>', properties));
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).on({
|
|
||||||
ajaxStart: function() {
|
|
||||||
$('#spinner').show();
|
|
||||||
},
|
|
||||||
ajaxStop: function() {
|
|
||||||
$('#spinner').hide();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
$('#search').prop('disabled', false);
|
ctx.grapher.setColumnHints(hintData);
|
||||||
$('#search').click(onSearch);
|
outputResults(results.items, params.maxResults);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSearch() {
|
||||||
|
var params = {
|
||||||
|
keyword: $('#keyword').val(),
|
||||||
|
searchRange: { min: -1.0, max: 1.0 },
|
||||||
|
minScore: parseInt($('#minScore').val()),
|
||||||
|
hintSteps: parseInt($('#hintSteps').val()),
|
||||||
|
maxResults: parseInt($('#maxResults').val())
|
||||||
|
};
|
||||||
|
|
||||||
|
$.getJSON('/node/search', params, function(results) {
|
||||||
|
ctx.searchParams = results.params;
|
||||||
|
ctx.searchRange = params.searchRange;
|
||||||
|
ctx.minScore = params.minScore;
|
||||||
|
ctx.hintSteps = params.hintSteps;
|
||||||
|
ctx.maxResults = params.maxResults;
|
||||||
|
|
||||||
|
ctx.grapher = new Grapher('grapher', ctx.searchRange, true, true);
|
||||||
|
ctx.grapher.setColumns(results.columns);
|
||||||
|
ctx.grapher.setValueChangedListener(onAdjust);
|
||||||
|
|
||||||
|
outputResults(results.items, params.maxResults);
|
||||||
|
|
||||||
|
$('#query').text(params.keyword);
|
||||||
|
$('#useLocalScale').click(function() {
|
||||||
|
var useLocalScale = $('#useLocalScale').is(':checked');
|
||||||
|
ctx.grapher.setUseLocalScale(useLocalScale);
|
||||||
|
});
|
||||||
|
$('#useRelativeScale').click(function() {
|
||||||
|
var useRelativeScale = $('#useRelativeScale').is(':checked');
|
||||||
|
ctx.grapher.setUseRelativeScale(useRelativeScale);
|
||||||
|
});
|
||||||
|
$('#input').fadeOut(function() {
|
||||||
|
$('#output').fadeIn();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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}));
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$.getJSON('/node/keywords', function(keywords) {
|
||||||
|
for (var i = 0; i < keywords.length; ++i) {
|
||||||
|
var properties = { value: keywords[i], text: keywords[i] };
|
||||||
|
$('#keyword').append($('<option></option>', properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on({
|
||||||
|
ajaxStart: function() {
|
||||||
|
$('#spinner').show();
|
||||||
|
},
|
||||||
|
ajaxStop: function() {
|
||||||
|
$('#spinner').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#search').prop('disabled', false);
|
||||||
|
$('#search').click(onSearch);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}(window.hscd = window.hscd || {}));
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
<form>
|
<form>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading"><big>Semantic tweaks to <span id="query" class="text-primary"></span></big></div>
|
<div class="panel-heading"><big>Semantic tweaks to <span id="query" class="text-primary"></span></big></div>
|
||||||
<div class="row" style="padding: 10px;">
|
<div style="padding: 10px;">
|
||||||
<canvas id="grapher" width="500" height="550"></canvas><br>
|
<canvas id="grapher" width="500" height="550"></canvas><br>
|
||||||
<label class="checkbox-inline">
|
<label class="checkbox-inline">
|
||||||
<input type="checkbox" id="useLocalScale" name="useLocalScale" checked="checked"> Use local scale
|
<input type="checkbox" id="useLocalScale" name="useLocalScale" checked="checked"> Use local scale
|
||||||
|
Loading…
Reference in New Issue
Block a user