Cleanup
This commit is contained in:
parent
fc865ea2f8
commit
926cd27136
@ -1,28 +1,18 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var app = { };
|
|
||||||
|
|
||||||
|
(function(hscd) {
|
||||||
function outputResults(results, maxResults) {
|
var ctx = {};
|
||||||
$('#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) {
|
function onAdjust(name, value) {
|
||||||
app.searchParams[name] = value;
|
ctx.searchParams[name] = value;
|
||||||
console.log(app.searchParams);
|
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
searchParams: app.searchParams,
|
searchParams: ctx.searchParams,
|
||||||
searchRange: app.searchRange,
|
searchRange: ctx.searchRange,
|
||||||
minScore: app.minScore,
|
minScore: ctx.minScore,
|
||||||
hintSteps: app.hintSteps,
|
hintSteps: ctx.hintSteps,
|
||||||
maxResults: app.maxResults
|
maxResults: ctx.maxResults
|
||||||
};
|
};
|
||||||
|
|
||||||
$.getJSON('/node/search', params, function(results) {
|
$.getJSON('/node/search', params, function(results) {
|
||||||
@ -31,7 +21,7 @@ function onAdjust(name, value) {
|
|||||||
hintData[feature] = results.columns[feature].hints;
|
hintData[feature] = results.columns[feature].hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.grapher.setColumnHints(hintData);
|
ctx.grapher.setColumnHints(hintData);
|
||||||
outputResults(results.items, params.maxResults);
|
outputResults(results.items, params.maxResults);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -46,26 +36,26 @@ function onSearch() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.getJSON('/node/search', params, function(results) {
|
$.getJSON('/node/search', params, function(results) {
|
||||||
app.searchParams = results.params;
|
ctx.searchParams = results.params;
|
||||||
app.searchRange = params.searchRange;
|
ctx.searchRange = params.searchRange;
|
||||||
app.minScore = params.minScore;
|
ctx.minScore = params.minScore;
|
||||||
app.hintSteps = params.hintSteps;
|
ctx.hintSteps = params.hintSteps;
|
||||||
app.maxResults = params.maxResults;
|
ctx.maxResults = params.maxResults;
|
||||||
|
|
||||||
app.grapher = new Grapher('grapher', app.searchRange, true, true);
|
ctx.grapher = new Grapher('grapher', ctx.searchRange, true, true);
|
||||||
app.grapher.setColumns(results.columns);
|
ctx.grapher.setColumns(results.columns);
|
||||||
app.grapher.setValueChangedListener(onAdjust);
|
ctx.grapher.setValueChangedListener(onAdjust);
|
||||||
|
|
||||||
outputResults(results.items, params.maxResults);
|
outputResults(results.items, params.maxResults);
|
||||||
|
|
||||||
$('#query').text(params.keyword);
|
$('#query').text(params.keyword);
|
||||||
$('#useLocalScale').click(function() {
|
$('#useLocalScale').click(function() {
|
||||||
var useLocalScale = $('#useLocalScale').is(':checked');
|
var useLocalScale = $('#useLocalScale').is(':checked');
|
||||||
app.grapher.setUseLocalScale(useLocalScale);
|
ctx.grapher.setUseLocalScale(useLocalScale);
|
||||||
});
|
});
|
||||||
$('#useRelativeScale').click(function() {
|
$('#useRelativeScale').click(function() {
|
||||||
var useRelativeScale = $('#useRelativeScale').is(':checked');
|
var useRelativeScale = $('#useRelativeScale').is(':checked');
|
||||||
app.grapher.setUseRelativeScale(useRelativeScale);
|
ctx.grapher.setUseRelativeScale(useRelativeScale);
|
||||||
});
|
});
|
||||||
$('#input').fadeOut(function() {
|
$('#input').fadeOut(function() {
|
||||||
$('#output').fadeIn();
|
$('#output').fadeIn();
|
||||||
@ -73,6 +63,16 @@ function onSearch() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
$(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) {
|
||||||
@ -93,3 +93,4 @@ $(document).ready(function() {
|
|||||||
$('#search').click(onSearch);
|
$('#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